/* Medicine Reminder admin - same look as the elder app */
:root {
  --bg: #F7FAFD;
  --card: #EAF2FB;
  --white: #FFFFFF;
  --primary: #1B4F9C;
  --primary-dark: #163F7E;
  --pill: #9DC1EE;
  --text: #0F2B4A;
  --text-2: #4A5F78;
  --line: #C9D9EC;
  --line-soft: #E2EBF5;
  --taken: #1E7B4F;
  --taken-bg: #E1F3EA;
  --taken-ink: #14573A;
  --missed: #B3261E;
  --missed-bg: #FBE7E5;
  --missed-ink: #8E1E18;
  --missed-line: #E8B4AF;
  --wait-bg: #FFF1CC;
  --wait-ink: #6B4A00;
  --focus: #F2A900;
  --radius: 24px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 { line-height: 1.2; }
a { color: var(--primary); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Layout: sidebar + content ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 264px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--white);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; margin: 0; text-decoration: none; color: var(--text); }
.brand-icon {
  flex: none; width: 44px; height: 44px; border-radius: 14px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 18px; font-weight: 700; display: block; }
.brand-sub { font-size: 14px; color: var(--text-2); display: block; }

.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 0 14px; border-radius: 14px;
  font-size: 17px; font-weight: 700; color: var(--text); text-decoration: none;
}
.sidebar nav a:hover { background: var(--card); }
.sidebar nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.sidebar nav svg { flex: none; }

.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.doctor-card { background: var(--card); border-radius: 16px; padding: 14px; display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--pill); color: var(--text); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.doctor-card .avatar { width: 40px; height: 40px; }
.doctor-name { font-weight: 700; font-size: 15px; }
.doctor-email { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }

.signout {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line); color: var(--missed); font-weight: 700; text-decoration: none;
}
.signout:hover { background: var(--missed-bg); }

