/* Optical OS — UI prototype (opus)
   Neutral, calm design system. Tokens mirror shadcn/ui naming so they
   translate directly into a Tailwind theme. */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f2f2ee;
  --border: #e6e5e0;
  --border-strong: #d4d2cb;
  --text: #1b1b19;
  --text-2: #4b4b47;
  --muted: #85847d;
  --primary: #1e2933;
  --primary-hover: #2c3a47;
  --primary-fg: #ffffff;
  --accent: #2e6b66;
  --accent-soft: #e7f0ee;
  --ring: rgba(46, 107, 102, 0.28);

  --green: #3b7a55;   --green-soft: #eaf3ed;
  --amber: #9a6411;   --amber-soft: #faf1df;
  --red: #b0372c;     --red-soft: #fbecea;
  --blue: #36609a;    --blue-soft: #eaf0f8;
  --violet: #66519a;  --violet-soft: #f0ecf7;
  --gray: #6b6a64;    --gray-soft: #f0efeb;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.04);
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.04), 0 4px 16px rgba(20, 20, 15, 0.05);
  --shadow-lg: 0 10px 40px rgba(20, 20, 15, 0.14);

  --sidebar-w: 244px;
  --topbar-h: 56px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #121313;
  --surface: #191a1a;
  --surface-2: #1d1e1e;
  --surface-3: #232424;
  --border: #2a2b2b;
  --border-strong: #3a3b3b;
  --text: #ededea;
  --text-2: #bdbcb6;
  --muted: #8a8983;
  --primary: #e9e8e3;
  --primary-hover: #ffffff;
  --primary-fg: #161717;
  --accent: #7fbab3;
  --accent-soft: #1f2e2c;
  --ring: rgba(127, 186, 179, 0.3);
  --green: #7fc29a;  --green-soft: #1d2a22;
  --amber: #e0b066;  --amber-soft: #2d2618;
  --red: #ee8b80;    --red-soft: #321e1c;
  --blue: #8fb0e0;   --blue-soft: #1c2433;
  --violet: #b6a3e0; --violet-soft: #252033;
  --gray: #a9a8a2;   --gray-soft: #262727;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--primary); color: var(--primary-fg);
  display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 650; letter-spacing: -0.02em; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.loc-switch {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; text-align: left;
}
.loc-switch:hover { border-color: var(--border-strong); }
.loc-switch .grow { flex: 1; min-width: 0; }
.loc-switch .t { font-weight: 550; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.nav-item.active svg { color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-foot .grow > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .icon-btn { width: 30px; height: 30px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.crumbs .cur { color: var(--text); font-weight: 550; }
.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: 320px; max-width: 40vw;
  padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  color: var(--muted); cursor: pointer;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger .kbd { margin-left: auto; }
.kbd { font-family: var(--font); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2);
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg); }
.menu-btn { display: none; }

.page { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.g-side { grid-template-columns: 220px minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 6px 8px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card.flat { box-shadow: none; }
.card.inset { background: var(--surface-2); box-shadow: none; }

/* ---------- Stat ---------- */
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.delta-up { color: var(--green); font-weight: 550; }
.delta-down { color: var(--red); font-weight: 550; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 13.5px; white-space: nowrap;
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.06); background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label-sm { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2385847d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input-sm { height: 30px; font-size: 13px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 33px; }
.input-wrap .suffix { position: absolute; right: 10px; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(14px); }

/* ---------- Segmented / tabs ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--text); }
.tab .count { font-size: 11.5px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.chip .count { opacity: .7; font-variant-numeric: tabular-nums; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.teal { background: var(--accent-soft); color: var(--accent); }
.badge.outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); }

/* ---------- Avatar ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.t1 { background: #e9efe9; color: #46664f; } .avatar.t2 { background: #ebedf3; color: #4b5878; }
.avatar.t3 { background: #f3ece6; color: #7a5a40; } .avatar.t4 { background: #eeebf3; color: #5f5279; }
.avatar.t5 { background: #e7f0ef; color: #3b6a65; } .avatar.t6 { background: #f2eeea; color: #6c6158; }
[data-theme="dark"] .avatar[class*=" t"] { background: var(--surface-3); color: var(--text-2); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .n { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .s { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table.compact td { padding: 8px 14px; }
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.pager .btns { margin-left: auto; display: flex; gap: 6px; }

/* ---------- List ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }
.time-col { width: 56px; flex: none; font-variant-numeric: tabular-nums; font-weight: 550; }
.time-col .d { display: block; font-size: 11.5px; color: var(--muted); font-weight: 450; }
.att-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.att-icon.red { background: var(--red-soft); color: var(--red); }
.att-icon.amber { background: var(--amber-soft); color: var(--amber); }
.att-icon.blue { background: var(--blue-soft); color: var(--blue); }
.att-icon.green { background: var(--green-soft); color: var(--green); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.hbar { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 70px; gap: 12px; align-items: center; font-size: 13px; }
.hbar-track { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; background: var(--primary); opacity: .82; }
.hbar-fill.accent { background: var(--accent); opacity: 1; }

/* ---------- Schedule ---------- */
.sched-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sched-date { font-weight: 600; font-size: 15px; min-width: 190px; }
.sched { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.cal { overflow: hidden; }
.cal-head { display: grid; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-head > div { padding: 10px 12px; border-left: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.cal-head > div:first-child { border-left: 0; }
.cal-body { display: grid; position: relative; max-height: calc(100vh - 230px); overflow-y: auto; }
.cal-times { position: relative; }
.cal-time { position: absolute; right: 8px; font-size: 11px; color: var(--muted); transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-left: 1px solid var(--border); }
.cal-slot-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.cal-slot-line.half { border-top-style: dashed; opacity: .6; }
.cal-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--red); z-index: 3; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.appt {
  position: absolute; left: 6px; right: 6px; z-index: 2;
  padding: 6px 9px; border-radius: 8px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gray);
  box-shadow: var(--shadow-sm); cursor: pointer; font-size: 12.5px;
  transition: box-shadow .12s, transform .12s;
}
.appt:hover { box-shadow: var(--shadow); z-index: 4; }
.appt.sel { box-shadow: 0 0 0 2px var(--accent); z-index: 4; }
.appt .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .m { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.k-exam { border-left-color: #5d7f9c; background: color-mix(in srgb, #5d7f9c 7%, var(--surface)); }
.appt.k-cl { border-left-color: #6f8f7a; background: color-mix(in srgb, #6f8f7a 8%, var(--surface)); }
.appt.k-follow { border-left-color: #9a8466; background: color-mix(in srgb, #9a8466 8%, var(--surface)); }
.appt.k-pickup { border-left-color: #82769c; background: color-mix(in srgb, #82769c 8%, var(--surface)); }
.appt.k-child { border-left-color: #5f9590; background: color-mix(in srgb, #5f9590 8%, var(--surface)); }
.appt.s-CANCELLED, .appt.s-NO_SHOW { opacity: .55; }
.appt.s-CANCELLED .t { text-decoration: line-through; }
.appt.s-COMPLETED { opacity: .7; }
.appt .st { position: absolute; top: 6px; right: 7px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--gray); }
.status-dot.green { background: var(--green); } .status-dot.amber { background: var(--amber); } .status-dot.blue { background: var(--blue); }
.status-dot.red { background: var(--red); } .status-dot.violet { background: var(--violet); } .status-dot.teal { background: var(--accent); }
.week { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.week-col { border-left: 1px solid var(--border); min-height: 420px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.week-col:first-child { border-left: 0; }
.week-col.today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.week-item { padding: 6px 8px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; border-left: 3px solid var(--gray); }

/* ---------- Patient header ---------- */
.patient-hero { display: flex; gap: 18px; align-items: center; padding: 18px; flex-wrap: wrap; }
.patient-hero h1 { font-size: 20px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); font-size: 13px; margin-top: 6px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { color: var(--muted); width: 14px; height: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Rx grid ---------- */
.rx { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.rx th { font-size: 11.5px; font-weight: 550; color: var(--muted); text-align: center; padding: 6px 6px; text-transform: uppercase; letter-spacing: .04em; }
.rx th:first-child { text-align: left; }
.rx td { text-align: center; padding: 7px 6px; border-top: 1px solid var(--border); font-weight: 550; }
.rx td:first-child { text-align: left; font-weight: 650; width: 48px; }
.rx .eye { display: inline-grid; place-items: center; width: 30px; height: 22px; border-radius: 6px; background: var(--surface-3); font-size: 11.5px; font-weight: 650; }
.rx input { width: 100%; min-width: 58px; height: 32px; text-align: center; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); font-variant-numeric: tabular-nums; outline: none; }
.rx input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.rx input[readonly] { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.diff { font-size: 11px; font-weight: 600; margin-left: 3px; }
.diff.up { color: var(--amber); } .diff.down { color: var(--blue); }

/* ---------- Encounter ---------- */
.enc { display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.enc-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.enc-nav a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.enc-nav a:hover { background: var(--surface-3); color: var(--text); }
.enc-nav a .ck { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.enc-nav a .ck.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.enc-nav a .ck.done svg { width: 10px; height: 10px; stroke-width: 3; }
.enc-section { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.enc-aside { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.enc-bar { position: sticky; top: var(--topbar-h); z-index: 10; margin: -24px -24px 20px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.locked-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--green-soft); color: var(--green); font-size: 13px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.notice svg { margin-top: 1px; color: var(--muted); }
.notice.amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.notice.amber svg { color: var(--amber); }
.notice.blue { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.notice.blue svg { color: var(--blue); }

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; padding: 8px 12px 8px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; color: var(--text-2); font-size: 13px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; background: var(--surface-3); color: var(--text-2); }
.step.on { border-color: var(--text); color: var(--text); }
.step.on .n { background: var(--primary); color: var(--primary-fg); }
.step.done .n { background: var(--accent); color: #fff; }
.step.done .n svg { width: 12px; height: 12px; stroke-width: 3; }
.step-line { flex: 0 0 16px; align-self: center; height: 1px; background: var(--border-strong); }

/* ---------- Option cards ---------- */
.opt-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.opt { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.opt:hover { border-color: var(--border-strong); }
.opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.opt.on::after { content: ""; position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center no-repeat; }
.opt .t { font-weight: 600; }
.opt .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.opt .p { margin-top: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.frame-img { height: 92px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; margin-bottom: 12px; color: var(--text-2); }
.frame-img svg { width: 120px; height: 46px; }
.list-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.list-opt:hover { border-color: var(--border-strong); }
.list-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.list-opt .price { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Summary ---------- */
.summary-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.summary-line .l { color: var(--text-2); }
.summary-line.total { font-size: 16px; font-weight: 650; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--border); }
.summary-line.neg .r { color: var(--green); }
.sticky-col { position: sticky; top: calc(var(--topbar-h) + 20px); }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; min-height: 380px; display: flex; flex-direction: column; gap: 8px; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 6px; font-weight: 600; font-size: 13px; }
.board-col-head .count { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; }
.ocard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 12px; cursor: pointer; box-shadow: var(--shadow-sm); }
.ocard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.ocard .id { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.ocard .n { font-weight: 600; margin-top: 3px; }
.ocard .d { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.ocard .f { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--border-strong); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.tl-item.on::before { border-color: var(--accent); background: var(--accent); }
.tl-item.cur::before { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.tl-item .t { font-weight: 550; font-size: 13.5px; }
.tl-item .s { font-size: 12.5px; color: var(--muted); }
.tl-item.future { opacity: .5; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.prod { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: border-color .12s, box-shadow .12s; }
.prod:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.prod .cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.prod .n { font-weight: 600; font-size: 13.5px; }
.prod .s { font-size: 12px; color: var(--muted); }
.prod .p { margin-top: 8px; font-weight: 650; display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.qty button { width: 26px; height: 26px; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--text-2); }
.qty button:hover { background: var(--surface-3); }
.qty span { width: 28px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pay-m { border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; text-align: center; cursor: pointer; font-size: 12px; font-weight: 550; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-2); background: var(--surface); }
.pay-m.on { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--ring); }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; margin-bottom: 8px; opacity: .6; }

/* ---------- Overlay: drawer / modal / palette ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 16, .28); backdrop-filter: blur(2px); animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: 480px; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { font-size: 16px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal { position: fixed; z-index: 51; left: 50%; top: 12vh; transform: translateX(-50%); width: 520px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .16s ease; }
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { font-size: 16px; }
.modal-head p { color: var(--muted); margin-top: 4px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.palette { width: 600px; top: 14vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 15px; }
.palette-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .05em; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-item:hover, .palette-item.on { background: var(--surface-3); }
.palette-item .s { margin-left: auto; font-size: 12px; color: var(--muted); }
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; min-width: 280px; background: var(--primary); color: var(--primary-fg); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .16s ease; }
.toast svg { color: #9fd3c9; }
[data-theme="dark"] .toast svg { color: var(--accent); }
.popover { position: absolute; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 240px; }
.popover .palette-item { font-size: 13.5px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 6px) scale(.98); } }
.toast { animation-name: toastIn; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-form { display: flex; flex-direction: column; padding: 32px 48px; }
.auth-form .inner { margin: auto; width: 100%; max-width: 360px; }
.auth-form h1 { font-size: 24px; }
.auth-side { margin: 12px; border-radius: 20px; background: var(--primary); color: #e9ece9; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 44px; }
[data-theme="dark"] .auth-side { background: #1f2a2a; }
.auth-side h2 { font-size: 26px; font-weight: 600; line-height: 1.25; max-width: 460px; color: #fff; letter-spacing: -0.02em; }
.auth-side p { color: #b9c2c3; margin-top: 12px; max-width: 440px; }
.lens-art { position: absolute; top: 10%; right: -60px; width: 520px; height: 300px; opacity: .9; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 24px; }
.flow span { font-size: 12px; padding: 5px 10px; border-radius: 20px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); color: #d6dcdc; }
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp input { height: 46px; text-align: center; font-size: 18px; font-weight: 600; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); outline: none; }
.otp input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ---------- Import ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 34px; text-align: center; background: var(--surface-2); }
.dropzone svg { width: 26px; height: 26px; color: var(--muted); }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 6px; }

/* ---------- Settings ---------- */
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.subnav button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 9px; }
.subnav button:hover { background: var(--surface-3); color: var(--text); }
.subnav button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }

/* ---------- Chart series / small fixes ---------- */
.bar-a { fill: var(--accent); }
.bar-b { fill: var(--primary); opacity: .78; }
.lg-a { background: var(--accent); }
.lg-b { background: var(--primary); opacity: .78; }
.appt.tiny { display: flex; align-items: center; gap: 6px; padding: 2px 8px; }
.appt.tiny .t { flex: none; max-width: 55%; }
.appt.tiny .m { min-width: 0; }
.enc-nav, .enc-aside { top: calc(var(--topbar-h) + 84px); }
.enc-section { scroll-margin-top: calc(var(--topbar-h) + 84px); }
.list-opt.disabled { pointer-events: none; }
.card-foot svg.i { color: var(--muted); }
.card-foot .btn svg.i { color: inherit; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .enc { grid-template-columns: 180px minmax(0, 1fr); }
  .enc-aside { display: none; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .g-main, .sched, .pos { grid-template-columns: 1fr; }
  .sticky-col { position: static; }
}
@media (max-width: 960px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; z-index: 55; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .search-trigger { width: auto; }
  .search-trigger .lbl, .search-trigger .kbd { display: none; }
  .enc { grid-template-columns: 1fr; }
  .enc-nav { display: none; }
  .g-3, .g-2, .g-side { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .page { padding: 18px; }
  .enc-bar { margin: -18px -18px 18px; padding: 12px 18px; }
}
@media (max-width: 640px) {
  .g-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
