/* ============================================
   DESIGN TOKENS
   Palette: clinical calm (deep teal) + ledger gold accent
   Display: Fraunces (editorial serif, used sparingly)
   Body: Inter | Data/amounts: IBM Plex Mono (tabular figures)
   Signature: the "vitals line" — a pulse/ledger line that runs
   through the header, tying physiotherapy (pulse) + ledger (trend line)
   ============================================ */
:root {
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --surface-sunken: #EFF3F1;
  --ink: #17231F;
  --ink-soft: #55655F;
  --border: #DCE4E0;
  --teal: #163C36;
  --teal-light: #1F544B;
  --gold: #C4872A;
  --gold-soft: #F3E3C6;
  --danger: #A8412C;
  --danger-soft: #F5DFD9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23,35,31,0.04), 0 8px 24px rgba(23,35,31,0.06);
}

* { box-sizing: border-box; }
body { margin: 0; }

body, input, select, button {
  font-family: 'Inter', sans-serif;
  color: var(--ink);
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }

/* ---------- Vitals line signature ---------- */
.vitals-line {
  width: 100%;
  height: 28px;
  overflow: hidden;
}
.vitals-line svg { width: 200%; height: 100%; animation: scrollLine 8s linear infinite; }
@keyframes scrollLine { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .vitals-line svg { animation: none; }
}

/* ============================================
   LOGIN VIEW
   ============================================ */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, var(--teal-light) 0%, var(--teal) 55%, #0F2A26 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  overflow: hidden;
}
.login-card .vitals-line { background: var(--teal); }
.login-body { padding: 36px 32px 32px; }
.login-eyebrow {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 4px;
}
.login-title { font-size: 26px; margin: 0 0 28px; color: var(--teal); }

label { display: block; font-size: 13px; font-weight: 500; margin: 16px 0 6px; color: var(--ink-soft); }
input, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 14.5px; background: var(--surface);
  transition: border-color 0.15s;
}
input:focus, select:focus, button:focus-visible {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,60,54,0.12);
}

button {
  cursor: pointer; border: none; font-weight: 600; font-size: 14.5px;
  border-radius: 7px; padding: 11px 18px; transition: transform 0.1s, background 0.15s;
}
button:active { transform: scale(0.98); }

.btn-primary { background: var(--teal); color: #fff; width: 100%; margin-top: 22px; }
.btn-primary:hover { background: var(--teal-light); }
.btn-secondary { background: var(--surface-sunken); color: var(--ink); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #ECC9BF; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #B37A22; }

.error-msg {
  background: var(--danger-soft); color: var(--danger); font-size: 13.5px;
  padding: 10px 13px; border-radius: 7px; margin-top: 16px; display: none;
}

/* ============================================
   APP SHELL
   ============================================ */
#app-view { display: none; min-height: 100vh; background: var(--bg); }
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; background: var(--teal); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 24px 22px 18px; }
.sidebar-header .eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.6; }
.sidebar-header h2 { font-size: 19px; margin: 4px 0 0; color: #fff; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 22px; font-size: 14px; font-weight: 500;
  color: rgba(255,255,255,0.72); cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.09); color: #fff; border-left-color: var(--gold); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto; padding: 18px 22px; border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}
.sidebar-footer .who { font-weight: 600; }
.sidebar-footer .role-tag {
  display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--gold); color: #fff; padding: 2px 7px; border-radius: 4px; margin-top: 4px;
}
.logout-link { color: rgba(255,255,255,0.55); font-size: 12.5px; margin-top: 10px; cursor: pointer; display: block; }
.logout-link:hover { color: #fff; }

.main { flex: 1; padding: 30px 40px 60px; max-width: 1180px; }
.main-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 26px; }
.main-header h1 { font-size: 25px; margin: 0; color: var(--teal); }
.main-header p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 30px; }
.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: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 26px; margin-top: 6px; color: var(--teal); }
.stat-card .value.gold { color: var(--gold); }
.stat-card .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: 17px; margin: 0; }

.filters { display: flex; gap: 10px; padding: 14px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 130px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
     color: var(--ink-soft); padding: 12px 22px; border-bottom: 1px solid var(--border); background: var(--surface-sunken); }
td { padding: 13px 22px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-sunken); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill-fee { background: #DCEAE6; color: var(--teal); }
.pill-incentive { background: var(--gold-soft); color: var(--gold); }
.pill-refund { background: var(--danger-soft); color: var(--danger); }
.pill-other { background: var(--surface-sunken); color: var(--ink-soft); }

.row-actions { display: flex; gap: 8px; }
.row-actions button { padding: 6px 11px; font-size: 12.5px; }

.empty-state { padding: 50px 22px; text-align: center; color: var(--ink-soft); }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

/* Modal */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,25,22,0.45);
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 460px;
         box-shadow: 0 24px 60px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; padding: 4px 8px; color: var(--ink-soft); font-size: 18px; }
.modal-body { padding: 20px 24px 24px; }
.modal-footer { display: flex; gap: 10px; margin-top: 22px; }
.modal-footer button { flex: 1; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 400; color: var(--ink); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--teal); color: #fff;
  padding: 13px 20px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow);
  display: none; z-index: 200;
}
.toast.danger { background: var(--danger); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar-header, .sidebar-footer { display: none; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .nav-item.active { border-bottom-color: var(--gold); }
  .main { padding: 22px 18px 50px; }
}
