/* ============================================================
   Clinic Management — Ayurvedic theme
   Palette: cream parchment, deep herbal green, turmeric gold,
   kumkum red accents. Variable names kept from the original
   theme (teal-*, ochre, coral, sage) so every view picks up the
   new colours without changes.
   ============================================================ */
:root {
  --paper: #FAF6EC;
  --paper-raised: #FFFDF8;
  --ink: #2B2A1F;
  --ink-soft: #6B6650;
  --line: #E8DFC8;

  --teal-900: #1F3D2B;
  --teal-700: #2E5E3E;
  --teal-500: #4A7C4E;
  --teal-100: #EAF1E0;

  --ochre: #C8962E;
  --ochre-light: #E6C36A;
  --ochre-100: #FBF1D6;

  --coral: #B8502F;
  --coral-100: #F8E3D9;

  --sage: #5F8A3F;
  --sage-100: #EAF2DD;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow: 0 1px 2px rgba(60, 45, 10, 0.05), 0 6px 18px rgba(60, 45, 10, 0.06);
  --shadow-lg: 0 10px 34px rgba(31, 61, 43, 0.18);

  --font-display: 'Marcellus', 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sanskrit: 'Tiro Devanagari Sanskrit', 'Noto Serif Devanagari', serif;
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--teal-900); }

a { color: var(--teal-700); }

button { font-family: inherit; cursor: pointer; }

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

/* ---------------- Layout shell ---------------- */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--teal-900);
  color: #EAF3F1;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  padding: 0 10px 22px 10px;
  letter-spacing: 0.2px;
}
.sidebar .brand span { color: var(--ochre); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #C7DDD8;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--teal-700); color: #fff; }
.nav-item .icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 0 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12.5px;
  color: #9FBDB6;
}
.sidebar-footer button {
  background: none; border: none; color: #EAF3F1; font-size: 12.5px; padding: 8px 0; text-decoration: underline;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 34px 50px 34px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}
.topbar .eyebrow { color: var(--ink-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;}
.topbar h1 { font-size: 26px; }

/* ---------------- Cards / grids ---------------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.stat-card .value { font-family: var(--font-display); font-size: 30px; margin-top: 4px; color: var(--teal-900); }
.stat-card .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat-card.alert .value { color: var(--coral); }
.stat-card.good .value { color: var(--sage); }

/* ---------------- Room pods (signature element) ---------------- */
.room-pods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .room-pods { grid-template-columns: repeat(2, 1fr); } }

.room-pod {
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--teal-100);
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.room-pod.busy { background: var(--ochre-100); border-color: #EBD3A0; }
.room-pod .room-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--teal-900); }
.room-pod .room-status { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.room-pod .room-count { font-size: 11px; margin-top: 10px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--teal-700); }
.room-pod.busy .room-count { color: #A46B1F; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--teal-100); }
tbody tr:last-child td { border-bottom: none; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge.teal { background: var(--teal-100); color: var(--teal-700); }
.badge.ochre { background: var(--ochre-100); color: #A46B1F; }
.badge.coral { background: var(--coral-100); color: var(--coral); }
.badge.sage { background: var(--sage-100); color: var(--sage); }
.badge.gray { background: #EDEFEE; color: var(--ink-soft); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  background: var(--teal-700);
  color: #fff;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--teal-900); }
.btn.secondary { background: var(--paper-raised); color: var(--teal-700); border-color: var(--line); }
.btn.secondary:hover { background: var(--teal-100); }
.btn.danger { background: var(--coral); }
.btn.danger:hover { background: #B5493A; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper-raised);
  text-decoration: none; font-size: 14px; margin-right: 4px;
}
.icon-btn.call { color: var(--teal-700); }
.icon-btn.whatsapp { color: var(--sage); }
.icon-btn:hover { background: var(--teal-100); }

/* ---------------- Forms ---------------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper-raised);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--teal-500); }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

/* ---------------- Toolbar / search ---------------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar .search-box { position: relative; min-width: 240px; }
.toolbar input[type="search"], .search-box input { padding-left: 30px; }
.tab-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-raised);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
}
.tab-btn.active { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 58, 56, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--paper-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal h2 { font-size: 19px; margin-bottom: 18px; }
.modal .modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------------- Toast ---------------- */
#toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--teal-900); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease;
}
.toast.error { background: var(--coral); }
.toast.success { background: var(--sage); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Empty / loading states ---------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .icon { font-size: 28px; margin-bottom: 8px; }
.loading-row td { text-align: center; color: var(--ink-soft); padding: 20px; }

/* ---------------- Login page ---------------- */
#login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--teal-100), var(--paper) 60%);
}
.login-card { width: 380px; max-width: 90vw; padding: 34px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p.tagline { color: var(--ink-soft); font-size: 13px; margin: 0 0 22px 0; }
.login-error { color: var(--coral); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

.hidden { display: none !important; }

.section-title { font-size: 15px; margin-bottom: 12px; color: var(--teal-900); }
.helper-text { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }

.drawer-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; flex-wrap: wrap; }
.drawer-tabs button {
  background: none; border: none; padding: 9px 6px; margin-right: 14px; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); border-bottom: 2px solid transparent;
}
.drawer-tabs button.active { color: var(--teal-700); border-color: var(--teal-700); }

/* ============================================================
   Mobile layout (<= 900px): sidebar becomes a slide-in drawer
   opened via a hamburger button in a sticky mobile top bar.
   ============================================================ */
.mobile-topbar { display: none; }

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--teal-900);
    padding: 13px 16px;
    position: sticky;
    top: 0;
    z-index: 60;
  }
  .mobile-topbar .brand {
    font-family: var(--font-display); font-size: 17px; font-weight: 700; color: #fff; padding: 0;
  }
  .mobile-topbar .brand span { color: var(--ochre); }
  #hamburger-btn {
    background: none; border: none; color: #fff; font-size: 22px; padding: 2px 6px; line-height: 1;
  }

  #app-shell { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 90;
  }
  .sidebar.open { transform: translateX(0); }
  /* The desktop sidebar already shows its own brand row; no need to show it twice on mobile. */
  .sidebar > .brand { display: none; }

  #sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(18, 58, 56, 0.45);
    z-index: 80;
  }
  #sidebar-backdrop.open { display: block; }

  .main { padding: 16px 14px 40px 14px; }

  .topbar { flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .topbar h1 { font-size: 20px; }

  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .room-pods { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .card { padding: 14px 16px; }

  .modal { padding: 18px; max-height: 92vh; }
  .modal h2 { font-size: 17px; }

  .toolbar .search-box, .toolbar input[type="search"] { width: 100%; min-width: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }

  /* Prevents iOS Safari from auto-zooming the page when a form field is focused. */
  input, select, textarea { font-size: 16px; }
  .btn, .tab-btn { font-size: 13px; }
}

@media (max-width: 480px) {
  .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 24px; }
  thead th { padding: 8px; font-size: 10.5px; }
  tbody td { padding: 9px 8px; font-size: 12.5px; }
  .login-card { padding: 22px; }
}


