/* ---------------------------------------------------------------------
   Design tokens
   Palette: clinical, calm, legible. A deep teal does the work a "brand
   color" usually does; amber is reserved only for things that need
   attention (due reminders, warnings). Record/receipt/voucher codes
   (CR-1-00001 etc.) are rendered as monospace chips throughout — they're
   the one truly domain-specific artifact this system produces, so they
   get a consistent visual treatment instead of blending into prose.
------------------------------------------------------------------------ */
:root {
  --bg: #F1F4FA;
  --surface: #FFFFFF;
  --surface-alt: #EAEFF8;
  --ink: #16223F;
  --muted: #5B6A8C;
  --border: #DBE2F0;
  --primary: #16295C;
  --primary-dark: #0C1A3B;
  --primary-tint: #E7EAF6;
  --amber: #B9822B;
  --amber-tint: #FAF0DF;
  --danger: #C1272D;
  --danger-tint: #FBEAEA;
  --success: #2F7D5C;
  --success-tint: #E7F3EC;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 26, 59, 0.05), 0 4px 16px rgba(16, 26, 59, 0.07);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   App shell: fixed sidebar + topbar + scrollable content
------------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--primary-dark);
  color: #E8F2F0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 10px 22px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.2px;
  color: #fff;
  line-height: 1.15;
}
.brand-text span {
  font-size: 10px;
  color: #9FB0DA;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Slim info strip across the top of every page, in the reference site's
   spirit: hours / emergency line / contact, right above the page title. */
.info-bar {
  background: var(--primary-dark);
  color: #C7D2EE;
  font-size: 12px;
  padding: 7px 28px;
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  align-items: center;
}
.info-bar__item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.info-bar__item strong { color: #fff; font-weight: 600; }
.info-bar__item svg { flex-shrink: 0; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #CFE6E2;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar__link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar__link.is-active { background: var(--primary); color: #fff; }

.sidebar__badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--amber);
  color: #241505;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}
.sidebar__badge.is-visible { display: inline-flex; animation: pulse 2.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 122, 43, 0.55); }
  50% { box-shadow: 0 0 0 4px rgba(201, 122, 43, 0); }
}

.sidebar__footer { padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.12); }
.sidebar__user { font-size: 12.5px; color: #B8D9D4; padding: 0 10px 10px; }
.sidebar__user strong { display: block; color: #fff; font-size: 13.5px; }

.btn-logout {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #E8F2F0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar h1 { font-size: 21px; }
.topbar__sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.content { padding: 24px 28px 60px; }

/* ---------------------------------------------------------------------
   Cards, tables, forms
------------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card__header h2 { font-size: 16px; }
.card__body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-card__value { font-family: var(--font-display); font-size: 30px; margin-top: 6px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: var(--surface-alt); }
tbody tr:hover { background: var(--surface-alt); }
.table-wrap { overflow-x: auto; }

.code-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: capitalize;
}
.pill-pending, .pill-open { background: var(--amber-tint); color: var(--amber); }
.pill-confirmed { background: var(--primary-tint); color: var(--primary-dark); }
.pill-completed, .pill-closed { background: var(--success-tint); color: var(--success); }
.pill-active { background: var(--success-tint); color: var(--success); }
.pill-inactive { background: var(--danger-tint); color: var(--danger); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pagination .btns { display: flex; gap: 8px; }

/* ---------------------------------------------------------------------
   Modal
------------------------------------------------------------------------ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 26, 25, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-overlay.is-hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal__header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal__header h3 { font-size: 17px; }
.modal__close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal__body { padding: 20px 22px; }
.modal__footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-error-banner { background: var(--danger-tint); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---------------------------------------------------------------------
   Toasts
------------------------------------------------------------------------ */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px;
  font-size: 13.5px; box-shadow: var(--shadow); min-width: 220px;
  animation: toast-in 0.18s ease;
}
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------
   Login page
------------------------------------------------------------------------ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(22, 41, 92, 0.14), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(193, 39, 45, 0.10), transparent 40%),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 30px;
}
.login-card__mark { font-family: var(--font-display); font-size: 24px; color: var(--primary-dark); margin-bottom: 2px; }
.login-card__tag { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); background: var(--surface-alt); padding: 10px 12px; border-radius: 8px; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------------
   Sidebar v2 — icons, accent bar, avatar chip, mobile off-canvas
   (extends the base .sidebar rules above; loaded via shell.js partial)
------------------------------------------------------------------------ */
.sidebar__brand { position: relative; }
.sidebar__close, .sidebar__open {
  display: none;
  background: transparent; border: none; cursor: pointer;
  color: #C7D2EE; padding: 4px;
}
.sidebar__open { color: #C7D2EE; margin-right: 4px; }

.sidebar__link { justify-content: flex-start; }
.sidebar__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; flex-shrink: 0; color: #8FA3D6; transition: color 0.15s ease;
}
.sidebar__label { flex: 1; }
.sidebar__link:hover .sidebar__icon { color: #fff; }
.sidebar__link.is-active .sidebar__icon { color: var(--amber); }

.sidebar__link {
  position: relative;
  border-radius: 0 8px 8px 0;
  margin-left: -14px;
  padding-left: 17px;
}
.sidebar__link::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 3px; height: 60%;
  background: var(--amber);
  border-radius: 0 3px 3px 0;
  transition: transform 0.18s ease;
}
.sidebar__link.is-active::before { transform: translateY(-50%) scaleY(1); }
.sidebar__link.is-active { background: rgba(255,255,255,0.08); }

.sidebar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px 12px;
}
.sidebar__avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--amber), #8a5f1e);
  color: #241505;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12.5px;
}
.sidebar__user-meta { min-width: 0; }
.sidebar__user-meta strong { display: block; color: #fff; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-meta span { font-size: 11.5px; color: #B8D9D4; text-transform: capitalize; }

.btn-logout { display: flex; align-items: center; justify-content: center; gap: 7px; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 100vmax rgba(9, 14, 32, 0);
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(9, 14, 32, 0.45); }
  .sidebar__close { display: block; }
  .sidebar__open { display: inline-flex; }
}

/* ---------------------------------------------------------------------
   Topbar v2 — heading + search / notification bell / profile chip
------------------------------------------------------------------------ */
.info-bar { gap: 22px; }
.info-bar__item:nth-child(3) { margin-left: auto; }
@media (max-width: 640px) { .info-bar__item:not(:first-child) { display: none; } }

.topbar { gap: 16px; flex-wrap: wrap; }
.topbar__heading h1 { font-size: 21px; }
.topbar__sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.topbar__actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }

.topbar__search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  width: 220px;
}
.topbar__search input {
  border: none; background: transparent; padding: 0; font-size: 13px;
  width: 100%; color: var(--ink);
}
.topbar__search input:focus { outline: none; }
@media (max-width: 720px) { .topbar__search { display: none; } }

.topbar__bell {
  position: relative;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); cursor: pointer; flex-shrink: 0;
}
.topbar__bell:hover { border-color: var(--primary); color: var(--primary); }
.topbar__bell-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  align-items: center; justify-content: center;
  display: none; border: 2px solid var(--surface);
}
.topbar__bell-badge.is-visible { display: inline-flex; }

.topbar__divider { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }

.topbar__profile { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar__avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-tint); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12.5px; flex-shrink: 0;
}
.topbar__profile-meta { line-height: 1.25; }
.topbar__profile-meta strong { display: block; font-size: 13px; }
.topbar__profile-meta span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
@media (max-width: 560px) { .topbar__profile-meta { display: none; } }
