:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #14211f;
  --muted: #66736f;
  --line: #dce4e0;
  --brand: #0f766e;
  --brand-2: #115e59;
  --accent: #9f1239;
  --amber: #b45309;
  --green: #15803d;
  --red: #b91c1c;
  --blue: #1d4ed8;
  --shadow: 0 12px 32px rgba(20, 33, 31, .08);
  --shadow-soft: 0 1px 2px rgba(20, 33, 31, .05);
  --radius: 8px;
  --sidebar: 232px;
  --header: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15,118,110,.22); outline-offset: 2px; }

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.login-panel { background: var(--surface); padding: 48px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
.login-visual { padding: 64px; display: flex; align-items: center; background: linear-gradient(145deg, #0f766e, #164e63); color: white; }
.login-visual h1 { font-size: 52px; line-height: 1; margin: 0 0 18px; letter-spacing: 0; }
.login-visual p { font-size: 18px; max-width: 560px; color: rgba(255,255,255,.82); }
.brand { font-weight: 800; font-size: 22px; color: var(--brand); margin-bottom: 36px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span, .field label { font-size: 12px; font-weight: 800; color: var(--ink); }
.input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: white; color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--brand); }

.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; z-index: 8; }
.logo { padding: 8px 10px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.logo strong { display: block; font-size: 21px; color: var(--brand); }
.logo span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nav { display: grid; gap: 4px; }
.nav button { height: 40px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 0 12px; text-align: left; font-weight: 700; }
.nav button.active, .nav button:hover { background: var(--brand); color: white; box-shadow: var(--shadow-soft); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 8px 0; font-size: 12px; color: var(--muted); }
.topbar { position: fixed; left: var(--sidebar); right: 0; top: 0; min-height: var(--header); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 28px; z-index: 4; }
.content { margin-left: var(--sidebar); padding: calc(var(--header) + 24px) 28px 32px; max-width: 1680px; }
.page-title { margin: 0; font-size: 22px; line-height: 1.15; }
.subtle { color: var(--muted); font-size: 13px; }

.btn { border: 0; min-height: 38px; padding: 0 14px; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: #fee2e2; color: var(--red); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { min-height: 32px; font-size: 12px; padding: 0 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1.2fr .8fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(20,33,31,.03); min-width: 0; }
.card.pad { padding: 18px; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-body { padding: 16px; overflow-x: auto; }
.kpi strong { display: block; font-size: 28px; margin-bottom: 4px; }
.kpi span { color: var(--muted); font-size: 13px; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 900; text-transform: capitalize; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.scheduled { background: #fef3c7; color: var(--amber); }
.confirmed, .in_progress, .in-progress { background: #dbeafe; color: var(--blue); }
.waiting, .billing_pending, .billing-pending, .partial, .issued, .ready { background: #ffedd5; color: var(--amber); }
.completed, .paid, .delivered, .synced { background: #dcfce7; color: var(--green); }
.cancelled, .no_show, .void { background: #fee2e2; color: var(--red); }

.table { width: 100%; min-width: 760px; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: #fafbf9; }
.table tr:hover td { background: #fbfcfa; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.lane { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: stretch; }
.time-col { color: var(--muted); font-size: 12px; padding-top: 12px; }
.slot { padding: 12px 14px; border-left: 4px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border-radius: 0 var(--radius) var(--radius) 0; }
.slot.in_progress, .slot.in-progress { border-left-color: var(--blue); background: #eff6ff; }
.slot.waiting { border-left-color: var(--amber); background: #fff7ed; }
.slot.billing_pending, .slot.billing-pending { border-left-color: var(--amber); }
.slot.completed { border-left-color: var(--green); opacity: .75; }
.slot.no_show { border-left-color: var(--red); opacity: .72; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 14px 8px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.timeline { display: grid; gap: 12px; }
.timeline-item { border-left: 3px solid var(--brand); padding: 12px 14px; background: #fafbf9; border-radius: 0 var(--radius) var(--radius) 0; }
.timeline-item.warn { border-left-color: var(--amber); background: #fff7ed; }
.split { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 18px; align-items: start; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.compact-select { min-height: 38px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; background: var(--surface); color: var(--ink); font-weight: 800; max-width: 180px; }
.dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: white; display: inline-grid; place-items: center; font-size: 11px; }
.drawer { position: fixed; inset: 0; background: rgba(20,33,31,.38); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-panel { width: min(560px, 96vw); background: white; height: 100%; box-shadow: var(--shadow); padding: 24px; overflow: auto; }
#toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 50; }
.toast { background: var(--ink); color: white; border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; max-width: 360px; }
.empty { padding: 48px 18px; text-align: center; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.error-box { background: #111827; color: #f9fafb; border-radius: var(--radius); padding: 14px; overflow: auto; max-height: 240px; font-size: 12px; }
.search-results { display: grid; gap: 8px; margin-top: 14px; max-height: 56vh; overflow: auto; }
.search-result { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px; display: grid; gap: 4px; }
.search-result:hover { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.search-result span { color: var(--muted); font-size: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.mt8 { margin-top: 8px; }
.grow { flex: 1; min-width: 220px; }
.sticky { position: sticky; top: calc(var(--header) + 24px); }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: white; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.alert { padding: 10px 12px; border-radius: var(--radius); background: #ecfeff; color: #155e75; margin: 12px 0; font-size: 13px; }
.alert.danger { background: #fee2e2; color: var(--red); }
.info-list { display: grid; grid-template-columns: 96px 1fr; gap: 8px 10px; font-size: 13px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 14px 0 8px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.live-layout { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); align-items: start; }
.doctor-lane { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: white; }
.lane-head { border-left: 4px solid var(--doc); padding: 12px 14px; background: #fafbf9; display: flex; justify-content: space-between; gap: 12px; }
.lane-head span { color: var(--muted); font-size: 12px; }
.slot.muted { opacity: .72; background: var(--surface-2); }
.tooth-grid { display: grid; grid-template-columns: repeat(16, minmax(32px, 1fr)); gap: 6px; margin: 16px 0; overflow-x: auto; }
.tooth { min-height: 42px; border: 1px solid var(--line); background: white; border-radius: 7px; color: var(--muted); font-size: 12px; }
.tooth.selected { background: var(--brand); color: white; border-color: var(--brand); }
.tooth.treated { border-color: var(--green); background: #dcfce7; color: var(--green); }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; font-size: 13px; }
.result { width: 100%; justify-content: flex-start; margin-bottom: 6px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,33,31,.42); display: grid; place-items: center; z-index: 80; padding: 18px; }
.modal { width: min(560px, 96vw); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.modal-head, .modal-foot { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-foot { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 18px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; color: var(--muted); }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .sidebar { position: static; width: auto; height: auto; }
  .topbar { position: static; height: auto; margin-left: 0; padding: 16px; align-items: flex-start; }
  .content { margin-left: 0; padding: 18px; }
  .shell { display: block; }
  .cols-2, .cols-3, .cols-4, .split, .lane, .live-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .tooth-grid { grid-template-columns: repeat(8, minmax(32px, 1fr)); }
  .table { min-width: 680px; }
  .compact-select { max-width: 100%; }
}
