/* Akeso design tokens + chrome (run 1). Apple-clinical: calm, dense, legible. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5;
  --ink: #16181d; --ink-2: #5c6470; --ink-3: #9aa2af;
  --line: #e3e6eb; --accent: #0a7ea4; --accent-ink: #ffffff;
  --ok: #1f9d55; --warn: #d97706; --crit: #dc2626;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 650; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 550; }

.btn { display: inline-block; border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.brand { font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { color: var(--ink-3); font-size: 12px; margin-left: 8px; font-weight: 500; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fef2f2; color: var(--crit); border: 1px solid #fecaca; }
.empty { text-align: center; padding: 80px 20px; color: var(--ink-2); }

/* ---------- landing ---------- */
.landing { background: #0b1220; color: #e8ecf3; min-height: 100vh; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 40px; max-width: 1200px; margin: 0 auto; }
.landing .brand { color: #fff; }
.landing .btn-ghost { color: #e8ecf3; border-color: #2c3648; }
.hero { max-width: 900px; margin: 0 auto; padding: 90px 40px 60px; text-align: center; }
.hero-kicker { color: #7dd3fc; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; }
.hero h1 { font-size: clamp(34px, 5.4vw, 58px); letter-spacing: -.025em; font-weight: 700; margin: 14px 0; }
.hero-sub { color: #a7b0c0; font-size: 17px; max-width: 640px; margin: 0 auto 28px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; }
.suite { max-width: 1200px; margin: 0 auto; padding: 40px; }
.suite h2, .principles h2 { font-size: 26px; letter-spacing: -.02em; }
.suite-sub { color: #a7b0c0; margin-bottom: 26px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.product-card { background: #111a2c; border: 1px solid #1f2a3f; border-radius: var(--radius); padding: 20px; position: relative; transition: transform .15s ease, border-color .15s; }
.product-card:hover { transform: translateY(-2px); border-color: #33445f; }
.product-card.is-building { border-color: #0a7ea4; }
.product-glyph { font-size: 26px; margin-bottom: 10px; }
.product-card h3 { font-size: 16px; color: #fff; }
.product-card p { color: #98a2b3; font-size: 13px; margin: 0; }
.product-status { position: absolute; top: 14px; right: 14px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: #1c2739; color: #7c8798; }
.status-building { background: #0a7ea422; color: #7dd3fc; }
.principles { max-width: 1200px; margin: 0 auto; padding: 30px 40px 70px; }
.principle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.principle-grid > div { background: #111a2c; border: 1px solid #1f2a3f; border-radius: var(--radius); padding: 18px; }
.principle-grid h3 { font-size: 15px; color: #fff; }
.principle-grid p { color: #98a2b3; font-size: 13px; margin: 0; }
.landing-footer { border-top: 1px solid #1f2a3f; padding: 22px 40px; text-align: center; color: #667085; font-size: 13px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px; width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; margin-top: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.auth-note { color: var(--ink-3); font-size: 12px; margin: 14px 0 0; }
.auth-back { display: inline-block; margin-top: 10px; font-size: 13px; }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-spacer { flex: 1; }
.clinic-select { max-width: 240px; }
.user-chip { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.icon-button, .ai-button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 36px; height: 36px; font-size: 16px; display: grid; place-items: center; }
.ai-button { background: linear-gradient(135deg, #0a7ea4, #6d28d9); color: #fff; border: none; box-shadow: 0 2px 10px rgba(109,40,217,.35); }
.logout-form { margin: 0; }
.app-body { display: flex; flex: 1; min-height: 0; }
.patient-rail { width: 280px; min-width: 280px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px; gap: 10px; overflow-y: auto; }
.rail-head { display: flex; align-items: center; justify-content: space-between; }
.rail-head h2 { font-size: 15px; margin: 0; }
.patient-search { width: 100%; }
.patient-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.patient-list li { padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.patient-list li:hover { background: var(--surface-2); }
.patient-list li.active { background: color-mix(in srgb, var(--accent) 9%, white); border-color: color-mix(in srgb, var(--accent) 30%, white); }
.patient-list .p-name { font-weight: 600; font-size: 14px; }
.patient-list .p-meta { font-size: 12px; color: var(--ink-3); }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.rail-foot h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.activity-feed { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-2); max-height: 180px; overflow-y: auto; }
.activity-feed li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.activity-feed .a-ts { color: var(--ink-3); font-family: var(--mono); font-size: 10px; }

.dashboard { flex: 1; overflow-y: auto; padding: 18px; min-width: 0; }
.dash-empty { text-align: center; color: var(--ink-2); padding: 90px 30px; max-width: 560px; margin: 0 auto; }
.panel-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); grid-column: span 3; overflow: hidden; }
.panel.span-2 { grid-column: span 2; } .panel.span-3 { grid-column: span 3; }
.panel.span-4 { grid-column: span 4; } .panel.span-6 { grid-column: span 6; }
.panel.fullscreen { position: fixed; inset: 12px; z-index: 60; grid-column: auto; overflow: auto; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.panel-head h3 { font-size: 14px; margin: 0; flex: 1; }
.panel-head .p-tools { display: flex; gap: 4px; }
.panel-head button { border: none; background: transparent; color: var(--ink-3); border-radius: 6px; width: 26px; height: 26px; font-size: 13px; }
.panel-head button:hover { background: var(--surface-2); color: var(--ink); }
.panel-body { padding: 14px; min-height: 90px; color: var(--ink-2); font-size: 13.5px; }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed { opacity: .85; }
.panel-placeholder { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 14px; color: var(--ink-3); font-size: 12.5px; background: var(--surface-2); }

/* ---------- modal ---------- */
.modal { border: none; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; width: min(480px, 92vw); }
.modal::backdrop { background: rgba(11,18,32,.45); backdrop-filter: blur(2px); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.form-grid label:first-child, .form-grid label:nth-child(2) { grid-column: span 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 900px) {
  .patient-rail { width: 220px; min-width: 220px; }
  .panel-grid { grid-template-columns: repeat(2, 1fr); }
  .panel, .panel.span-2, .panel.span-3, .panel.span-4, .panel.span-6 { grid-column: span 2; }
}