/* ============================================================
   Ayurvedic theme — backgrounds, artwork and ornaments
   ============================================================ */
body {
  background-color: var(--paper);
  background-image:
    url('/img/leaf-pattern.svg'),
    radial-gradient(circle at 100% 0%, rgba(200, 150, 46, 0.10), transparent 45%),
    radial-gradient(circle at 0% 100%, rgba(74, 124, 78, 0.10), transparent 45%);
  background-size: 180px 180px, 100% 100%, 100% 100%;
  background-attachment: fixed;
}

h1, h2, h3, h4 { letter-spacing: 0.01em; }

/* ---- Sidebar: deep herbal green with leaf texture, gold edge + mandala ---- */
.sidebar {
  background-color: var(--teal-900);
  background-image:
    url('/img/mandala-light.svg'),
    url('/img/leaf-pattern-dark.svg'),
    linear-gradient(180deg, #2A5037 0%, #1F3D2B 55%, #17301F 100%);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: 300px 300px, 180px 180px, 100% 100%;
  background-position: -110px calc(100% + 130px), 0 0, 0 0;
  border-right: 3px solid var(--ochre);
  box-shadow: inset -1px 0 0 rgba(230, 195, 106, 0.35);
  overflow-y: auto;
}
.sidebar .brand, .mobile-topbar .brand {
  display: flex; align-items: center; gap: 10px;
}
.sidebar .brand::before, .mobile-topbar .brand::before {
  content: ''; flex-shrink: 0; width: 38px; height: 38px;
  background: url('/img/logo.svg') center / contain no-repeat;
}
.mobile-topbar .brand::before { width: 30px; height: 30px; }
.sidebar .brand { padding-bottom: 18px; margin-bottom: 12px; border-bottom: 1px solid rgba(230, 195, 106, 0.25); }
.sidebar .brand span, .mobile-topbar .brand span { color: var(--ochre-light); margin-left: -6px; }

.nav-item { color: #D6E2CF; position: relative; }
.nav-item:hover { background: rgba(230, 195, 106, 0.10); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(230, 195, 106, 0.22), rgba(230, 195, 106, 0.06));
  color: #FFF6DA;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 3px; background: var(--ochre-light);
}
.nav-item .icon { color: var(--ochre-light); }
.sidebar-footer {
  border-top-color: rgba(230, 195, 106, 0.25); color: #D6E2CF;
  background: rgba(15, 32, 21, 0.55); border-radius: var(--radius-sm); padding-bottom: 8px;
  position: relative; z-index: 1;
}
.sidebar-footer button { color: #F3E3B5; }

.mobile-topbar {
  background: linear-gradient(90deg, #2A5037, #1F3D2B) !important;
  border-bottom: 2px solid var(--ochre);
}

/* ---- Main content: faint mandala watermark ---- */
.main { position: relative; }
.main::before {
  content: ''; position: fixed; right: -140px; bottom: -140px;
  width: 520px; height: 520px; pointer-events: none; z-index: 0;
  background: url('/img/mandala.svg') center / contain no-repeat;
  opacity: 0.10;
}
#view-root { position: relative; z-index: 1; }

/* ---- Page headers: gold ornament under titles ---- */
.topbar .eyebrow { color: var(--ochre); font-weight: 600; letter-spacing: 0.14em; }
.topbar h1 { font-size: 28px; position: relative; padding-bottom: 10px; }
.topbar h1::after {
  content: ''; position: absolute; left: 0; bottom: 0; width: 64px; height: 2px;
  background: linear-gradient(90deg, var(--ochre), transparent);
}

/* ---- Cards: warm paper with gold hairline ---- */
.card {
  background: linear-gradient(180deg, #FFFDF8, #FFFBF1);
  border-color: var(--line);
  position: relative;
}
.stat-card { overflow: hidden; border-top: 3px solid var(--ochre); }
.stat-card::after {
  content: ''; position: absolute; right: -6px; bottom: -6px; width: 58px; height: 58px;
  background: url('/img/sprig.svg') center / contain no-repeat; opacity: 0.22; pointer-events: none;
}
.stat-card.alert { border-top-color: var(--coral); }
.stat-card.good { border-top-color: var(--sage); }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title::before {
  content: ''; width: 16px; height: 16px; flex-shrink: 0;
  background: url('/img/sprig.svg') center / contain no-repeat;
}

.room-pod { background: linear-gradient(160deg, #F1F6E8, #E4EED8); border-color: #D5E2C4; }
.room-pod.busy { background: linear-gradient(160deg, #FDF5DF, #F8E8BE); border-color: #EBD3A0; }

tbody tr:hover { background: #F5F1E3; }
thead th { color: var(--teal-700); border-bottom: 2px solid #E9DDBE; }

/* ---- Buttons ---- */
.btn { background: linear-gradient(180deg, #37704A, #2E5E3E); box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset; }
.btn:hover { background: var(--teal-900); }
.btn.secondary { background: var(--paper-raised); box-shadow: none; }
.btn.danger { background: var(--coral); }
.tab-btn.active { background: var(--teal-700); border-color: var(--ochre); box-shadow: 0 0 0 1px var(--ochre) inset; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ochre); box-shadow: 0 0 0 3px rgba(200, 150, 46, 0.18); }

.modal { border-top: 4px solid var(--ochre); }
.modal-backdrop { background: rgba(31, 61, 43, 0.40); }

/* ---- Dashboard welcome banner ---- */
.hero-banner {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; padding: 24px 28px; min-height: 150px;
  border-radius: var(--radius-lg);
  color: #F6F1DE;
  background:
    url('/img/leaf-pattern-dark.svg'),
    linear-gradient(115deg, #2E5E3E 0%, #1F3D2B 60%, #17301F 100%);
  background-size: 180px 180px, 100% 100%;
  border: 1px solid rgba(200, 150, 46, 0.6);
  box-shadow: var(--shadow-lg);
}
.hero-banner .eyebrow { color: var(--ochre-light); font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.hero-banner h1 { color: #FFF8E2; font-size: 28px; margin: 6px 0 4px; }
.hero-banner .sanskrit { font-family: var(--font-sanskrit); color: var(--ochre-light); font-size: 17px; }
.hero-banner .hero-sub { color: #CFDCC4; font-size: 13px; margin-top: 4px; }
.hero-banner .hero-art {
  flex-shrink: 0; width: 330px; height: 138px; margin: -12px -14px -24px 0;
  background: url('/img/herbs-banner.svg') right bottom / contain no-repeat;
}

/* ---- Login: temple-arch illustration beside the form ---- */
#login-page {
  background-color: var(--paper);
  background-image:
    url('/img/leaf-pattern.svg'),
    radial-gradient(circle at 15% 15%, rgba(74, 124, 78, 0.16), transparent 50%),
    radial-gradient(circle at 85% 85%, rgba(200, 150, 46, 0.18), transparent 50%);
  background-size: 180px 180px, 100% 100%, 100% 100%;
  padding: 24px;
}
.login-wrap {
  display: flex; align-items: stretch; width: 860px; max-width: 100%;
  background: var(--paper-raised); border-radius: 24px; overflow: hidden;
  border: 1px solid #E3D3A6; box-shadow: var(--shadow-lg);
}
.login-art {
  flex: 1 1 50%; min-height: 520px;
  background:
    url('/img/login-hero.svg') center / contain no-repeat,
    linear-gradient(180deg, #F7EFD8, #EFE2BF);
  padding: 22px;
}
.login-wrap .login-card {
  flex: 1 1 50%; width: auto; border: none; box-shadow: none; border-radius: 0;
  padding: 44px 40px; display: flex; flex-direction: column; justify-content: center;
}
.login-logo { width: 64px; height: 64px; margin-bottom: 14px; }
.login-card .eyebrow { color: var(--ochre); font-size: 11.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 4px; }
.login-card h1 { font-size: 26px; line-height: 1.2; }
.login-card .sanskrit { font-family: var(--font-sanskrit); color: var(--ochre); font-size: 16px; margin: 6px 0 4px; }
.login-divider { height: 1px; margin: 4px 0 22px; background: linear-gradient(90deg, var(--ochre), transparent); }

@media (max-width: 900px) {
  .hero-banner { padding: 18px; min-height: 0; }
  .hero-banner h1 { font-size: 21px; }
  .hero-banner .hero-art { width: 150px; height: 90px; margin: -8px -8px -18px 0; opacity: 0.9; }
  .main::before { width: 320px; height: 320px; right: -110px; bottom: -110px; }
}
@media (max-width: 720px) {
  .login-art { display: none; }
  .login-wrap { width: 420px; }
  .login-wrap .login-card { padding: 30px 24px; }
}
@media (max-width: 480px) {
  .hero-banner .hero-art { display: none; }
}

/* ============================================================
   Treatment Reports (Documents → first tab)
   ============================================================ */
.tr-wrap { display: flex; flex-direction: column; gap: 16px; padding-bottom: 84px; }
.tr-section { margin: 0; }
.tr-banner {
  background: var(--ochre-100); border: 1px solid #EBD9A6; color: var(--ink);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
}
.tr-report-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tr-pick {
  position: relative; display: flex; flex-direction: column; gap: 2px; margin: 0;
  padding: 14px 14px 14px 44px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper-raised); cursor: pointer; transition: border-color .15s, background .15s;
}
.tr-pick input { position: absolute; left: 14px; top: 16px; width: 18px; height: 18px; accent-color: var(--teal-700); }
.tr-pick.on { border-color: var(--teal-700); background: var(--teal-100); }
.tr-pick-title { font-size: 14px; color: var(--teal-900); font-weight: 700; }
.tr-pick-sub { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.tr-tight { gap: 10px; }
.tr-grid-3 { grid-template-columns: repeat(3, 1fr); }
.tr-table { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
.tr-table th { font-size: 12px; padding: 7px 8px; }
.tr-table td { padding: 3px 6px; }
.tr-table td input { border: 1px solid transparent; background: transparent; padding: 6px; }
.tr-table td input:hover { border-color: var(--line); }
.tr-days { max-height: 340px; overflow-y: auto; }
.tr-row-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tr-x {
  border: none; background: transparent; color: var(--ink-soft); font-size: 20px; line-height: 1;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
}
.tr-x:hover { background: var(--coral-100); color: var(--coral); }
.tr-check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); margin: 6px 0 4px; cursor: pointer; }
.tr-check input { width: auto; accent-color: var(--teal-700); }
.tr-check-inline { font-weight: 400; font-size: 12.5px; margin-top: 6px; }
.tr-readonly { background: var(--teal-100) !important; }
.tr-totals {
  display: flex; gap: 22px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px;
  padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--teal-100);
}
.tr-totals div { display: flex; gap: 8px; color: var(--ink-soft); }
.tr-totals b { color: var(--ink); }
.tr-totals .grand b { color: var(--teal-900); font-size: 15px; }
.tr-actionbar {
  position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius); background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.tr-actionbar .helper-text { margin: 0 auto 0 0; }

.modal.tr-preview-modal { width: 880px; max-height: 94vh; display: flex; flex-direction: column; padding: 18px 20px; }
.tr-preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.tr-close { flex: none; }
.tr-warn {
  background: var(--ochre-100); border: 1px solid #EBD9A6; border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 12.5px; margin-bottom: 10px; color: #6A4E12;
}
.tr-preview-pages {
  flex: 1; overflow-y: auto; background: #DCDDD8; border-radius: var(--radius-sm);
  padding: 14px 4px; display: flex; flex-direction: column; align-items: center; gap: 14px; min-height: 300px;
}
.tr-page { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.18); max-width: 100%; height: auto; }
.tr-iframe { width: 100%; height: 70vh; border: none; background: #fff; }
.tr-preview-foot { margin-top: 12px; }

@media (max-width: 900px) {
  .tr-report-picks, .tr-grid-3 { grid-template-columns: 1fr; }
  .tr-actionbar { flex-wrap: wrap; }
  .tr-actionbar .btn { flex: 1; justify-content: center; }
  .tr-actionbar .helper-text { width: 100%; }
  .modal.tr-preview-modal { padding: 12px; }
  .tr-preview-foot { flex-wrap: wrap; }
  .tr-preview-foot .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   Treatments
   ============================================================ */
.tr-picker-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.tr-picker-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tr-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tr-no { font-family: var(--font-display); font-size: 22px; color: var(--teal-900); letter-spacing: 0.02em; }
.tr-today td { background: var(--ochre-100); }
.tx-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tx-toolbar .search-box { flex: 1; min-width: 240px; }
.tx-filter { margin: 0; }
.tx-row { cursor: pointer; }
.tx-actions { white-space: nowrap; text-align: right; }
.tx-actions .btn { margin-left: 4px; }
.tx-pager { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-top: 1px solid var(--line); }
.tx-backlink { display: inline-block; font-size: 13px; color: var(--teal-700); margin-bottom: 4px; text-decoration: none; }
.tx-backlink:hover { text-decoration: underline; }
.tx-h1-sub { font-family: var(--font-body); font-size: 15px; color: var(--ink-soft); font-weight: 500; margin-left: 8px; }
.tx-top-actions { display: flex; gap: 8px; }
.tx-picked { padding: 8px 10px; background: var(--teal-100); border-radius: var(--radius-sm); }
.tx-results { max-height: 180px; overflow-y: auto; }
.tx-result { padding: 7px 4px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.tx-result:hover { background: var(--teal-100); }
.tx-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 10px; font-size: 14px; }
.tx-summary label, .tx-summary-line label { display: block; margin-bottom: 2px; }
.tx-summary-line { font-size: 14px; margin-top: 8px; }

@media (max-width: 900px) {
  .tx-summary { grid-template-columns: repeat(2, 1fr); }
  .tr-head .form-row { width: 100%; }
  /* Treatment list becomes stacked cards on phones */
  table.tx-list thead { display: none; }
  table.tx-list, table.tx-list tbody, table.tx-list tr, table.tx-list td { display: block; width: 100%; }
  table.tx-list tr { padding: 10px 4px; border-bottom: 1px solid var(--line); }
  table.tx-list td { border: none; padding: 3px 8px; }
  table.tx-list td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 100px; color: var(--ink-soft); font-size: 12px; }
  .tx-actions { text-align: left; padding-top: 8px !important; }
  .tx-actions .btn { margin: 0 6px 0 0; }
}
.tr-days table { table-layout: fixed; }
.tr-days td input { width: 100%; min-width: 0; }
@media (max-width: 900px) {
  .tr-days th:first-child { width: 86px !important; }
  .tr-days th:last-child { width: 64px !important; }
  .tr-days td, .tr-days th { padding-left: 4px; padding-right: 4px; font-size: 12px; }
  .tr-days th { white-space: normal; letter-spacing: 0; font-size: 10.5px; }
  .tr-days .badge { display: block; width: fit-content; margin-top: 2px; }
}

/* ============================================================
   Voice typing (mic button on long text fields)
   ============================================================ */
.voice-wrap { position: relative; display: block; }
.voice-field { padding-right: 42px !important; }
.voice-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper-raised); color: var(--teal-700); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: background .15s, color .15s, box-shadow .15s;
}
.voice-wrap-area .voice-btn { top: 6px; transform: none; }
.voice-btn:hover { background: var(--teal-100); }
.voice-btn.listening {
  background: var(--coral); border-color: var(--coral); color: #fff;
  animation: voice-pulse 1.2s ease-out infinite;
}
@keyframes voice-pulse {
  0% { box-shadow: 0 0 0 0 rgba(184, 80, 47, 0.45); }
  100% { box-shadow: 0 0 0 12px rgba(184, 80, 47, 0); }
}
.no-voice .voice-btn { display: none; }
.no-voice .voice-field { padding-right: 12px !important; }
.voice-banner {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%); z-index: 300;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  background: var(--teal-900); color: #fff; border-radius: 999px; box-shadow: var(--shadow-lg);
  font-size: 14px; transition: transform .2s ease, opacity .2s ease, visibility .2s; pointer-events: none;
  opacity: 0; visibility: hidden;
}
.voice-banner.show { transform: translate(-50%, 0); pointer-events: auto; opacity: 1; visibility: visible; }
.voice-banner button {
  border: none; background: #fff; color: var(--coral); font-weight: 700; border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: 13px;
}
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: #F26B4F; animation: voice-blink 1s infinite; }
@keyframes voice-blink { 50% { opacity: .3; } }
@media (max-width: 900px) {
  .voice-btn { width: 38px; height: 38px; }
  .voice-field { padding-right: 48px !important; }
  .voice-banner { bottom: 86px; } /* clear the sticky Save/Preview bar */
}
.tr-table th.col-qty { width: 110px; }
.tr-table th.col-amt { width: 130px; }
.tr-table th.col-x { width: 40px; }
@media (max-width: 900px) {
  .tr-table th.col-qty { width: 62px; }
  .tr-table th.col-amt { width: 92px; }
  .tr-table th.col-x { width: 34px; }
  .tr-table th, .tr-table td { padding-left: 4px; padding-right: 4px; }
  .tr-table table { table-layout: fixed; }
}

/* ---- Bill / IP number with Auto button; therapy rates ---- */
.tr-inline { display: flex; gap: 8px; align-items: center; }
.tr-inline input { flex: 1; min-width: 0; }
.tr-table td input.tr-manual { background: var(--ochre-100); }
.tr-totals-therapy { justify-content: space-between; margin: 4px 0 10px; }
@media (max-width: 900px) {
  /* Therapy rows become two-line cards: name on top, sessions / rate / amount below */
  .tr-therapies table { table-layout: auto; }
  .tr-therapies thead { display: none; }
  .tr-therapies tbody tr {
    display: grid; grid-template-columns: 1fr 1fr 1fr 34px; gap: 4px 6px; align-items: center;
    padding: 8px 6px; border-bottom: 1px solid var(--line);
  }
  .tr-therapies tbody td { display: block; padding: 0; border: none; }
  .tr-therapies tbody td.cell-name { grid-column: 1 / -1; }
  .tr-therapies tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ink-soft); margin: 0 0 2px 2px; }
  .tr-therapies tbody td:last-child { align-self: end; }
  .tr-therapies td input { border: 1px solid var(--line) !important; background: #fff; }
  .tr-therapies td input.tr-manual { background: var(--ochre-100); }
  .tr-totals-therapy { flex-direction: column; gap: 4px; align-items: stretch; }
  .tr-totals-therapy div { justify-content: space-between; }
}
.tr-tpl-select { margin-top: 8px; font-size: 12.5px; padding: 5px 8px; }
.tr-template-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 14px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--ochre-100); }
.tr-template-bar .helper-text { margin: 0; }
.tr-tpl-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 400; color: var(--ink); }
.tr-tpl-option input { width: auto; margin-top: 3px; }
.tr-tpl-option:hover { background: var(--teal-100); }

/* ============================================================
   Templates page
   ============================================================ */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tpl-card { margin: 0; }
.tpl-name { font-family: var(--font-display); font-size: 17px; color: var(--teal-900); }
.tpl-desc { margin: 8px 0 0; font-size: 13.5px; }
.tpl-chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tpl-details:not(:empty) { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.tpl-table th, .tpl-table td { padding: 5px 6px; font-size: 12.5px; }
.tpl-dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; margin: 10px 0 0; }
.tpl-dl dt { color: var(--ink-soft); }
.tpl-dl dd { margin: 0; }
.rt-types { margin-bottom: 14px; }
.rt-layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
.rt-side { display: flex; flex-direction: column; gap: 14px; }
.rt-side .card { margin: 0; }
.rt-item { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; padding: 9px 10px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-raised); cursor: pointer; font: inherit; }
.rt-item.active { border-color: var(--teal-700); background: var(--teal-100); }
.rt-group { border-top: 1px solid var(--line); padding: 8px 0; }
.rt-group summary { cursor: pointer; font-weight: 600; color: var(--teal-900); padding: 4px 0; }
.rt-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 8px; }
.rt-fields .rt-wide { grid-column: 1 / -1; }
.rt-fields input[type="color"] { height: 38px; padding: 2px 4px; }
.rt-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.rt-preview { position: sticky; top: 12px; margin: 0; }
.rt-preview-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.rt-preview .tr-preview-pages { max-height: 78vh; }
.rt-font-list { list-style: none; padding: 0; margin: 0 0 10px; }
.rt-font-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.rt-font-list .tr-x { margin-left: auto; }
.rt-font-form .form-row { margin-bottom: 8px; }
@media (max-width: 1100px) {
  .rt-layout { grid-template-columns: 1fr; }
  .rt-preview { position: static; }
}
@media (max-width: 600px) { .rt-fields { grid-template-columns: 1fr; } }

/* ============================================================
   Reports page
   ============================================================ */
.rp-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.rp-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-custom input { width: auto; }
.rp-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.rp-tile { margin: 0; padding: 14px 16px; }
.rp-tile-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.rp-tile-value { font-family: var(--font-body); font-weight: 600; font-size: 22px; color: var(--ink); margin: 4px 0 2px; white-space: nowrap; }
.rp-hero .rp-tile-value { font-size: 28px; color: var(--teal-900); }
.rp-charts, .rp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.rp-charts .card, .rp-two .card { margin: 0; }
.rp-chart-title { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.rp-chart { position: relative; margin-top: 8px; }
.rp-svg { width: 100%; height: auto; display: block; overflow: visible; }
.rp-grid { stroke: #ECE4D0; stroke-width: 1; shape-rendering: crispEdges; }
.rp-axis { fill: var(--ink-soft); font-size: 10.5px; font-variant-numeric: tabular-nums; font-family: var(--font-body); }
.rp-val { fill: var(--ink); font-size: 10.5px; font-weight: 600; font-family: var(--font-body); }
.rp-col { cursor: default; outline: none; }
.rp-col.hover .rp-bar, .rp-col:focus .rp-bar { opacity: 0.8; }
.rp-col:focus-visible rect { stroke: var(--teal-500); stroke-width: 1; }
.rp-tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; opacity: 0; transition: opacity .1s;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 12.5px; white-space: nowrap; z-index: 5;
}
.rp-tip.show { opacity: 1; }
.rp-tip b { color: var(--ink); font-weight: 700; }
.rp-tip span { color: var(--ink-soft); }
.rp-tip-sub { margin-top: 2px; }
.rp-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.rp-table td.num, .rp-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); padding: 10px 12px; }
.rp-barcell { width: 22%; min-width: 90px; }
.rp-inline-bar { display: block; height: 8px; background: #2E7D4B; border-radius: 0 4px 4px 0; }

@media (max-width: 900px) {
  .rp-charts, .rp-two { grid-template-columns: 1fr; }
  .rp-kpis { grid-template-columns: repeat(2, 1fr); }
  .rp-barcell { display: none; }
}

/* ============================================================
   Audit log
   ============================================================ */
.al-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.al-filters input[type="search"] { flex: 1; min-width: 220px; }
.al-filters select, .al-filters input[type="date"] { width: auto; }
.al-entry { display: grid; grid-template-columns: 170px 1fr; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.al-entry:last-child { border-bottom: none; }
.al-when { font-size: 13px; white-space: nowrap; }
.al-what { font-size: 13.5px; min-width: 0; }
.al-changes { list-style: none; margin: 6px 0 0; padding: 0; }
.al-changes li { padding: 3px 0; font-size: 12.5px; overflow-wrap: anywhere; }
.al-field { color: var(--ink-soft); margin-right: 6px; }
.al-from { text-decoration: line-through; color: var(--coral); background: var(--coral-100); padding: 0 4px; border-radius: 4px; }
.al-to { color: var(--sage); background: var(--sage-100); padding: 0 4px; border-radius: 4px; }
.al-arrow { color: var(--ink-soft); }
.al-more { border: none; background: none; color: var(--teal-700); cursor: pointer; padding: 4px 0; font-size: 12.5px; text-decoration: underline; }
.al-raw { max-width: 520px; word-break: break-word; }
.al-pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; gap: 8px; }
.modal.al-modal { width: 760px; }
.al-history { max-height: 64vh; overflow-y: auto; }
@media (max-width: 700px) {
  .al-entry { grid-template-columns: 1fr; gap: 4px; }
}
.th-list .th-rate { text-align: right; white-space: nowrap; }
@media (max-width: 900px) { .th-list .th-rate { text-align: left; } }
.tpl-intro { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.tr-charges tfoot td { padding: 8px 6px; border-top: 2px solid var(--line); font-weight: 700; }
.tr-charges .tr-foot-label { text-align: right; color: var(--ink-soft); font-weight: 600; }
.tr-charges .tr-foot-val { white-space: nowrap; }
@media (max-width: 900px) {
  .tr-charges tfoot tr { display: flex; justify-content: space-between; padding: 8px 6px; }
  .tr-charges tfoot td { border: none; padding: 0; }
  .tr-charges tfoot td:empty { display: none; }
}
.tpl-intro-actions, .rt-list-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rt-list-actions { margin-top: 10px; }
.imp-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.imp-mode { font-weight: 400; margin: 6px 0; }

/* ---- Data export/import & patient documents ---- */
.dt-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dt-buttons { display: inline-flex; gap: 8px; }
.dt-menu { position: relative; display: inline-block; }
.dt-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; min-width: 160px; padding: 4px; }
.dt-menu-list.hidden { display: none; }
.dt-menu-list button { border: none; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13.5px; }
.dt-menu-list button:hover { background: var(--teal-100); }
.dt-result { margin: 12px 0 0; background: var(--teal-100); }
.dt-errors { max-height: 170px; overflow-y: auto; margin-top: 8px; font-size: 12px; }
.pd-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pd-upload { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; background: var(--paper-raised); }
.pd-upload.hidden { display: none; }
.pd-upload-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pd-list { list-style: none; margin: 0; padding: 0; }
.pd-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.pd-item:last-child { border-bottom: none; }
.pd-icon { flex: none; width: 42px; height: 42px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--teal-500); }
.pd-icon.pd-pdf { background: #B8502F; }
.pd-icon.pd-img { background: #4A7C4E; }
.pd-icon.pd-doc { background: #2F5D9A; }
.pd-icon.pd-xls { background: #2E7D4B; }
.pd-main { flex: 1; min-width: 0; }
.pd-title { font-weight: 600; overflow-wrap: anywhere; }
.pd-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.tr-keep { font-weight: 400; margin: 10px 0 0; }
@media (max-width: 700px) {
  .pd-item { flex-wrap: wrap; }
  .pd-actions { width: 100%; justify-content: flex-end; }
}
