/* Antrian Klinik — admin UI. Token di :root, tanpa !important. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --ok: #15803d;
  --ok-50: #f0fdf4;
  --warn: #b45309;
  --warn-50: #fffbeb;
  --r-sm: 8px;
  --r-md: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sidebar-w: 13.5rem;
  --font: Inter, "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 0.8rem/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.05rem; }
h2 { font-size: 0.9rem; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 0.5rem; }
form.inline { display: inline; }
.hidden { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 0.75rem 0.5rem;
  display: none;
  flex-direction: column;
  gap: 1rem;
}
.sidebar.open { display: flex; }
.brand { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.5rem; font-weight: 600; font-size: 0.9rem; }
.brand-mark { width: 1.4rem; height: 1.4rem; border-radius: 6px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 0.7rem; }
.brand.plain { padding: 0 0 0.75rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0.5rem 0.5rem 0.2rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.5rem; border-radius: var(--r-sm);
  color: var(--text); text-decoration: none;
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--primary-50); color: var(--primary-600); font-weight: 500; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar .who { text-align: right; line-height: 1.25; }
.topbar .who small { display: block; color: var(--muted); font-size: 0.7rem; }
.menu-btn { display: inline-flex; }
.content { width: 100%; max-width: 78rem; margin-inline: auto; padding: 1rem; }

@media (min-width: 64rem) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar { display: flex; position: sticky; top: 0; height: 100dvh; }
  .menu-btn { display: none; }
  .content { padding: 1.25rem 1.5rem; }
}

/* ---------- page bits ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.9rem; }
.page-head .sub { color: var(--muted); margin-top: 0.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.card-h { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card-b { padding: 0.8rem; }
.grid { display: grid; gap: 0.75rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.stack { display: grid; gap: 0.75rem; }

.stat { padding: 0.7rem 0.8rem; }
.stat .label { color: var(--muted); font-size: 0.72rem; }
.stat .value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.stat-num { font-size: 1.2rem; font-weight: 600; line-height: 1.3; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 2rem; padding: 0.3rem 0.75rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-50); }
.btn.sm { min-height: 1.6rem; padding: 0.15rem 0.5rem; font-size: 0.75rem; }
.btn.lg { min-height: 2.6rem; padding: 0.4rem 1.1rem; font-size: 0.9rem; }
@media (pointer: coarse) { .btn { min-height: 2.5rem; } .btn.sm { min-height: 2.2rem; } }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.chip.gray { background: #f3f4f6; color: #374151; border-color: var(--line); }
.chip.blue { background: var(--primary-50); color: var(--primary-600); border-color: #bfdbfe; }
.chip.green { background: var(--ok-50); color: var(--ok); border-color: #bbf7d0; }
.chip.amber { background: var(--warn-50); color: var(--warn); border-color: #fde68a; }
.chip.red { background: var(--danger-50); color: var(--danger); border-color: #fecaca; }

/* ---------- alerts ---------- */
.alert { padding: 0.5rem 0.75rem; border-radius: var(--r-sm); border: 1px solid var(--line); margin-bottom: 0.75rem; }
.alert.ok { background: var(--ok-50); border-color: #bbf7d0; color: var(--ok); }
.alert.err { background: var(--danger-50); border-color: #fecaca; color: var(--danger); }
.alert ul { margin: 0; padding-left: 1.1rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 500; background: #fafafa; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.wrap { overflow-wrap: anywhere; min-width: 10rem; }
.empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- forms ---------- */
.form { display: grid; gap: 0.75rem; max-width: 34rem; }
.form.wide { max-width: 44rem; }
.field { display: grid; gap: 0.25rem; }
.field label, .field .lbl { font-weight: 500; }
.field .hint { color: var(--muted); font-size: 0.72rem; }
.field .err { color: var(--danger); font-size: 0.72rem; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { padding: 0; margin-bottom: 0.35rem; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--line-strong); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; min-height: 2rem; padding: 0.3rem 0.6rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-50); border-color: var(--primary); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.row { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.check { display: flex; align-items: center; gap: 0.4rem; }
.check input { width: 1rem; height: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.toolbar input[type="search"] { max-width: 20rem; }
@media (max-width: 40rem) {
  input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select { font-size: 1rem; min-height: 2.5rem; }
}

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.75rem; border-top: 1px solid var(--line); color: var(--muted); }

/* ---------- pilih titik layanan (kartu radio) ---------- */
.choices { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.6rem 0.75rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
}
.choice b { font-size: 1rem; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-50); }
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- panel layanan ---------- */
.now { padding: 1rem; display: grid; gap: 0.75rem; }
.now .num { font-size: 3rem; font-weight: 700; line-height: 1; letter-spacing: 0.02em; }
.now .who { font-size: 0.95rem; font-weight: 500; }
.now-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- tiket cetak ---------- */
.ticket-print { max-width: 18rem; margin-inline: auto; text-align: center; padding: 1rem; }
.ticket-print .num { font-size: 3.2rem; font-weight: 700; line-height: 1.1; }
.ticket-print .meta { color: var(--muted); }
.ticket-print hr { border: 0; border-top: 1px dashed var(--line-strong); margin: 0.75rem 0; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 22rem; padding: 1.25rem; }
.auth-card h1 { margin-bottom: 0.9rem; }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .alert { display: none; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
}
