/* Crescent Care — design system. Tokens first; components use tokens only. */
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(../vendor/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(../vendor/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(../vendor/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(../vendor/fonts/inter-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans Tamil'; font-weight: 400; font-display: swap; src: url(../vendor/fonts/noto-sans-tamil-tamil-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans Tamil'; font-weight: 600; font-display: swap; src: url(../vendor/fonts/noto-sans-tamil-tamil-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans Tamil'; font-weight: 700; font-display: swap; src: url(../vendor/fonts/noto-sans-tamil-tamil-700-normal.woff2) format('woff2'); }

:root {
  --font: Inter, 'Noto Sans Tamil', system-ui, sans-serif;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #15211f;
  --ink-2: #4a5a57;
  --ink-3: #7b8a87;
  --line: #e1e7e5;
  --line-2: #cfd8d5;
  --primary: #0e6e66;
  --primary-ink: #ffffff;
  --primary-soft: #e3f2ef;
  --primary-dark: #0a524c;
  --accent: #c58a17;          /* crescent gold */
  --accent-soft: #fbf1dc;
  --green: #1d7a46; --green-soft: #e2f3e8;
  --amber: #a2650a; --amber-soft: #fcf0d9;
  --red: #b3261e; --red-soft: #fbe6e4;
  --blue: #1f5fa8; --blue-soft: #e3edf9;
  --violet: #6a3fa0; --violet-soft: #efe8f8;
  --grey-soft: #eef1f0;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16,40,36,.06), 0 1px 1px rgba(16,40,36,.04);
  --shadow-lg: 0 10px 30px rgba(16,40,36,.14);
  --sidebar: 236px;
  --focus: 0 0 0 3px rgba(14,110,102,.28);
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .6rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.ta { font-family: 'Noto Sans Tamil', var(--font); }
.mono { font-family: ui-monospace, 'DejaVu Sans Mono', monospace; font-size: .92em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
[x-cloak] { display: none !important; }

/* ---------- app shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: #0d2a27; color: #cfe3df; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 30px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; }
.brand svg { flex: none; }
.brand b { display: block; font-size: 1.02rem; letter-spacing: .01em; }
.brand small { color: #8fb3ad; font-size: .74rem; }
.nav-group { margin-top: 12px; }
.nav-group > span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #6f9590; padding: 6px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #cfe3df; font-size: .93rem; }
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 18px; height: 18px; opacity: .9; flex: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 650; font-size: 1.02rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; }
.pill.session { background: var(--accent-soft); color: #7a5208; font-weight: 600; }
.userchip { display: flex; align-items: center; gap: 8px; font-size: .86rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.content { padding: 20px 22px 60px; max-width: 1500px; width: 100%; }
.menu-btn { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 16px 60px; }
  .topbar { padding: 8px 16px; }
  .hide-sm { display: none !important; }
}

/* ---------- layout helpers */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 360px; }
.g-side-l { grid-template-columns: 320px minmax(0, 1fr); }
@media (max-width: 1100px) { .g-side, .g-side-l { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; } .mt0 { margin-top: 0; }

/* ---------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { margin: 0; }
.card-h .spacer { flex: 1; }
.card-b { padding: 14px 16px; }
.card-f { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card.flat { box-shadow: none; }
.section-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; margin: 0 0 8px; }

/* ---------- KPI tiles */
.kpi { padding: 14px 16px; }
.kpi .label { font-size: .8rem; color: var(--ink-3); }
.kpi .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--ink-2); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: .92rem; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--grey-soft); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .84rem; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 1rem; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.kbd { font-family: ui-monospace, monospace; font-size: .72rem; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-3); background: #fff; }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.req::after { content: ' *'; color: var(--red); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=tel], input[type=email], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; color: var(--ink); font: inherit; font-size: .95rem;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-2); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .92rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg label, .seg a, .seg button { padding: 7px 12px; font-size: .88rem; cursor: pointer; border: 0; background: none; color: var(--ink-2); border-right: 1px solid var(--line); font: inherit; text-decoration: none !important; }
.seg label:last-child, .seg a:last-child, .seg button:last-child { border-right: 0; }
.seg input { display: none; }
.seg input:checked + span, .seg .on { color: var(--primary-dark); font-weight: 650; }
.seg label:has(input:checked), .seg a.on, .seg button.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.form-grid .span2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid .span2 { grid-column: auto; } }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: #f6faf9; }
table.t tfoot td { font-weight: 650; background: var(--surface-2); }

/* ---------- badges & alerts */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: .74rem; font-weight: 650; white-space: nowrap; }
.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-grey { background: var(--grey-soft); color: var(--ink-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .92rem; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--green-soft); border-color: #bfe3cc; color: #14522f; }
.alert-error { background: var(--red-soft); border-color: #f1c3bf; color: #7d1b15; }
.alert-info { background: var(--blue-soft); border-color: #c6d9f1; color: #173f70; }
.alert-warn { background: var(--amber-soft); border-color: #f0d7a8; color: #6b4306; }
.allergy-flag { display: inline-flex; align-items: center; gap: 6px; background: var(--red); color: #fff; padding: 3px 10px; border-radius: 6px; font-weight: 650; font-size: .82rem; }

/* ---------- patient banner */
.pt-banner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pt-banner .nm { font-size: 1.12rem; font-weight: 700; }
.pt-banner .meta { color: var(--ink-2); font-size: .88rem; }
.pt-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--primary-soft); color: var(--primary-dark); flex: none; }
.pt-avatar.f { background: #fde7ef; color: #9b2c55; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; border: 0; background: none; font: inherit; font-size: .92rem; color: var(--ink-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.tabs .on { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 650; }

/* ---------- modal (Alpine: x-show) */
.modal-bg { position: fixed; inset: 0; background: rgba(10,30,28,.45); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(900px, 100%); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h3 { margin: 0; flex: 1; }
.modal-b { padding: 16px 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- search dropdown */
.search-box { position: relative; }
.search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 40; max-height: 360px; overflow: auto; }
.search-results .item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results .item:last-child { border-bottom: 0; }
.search-results .item:hover, .search-results .item.on { background: var(--primary-soft); }

/* ---------- token & queue */
.token { display: inline-grid; place-items: center; min-width: 58px; height: 34px; padding: 0 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.token.big { min-width: 120px; height: 70px; font-size: 2rem; border-radius: 12px; }
.queue-col { min-width: 0; }
.qitem { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.qitem:last-child { border-bottom: 0; }
.qitem.now { background: #fff8e9; }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-3); font-size: .92rem; }

/* ---------- bed board */
.beds { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bed { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 12px; min-height: 120px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.bed.free { border-style: dashed; background: var(--surface-2); }
.bed.occupied { border-left: 4px solid var(--blue); }
.bed.maint { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 8px, #f1f1f1 8px, #f1f1f1 16px); }
.bed .code { font-weight: 800; font-size: 1.05rem; }

/* ---------- toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0d2a27; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: .9rem; max-width: 360px; }
.toast.error { background: var(--red); }

/* ---------- timeline */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px 10px; }
.tl-item::before { content: ''; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.tl-item .when { font-size: .78rem; color: var(--ink-3); }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(160deg, #0d2a27, #0e6e66); color: #e5f4f1; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 2.2rem; color: #fff; max-width: 460px; }
.login-form { display: grid; place-items: center; padding: 30px 16px; }
.login-form .card { width: min(420px, 100%); }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- misc */
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; }
.qr { width: 150px; height: 150px; }
.qr svg, .qr img { width: 100%; height: 100%; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,245,.95); backdrop-filter: blur(4px); padding: 10px 0; border-top: 1px solid var(--line); margin-top: 16px; z-index: 5; }
.signed-stamp { display: inline-flex; gap: 6px; align-items: center; color: var(--green); font-weight: 650; font-size: .86rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line-2); font-size: .84rem; background: #fff; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary-dark); }

@media (max-width: 480px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar .pill.session { display: none; }
  .userchip .avatar { width: 26px; height: 26px; }
}
