/* ==========================================================================
   cural. shared stylesheet
   Light app on a cool off-white ground, indigo-violet accent.
   Light + dark (via prefers-color-scheme). No frameworks.
   ========================================================================== */

:root {
  /* Brand + semantic color */
  --primary:        #5A47E0;
  --primary-hover:  #4A38D0;
  --primary-soft:   rgba(90, 71, 224, .10);
  --primary-line:   rgba(90, 71, 224, .24);

  --ink:            #1A1D29;
  --muted:          #616779;
  --hairline:       rgba(26, 29, 41, .10);
  --hairline-strong: rgba(26, 29, 41, .16);

  --ground:         #F5F6FA;
  --surface:        #FFFFFF;
  --surface-2:      #FBFBFE;

  --mint:           #18B389;
  --mint-soft:      rgba(24, 179, 137, .12);
  --amber:          #E0952A;
  --amber-soft:     rgba(224, 149, 42, .14);
  --red:            #E0503A;
  --red-soft:       rgba(224, 80, 58, .12);
  --info:           #3D6FE0;
  --info-soft:      rgba(61, 111, 224, .12);

  /* Type */
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Metrics */
  --radius:      12px;
  --radius-sm:   9px;
  --radius-pill: 999px;
  --sidebar-w:   248px;
  --gutter:      16px;
  --shadow-1:    0 1px 2px rgba(26, 29, 41, .05);
  --shadow-2:    0 6px 24px rgba(26, 29, 41, .08);
  --shadow-pop:  0 10px 34px rgba(26, 29, 41, .14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary:        #8778F0;
    --primary-hover:  #9A8DF4;
    --primary-soft:   rgba(135, 120, 240, .16);
    --primary-line:   rgba(135, 120, 240, .34);

    --ink:            #ECEDF3;
    --muted:          #9AA0B4;
    --hairline:       rgba(236, 237, 243, .12);
    --hairline-strong: rgba(236, 237, 243, .20);

    --ground:         #14151C;
    --surface:        #1C1E27;
    --surface-2:      #21232E;

    --mint:           #3FD3A8;
    --mint-soft:      rgba(63, 211, 168, .16);
    --amber:          #F0B25A;
    --amber-soft:     rgba(240, 178, 90, .16);
    --red:            #F0705A;
    --red-soft:       rgba(240, 112, 90, .16);
    --info:           #6E96F0;
    --info-soft:      rgba(110, 150, 240, .16);

    --shadow-1:    0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2:    0 6px 24px rgba(0, 0, 0, .4);
    --shadow-pop:  0 10px 34px rgba(0, 0, 0, .5);
  }
}

/* --------------------------------------------------------------------------
   Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 16px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -.02em;
  color: var(--ink);
  display: inline-flex; align-items: baseline; gap: 1px;
}
.wordmark .dot { color: var(--primary); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center; flex: 0 0 auto;
}

.clinic-card {
  margin: 4px 12px 10px;
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex; align-items: center; gap: 10px;
}
.clinic-card__badge {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--primary); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.clinic-card__name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.clinic-card__meta { margin-top: 3px; }

.plan-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em;
  color: var(--primary); background: var(--primary-soft);
  border-radius: var(--radius-pill); padding: 2px 8px;
}
.plan-chip::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary);
}

.nav { padding: 6px 12px; overflow-y: auto; flex: 1; }
.nav__label {
  padding: 10px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 14px;
  margin-bottom: 1px; position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav__badge {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--red-soft); color: var(--red);
  border-radius: var(--radius-pill); padding: 1px 7px; line-height: 1.5;
}
.sidebar__foot {
  padding: 12px 18px; border-top: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.sidebar__foot .avatar { flex: 0 0 auto; }
.sidebar__foot-name { font-weight: 600; font-size: 13px; line-height: 1.2; }

/* Main column */
.main {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topbar__title { font-size: 19px; }
.topbar__spacer { flex: 1; }

.hamburger {
  display: none;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--hairline); background: var(--surface);
  color: var(--ink); place-items: center;
}
.hamburger svg { width: 18px; height: 18px; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-pill); padding: 7px 14px;
  color: var(--muted); width: 260px; max-width: 34vw;
}
.search svg { width: 15px; height: 15px; flex: 0 0 auto; }
.search input {
  border: 0; background: transparent; outline: none; width: 100%;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
.search input::placeholder { color: var(--muted); }

.date-control {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-pill); padding: 7px 13px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink);
}
.date-control svg { width: 15px; height: 15px; color: var(--muted); }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  border: 1px solid var(--hairline); background: var(--surface);
  color: var(--muted); display: grid; place-items: center; position: relative;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot-badge {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  border: 1.5px solid var(--surface);
}

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7A6BF0);
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px;
  flex: 0 0 auto;
}

/* Content */
.content { padding: 24px 28px 56px; max-width: 1240px; width: 100%; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; margin-bottom: 6px; }
.page-head p { color: var(--muted); margin: 0; max-width: 60ch; }