.content {
  flex: 1 1 auto; min-width: 0;
  padding: 32px 40px 48px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1400px;
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { margin: 0; font-size: 32px; }
.muted { margin: 4px 0 0; color: var(--text-2); }

/* ---------- Cards ---------- */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.panel h2, .section-title { margin: 0; font-size: 22px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head a { font-weight: 700; text-decoration: none; }

.row-2 { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.row-2 > * { flex: 1 1 340px; }
.row-2 > .wide { flex: 2 1 460px; }

.item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 20px; padding: 14px 18px;
}
.item.blue { background: var(--card); border-color: transparent; }
.item-main { flex: 1 1 200px; min-width: 0; }
.item-title { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.item-sub { font-size: 15px; color: var(--text-2); overflow-wrap: anywhere; }
.item.editing { outline: 3px solid var(--focus); }
.item.row-missed { background: var(--missed-bg); border-color: var(--missed-line); }
.item.new-row { background: var(--taken-bg); border-color: #A9D9BF; }

.pill-icon {
  flex: none; width: 52px; height: 52px; border-radius: 16px;
  background: var(--white); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}

.time-tag {
  flex: none; min-width: 92px; text-align: center;
  background: var(--pill); color: var(--text);
  font-weight: 700; font-size: 16px; border-radius: 14px; padding: 8px 10px;
}
.tag {
  display: inline-block; padding: 6px 14px; border-radius: 14px;
  background: var(--white); border: 1px solid var(--line); font-weight: 700; font-size: 15px;
}

.date-tile {
  flex: none; width: 64px; text-align: center; padding: 6px 0;
  border-radius: 16px; background: var(--white); border: 1px solid var(--line);
}
.date-tile .m { font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; }
.date-tile .d { font-size: 26px; font-weight: 700; line-height: 1.1; }

.group-title {
  margin: 4px 0 0; font-size: 15px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em;
}
.list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Status badges ---------- */
.badge {
  flex: none; display: inline-block; padding: 6px 14px; border-radius: 14px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
}
.badge-ok { background: var(--taken-bg); color: var(--taken-ink); }
.badge-missed { background: var(--missed-bg); color: var(--missed-ink); }
.badge-wait { background: var(--wait-bg); color: var(--wait-ink); }
.badge-info { background: #D6E6F8; color: var(--primary-dark); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 22px; display: flex; align-items: center; gap: 16px; min-width: 0; }
.stat-icon { flex: none; width: 56px; height: 56px; border-radius: 18px; display: flex; align-items: center; justify-content: center; }
.stat-icon.ok { background: var(--taken-bg); color: var(--taken); }
.stat-icon.bad { background: var(--missed-bg); color: var(--missed); }
.stat-icon.next { background: #D6E6F8; color: var(--primary); }
.stat .num { font-size: 40px; font-weight: 700; line-height: 1; }
.stat .label { margin-top: 4px; font-size: 16px; color: var(--text-2); }
.stat.plain { display: block; padding: 18px 20px; }
.stat.plain .num { font-size: 32px; }
.stat.good { background: var(--taken-bg); }
.stat.good .num, .stat.good .label { color: var(--taken-ink); }
.stat.bad { background: var(--missed-bg); }
.stat.bad .num, .stat.bad .label { color: var(--missed-ink); }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field label { margin-bottom: 6px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 16px;
}
textarea { padding: 12px 16px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(27, 79, 156, .2); }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 700; font-size: 16px; margin-bottom: 8px; padding: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px;
  font: inherit; font-size: 17px; font-weight: 700;
  color: #fff; background: var(--primary);
  border: 2px solid var(--primary); border-radius: 26px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-block { width: 100%; }
.btn-outline { color: var(--primary); background: var(--white); border-color: var(--primary); }
.btn-outline:hover { background: var(--card); border-color: var(--primary); }
.btn-small { min-height: 44px; padding: 0 18px; font-size: 16px; border-radius: 22px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions button {
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--white); color: var(--primary); border: 2px solid var(--primary);
}
.row-actions button:hover { background: var(--card); }
.row-actions .neutral { color: var(--text); border-color: var(--line); }
.row-actions .delete { color: var(--missed); border-color: var(--missed-line); }
.row-actions .delete:hover { background: var(--missed-bg); }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-error {
  margin: 0; padding: 12px 16px; border-radius: 16px;
  background: var(--missed-bg); color: var(--missed-ink); border: 1px solid var(--missed-line); font-weight: 700;
}
.added-msg {
  margin: 0; padding: 12px 16px; border-radius: 16px;
  background: var(--taken-bg); color: var(--taken-ink); border: 1px solid #A9D9BF; font-weight: 700;
}

/* Chips (elder picker, filters, tabs) */
.chips-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 48px; padding: 0 20px; border-radius: 24px;
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  background: var(--white); color: var(--text); border: 2px solid var(--line);
}
.chip:hover { border-color: var(--primary); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--card); border-radius: 26px; padding: 4px; }
.segmented button {
  min-height: 44px; padding: 0 18px; border-radius: 22px; border: 0;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  background: transparent; color: var(--text);
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* Time chips on the schedule form */
.time-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.time-row input { max-width: 200px; }
.chips { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 6px 0 16px; border-radius: 22px;
  background: var(--pill); font-weight: 700; font-size: 16px;
}
.chips button {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--white); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
}

/* Day toggles */
.day-boxes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day-boxes label {
  position: relative; margin: 0;
  min-height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 14px; border: 2px solid var(--line); background: var(--white);
  font-size: 15px; font-weight: 700; cursor: pointer; user-select: none;
}
.day-boxes input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.day-boxes label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }
.day-boxes label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Search box */
.search {
  display: flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border: 2px solid var(--line); border-radius: 24px; background: var(--bg);
  min-width: 240px; margin: 0; font-weight: 400;
}
.search input { border: 0; background: transparent; min-height: 44px; padding: 0; box-shadow: none !important; }

/* Pairing code panel */
.code-panel {
  background: var(--primary); color: #fff; border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.code-panel .eyebrow { font-size: 15px; font-weight: 700; color: #D6E6F8; text-transform: uppercase; letter-spacing: .05em; }
.code-panel p { margin: 0; color: #D6E6F8; }
.code-boxes { display: flex; flex-wrap: wrap; gap: 8px; }
.code-boxes span {
  width: 52px; height: 64px; border-radius: 14px; background: #fff; color: var(--text);
  font-size: 32px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.code-panel .btn-small { background: #fff; color: var(--primary); border-color: #fff; }
.code-panel .btn-ghost { background: transparent; color: #fff; border-color: var(--pill); }
.code-empty { color: #D6E6F8; font-size: 17px; }
.code-inline { font-size: 18px; font-weight: 700; letter-spacing: .12em; font-variant-numeric: tabular-nums; }

/* Table (history) */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 0; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 16px; }
th { text-align: left; padding: 14px 12px; color: var(--text-2); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 14px 12px; border-top: 1px solid var(--line-soft); }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
td:first-child { font-weight: 700; }
tr.row-missed td { background: #FDF3F2; }

.empty { margin: 0; padding: 20px; text-align: center; color: var(--text-2); background: var(--bg); border: 2px dashed var(--line); border-radius: 20px; }

/* ---------- Missed-dose banner (from store.js) ---------- */
#alert-banner { display: flex; flex-direction: column; gap: 10px; }
#alert-banner:empty { display: none; }
.alert-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  background: var(--missed-bg); border: 1px solid var(--missed-line); border-radius: 20px; padding: 16px 20px;
}
.alert-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--missed); color: #fff; display: flex; align-items: center; justify-content: center; }
.alert-text { flex: 1 1 260px; min-width: 0; }
.alert-title { font-weight: 700; font-size: 18px; color: #7A1B16; }
.alert-sub { font-size: 16px; color: #5C1B17; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.alert-actions button {
  min-height: 44px; padding: 0 18px; border-radius: 22px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  border: 2px solid var(--missed); background: #fff; color: var(--missed);
}
.alert-actions button.filled { background: var(--missed); color: #fff; }
.alert-all { align-self: flex-start; }
#alert-enable {
  position: fixed; right: 16px; bottom: 16px; z-index: 9998;
  min-height: 48px; padding: 0 20px; border-radius: 24px; border: 0;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(15, 43, 74, .3);
}

/* ---------- Sign in / create account ---------- */
.login { display: flex; flex-wrap: wrap; min-height: 100vh; }
.login-intro {
  flex: 1 1 420px; min-width: 0;
  background: var(--primary); color: #fff;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.login-intro .brand { color: #fff; }
.login-intro .brand-icon { background: #fff; color: var(--primary); width: 52px; height: 52px; border-radius: 16px; }
.login-intro .brand-name { font-size: 22px; }
.login-intro h1 { margin: 0 0 16px; font-size: 44px; max-width: 14ch; }
.lead { margin: 0; font-size: 19px; color: #D6E6F8; max-width: 40ch; }
.dose-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.dose-list li { display: flex; align-items: center; gap: 12px; background: #16427F; border-radius: 18px; padding: 12px 16px; }
.dose-list .dot { flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.dot-taken { background: var(--taken-bg); color: var(--taken); }
.dot-missed { background: var(--missed-bg); color: var(--missed); }
.dot-next { background: #D6E6F8; color: var(--primary); }
.dose-name { flex: 1; font-weight: 700; }
.dose-status { font-size: 15px; color: #D6E6F8; }

.login-panel { flex: 1 1 420px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 56px 24px; }
.login-form {
  width: 100%; max-width: 440px;
  background: var(--white); border: 1px solid var(--line); border-radius: 28px; padding: 36px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-form h2 { margin: 0; font-size: 30px; }
.login-form .muted { margin-top: -8px; }
.login-form label { margin-bottom: -10px; }
.login-form .switch { margin: 0; text-align: center; color: var(--text-2); }
.login-form .switch a { font-weight: 700; }

/* ---------- Phones and small windows ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    position: static; height: auto; flex: none;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .sidebar nav a { min-height: 44px; font-size: 15px; padding: 0 12px; }
  .side-bottom { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .doctor-card { display: none; }
  .content { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 26px; }
  .stats { grid-template-columns: 1fr; }
  .login-intro { padding: 32px 20px; }
  .login-intro h1 { font-size: 32px; }
  .login-form { padding: 24px; }
}
@media (max-width: 520px) {
  .day-boxes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fields-2 { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; }
}

/* ---------- Printing the history ---------- */
@media print {
  .sidebar, #history-toolbar, #alert-banner, #alert-enable, .filters, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .table-wrap { border: 0; }
  body { background: #fff; }
}

/* ---------- Dashboard: elder cards ---------- */
.elder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; }
.elder-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.elder-card-head { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.elder-card-head .avatar { width: 52px; height: 52px; font-size: 19px; }
.elder-card-name { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.med-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  background: var(--card); border-radius: 18px; padding: 14px 16px;
}
.med-row .pill-icon { width: 46px; height: 46px; border-radius: 14px; }
.med-times { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.med-times .time-tag { min-width: 0; font-size: 15px; padding: 6px 12px; background: var(--white); border: 1px solid var(--line); }
@media (max-width: 520px) {
  .elder-grid { grid-template-columns: 1fr; }
  .med-times { justify-content: flex-start; width: 100%; }
}
.med-row .item-main { flex: 1 1 140px; }
.med-times { flex-direction: column; align-items: flex-end; }
@media (max-width: 520px) { .med-times { flex-direction: row; } }

/* ---------- Calendar on the schedule form ---------- */
.quick-range { margin-top: 10px; }
.quick-range .chip { min-height: 44px; padding: 0 16px; font-size: 15px; }
.cal { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-title { font-weight: 700; font-size: 18px; }
.cal-nav {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--white);
  color: var(--primary); font: inherit; font-size: 26px; line-height: 1; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.cal-nav:hover { border-color: var(--primary); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 13px; font-weight: 700; color: var(--text-2); padding: 4px 0; }
.cal-day {
  min-height: 40px; border-radius: 12px; border: 2px solid transparent; background: transparent;
  font: inherit; font-size: 15px; color: var(--text); cursor: pointer; padding: 0;
}
.cal-day:hover { border-color: var(--pill); }
.cal-day.out { color: #9AA9BB; }
.cal-day.in-range { background: var(--card); }
.cal-day.rings { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day.edge { box-shadow: inset 0 0 0 2px var(--text); }
.cal-day.today { border-color: var(--focus); }
.cal-summary { margin: 12px 0 0; font-weight: 700; }
.cal-hint { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }

.range-text { font-size: 15px; color: var(--text-2); }

/* ---------- Dashboard: day picker and dose marks ---------- */
.day-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.day-nav input { width: auto; min-height: 44px; background: var(--white); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.mark { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; }
.mark::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.mark-taken, .st-taken { background: var(--taken-bg); color: var(--taken-ink); }
.mark-missed, .st-missed { background: var(--missed-bg); color: var(--missed-ink); }
.mark-waiting, .st-waiting { background: var(--wait-bg); color: var(--wait-ink); }
.mark-upcoming, .st-upcoming { background: #D6E6F8; color: var(--primary-dark); }
.mark-none, .st-none { background: #EEF1F5; color: #4A5F78; }

.dose-chip {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  padding: 8px 12px; border-radius: 14px; min-width: 128px; text-align: right;
}
.dose-chip b { font-size: 16px; }
.dose-chip small { font-size: 13px; font-weight: 700; }
.elder-progress { font-size: 15px; color: var(--text-2); }
@media (max-width: 520px) {
  .dose-chip { align-items: flex-start; text-align: left; }
}

/* ---------- Different times on chosen days ---------- */
.cal-day.custom { box-shadow: inset 0 0 0 3px #E07B00; }
.cal-day.skipped { background: #EEF1F5; color: #4A5F78; text-decoration: line-through; }
.cal-day.selected { outline: 3px solid var(--focus); outline-offset: 1px; }
.day-editor {
  margin-top: 12px; padding: 16px; border-radius: 16px;
  background: var(--white); border: 2px solid #E07B00;
  display: flex; flex-direction: column; gap: 12px;
}
.day-editor .chips { margin: 0; }
.special-text { font-size: 15px; font-weight: 700; color: #9A5400; }

/* ---------- Schedule calendar: click days, then add times ---------- */
.cal-grid { gap: 6px; }
.cal .cal-day {
  min-height: 58px; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--white); border: 2px solid var(--line-soft); border-radius: 14px;
  color: var(--text); text-decoration: none; box-shadow: none; outline: none;
}
.cal .cal-day .n { font-size: 16px; font-weight: 700; line-height: 1; }
.cal .cal-day .t { font-size: 12px; font-weight: 700; line-height: 1.1; color: var(--primary); min-height: 13px; white-space: nowrap; }
.cal .cal-day:hover:not(:disabled) { border-color: var(--primary); }
.cal .cal-day.out { opacity: .55; }
.cal .cal-day.has { background: #D6E6F8; border-color: #D6E6F8; }
.cal .cal-day.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.cal .cal-day.sel .t { color: #fff; }
.cal .cal-day.today .n { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; text-decoration-color: var(--focus); }
.cal .cal-day.past { opacity: .4; cursor: default; background: var(--bg); }
.cal .cal-day:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.quick-select { margin-top: 12px; }
.quick-select .chip { min-height: 40px; padding: 0 14px; font-size: 15px; }

.time-box {
  margin-top: 12px; padding: 16px; border-radius: 16px;
  background: var(--white); border: 2px solid var(--primary);
  display: flex; flex-direction: column; gap: 6px;
}
.time-box-title { font-size: 18px; }
.time-box .chips { margin-top: 8px; }
.link-danger {
  align-self: flex-start; margin-top: 10px; padding: 8px 0; border: 0; background: none;
  font: inherit; font-size: 15px; font-weight: 700; color: var(--missed); text-decoration: underline; cursor: pointer;
}
@media (max-width: 520px) {
  .cal .cal-day { min-height: 50px; }
  .cal .cal-day .t { font-size: 10px; }
}

/* ---------- Dashboard: every date of every medicine ---------- */
.elder-grid { grid-template-columns: 1fr; }
.med-block { background: var(--card); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.med-block-head { display: flex; align-items: center; gap: 14px; }
.med-block-head .pill-icon { width: 46px; height: 46px; border-radius: 14px; }
.med-name { margin: 0; font-size: 20px; }
.med-note { margin: 0; font-size: 14px; color: var(--text-2); }
.day-rows { display: flex; flex-direction: column; background: var(--white); border-radius: 14px; overflow: hidden; }
.day-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 14px; border-top: 1px solid var(--line-soft);
}
.day-row:first-child { border-top: 0; }
.day-row.is-today { background: #FFF8E1; box-shadow: inset 4px 0 0 var(--focus); }
.day-label { flex: 0 0 170px; font-weight: 700; font-size: 16px; }
.day-doses { flex: 1 1 260px; display: flex; flex-wrap: wrap; gap: 8px; }
.dose-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 12px; font-size: 14px; font-weight: 700;
}
.dose-pill b { font-size: 15px; }
.more-days { align-self: flex-start; }
@media (max-width: 520px) {
  .day-label { flex-basis: 100%; }
}

/* ---------- Dashboard: find one elder ---------- */
.elder-finder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.elder-finder .search { flex: 0 1 340px; background: var(--white); }
.elder-finder .chips-row { flex: 1 1 300px; }
.elder-finder .chip { min-height: 44px; }

/* ---------- Schedules page: fits on one screen ---------- */
.sched-page { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.sched-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.sched-top h1 { margin: 0; font-size: 28px; }
.sched-top .chip { min-height: 42px; padding: 0 16px; font-size: 15px; }
.sched-body { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.sched-form { padding: 20px; gap: 12px; }
.sched-form-head h2 { margin: 0; font-size: 21px; }
.sched-form-head .cal-hint { margin: 2px 0 0; }
.sched-cols { display: grid; grid-template-columns: minmax(220px, 0.9fr) minmax(300px, 1.1fr); gap: 18px; align-items: start; }
.sched-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sched-left label { margin-bottom: 4px; font-size: 15px; }
.sched-left input, .sched-left select { min-height: 44px; font-size: 16px; padding: 0 12px; border-radius: 12px; }
.sched-left .time-box { margin-top: 2px; padding: 12px; gap: 4px; }
.sched-left .time-box-title { font-size: 16px; }
.sched-left .time-row { margin-top: 8px; gap: 8px; flex-wrap: nowrap; }
.sched-left .time-row input { max-width: none; flex: 1 1 auto; min-width: 0; }
.sched-left .time-row .btn { flex: none; padding: 0 14px; }
.sched-left .chips { margin-top: 6px; }
.sched-left .chips li { min-height: 38px; font-size: 15px; }
.sched-left .link-danger { margin-top: 6px; padding: 4px 0; font-size: 14px; }
.sched-right { min-width: 0; }
.sched-right .cal { padding: 12px; }
.sched-right .cal-head { margin-bottom: 6px; }
.sched-right .cal-nav { width: 38px; height: 38px; font-size: 22px; }
.sched-right .cal-title { font-size: 17px; }
.sched-right .cal-grid { gap: 4px; }
.sched-right .cal-dow { font-size: 12px; padding: 2px 0; }
.sched-right .cal .cal-day { min-height: 44px; border-radius: 10px; padding: 2px; }
.sched-right .cal .cal-day .n { font-size: 15px; }
.sched-right .cal .cal-day .t { font-size: 11px; min-height: 12px; }
.sched-right .quick-select { margin-top: 10px; gap: 6px; }
.sched-right .quick-select .chip { min-height: 36px; padding: 0 12px; font-size: 14px; }
.sched-right .cal-summary { margin: 8px 0 0; font-size: 15px; }
.sched-actions .btn { min-height: 46px; }

.sched-list { padding: 18px; gap: 12px; }
.sched-list h2 { margin: 0; font-size: 20px; }
.sched-list .item { padding: 14px !important; gap: 10px !important; }
.sched-list .item-title { font-size: 17px; }
.sched-list .pill-icon { width: 42px; height: 42px; border-radius: 12px; }
.sched-list .row-actions button { min-height: 40px; padding: 0 14px; }

/* Big enough screens: the page itself does not scroll; the medicine list scrolls inside its box */
@media (min-width: 1100px) and (min-height: 600px) {
  .content:has(.sched-page) { height: 100vh; overflow: hidden; padding-top: 22px; padding-bottom: 22px; }
  .sched-page { flex: 1 1 auto; height: 100%; }
  .sched-body { flex: 1 1 auto; min-height: 0; height: 100%; }
  .sched-form { max-height: 100%; overflow-y: auto; }
  .sched-list { max-height: 100%; min-height: 0; display: flex; flex-direction: column; }
  .sched-list-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
}
@media (max-width: 1099px) {
  .sched-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sched-cols { grid-template-columns: 1fr; }
}
/* tighter fit */
.sched-cols { grid-template-columns: minmax(250px, 1fr) minmax(280px, 1.15fr); gap: 16px; }
.sched-right .cal .cal-day { min-height: 40px; }
.sched-right .quick-select { flex-wrap: nowrap; }
.sched-right .quick-select .chip { flex: 1 1 0; min-width: 0; padding: 0 6px; }
.sched-left .time-row input { min-width: 120px; }
.sched-actions { margin-top: 2px; }
.sched-actions .btn { width: 100%; }
.sched-actions #cancel-btn:not([hidden]) { width: auto; }
.sched-actions:has(#cancel-btn:not([hidden])) #save-btn { width: auto; flex: 1 1 auto; }
.sched-left .time-row input { min-width: 0; flex: 1 1 0; width: 0; }
.sched-left .time-row .btn { padding: 0 12px; font-size: 15px; white-space: nowrap; }
.sched-right .quick-select .chip { white-space: nowrap; font-size: 13px; padding: 0 4px; }
