:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --red: #b91c1c;
  --green: #047857;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
  --sidebar: 248px;
  color: var(--ink);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-brand {
  padding: 48px;
  background:
    radial-gradient(900px 400px at 0% 0%, rgba(37, 99, 235, 0.18), transparent 50%),
    linear-gradient(160deg, #ffffff 0%, #f8fafc 45%, #ecfeff 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand-mark { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--blue); color: white; display: grid; place-items: center; font-weight: 700;
}
.wordmark { font-family: Newsreader, Georgia, serif; font-size: 28px; margin: 0; }
.eyebrow { letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: var(--teal); font-weight: 700; }
.login-brand h1 { font-family: Newsreader, Georgia, serif; font-size: 52px; line-height: 1.05; margin: 18px 0; max-width: 640px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: white; }
.panel-card { width: min(460px, 100%); }
.demo-accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.demo-accounts button, .btn, .btn-primary, .btn-ghost, .btn-danger {
  border-radius: 10px; border: 1px solid var(--line); background: white; padding: 8px 12px; text-align: left;
}
.btn, .btn-primary, .btn-ghost, .btn-danger { text-align: center; font-weight: 600; }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: #fecaca; background: #fff5f5; }
.demo-accounts button small { display: block; color: var(--muted); font-weight: 500; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: white; border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; padding: 18px 12px; display: flex; flex-direction: column; gap: 8px;
}
.nav-scroll { overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-weight: 600;
}
.nav-link.active, .nav-link:hover { background: #eff6ff; color: var(--blue); }
.main { flex: 1; min-width: 0; }
.topbar {
  height: 68px; display: flex; align-items: center; gap: 16px; padding: 0 24px;
  background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; position: relative; }
.search input, .field input, .field select, .field textarea, .filters select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: white; color: var(--ink);
}
.field select option { color: #1e293b; background: white; }
.field select option:disabled { color: #94a3b8; }
.field textarea { min-height: 90px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; background: white; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 6;
}
.search-results a { display: block; padding: 10px 12px; text-decoration: none; color: var(--ink); }
.search-results a:hover { background: #f8fafc; }
.banner {
  background: var(--amber-bg); color: var(--amber); padding: 8px 24px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid #fde68a;
}
.page { padding: 24px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.muted { color: var(--muted); }
.grid-4, .grid-3, .grid-2 { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.2fr 0.8fr; }
.card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: 0 1px 0 rgba(15,23,42,.02); }
.kpi strong { display: block; font-size: 28px; margin-top: 6px; }
.kpi span { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; background: #e2e8f0; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.teal { background: var(--teal-soft); color: var(--teal); }
.badge.green { background: #d1fae5; color: var(--green); }
.badge.amber { background: #fef3c7; color: var(--amber); }
.badge.red { background: #fee2e2; color: var(--red); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.active { background: #eff6ff; color: var(--blue); border-color: #bfdbfe; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: white; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal { width: min(720px, 100%); background: white; border-radius: 18px; padding: 20px; max-height: 90vh; overflow: auto; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--ink); color: white; padding: 12px 14px; border-radius: 12px; max-width: 360px; }
.toast.error { background: var(--red); }
.bed-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.bed { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: white; }
.bed.occupied { background: #fff1f2; }
.bed.available { background: #f0fdf4; }
.timeline { border-left: 2px solid var(--line); margin-left: 8px; padding-left: 16px; }
.timeline article { margin-bottom: 14px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 42px; background: white; border: 1px solid var(--line); border-radius: 12px; min-width: 220px; box-shadow: var(--shadow); }
.menu-pop button, .menu-pop a { display: block; width: 100%; text-align: left; padding: 10px 12px; background: none; border: 0; text-decoration: none; color: var(--ink); }
.icon-btn { border: 1px solid var(--line); background: white; border-radius: 999px; width: 38px; height: 38px; }
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; }
.step b { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #eff6ff; color: var(--blue); }
.error-text { color: var(--red); font-size: 13px; margin-top: 4px; }
.chart-box { height: 260px; }
@media (min-width: 801px) {
  #menu-toggle { display: none; }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2, .login-screen { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; z-index: 10; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .grid-4, .grid-3, .demo-accounts { grid-template-columns: 1fr; }
  .page-head, .topbar { align-items: stretch; flex-direction: column; height: auto; padding: 12px; }
  .login-brand h1 { font-size: 36px; }
}
.mention { background: #ecfdf5; border: 1px solid #99f6e4; color: #115e59; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.queue-counts { margin-bottom: 14px; }
.queue { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.queue-card { display: grid; grid-template-columns: 84px 1fr auto; gap: 16px; align-items: center; background: white; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.queue-card.waiting { border-color: #99f6e4; background: #f0fdfa; }
.queue-card time { font-size: 22px; font-weight: 700; }
.queue-card h2 { margin: 0; font-size: 22px; }
.queue-card p { margin: 2px 0 0; color: var(--muted); }
.queue-state { font-weight: 700; color: var(--teal) !important; }
.queue-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.slip-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.slip { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 28px 32px 22px; max-width: 820px; }
.slip-head { display: flex; gap: 16px; align-items: center; border-bottom: 3px solid var(--blue); padding-bottom: 16px; }
.slip-head h1 { margin: 0 0 4px; font-size: 26px; }
.slip-head p { margin: 0; color: var(--muted); }
.slip-logo, .slip-logo-img { width: 72px; height: 72px; border-radius: 16px; flex: none; object-fit: cover; }
.slip-kicker { margin: 18px 0 0; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; font-weight: 700; color: var(--teal); }
.slip-name { margin: 4px 0 0; font-size: 32px; }
.slip-id { margin: 2px 0 14px; color: var(--muted); }
.slip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.slip-row { display: grid; grid-template-columns: 148px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.slip-row dt { color: var(--muted); font-size: 13px; }
.slip-row dd { margin: 0; font-weight: 600; }
.slip-block { margin-top: 14px; }
.slip-label { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.slip-block p { margin: 0; }
.slip-foot { margin: 22px 0 0; font-size: 12px; color: var(--amber); }
.slip-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.slip-table th, .slip-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.slip-table th { color: var(--muted); font-size: 13px; font-weight: 700; }
.slip-table .num, .slip-table tfoot td { text-align: right; }
.slip-table tfoot td { font-weight: 700; font-size: 16px; }
.med-list { margin: 8px 0 0; padding-left: 18px; }
.med-list li { margin: 6px 0; }
@media (max-width: 700px) {
  .slip { padding: 18px; }
  .slip-grid, .slip-row { grid-template-columns: 1fr; }
  .slip-name { font-size: 26px; }
  .queue-card { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .banner, .no-print, .mention, .slip-actions { display: none !important; }
  .page { padding: 0; }
  .main { background: white; }
  .slip { border: 0; border-radius: 0; max-width: none; padding: 0; }
}