.section { margin-top: 30px; }
.section__head {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px;
}
.section__head h2 { font-size: 16px; }
.section__head .eyebrow { margin-left: auto; }
.section__link {
  margin-left: auto; color: var(--primary); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 4px;
}
.section__link svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   Cards, grids, tiles
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card__pad { padding: 18px; }
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--hairline);
}
.card__head h3 { font-size: 14.5px; }
.card__head .eyebrow { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { grid-template-columns: 1.5fr 1fr; }

/* KPI tile */
.kpi {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 3px;
}
.kpi__label { color: var(--muted); font-size: 13px; }
.kpi__value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 500; letter-spacing: -.02em; line-height: 1.05;
  margin-top: 2px;
}
.kpi__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; }
.kpi__trend { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.kpi__trend svg { width: 13px; height: 13px; }
.kpi__trend.up   { color: var(--mint); }
.kpi__trend.down { color: var(--mint); }
.kpi__trend.flat { color: var(--muted); }
.kpi__spark { flex: 0 0 auto; }

/* Summary tile (patients/billing) */
.tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow-1);
}
.tile__label { color: var(--muted); font-size: 12.5px; }
.tile__value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 25px; font-weight: 500; letter-spacing: -.02em; margin-top: 5px;
}
.tile__sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --------------------------------------------------------------------------
   Pills
   -------------------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 9px 4px 8px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--good   { color: var(--mint);  background: var(--mint-soft); }
.pill--warn   { color: var(--amber); background: var(--amber-soft); }
.pill--bad    { color: var(--red);   background: var(--red-soft); }
.pill--info   { color: var(--info);  background: var(--info-soft); }
.pill--accent { color: var(--primary); background: var(--primary-soft); }
.pill--muted  { color: var(--muted); background: var(--hairline); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { min-width: 640px; }
table.data th, table.data td {
  text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--hairline);
  font-size: 13.5px; white-space: nowrap;
}
table.data thead th {
  font-family: var(--font-mono); font-weight: 500; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); position: sticky; top: 0;
}
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.right, table.data th.right { text-align: right; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); }
.cell-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell .mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 10.5px;
}

/* --------------------------------------------------------------------------
   Lists (upcoming, tasks)
   -------------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list__item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--hairline);
}
.list__item:last-child { border-bottom: 0; }
.list__time {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 13px; color: var(--ink); width: 52px; flex: 0 0 auto;
}
.list__body { min-width: 0; flex: 1; }
.list__title { font-weight: 600; font-size: 13.5px; }
.list__meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.list__end { margin-left: auto; flex: 0 0 auto; }

.task__icon {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center;
}
.task__icon svg { width: 17px; height: 17px; }
.task__icon--mint  { background: var(--mint-soft);  color: var(--mint); }
.task__icon--amber { background: var(--amber-soft); color: var(--amber); }
.task__icon--red   { background: var(--red-soft);   color: var(--red); }

/* Provider dot */
.prov-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.prov-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.prov-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }

/* --------------------------------------------------------------------------
   Schedule calendar
   -------------------------------------------------------------------------- */
.date-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px;
}
.date-strip button {
  border: 1px solid var(--hairline); background: var(--surface);
  border-radius: var(--radius-sm); padding: 8px 4px; min-width: 58px;
  text-align: center; color: var(--muted); flex: 0 0 auto;
}
.date-strip button .dow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; display: block;
}
.date-strip button .dnum { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink); display: block; margin-top: 2px; }
.date-strip button[aria-current="date"] {
  background: var(--primary); border-color: var(--primary);
}
.date-strip button[aria-current="date"] .dow,
.date-strip button[aria-current="date"] .dnum { color: #fff; }

.calendar-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface); }
.calendar {
  --row-h: 62px;
  --time-col: 66px;
  min-width: 720px;
  display: grid;
  grid-template-columns: var(--time-col) repeat(3, 1fr);
}
.cal-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 9px;
}
.cal-head--time { justify-content: center; }
.cal-head__name { font-family: var(--font-display); font-weight: 700; font-size: 13.5px; }
.cal-head__role { color: var(--muted); font-size: 11.5px; }
.cal-col { position: relative; border-left: 1px solid var(--hairline); }
.cal-col--time { border-left: 0; }
.cal-cell {
  height: var(--row-h); border-bottom: 1px solid var(--hairline);
}
.cal-time {
  height: var(--row-h); border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: center; padding-top: 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.cal-body { position: relative; }
.appt {
  position: absolute; left: 5px; right: 5px;
  border-radius: 9px; padding: 7px 9px; overflow: hidden;
  border-left: 3px solid var(--prov, var(--primary));
  background: var(--surface); box-shadow: var(--shadow-1);
  border-top: 1px solid var(--hairline); border-right: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  cursor: default;
}
.appt__time { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.appt__name { font-weight: 600; font-size: 12.5px; line-height: 1.25; margin-top: 1px; }
.appt__reason { color: var(--muted); font-size: 11.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt__status { margin-top: 5px; }
.appt--completed { opacity: .72; }
.appt--noshow { background: var(--red-soft); }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* Toolbar / filters */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.chip-row { display: inline-flex; gap: 6px; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 3px; }
.chip {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: var(--radius-pill);
}
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; }
.toolbar__count { margin-left: auto; color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); }

.demo-note {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--hairline);
  color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px;
}
.demo-note svg { width: 14px; height: 14px; flex: 0 0 auto; color: var(--muted); }

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; background: rgba(26, 29, 41, .42);
  z-index: 39; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 244px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .content { padding: 20px 16px 48px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .search { display: none; }
  .topbar__title { font-size: 17px; }
  .date-control span.date-full { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .kpi, .tile, .card { transition: transform .18s ease, box-shadow .18s ease; }
  .kpi:hover, .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
  .appt { transition: transform .14s ease, box-shadow .14s ease; }
  .appt:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
}
