:root {
  --bg: #f2f8f5;
  --ink: #153530;
  --muted: #50716b;
  --card: rgba(255, 255, 255, 0.86);
  --line: rgba(21, 53, 48, 0.12);
  --teal-900: #0e4740;
  --teal-700: #137165;
  --teal-500: #19a58d;
  --amber: #f6b73c;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 18px 38px rgba(14, 71, 64, 0.18);
}

body.dark-mode {
  --bg: #0f1a18;
  --ink: #e7f2ef;
  --muted: #9bb5af;
  --card: rgba(28, 42, 39, 0.86);
  --line: rgba(255, 255, 255, 0.1);
  --teal-900: #19a58d;
  --teal-700: #2bbfa3;
  --teal-500: #34d3b4;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
}

body.dark-mode {
  background:
    radial-gradient(circle at 10% 0%, rgba(43, 191, 163, 0.2), transparent 34%),
    radial-gradient(circle at 92% 96%, rgba(246, 183, 60, 0.12), transparent 30%),
    linear-gradient(135deg, #081512 0%, #10211d 54%, #0b1716 100%);
}

/* Green writing surfaces in dark mode */
body.dark-mode .card,
body.dark-mode .topbar,
body.dark-mode .summary-tile,
body.dark-mode .dashboard-chart-panel,
body.dark-mode .dashboard-duty-panel,
body.dark-mode .patient-total-card,
body.dark-mode .doctor-row,
body.dark-mode .metric-chart-card,
body.dark-mode .modal-box {
  background: #14403a;
  color: #eaf6f2;
}

/* Force readable light text on everything inside content areas */
body.dark-mode .card h2,
body.dark-mode .card h3,
body.dark-mode .card h4,
body.dark-mode .card h5,
body.dark-mode .card p,
body.dark-mode .card span,
body.dark-mode .card strong,
body.dark-mode .card label,
body.dark-mode .card li,
body.dark-mode .card td,
body.dark-mode .card th,
body.dark-mode .card a,
body.dark-mode .topbar h2,
body.dark-mode .topbar p,
body.dark-mode .topbar strong,
body.dark-mode .modal-box h3,
body.dark-mode .modal-box span,
body.dark-mode .modal-box label,
body.dark-mode .summary-tile span,
body.dark-mode .summary-tile strong,
body.dark-mode .duty-name-row,
body.dark-mode .duty-branch-header,
body.dark-mode .dashboard-duty-list,
body.dark-mode .duty-name-list li {
  color: #eaf6f2 !important;
}

/* Muted secondary text a touch dimmer */
body.dark-mode .card .shift-label,
body.dark-mode .card .duty-shift-label,
body.dark-mode .topbar .active-module span,
body.dark-mode .list-filter-item span {
  color: #9fc8bf !important;
}

/* Filter inputs (date/month) match the branch select in dark mode */
body.dark-mode .list-filter-item select,
body.dark-mode .list-filter-item input[type="date"],
body.dark-mode .list-filter-item input[type="month"] {
  background: #0f322d;
  color: #eaf6f2;
  border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .month-step-btn {
  background: #0f322d;
  color: #eaf6f2;
  border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .month-step-btn:hover {
  background: #16453e;
  border-color: rgba(142, 214, 198, 0.45);
}

body.dark-mode .list-filter-item input[type="date"]::-webkit-calendar-picker-indicator,
body.dark-mode .list-filter-item input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

/* Table headers / row separators */
body.dark-mode .doctor-table th,
body.dark-mode thead th {
  background: rgba(255, 255, 255, 0.06);
  color: #cfe9e2 !important;
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode tbody td,
body.dark-mode .doctor-table td {
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .sales-chart-summary div,
body.dark-mode .sales-chart-content {
  background: rgba(15, 50, 45, 0.78);
  border-color: rgba(255, 255, 255, 0.16);
}

body.dark-mode .sales-chart-track {
  background: rgba(255, 255, 255, 0.2);
}

/* Inputs / selects */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #0f322d;
  color: #eaf6f2;
  border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #7fa69d;
}

/* Switches */
body.dark-mode .lang-switch,
body.dark-mode .theme-switch {
  background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .lang-btn {
  color: #eaf6f2;
}

body.dark-mode .lang-btn.active,
body.dark-mode .theme-btn.active {
  background: rgba(255, 255, 255, 0.18);
}

/* Action / table buttons stay readable */
body.dark-mode .dt-btn,
body.dark-mode .entry-action {
  color: #102e29 !important;
}

body.dark-mode .brand-logo-img {
  background: rgba(255, 255, 255, 0.95);
}

/* Form sections / summaries in dark mode */
body.dark-mode .form-section {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .form-section legend {
  color: #cfe9e2 !important;
}

body.dark-mode .form-summary {
  background: rgba(25, 165, 141, 0.16);
  border-color: rgba(25, 165, 141, 0.3);
}

body.dark-mode .form-summary p,
body.dark-mode .total-field input {
  color: #eaf6f2 !important;
}

body.dark-mode .total-field input {
  background: #0c2b27;
}

/* Settings > Staff list — match Doctor settings tone in dark mode */
body.dark-mode .name-item {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .name-item span {
  color: #eaf6f2;
}

body.dark-mode .payee-source-badge {
  background: rgba(43, 191, 163, 0.22);
  color: #dff8f2 !important;
}

body.dark-mode .name-list-empty {
  color: #9fc8bf;
  border-color: rgba(255, 255, 255, 0.18);
}

body.dark-mode .self-password-panel {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode .self-password-panel strong {
  color: #eaf6f2;
}

body.dark-mode .settings-form-row input {
  background: #0f322d;
  color: #eaf6f2;
  border-color: rgba(255, 255, 255, 0.18);
}

/* List action + delete buttons — solid, readable in dark mode */
body.dark-mode .entry-action.edit {
  background: #2bbfa3;
  color: #06241f !important;
}

body.dark-mode .entry-action.delete,
body.dark-mode .delete-name-btn {
  background: #e7635a;
  color: #2a0906 !important;
}

body.dark-mode .entry-action.whatsapp {
  background: #25d366;
  color: #06241f !important;
}

body.dark-mode .audit-status-item {
  background: rgba(15, 50, 45, 0.76);
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode .cash-balance-cell {
  background: rgba(43, 191, 163, 0.13);
  border-color: rgba(43, 191, 163, 0.24);
}

body.dark-mode .cash-balance-cell strong {
  color: #eaf6f2;
}

body.dark-mode .cash-balance-field small,
body.dark-mode .cash-balance-cell span {
  color: #b6d4cd;
}

body.dark-mode .audit-status-name {
  color: #eaf6f2;
}

body.dark-mode .audit-status-time,
body.dark-mode .audit-status-empty {
  color: #b6d4cd;
}

body.dark-mode .dt-btn-edit {
  background: #2bbfa3;
  color: #06241f !important;
}

body.dark-mode .dt-btn-merge {
  background: #8fb6f0;
  color: #0a1c38 !important;
}

body.dark-mode .dt-btn-del {
  background: #e7635a;
  color: #2a0906 !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(22, 163, 138, 0.16), transparent 34%),
    radial-gradient(circle at 94% 92%, rgba(245, 197, 66, 0.16), transparent 32%),
    linear-gradient(135deg, #f7fbf8 0%, #eef7f3 54%, #fffaf0 100%);
  background-attachment: fixed;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  z-index: -1;
  filter: blur(4px);
}

.orb-1 {
  width: 320px;
  height: 320px;
  top: -80px;
  right: -90px;
  background: radial-gradient(circle at 35% 35%, rgba(25, 165, 141, 0.3), rgba(25, 165, 141, 0.04));
}

.orb-2 {
  width: 360px;
  height: 360px;
  left: -140px;
  bottom: -90px;
  background: radial-gradient(circle at 52% 52%, rgba(246, 183, 60, 0.24), rgba(246, 183, 60, 0.02));
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 220px) 1fr;
  gap: 16px;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 14px;
  transition: grid-template-columns 0.28s ease;
}

.app-shell.sidebar-collapsed {
  --sidebar-w: 56px;
}

.sidebar {
  background: linear-gradient(170deg, var(--teal-900), #0a2f2a 68%, #09231f 100%);
  color: #dff7f2;
  border-radius: var(--radius-lg);
  padding: 14px 10px;
  box-shadow: var(--shadow);
  animation: fade-slide 0.45s ease;
  overflow: hidden;
  width: var(--sidebar-w, 220px);
  transition: width 0.28s ease, padding 0.28s ease;
  align-self: start;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 56px;
  padding: 14px 8px;
}

/* Toggle button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #dff7f2;
  border-radius: 10px;
  padding: 8px;
  font-size: 1.05rem;
  cursor: pointer;
  margin-bottom: 14px;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.18);
}

/* Brand */
.brand-logo {
  display: flex;
  justify-content: center;
  padding: 4px 0 12px;
}

.brand-logo-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: width 0.28s ease, height 0.28s ease;
}

.app-shell.sidebar-collapsed .brand-logo {
  padding: 2px 0 8px;
}

.app-shell.sidebar-collapsed .brand-logo-img {
  width: 38px;
  height: 38px;
  padding: 4px;
  border-radius: 10px;
}

.brand {
  padding: 4px 6px 16px;
  border-bottom: 1px solid rgba(223, 247, 242, 0.2);
  margin-bottom: 2px;
}

/* Hide labels when collapsed */
.app-shell.sidebar-collapsed .sidebar-expanded-only {
  display: none;
}

/* Collapsed menu items show icon only */
.app-shell.sidebar-collapsed .menu-item {
  padding: 10px;
  text-align: center;
  font-size: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .menu-item::before {
  font-size: 1.1rem;
  content: attr(data-icon);
}

.app-shell.sidebar-collapsed .menu-block {
  margin-top: 6px;
}

.kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fddd1;
}

.brand h1 {
  margin: 8px 0 0;
  font-family: "Archivo", sans-serif;
  font-size: 1.32rem;
  line-height: 1.28;
}

.menu-block {
  margin-top: 22px;
}

.menu-block h2 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #95d8ce;
}

.menu-item {
  width: 100%;
  margin-bottom: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: #f4fffc;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.96rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.menu-item:hover {
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.14);
}

.menu-item.active {
  background: linear-gradient(130deg, rgba(25, 165, 141, 0.9), rgba(19, 113, 101, 0.92));
  border-color: rgba(255, 255, 255, 0.2);
}

.content {
  animation: fade-slide 0.5s ease;
  min-width: 0;
}

.topbar {
  background: var(--card);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 28px rgba(21, 53, 48, 0.12);
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.topbar h2 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 1.58rem;
  letter-spacing: 0.02em;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.theme-switch {
  display: inline-flex;
  gap: 8px;
  background: #ecf3f2;
  border-radius: 12px;
  padding: 6px;
}

.theme-btn {
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
}

.theme-btn.active {
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(17, 78, 70, 0.15);
}

.lang-switch {
  display: inline-flex;
  gap: 8px;
  background: #ecf3f2;
  border-radius: 12px;
  padding: 6px;
}

.lang-btn {
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  background: transparent;
  color: var(--teal-900);
  font-weight: 700;
}

.lang-btn.active {
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(17, 78, 70, 0.15);
}

.panel {
  display: none;
  margin-top: 18px;
}

.panel.active {
  display: block;
  animation: panel-rise 0.34s ease;
}

/* Form shown as a popup modal (New Entry) */
.panel.is-modal {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1100;
  margin: 0;
  padding: 24px 16px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  animation: none;
}

.panel.is-modal .form-card {
  width: min(75vw, 1280px);
  max-width: none;
  margin: 0 auto;
  position: relative;
}

.newentry-close {
  display: none;
  font-size: 1.6rem;
  line-height: 1;
}

.panel.is-modal .newentry-close {
  display: block;
}

body.modal-open {
  overflow: hidden;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 12px 24px rgba(21, 53, 48, 0.1);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-head h3 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 1.22rem;
}

.card-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.period-tabs {
  display: inline-flex;
  gap: 8px;
  background: #e6efed;
  border-radius: 12px;
  padding: 6px;
}

.period-btn {
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
  background: transparent;
  color: #2a4a44;
}

.period-btn.active {
  background: linear-gradient(125deg, #ffffff, #f6fffc);
  box-shadow: 0 4px 12px rgba(17, 78, 70, 0.16);
}

.sales-report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.sales-summary-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.sales-month-filter.is-hidden {
  display: none;
}

/* Small helper text under the report period control (clarifies the View By mode) */
.report-filter-helper {
  flex-basis: 100%;
  width: 100%;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}
.report-filter-helper:empty {
  display: none;
}
body.dark-mode .report-filter-helper {
  color: #9fb4ad;
}

.table-wrap {
  margin-top: 8px;
  overflow-x: auto;
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.list-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.list-filter-item select,
.list-filter-item input[type="date"],
.list-filter-item input[type="month"] {
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.88rem;
  font-family: "Manrope", sans-serif;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

/* List search box */
.list-search-item { flex: 1 1 280px; }
.list-search-wrap { display: flex; align-items: center; gap: 6px; flex: 1; }
.list-search-wrap input[type="search"] {
  flex: 1;
  min-width: 160px;
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.88rem;
  font-family: "Manrope", sans-serif;
  background: #fff;
  color: var(--text);
}
.list-search-wrap .form-btn { padding: 6px 14px; white-space: nowrap; }
body.dark-mode .list-search-wrap input[type="search"] {
  background: #1f2937;
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.15);
}

.month-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 240px;
}

.month-stepper input[type="month"],
.month-stepper input[type="date"] {
  flex: 1 1 auto;
  min-width: 0;
}

.month-step-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  background: #fff;
  color: #2a4a44;
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  flex: 0 0 34px;
}

.month-step-btn:hover {
  background: #edf6f3;
  border-color: rgba(15, 118, 110, 0.35);
}

.month-step-btn:focus-visible {
  outline: 3px solid rgba(17, 78, 70, 0.2);
  outline-offset: 2px;
}

.list-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.duty-name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.duty-name-list li {
  font-size: inherit;
  line-height: 1.4;
  padding: 2px 0;
}

.duty-name-list .shift-label {
  font-size: inherit;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

thead th {
  text-align: left;
  font-size: 0.84rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.sales-report-group-row th {
  text-align: center;
  background: rgba(20, 71, 64, 0.08);
  color: #174942;
  font-family: "Archivo", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(21, 53, 48, 0.18);
}

tbody td,
tfoot th {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.08);
}

tbody tr:hover {
  background: rgba(25, 165, 141, 0.06);
}

tbody tr.duplicate-entry-row,
tbody tr.duplicate-entry-row:hover {
  background: rgba(220, 53, 46, 0.14);
}

tbody tr.duplicate-entry-row td {
  border-bottom-color: rgba(220, 53, 46, 0.28);
}

.duplicate-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #d83a32;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
}

/* ── Mobile (≤640px): compact action buttons ─────────────────────────────── */
@media (max-width: 640px) {
  .entry-action {
    padding: 6px 8px;
    font-size: 0.72rem;
  }
}

.sales-report-table {
  min-width: 1060px;
}

.sales-report-table th,
.sales-report-table td,
.sales-report-table tfoot th {
  text-align: center;
}

.sales-report-table thead th {
  text-align: center;
  vertical-align: middle;
}

.sales-report-table thead tr:last-child th {
  text-align: center;
}

.sales-report-table thead tr:last-child th:first-child {
  text-align: center;
}

.sales-report-table .sales-section-start {
  border-left: 3px solid rgba(19, 113, 101, 0.42);
}

.sales-pagination {
  padding-top: 10px;
}

.sales-report-tabs,
.patient-report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.12);
  padding-bottom: 8px;
}

.sales-report-tab-button,
.patient-report-tab-button {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: #f7fbfa;
  color: #426b64;
  font-weight: 800;
  padding: 8px 12px;
  cursor: pointer;
}

.sales-report-tab-button.active,
.patient-report-tab-button.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.sales-report-tab-panel,
.patient-report-tab-panel {
  display: none;
}

.sales-report-tab-panel.active,
.patient-report-tab-panel.active {
  display: block;
}

@media (max-width: 640px) {
  .sales-report-tab-button,
  .patient-report-tab-button {
    flex: 1 1 calc(50% - 8px);
  }
}

/* ── Sales KPI Cards ─────────────────────────────────────────────────────── */
.sales-kpi-section {
  margin: 14px 0 0;
}

.sales-kpi-section-head {
  margin-bottom: 8px;
}

.sales-kpi-section-head h4 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 0.96rem;
  color: var(--teal-900);
}

.sales-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

@media (max-width: 1100px) {
  .sales-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .sales-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.sales-kpi-card {
  background: #fff;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.18s;
}

.sales-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 8px 8px 0 0;
}

.kpi-accent-total::before   { background: linear-gradient(90deg, #0f766e, #14b8a6); }
.kpi-accent-nonpanel::before { background: linear-gradient(90deg, #0f766e, #34d399); }
.kpi-accent-panel::before   { background: linear-gradient(90deg, #c2410c, #fb923c); }
.kpi-accent-cash::before    { background: linear-gradient(90deg, #1d4ed8, #60a5fa); }
.kpi-accent-digital::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.kpi-accent-avg::before     { background: linear-gradient(90deg, #0369a1, #38bdf8); }

.kpi-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #426b64;
}

.kpi-value {
  display: block;
  font-family: "Archivo", sans-serif;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--teal-900);
  line-height: 1.2;
  margin-top: 2px;
}

.kpi-hint {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
}

body.dark-mode .sales-kpi-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sales-kpi-section-head h4,
body.dark-mode .kpi-value {
  color: #e2f8f4;
}

body.dark-mode .kpi-label {
  color: #9fc8bf;
}

body.dark-mode .sales-trend-panel {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sales-trend-mix-panel {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sales-trend-mix-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sales-trend-mix-card strong,
body.dark-mode .sales-trend-mix-card span,
body.dark-mode .sales-trend-mix-value-label {
  color: #e2f8f4;
  fill: #bdf8eb;
}

body.dark-mode .sales-trend-mix-x-label,
body.dark-mode .sales-trend-mix-y-label {
  fill: #9fc8bf;
}

body.dark-mode .sales-trend-mix-axis {
  stroke: rgba(255, 255, 255, 0.28);
}

body.dark-mode .sales-trend-mix-grid {
  stroke: rgba(255, 255, 255, 0.08);
}

body.dark-mode .sales-trend-mix-tooltip {
  background: #1a2e2b;
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2f8f4;
}

body.dark-mode .sales-trend-mix-tooltip strong {
  color: #e2f8f4;
}

body.dark-mode .payment-method-panel {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sales-report-tab-button,
body.dark-mode .patient-report-tab-button {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #9fc8bf;
}

body.dark-mode .sales-report-tab-button.active,
body.dark-mode .patient-report-tab-button.active {
  background: #0f766e;
  border-color: #14b8a6;
  color: #fff;
}

body.dark-mode .branch-sales-panel,
body.dark-mode .sales-heatmap-panel,
body.dark-mode .patient-branch-comparison-panel,
body.dark-mode .patient-heatmap-panel,
body.dark-mode .branch-sales-card,
body.dark-mode .branch-sales-metrics div {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .branch-sales-card h5,
body.dark-mode .branch-sales-card-head strong,
body.dark-mode .branch-sales-metrics strong {
  color: #e2f8f4;
}

body.dark-mode .branch-sales-compare-track {
  background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .heatmap-empty {
  background: rgba(255, 255, 255, 0.06);
  color: #9fc8bf;
}

body.dark-mode .payment-method-name,
body.dark-mode .payment-method-value strong {
  color: #e2f8f4;
}

body.dark-mode .payment-method-track {
  background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .payment-method-value small {
  color: #9fc8bf;
}

body.dark-mode .sales-trend-bar {
  fill: #2bbfa3;
}

body.dark-mode .sales-trend-value-label {
  fill: #bdf8eb;
}

body.dark-mode .sales-trend-tooltip {
  background: #1a2e2b;
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2f8f4;
}

body.dark-mode .sales-trend-tooltip strong {
  color: #e2f8f4;
}

.sales-chart-panel {
  margin-top: 18px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 14px;
}

.sales-trend-panel {
  margin-top: 14px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 14px;
}

.sales-trend-mix-panel {
  margin-top: 14px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.sales-trend-mix-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #0f766e, #c2410c);
}

.payment-method-panel {
  margin-top: 14px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.payment-method-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #0f766e, #2563eb, #7c3aed, #f97316);
}

.branch-sales-panel,
.sales-heatmap-panel,
.patient-branch-comparison-panel,
.patient-heatmap-panel {
  margin-top: 14px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.branch-sales-panel::before,
.sales-heatmap-panel::before,
.patient-branch-comparison-panel::before,
.patient-heatmap-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: #0f766e;
}

.sales-chart-head h4 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 1rem;
  color: var(--teal-900);
}

.sales-chart-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.sales-trend-chart {
  position: relative;
  min-height: 340px;
  margin-top: 12px;
}

.sales-trend-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.sales-trend-scroll svg {
  display: block;
  min-height: 340px;
}

.sales-trend-axis {
  stroke: rgba(21, 53, 48, 0.28);
  stroke-width: 1.5;
}

.sales-trend-bar {
  transition: opacity 0.15s, filter 0.15s;
}

.sales-trend-bar-group {
  cursor: default;
}

.sales-trend-bar-group:hover .sales-trend-bar {
  opacity: 0.84;
  filter: brightness(1.08);
}

.sales-trend-x-label {
  font-size: 11px;
  font-weight: 700;
  fill: rgba(80, 113, 107, 0.9);
}

.sales-trend-value-label {
  font-size: 10px;
  font-weight: 800;
  fill: #0e4740;
}

.sales-trend-empty {
  min-height: 292px;
}

.sales-trend-tooltip {
  position: fixed;
  z-index: 9999;
  min-width: 148px;
  border: 1px solid rgba(21, 53, 48, 0.15);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.55;
  pointer-events: none;
}

.sales-trend-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: var(--teal-900);
}

.sales-trend-mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  margin: 12px 0 0;
}

.sales-trend-mix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sales-trend-mix-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.sales-trend-mix-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sales-trend-mix-card {
  border: 1px solid rgba(21, 53, 48, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.sales-trend-mix-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: #0f766e;
}

.sales-trend-mix-card.panel::before {
  background: #c2410c;
}

.sales-trend-mix-card.total::before {
  background: #143d38;
}

.sales-trend-mix-card span,
.sales-trend-mix-card small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.sales-trend-mix-card strong {
  display: block;
  margin-top: 5px;
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 1rem;
  line-height: 1.2;
}

.sales-trend-mix-card small {
  margin-top: 3px;
}

.sales-trend-mix-chart {
  position: relative;
  min-height: 360px;
  margin-top: 12px;
}

.sales-trend-mix-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.sales-trend-mix-scroll svg {
  display: block;
  min-height: 360px;
}

.sales-trend-mix-axis {
  stroke: rgba(21, 53, 48, 0.28);
  stroke-width: 1.5;
}

.sales-trend-mix-grid {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.sales-trend-mix-bar-group {
  cursor: default;
}

.sales-trend-mix-segment {
  transition: opacity 0.15s, filter 0.15s;
}

.sales-trend-mix-bar-group:hover .sales-trend-mix-segment {
  opacity: 0.86;
  filter: brightness(1.06);
}

.sales-trend-mix-segment.non-panel {
  fill: #0f766e;
}

.sales-trend-mix-segment.panel-sales {
  fill: #c2410c;
}

.sales-trend-mix-zero {
  fill: #cbd5d1;
}

.sales-trend-mix-x-label,
.sales-trend-mix-y-label {
  font-size: 11px;
  font-weight: 700;
  fill: #52706b;
}

.sales-trend-mix-value-label {
  font-size: 10px;
  font-weight: 800;
  fill: #143d38;
}

.sales-trend-mix-empty {
  min-height: 312px;
}

.sales-trend-mix-tooltip {
  position: fixed;
  z-index: 9999;
  min-width: 210px;
  border: 1px solid rgba(21, 53, 48, 0.15);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.55;
  pointer-events: none;
}

.sales-trend-mix-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: var(--teal-900);
}

@media (max-width: 720px) {
  .sales-trend-mix-summary {
    grid-template-columns: 1fr;
  }
}

.payment-method-breakdown {
  margin-top: 12px;
}

.payment-method-rows {
  display: grid;
  gap: 12px;
}

.payment-method-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(140px, 2fr) minmax(112px, auto);
  align-items: center;
  gap: 14px;
}

.payment-method-name {
  color: var(--teal-900);
  font-size: 0.88rem;
  font-weight: 800;
}

.payment-method-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #edf4f2;
  overflow: hidden;
}

.payment-method-fill {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: 999px;
  transition: width 0.2s ease;
}

.payment-color-cash {
  background: #0f766e;
}

.payment-color-merchant {
  background: #2563eb;
}

.payment-color-qr {
  background: #7c3aed;
}

.payment-color-bank {
  background: #f97316;
}

.payment-method-value {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  text-align: right;
}

.payment-method-value strong {
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 0.94rem;
  line-height: 1.2;
}

.payment-method-value small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.payment-method-empty {
  margin: 12px 0 0;
  min-height: auto;
  padding: 8px 0 0;
}

@media (max-width: 720px) {
  .payment-method-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .payment-method-value {
    justify-content: space-between;
    text-align: left;
  }
}

.branch-sales-comparison,
.patient-branch-comparison-cards {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.branch-sales-card {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.branch-sales-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.branch-sales-card h5 {
  margin: 0;
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 0.98rem;
}

.branch-sales-card-head strong {
  display: block;
  margin-top: 4px;
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 1.08rem;
}

.branch-sales-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.branch-sales-badges span {
  border-radius: 999px;
  background: #e6f6f2;
  color: #0f766e;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 8px;
}

.branch-sales-compare-track {
  height: 12px;
  border-radius: 999px;
  background: #edf4f2;
  overflow: hidden;
  margin: 12px 0;
}

.branch-sales-compare-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.branch-sales-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.branch-sales-metrics div {
  border: 1px solid rgba(21, 53, 48, 0.1);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.branch-sales-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.branch-sales-metrics strong {
  display: block;
  margin-top: 4px;
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 0.9rem;
}

.monthly-sales-heatmap,
.monthly-patient-heatmap {
  margin-top: 12px;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 8px;
  min-width: 720px;
}

.heatmap-weekday {
  color: #52706b;
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
}

.heatmap-cell {
  min-height: 78px;
  border: 1px solid rgba(21, 53, 48, 0.1);
  border-radius: 8px;
  padding: 8px;
  color: #143d38;
}

.heatmap-cell span,
.heatmap-cell small {
  display: block;
  font-weight: 800;
}

.heatmap-cell strong {
  display: block;
  margin-top: 8px;
  font-family: "Archivo", sans-serif;
  font-size: 0.86rem;
}

.heatmap-cell small {
  margin-top: 4px;
  font-size: 0.72rem;
}

.heatmap-yearly-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  min-width: 480px;
}

.heatmap-yearly-cell span {
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.heatmap-blank {
  visibility: hidden;
}

.heatmap-empty { background: #f3f4f6; }
.heatmap-low { background: #d1f3ed; }
.heatmap-medium { background: #8ddfd3; }
.heatmap-high { background: #37b5a3; color: #fff; }
.heatmap-very-high { background: #0f766e; color: #fff; }

.heatmap-note {
  margin: 10px 0 0;
  min-height: auto;
}

@media (max-width: 980px) {
  .branch-sales-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .branch-sales-card-head {
    display: block;
  }

  .branch-sales-badges {
    justify-content: flex-start;
    margin-top: 8px;
  }

  .branch-sales-metrics {
    grid-template-columns: 1fr;
  }
}

.sales-chart-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.sales-chart-summary div {
  border: 1px solid rgba(21, 53, 48, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.sales-chart-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sales-chart-summary strong {
  display: block;
  margin-top: 4px;
  font-family: "Archivo", sans-serif;
  color: var(--teal-900);
}

.sales-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.sales-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sales-chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-non-panel,
.sales-chart-segment.non-panel {
  background: #0f766e;
}

.legend-panel,
.sales-chart-segment.panel-sales {
  background: #c2410c;
}

.sales-chart-bars {
  display: grid;
  gap: 0;
}

.sales-chart-row {
  display: grid;
  grid-template-columns: minmax(98px, 130px) minmax(300px, 1fr) minmax(92px, auto);
  gap: 14px;
  align-items: start;
  font-size: 0.84rem;
  padding: 10px 0;
  border-bottom: 1px solid rgba(21, 53, 48, 0.08);
}

.sales-chart-row:last-child {
  border-bottom: 0;
}

.sales-chart-label {
  color: #274d46;
  font-weight: 800;
  padding-top: 19px;
}

.sales-chart-content {
  min-width: 0;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  padding: 9px;
}

.sales-chart-track {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(21, 53, 48, 0.14);
}

.sales-chart-segment {
  display: block;
  height: 100%;
  min-width: 0;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.sales-chart-split-labels,
.sales-chart-split-values {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #274d46;
  font-size: 0.76rem;
  font-weight: 900;
}

.sales-chart-split-labels {
  margin-bottom: 5px;
}

.sales-chart-split-values {
  margin-top: 5px;
}

.sales-chart-split-values strong {
  font-family: "Archivo", sans-serif;
  font-size: 0.82rem;
}

.sales-chart-row strong {
  text-align: right;
  color: var(--teal-900);
}

.sort-th {
  cursor: pointer;
  user-select: none;
  white-space: normal; /* allow header text to wrap to next line */
}

.sort-th:hover {
  color: var(--teal-700);
}

.sort-th .sort-arrow {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.72rem;
  opacity: 0.35;
}

.sort-th.sorted .sort-arrow {
  opacity: 1;
  color: var(--teal-700);
}

body.dark-mode .sort-th:hover,
body.dark-mode .sort-th.sorted .sort-arrow {
  color: #34d3b4;
}

/* ── List Entry: stacked cards (one entry per box) ───────────────────────── */
.list-sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.list-sort-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.list-sort-bar .sort-th {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(19, 113, 101, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.list-sort-bar .sort-th.sorted {
  border-color: var(--teal-700);
  background: rgba(25, 165, 141, 0.10);
  color: var(--teal-700);
}

body.dark-mode .list-sort-bar .sort-th {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
  color: inherit;
}

body.dark-mode .list-sort-bar .sort-th.sorted {
  background: rgba(52, 211, 180, 0.14);
  border-color: #34d3b4;
}

.list-entry-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entry-card {
  border: 1px solid rgba(19, 113, 101, 0.14);
  border-radius: 12px;
  background: #fff;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.dark-mode .entry-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: none;
}

.entry-card.duplicate-entry-row {
  border-color: rgba(220, 53, 46, 0.45);
  background: rgba(220, 53, 46, 0.06);
}

.entry-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(19, 113, 101, 0.12);
}

body.dark-mode .entry-card-head {
  border-bottom-color: rgba(255, 255, 255, 0.10);
}

.entry-card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.entry-card-branch {
  font-size: 1rem;
  font-weight: 800;
}

.entry-card-date {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.entry-card-head .entry-actions {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.entry-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 22px;
}

.entry-field {
  min-width: 0;
}

.entry-field-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.entry-field,
.entry-field * {
  font-size: 0.85rem;
}

.entry-field .entry-field-label {
  font-size: 0.72rem;
}

.list-entry-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--muted);
}


.sales-breakdown {
  display: grid;
  gap: 4px;
  min-width: 0; /* don't force column wider than its allocated width */
  width: 100%;
}

.sales-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  min-width: 0;
}

.sales-breakdown-row strong {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.sales-breakdown-row.total {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(21, 53, 48, 0.14);
  color: #0e5d54;
  font-weight: 900;
}

/* ── Login gate ──────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(130deg, #e5f7f2 0%, #f8f6eb 46%, #f2f8f5 100%);
}

.login-overlay.hidden {
  display: none;
}

body.dark-mode .login-overlay {
  background: linear-gradient(130deg, #0c1614 0%, #111d1a 50%, #0f1a18 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: grid;
  gap: 14px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto;
}

.login-card h1 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  color: var(--teal-900);
  font-size: 1.5rem;
}

.login-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card .field {
  text-align: left;
  display: grid;
  gap: 6px;
}

.login-card .field span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.login-card input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
}

.login-error {
  color: #c2410c;
  font-size: 0.85rem;
  min-height: 1em;
  margin: 0;
}

.login-btn {
  width: 100%;
  justify-content: center;
}

body.dark-mode .login-card { background: #14403a; }
body.dark-mode .login-card h1 { color: #eaf6f2; }
body.dark-mode .login-card .field span { color: #9fc8bf; }
body.dark-mode .login-card input {
  background: #0f322d;
  color: #eaf6f2;
  border-color: rgba(255, 255, 255, 0.18);
}

/* Topbar user box */
.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-username {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.logout-btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
}

.logout-btn:hover {
  background: rgba(197, 82, 69, 0.14);
  color: #9e332a;
  border-color: transparent;
}

body.dark-mode .auth-username { color: #eaf6f2; }
body.dark-mode .logout-btn { color: #eaf6f2; }

/* User management add row */
.user-add-row {
  grid-template-columns: 1fr 1fr auto auto;
}

@media (max-width: 768px) {
  .user-add-row { grid-template-columns: 1fr; }
  .self-password-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}

.user-link-hint {
  margin: 2px 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.self-password-panel {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(19, 113, 101, 0.14);
  border-radius: 16px;
  background: rgba(25, 165, 141, 0.08);
}

.self-password-panel strong {
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
}

.self-password-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

/* ── Inline edit input in settings lists ──────────────────────────────────── */
.inline-edit-input {
  flex: 1;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

/* ── Expense settings panel ────────────────────────────────────────────────── */
.expense-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 16px;
}

.expense-settings-block h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .expense-settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Expense breakdown in list entry ───────────────────────────────────────── */
.exp-breakdown {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.exp-row {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1.5fr auto; /* Category, Payee, Item, Amount */
  gap: 4px;
  align-items: baseline;
  font-size: inherit;
  color: var(--muted);
  min-width: 0;
}

.exp-item {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-payee {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-category {
  color: var(--teal-700);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-amount {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.exp-total {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(21, 53, 48, 0.14);
  text-align: right;
  color: #0e5d54;
  font-size: inherit;
}

/* ── Patient breakdown in list entry ──────────────────────────────────────── */
.patient-breakdown {
  display: grid;
  gap: 3px;
  min-width: 0;
  width: 100%;
}

.patient-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: inherit;
  color: var(--muted);
}

.patient-row strong {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.patient-total {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid rgba(21, 53, 48, 0.14);
  color: #0e5d54;
  font-weight: 700;
}

.patient-total strong {
  color: #0e5d54;
}

/* ── List entry pagination ─────────────────────────────────────────────────── */
.list-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 4px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.page-size-label select {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1.5px solid rgba(21, 53, 48, 0.18);
  background: var(--card);
  color: var(--ink);
  font-size: 0.82rem;
  cursor: pointer;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-nav-btn {
  background: var(--card);
  border: 1.5px solid rgba(21, 53, 48, 0.18);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s;
  line-height: 1.4;
}

.page-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 100px;
  text-align: center;
}

.entry-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.audit-status-cell {
  display: grid;
  gap: 7px;
}

.cash-balance-field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.cash-balance-cell {
  display: grid;
  width: fit-content;
  max-width: 100%;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid rgba(19, 113, 101, 0.13);
  border-radius: 8px;
  background: rgba(25, 165, 141, 0.09);
}

.cash-balance-cell span {
  color: var(--muted);
  font-size: 0.72rem !important;
  font-weight: 900;
  line-height: 1.25;
}

.cash-balance-cell strong {
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 0.94rem !important;
  line-height: 1.2;
}

.audit-status-item {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid rgba(19, 113, 101, 0.13);
  border-radius: 8px;
  background: rgba(247, 251, 248, 0.78);
}

.audit-status-badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.68rem !important;
  font-weight: 900;
  line-height: 1.25;
}

.audit-status-badge.created {
  background: rgba(19, 113, 101, 0.12);
  color: #0e5d54;
}

.audit-status-badge.edited {
  background: rgba(58, 124, 191, 0.14);
  color: #225d97;
}

.audit-status-badge.whatsapp {
  background: rgba(37, 211, 102, 0.16);
  color: #128c4a;
}

.audit-status-name {
  color: var(--teal-900);
  font-weight: 800;
  line-height: 1.25;
}

.audit-status-time {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.25;
}

.audit-status-empty {
  color: var(--muted);
  font-weight: 800;
}

.entry-action {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
}

.entry-action.edit {
  background: rgba(19, 113, 101, 0.12);
  color: #0e5d54;
}

.entry-action.delete {
  background: rgba(197, 82, 69, 0.14);
  color: #9e332a;
}

.entry-action.whatsapp {
  background: rgba(37, 211, 102, 0.16);
  color: #128c4a;
}

tfoot th {
  font-family: "Archivo", sans-serif;
  border-top: 2px solid rgba(21, 53, 48, 0.12);
  border-bottom: 0;
}

.placeholder h3 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 1.16rem;
}

.placeholder p {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 72ch;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-tile {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-family: "Archivo", sans-serif;
  font-size: 1.18rem;
  color: var(--teal-900);
}

.dashboard-duty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.dashboard-duty-panel {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
}

.dashboard-duty-panel h4 {
  margin: 0 0 8px;
  font-family: "Archivo", sans-serif;
  font-size: 0.95rem;
}

.dashboard-duty-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: #284c46;
}

.dashboard-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.duty-branch-header {
  font-family: "Archivo", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal-900);
  background: rgba(20, 71, 64, 0.07);
  border-radius: 6px;
  padding: 4px 8px;
  margin-top: 10px;
}

.duty-branch-header:first-child {
  margin-top: 0;
}

.duty-shift-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px 1px;
  margin-top: 4px;
}

.duty-name-row {
  font-size: 0.88rem;
  padding: 2px 8px;
  line-height: 1.5;
}

.duty-empty-row {
  font-size: 0.84rem;
  color: var(--muted);
  padding: 2px 8px;
}

.dashboard-table-wrap {
  margin-top: 10px;
}

.dashboard-branch-filter {
  display: grid;
  gap: 5px;
  min-width: 210px;
}

.dashboard-branch-filter span {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 800;
}

.dashboard-branch-filter select {
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: #ffffff;
}

.dashboard-chart-panel {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 11px;
  margin-bottom: 14px;
}

.dashboard-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.dashboard-chart-head h4 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 0.94rem;
}

.dashboard-chart-head span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.dashboard-selected-date {
  margin: 4px 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--teal-900);
}

/* Pie chart */
.pie-chart-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.pie-chart {
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
}

.pie-chart path {
  transition: opacity 0.2s;
}

.pie-chart path:hover {
  opacity: 0.85;
}

.pie-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  flex: 1 1 160px;
  min-width: 160px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
}

.pie-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.pie-legend-label {
  font-weight: 700;
  color: var(--ink);
}

.pie-legend-value {
  margin-left: auto;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(340px, 1.1fr);
  gap: 12px;
}

.patient-total-card {
  display: grid;
  gap: 2px;
  min-width: 96px;
  padding: 7px 9px;
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  text-align: right;
}

.patient-total-card span {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.patient-total-card strong {
  font-family: "Archivo", sans-serif;
  font-size: 1.05rem;
  color: var(--teal-900);
}

/* Modern dashboard polish */
.sidebar {
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 22px 48px rgba(8, 43, 38, 0.28);
}

.brand-logo {
  margin: 0 4px 8px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-logo-img {
  box-shadow: 0 12px 26px rgba(2, 25, 21, 0.24);
}

.brand {
  padding: 10px 10px 16px;
}

.menu-block {
  margin-top: 18px;
}

.menu-block h2 {
  font-size: 0.72rem;
  letter-spacing: 0.13em;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  background: rgba(255, 255, 255, 0.065);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.menu-item::before {
  content: attr(data-icon);
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  flex: 0 0 auto;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.12);
}

.menu-item.active {
  background: linear-gradient(135deg, rgba(52, 211, 180, 0.98), rgba(20, 184, 166, 0.86));
  color: #042822;
  box-shadow: 0 12px 24px rgba(25, 165, 141, 0.24);
}

.menu-item.active::before {
  background: rgba(255, 255, 255, 0.74);
}

.topbar,
.card,
.dashboard-chart-panel,
.dashboard-duty-panel,
.summary-tile {
  border-color: rgba(19, 113, 101, 0.14);
}

.topbar {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(246, 253, 250, 0.82));
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 42px rgba(14, 71, 64, 0.12);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(245, 197, 66, 0.18), transparent 62%);
  pointer-events: none;
}

.topbar-main {
  position: relative;
  z-index: 1;
}

.topbar-brand-lockup {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.topbar-logo {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(19, 113, 101, 0.12);
  padding: 6px;
  box-shadow: 0 12px 24px rgba(14, 71, 64, 0.13);
}

.topbar-copy {
  min-width: 0;
}

.topbar-title {
  color: var(--teal-900);
  font-size: clamp(1.72rem, 2.4vw, 2.18rem) !important;
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar-subtitle {
  margin: 6px 0 0 !important;
  color: var(--teal-700) !important;
  font-size: 1.04rem;
  font-weight: 900;
}

.topbar-org {
  margin: 5px 0 0 !important;
  color: #426963 !important;
  font-size: 0.9rem;
  font-weight: 800;
}

.topbar-description {
  max-width: 720px;
  margin: 6px 0 0 !important;
  color: var(--muted) !important;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
}

.topbar-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.topbar-greeting,
.status-pill,
.sync-pill,
.active-module {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 11px;
  border: 1px solid rgba(19, 113, 101, 0.14);
  background: rgba(255, 255, 255, 0.68);
  color: #24534c;
  font-size: 0.82rem;
  font-weight: 800;
}

.topbar-greeting {
  border-radius: 12px;
}

.active-module strong {
  margin-left: 5px;
  color: var(--teal-700);
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 42px rgba(14, 71, 64, 0.1);
}

#newEntryBtn.form-btn.primary {
  border-radius: 14px;
  padding: 11px 18px;
  background: linear-gradient(135deg, #0e4740, #137165);
  box-shadow: 0 12px 24px rgba(14, 71, 64, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

#newEntryBtn.form-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(14, 71, 64, 0.28);
  filter: saturate(1.06);
}

.dashboard-summary-grid {
  grid-template-columns: repeat(6, minmax(148px, 1fr));
  gap: 14px;
}

.summary-tile {
  position: relative;
  min-height: 148px;
  overflow: hidden;
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.92), rgba(244, 251, 248, 0.78));
  box-shadow: 0 12px 28px rgba(14, 71, 64, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.summary-tile::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -42px;
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: rgba(25, 165, 141, 0.11);
}

.summary-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(25, 165, 141, 0.3);
  box-shadow: 0 18px 34px rgba(14, 71, 64, 0.14);
}

.summary-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 14px;
  color: #07312b;
  background: rgba(25, 165, 141, 0.14);
  font-size: 0.82rem;
  font-weight: 900;
}

.summary-expense .summary-icon {
  background: rgba(224, 121, 95, 0.14);
  color: #8b3528;
}

.summary-net .summary-icon,
.summary-staff .summary-icon {
  background: rgba(61, 123, 217, 0.14);
  color: #244f96;
}

.summary-sales .summary-icon,
.summary-doctors .summary-icon {
  background: rgba(245, 197, 66, 0.2);
  color: #79520b;
}

.summary-tile span,
.summary-tile small {
  position: relative;
  z-index: 1;
}

.summary-tile strong {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  font-size: clamp(1.35rem, 1.8vw, 1.78rem);
  letter-spacing: 0;
}

.summary-tile small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.dashboard-chart-grid {
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
}

.dashboard-chart-panel,
.dashboard-duty-panel {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  padding: 16px;
  box-shadow: 0 12px 28px rgba(14, 71, 64, 0.08);
}

.dashboard-chart-head {
  align-items: center;
}

.dashboard-chart-head h4,
.dashboard-duty-panel h4 {
  color: var(--teal-900);
  font-size: 1.02rem;
}

.pie-chart-wrap {
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
}

.pie-chart {
  width: 180px;
  height: 180px;
  filter: drop-shadow(0 10px 18px rgba(14, 71, 64, 0.12));
}

.pie-chart circle {
  transition: opacity 0.2s ease, stroke-width 0.2s ease;
}

.pie-chart circle:hover {
  opacity: 0.88;
}

.pie-legend {
  gap: 9px;
  min-width: 210px;
}

.pie-legend-item {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(19, 113, 101, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.pie-legend-dot {
  border-radius: 999px;
}

.chart-summary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.chart-summary-list li {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(19, 113, 101, 0.1);
  background: rgba(247, 251, 248, 0.82);
}

.chart-summary-list span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.chart-summary-list strong {
  color: var(--teal-900);
  font-family: "Archivo", sans-serif;
  font-size: 0.98rem;
}

.patient-total-card {
  border-radius: 14px;
  background: rgba(25, 165, 141, 0.1);
  border-color: rgba(25, 165, 141, 0.2);
}

.dashboard-duty-grid {
  gap: 14px;
  margin-top: 2px;
}

.dashboard-duty-list {
  display: grid;
  gap: 8px;
}

.duty-branch-header {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(19, 113, 101, 0.1);
  color: var(--teal-900);
}

.duty-shift-label {
  width: fit-content;
  margin-top: 8px;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(25, 165, 141, 0.12);
  color: var(--teal-900);
}

.duty-roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(19, 113, 101, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  line-height: 1.25;
}

.duty-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(25, 165, 141, 0.14);
  color: var(--teal-900);
  font-size: 0.76rem;
  font-weight: 900;
}

.duty-person-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.duty-person-main strong {
  color: #163d37;
  font-size: 0.92rem;
}

.duty-person-main small {
  color: var(--muted);
  font-weight: 700;
}

.shift-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(25, 165, 141, 0.13);
  color: var(--teal-900);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.duty-roster-row[data-shift*="evening"] .shift-badge,
.duty-roster-row[data-shift*="petang"] .shift-badge {
  background: rgba(246, 183, 60, 0.2);
  color: #80540d;
}

.duty-roster-row[data-shift*="night"] .shift-badge,
.duty-roster-row[data-shift*="malam"] .shift-badge {
  background: rgba(61, 123, 217, 0.16);
  color: #244f96;
}

body.dark-mode .topbar,
body.dark-mode .card,
body.dark-mode .dashboard-chart-panel,
body.dark-mode .dashboard-duty-panel,
body.dark-mode .summary-tile,
body.dark-mode .patient-total-card,
body.dark-mode .duty-roster-row,
body.dark-mode .pie-legend-item,
body.dark-mode .chart-summary-list li {
  background: rgba(20, 64, 58, 0.82);
  border-color: rgba(223, 247, 242, 0.12);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.22);
}

body.dark-mode .topbar-greeting,
body.dark-mode .status-pill,
body.dark-mode .sync-pill,
body.dark-mode .active-module {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #dff8f2;
}

body.dark-mode .topbar-subtitle,
body.dark-mode .active-module strong {
  color: #7ee3d3 !important;
}

body.dark-mode .topbar-org,
body.dark-mode .topbar-description {
  color: #b7d8d0 !important;
}

body.dark-mode .topbar-logo {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-mode .pie-chart .donut-center {
  fill: rgba(20, 64, 58, 0.96);
}

body.dark-mode .duty-person-main strong,
body.dark-mode .chart-summary-list strong {
  color: #eaf6f2;
}

body.dark-mode .summary-tile::after {
  background: rgba(52, 211, 180, 0.12);
}

body.dark-mode .duty-roster-row,
body.dark-mode .pie-legend-item,
body.dark-mode .chart-summary-list li {
  background: rgba(15, 50, 45, 0.74);
}

@media (max-width: 1180px) {
  .dashboard-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .dashboard-chart-grid,
  .dashboard-duty-grid {
    grid-template-columns: 1fr;
  }

  .chart-summary-list {
    grid-template-columns: 1fr;
  }

  .topbar-controls {
    align-items: flex-start;
    width: 100%;
  }

  .topbar-brand-lockup {
    align-items: flex-start;
  }

  .topbar-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }

  .topbar-title {
    font-size: 1.52rem !important;
  }

  .topbar-subtitle {
    font-size: 0.94rem;
  }

  .topbar-description {
    font-size: 0.8rem;
  }
}

@media (max-width: 660px) {
  .topbar {
    gap: 12px;
    padding: 14px;
  }

  .topbar-brand-lockup {
    gap: 10px;
  }

  .topbar-logo {
    width: 44px;
    height: 44px;
    padding: 4px;
  }

  .topbar-title {
    font-size: 1.36rem !important;
  }

  .topbar-subtitle {
    margin-top: 4px !important;
    font-size: 0.86rem;
  }

  .topbar-org,
  .topbar-description {
    margin-top: 4px !important;
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .topbar-status-row {
    gap: 6px;
    margin-top: 9px;
  }

  .topbar-greeting,
  .status-pill,
  .sync-pill,
  .active-module {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .topbar-controls {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
  }

  .lang-switch,
  .theme-switch {
    gap: 4px;
    padding: 4px;
  }

  .lang-btn,
  .theme-btn {
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .user-box {
    gap: 7px;
  }

  .logout-btn {
    padding: 5px 10px;
  }
}

.metric-chart-card {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 12px;
}

.metric-chart-card h5 {
  margin: 0 0 8px;
  font-family: "Archivo", sans-serif;
  font-size: 0.9rem;
  color: #1b443e;
}

.metric-chart {
  position: relative;
  min-height: 190px;
  padding-top: 8px;
}

.metric-empty {
  display: grid;
  min-height: 166px;
  place-items: center;
  border: 1px dashed rgba(21, 53, 48, 0.2);
  border-radius: 16px;
  color: var(--muted);
  font-weight: 700;
}

.metric-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(28px, 1fr));
  gap: 10px;
  align-items: end;
  height: 166px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.14);
}

.metric-day {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  height: 166px;
  align-items: end;
}

.metric-bar {
  display: block;
  border-radius: 5px 5px 0 0;
  min-height: 8px;
}

.metric-bar.patients {
  background: rgba(19, 113, 101, 0.78);
}

.metric-bar.sales {
  background: rgba(246, 183, 60, 0.82);
}

.metric-bar.expense {
  background: rgba(197, 82, 69, 0.78);
}

.metric-trend {
  position: absolute;
  inset: 8px 0 38px;
  width: 100%;
  height: 144px;
  pointer-events: none;
  overflow: visible;
}

.metric-trend polyline {
  fill: none;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric-trend.patients polyline {
  stroke: #0e4740;
}

.metric-trend.sales polyline {
  stroke: #b57b05;
}

.metric-trend.expense polyline {
  stroke: #9e332a;
}

.chart-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.form-card .card-head {
  margin-bottom: 18px;
}

.clinic-form {
  display: grid;
  gap: 14px;
}

.form-section {
  margin: 0;
  padding: 14px 14px 16px;
  border: 1px solid rgba(21, 53, 48, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
}

.form-section legend {
  padding: 0 8px;
  font-family: "Archivo", sans-serif;
  font-size: 0.95rem;
  color: var(--teal-900);
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.one-col {
  grid-template-columns: 1fr;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.doctor-row-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 42px;
  align-items: end;
}

.expense-row-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 42px;
  align-items: end;
}

/* Locum procedure picker (adds Commission Locum lines) */
.locum-proc-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(79, 43, 214, 0.04);
  border-radius: 8px;
}
.locum-proc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.locum-rate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.locum-rate-input {
  width: 90px;
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-family: "Manrope", sans-serif;
  background: #fff;
  color: var(--text);
}
body.dark-mode .locum-rate-input { background: #1f2937; color: #e5e7eb; border-color: rgba(255,255,255,0.15); }
.locum-proc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 999px;
  padding: 2px 6px 2px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.locum-proc-x {
  border: none;
  background: #eef2f7;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  font-size: 0.7rem;
}
.locum-proc-select {
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-family: "Manrope", sans-serif;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
body.dark-mode .locum-proc-chip,
body.dark-mode .locum-proc-select { background: #1f2937; color: #e5e7eb; border-color: rgba(255,255,255,0.15); }

/* Display order: Category, Payee, Item, Amount, X
   (HTML order is Payee, Item, Category, Price, button) */
.expense-row-grid > .field:nth-child(1) { order: 2; } /* Payee */
.expense-row-grid > .field:nth-child(2) { order: 3; } /* Item */
.expense-row-grid > .field:nth-child(3) { order: 1; } /* Category */
.expense-row-grid > .field:nth-child(4) { order: 4; } /* Amount */
.expense-row-grid > .clear-expense-btn { order: 5; }

.doctor-stack {
  display: grid;
  gap: 12px;
}

.expense-stack {
  display: grid;
  gap: 10px;
}

.staff-shift-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.staff-shift-block {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.56);
  padding: 10px;
}

.shift-title {
  margin: 0 0 10px;
  font-family: "Archivo", sans-serif;
  font-size: 0.96rem;
  color: #0f4d45;
}

.staff-stack {
  display: grid;
  gap: 10px;
}

.doctor-row {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.doctor-row.is-hidden {
  display: none;
}

.doctor-row-title {
  margin: 0 0 8px;
  font-family: "Archivo", sans-serif;
  font-size: 0.93rem;
  color: #144740;
}

/* Section II "Locum" tick box, shown beside the Doctor N title */
.locum-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.locum-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #19a58d;
  cursor: pointer;
}

.clear-doctor-btn,
.clear-staff-btn,
.clear-expense-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(141, 31, 24, 0.35);
  border-radius: 10px;
  background: #fff1ef;
  color: #8d1f18;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
}

.clear-doctor-btn:hover,
.clear-staff-btn:hover,
.clear-expense-btn:hover {
  background: #ffe3df;
}

.add-doctor-btn {
  justify-self: start;
  border: 1px dashed rgba(21, 53, 48, 0.35);
  background: rgba(237, 249, 245, 0.8);
  color: #0e4740;
  border-radius: 10px;
  padding: 8px 12px;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
}

.add-doctor-btn:hover {
  background: rgba(25, 165, 141, 0.16);
}

.add-doctor-btn.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.86rem;
  color: #2f534d;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 0.95rem;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: #ffffff;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(25, 165, 141, 0.25);
  border-color: rgba(25, 165, 141, 0.45);
}

.total-field input {
  background: #edf9f5;
  border-color: rgba(25, 165, 141, 0.45);
  font-weight: 800;
}

.form-summary {
  background: linear-gradient(125deg, rgba(25, 165, 141, 0.13), rgba(19, 113, 101, 0.08));
  border: 1px solid rgba(25, 165, 141, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
}

.form-summary p {
  margin: 0;
  color: #20534a;
  font-weight: 700;
}

.form-summary strong {
  margin-left: 8px;
  font-family: "Archivo", sans-serif;
  font-size: 1.06rem;
  color: #0f4d45;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.form-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: "Manrope", sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.form-btn.primary {
  color: #ffffff;
  background: linear-gradient(130deg, var(--teal-700), var(--teal-900));
}

.form-btn.secondary {
  color: #174942;
  background: #eaf3f1;
}

.form-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.save-status {
  margin: 6px 2px 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--muted);
}

.save-status[data-state="success"] {
  color: #117555;
  font-weight: 700;
}

.save-status[data-state="error"] {
  color: #a5332a;
  font-weight: 700;
}

.save-status[data-state="pending"] {
  color: #2e5d92;
  font-weight: 700;
}

.settings-form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-form-row input {
  border: 1px solid rgba(21, 53, 48, 0.2);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 0.95rem;
  font-family: "Manrope", sans-serif;
}

.settings-btn {
  padding: 10px 14px;
}

.name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.name-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(21, 53, 48, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 9px 10px;
}

.name-item span {
  font-size: 0.93rem;
  flex: 1;
}

.payee-doctor-item {
  background: rgba(25, 165, 141, 0.08);
}

.payee-source-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 800;
}
.payee-source-doctor {
  background: rgba(25, 165, 141, 0.14);
  color: var(--teal-700);
}
.payee-source-custom {
  background: rgba(61, 123, 217, 0.12);
  color: #3d7bd9;
}

.admin-only-badge {
  display: inline-block;
  margin-left: 8px;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(231, 76, 60, 0.12);
  color: #c0392b;
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: middle;
}

.expense-settings-section {
  border: 1px solid rgba(21, 53, 48, 0.1);
  border-radius: 10px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.5);
}

.expense-settings-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.expense-settings-section-head h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--teal-900);
}

.expense-settings-section-head p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

body.dark-mode .expense-settings-section {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}
body.dark-mode .admin-only-badge { background: rgba(231,76,60,0.18); color: #e57373; }
body.dark-mode .payee-source-doctor { color: #4dd9c7; background: rgba(25,165,141,0.2); }
body.dark-mode .payee-source-custom { color: #7ba8e8; background: rgba(61,123,217,0.2); }

.name-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* legacy - kept for safety */
.delete-name-btn {
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  background: #ffeceb;
  color: #8d1f18;
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

/* List header action buttons row */
.list-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.name-list-empty {
  border: 1px dashed rgba(21, 53, 48, 0.26);
  border-radius: 10px;
  padding: 10px;
  color: var(--muted);
  font-size: 0.93rem;
}

/* Doctor table */
.doctor-table-wrap {
  overflow-x: auto;
}

.doctor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.doctor-table th {
  text-align: left;
  padding: 8px 10px;
  background: rgba(20, 71, 64, 0.07);
  color: #144740;
  font-family: "Archivo", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  border-bottom: 2px solid rgba(21, 53, 48, 0.12);
  white-space: nowrap;
}

.doctor-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.08);
  vertical-align: middle;
}

.doctor-table tr:last-child td {
  border-bottom: none;
}

.doctor-table tr:hover td {
  background: rgba(20, 71, 64, 0.03);
}

.doctor-table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.doctor-cat-header td {
  background: rgba(19, 113, 101, 0.12);
  font-family: "Archivo", sans-serif;
  font-weight: 700;
  color: var(--teal-900);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
  padding: 8px 10px;
}

.doctor-cat-empty {
  color: var(--muted);
  font-style: italic;
  padding: 6px 10px;
}

.doctor-check-col {
  width: 36px;
  text-align: center;
}

.doctor-select,
.staff-select {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--teal-500);
}

.merge-source-list {
  font-weight: 700;
  color: var(--teal-900);
  background: rgba(19, 113, 101, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0 10px;
  font-size: 0.9rem;
}

body.dark-mode .merge-source-list {
  color: #dff8f2;
  background: rgba(43, 191, 163, 0.18);
}

body.dark-mode .doctor-cat-header td {
  background: rgba(43, 191, 163, 0.18);
  color: #dff8f2;
}

.dt-btn {
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  font-family: "Manrope", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.row-inactive { opacity: 0.55; }
.row-inactive td { font-style: italic; }

/* Yes/No toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 66px;
  height: 30px;
  border-radius: 999px;
  background: #c2c6d2;
  cursor: pointer;
  transition: background 0.2s ease;
  vertical-align: middle;
  user-select: none;
}
.toggle-switch.on { background: #4f2bd6; }
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: left 0.2s ease;
}
.toggle-switch.on .toggle-knob { left: 39px; }
.toggle-text {
  position: absolute;
  font-size: 0.74rem;
  font-weight: 800;
  pointer-events: none;
}
.toggle-switch.on .toggle-text { left: 11px; color: #fff; }
.toggle-switch:not(.on) .toggle-text { right: 11px; color: #5a5f6e; }
.dt-btn-edit  { background: #e8f4f2; color: #144740; }
.dt-btn-merge { background: #e8eef8; color: #1a3a6b; }
.dt-btn-del   { background: #ffeceb; color: #8d1f18; }

/* Locked / disabled state for protected doctors (non-admin view) */
.dt-btn-locked,
.dt-btn-locked:hover {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.row-protected { background: #fafdf9; }

.doctor-lock-badge {
  font-size: 0.72rem;
  opacity: 0.7;
  margin-left: 3px;
  cursor: help;
}

/* Read-only active indicator when toggle is disabled for non-admin */
.doctor-toggle-readonly {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 3px 9px;
  cursor: help;
}
.tog-readonly-on  { background: #d1fae5; color: #065f46; }
.tog-readonly-off { background: #f1f5f9; color: #64748b; }

/* Feature access control toggles */
.access-table td { vertical-align: middle; }
.access-table th:not(:first-child),
.access-cell { text-align: center; width: 110px; }
.access-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}
.access-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.access-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c2c6d2;
  transition: background 0.2s ease;
}
.access-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: left 0.2s ease;
}
.access-toggle input:checked + .access-slider { background: #4f2bd6; }
.access-toggle input:checked + .access-slider::before { left: 25px; }
.access-toggle input:focus-visible + .access-slider {
  outline: 2px solid #4f2bd6;
  outline-offset: 2px;
}
body.dark-mode .access-slider { background: #4b5563; }
body.dark-mode .access-toggle input:checked + .access-slider { background: #7c5cff; }

/* List Entry sub-actions (Edit / WhatsApp / Delete) nested under "List Entry" */
.access-table tr.access-subrow { background: rgba(79, 43, 214, 0.03); }
.access-table td.access-subfeature {
  padding-left: 2.25rem;
  position: relative;
  color: #475569;
  font-size: 0.92em;
}
.access-table td.access-subfeature::before {
  content: "\21B3"; /* ↳ */
  position: absolute;
  left: 1.1rem;
  color: #94a3b8;
}
body.dark-mode .access-table tr.access-subrow { background: rgba(124, 92, 255, 0.07); }
body.dark-mode .access-table td.access-subfeature { color: #cbd5e1; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(21, 53, 48, 0.1);
}

.modal-head h3 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  font-size: 1rem;
  color: #144740;
}

.modal-close-btn {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-body {
  padding: 18px 20px;
  display: grid;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(21, 53, 48, 0.1);
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w, 200px) 1fr;
    width: 100%;
    padding: 10px;
    gap: 10px;
  }

  .sidebar {
    padding-bottom: 14px;
    width: var(--sidebar-w, 200px);
  }

  .menu-block {
    display: grid;
    gap: 8px;
  }

  .menu-item {
    margin: 0;
  }

  .menu-item:hover {
    transform: none;
  }
}

@media (max-width: 660px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w, 56px) 1fr;
    width: 100%;
    padding: 8px;
    --sidebar-w: 56px;
  }

  .app-shell .sidebar-expanded-only {
    display: none;
  }

  .app-shell .menu-item {
    padding: 10px;
    text-align: center;
    font-size: 0;
  }

  .app-shell .menu-item::before {
    font-size: 1.1rem;
    content: attr(data-icon);
  }

  .sidebar {
    border-radius: 16px;
    width: 56px;
    padding: 14px 8px;
    top: 8px;
    max-height: calc(100vh - 16px);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-head {
    flex-direction: column;
  }

  .period-tabs {
    width: 100%;
  }

  .period-btn {
    flex: 1;
  }

  .dashboard-summary-grid,
  .dashboard-duty-grid,
  .sales-chart-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-branch-filter {
    width: 100%;
  }

  .dashboard-chart-grid {
    grid-template-columns: 1fr;
  }

  .sales-chart-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .sales-chart-row strong {
    text-align: left;
  }

  .form-grid.two-col,
  .form-grid.three-col,
  .form-grid.four-col {
    grid-template-columns: 1fr;
  }

  .staff-shift-grid {
    grid-template-columns: 1fr;
  }

  .doctor-row-grid {
    grid-template-columns: 1fr;
  }

  .expense-row-grid {
    grid-template-columns: 1fr;
  }

  .clear-doctor-btn,
  .clear-staff-btn,
  .clear-expense-btn {
    justify-self: end;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-btn {
    flex: 1;
  }

  .settings-form-row {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   PATIENT CENSUS REPORT
   ══════════════════════════════════════════════════════════════════════════ */

/* KPI grid: 8 cards — 4 per row on desktop, 2 on mobile */
.patient-kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .patient-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* KPI accent colours for patient cards */
.kpi-accent-morning::before  { background: linear-gradient(90deg, #137165, #34d399); }
.kpi-accent-evening::before  { background: linear-gradient(90deg, #d89a2b, #fbbf24); }
.kpi-accent-night::before    { background: linear-gradient(90deg, #3d7bd9, #818cf8); }

/* ── Charts row (Trend + Branch side by side) ─────────────────────────────── */
.patient-charts-row {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
@media (max-width: 860px) {
  .patient-charts-row {
    grid-template-columns: 1fr;
  }
}
.patient-chart-section {
  margin-top: 0 !important;
}

/* ── Insights strip ───────────────────────────────────────────────────────── */
.patient-insights-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.pi-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(19, 113, 101, 0.08);
  border: 1px solid rgba(19, 113, 101, 0.15);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--teal-900);
}
.pi-chip b { font-weight: 900; }

/* ── Trend bar chart ──────────────────────────────────────────────────────── */
/* ── Patient Trend Chart (SVG-based) ─────────────────────────────────────── */
.patient-trend-chart {
  height: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.patient-trend-chart svg {
  flex: 1;
  min-height: 0;
}

/* Empty state */
.pt-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

/* Month badge row + badge */
.trend-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
}
.trend-title-row h4 { margin: 0; }
.trend-month-badge {
  font-size: 0.88em;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

/* Legend strip above chart */
.pt-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--teal-900);
  margin-bottom: 4px;
}
.pt-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.pt-legend-item i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Floating tooltip */
.pt-tooltip {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid rgba(21, 53, 48, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.7;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  min-width: 148px;
}
.pt-tooltip strong { display: block; margin-bottom: 2px; font-size: 0.84rem; }
.pt-tt-total { border-top: 1px solid rgba(21,53,48,0.1); margin-top: 4px; padding-top: 4px; font-weight: 800; }
body.dark-mode .pt-tooltip { background: #1a2e2b; border-color: rgba(255,255,255,0.15); color: #e2f8f4; }
body.dark-mode .pt-tt-total { border-top-color: rgba(255,255,255,0.12); }

/* SVG bar hover */
.pt-svg-bar-g { cursor: default; }
.pt-svg-bar { transition: opacity 0.15s, filter 0.15s; }
.pt-svg-bar-g:hover .pt-svg-bar { opacity: 0.8; filter: brightness(1.12); }

/* Dark mode: lighten each shift colour */
body.dark-mode .pt-bar-morning { fill: #2bbfa3 !important; }
body.dark-mode .pt-bar-evening { fill: #f59e0b !important; }
body.dark-mode .pt-bar-night   { fill: #818cf8 !important; }

/* ── Branch comparison bars ───────────────────────────────────────────────── */
.patient-branch-bars { display: grid; gap: 10px; }

/* ── Branch patient volume line chart ─────────────────────────────────────── */
.pt-branch-line-chart {
  height: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.pt-branch-line-chart svg {
  flex: 1;
  min-height: 0;
}
.pt-branch-line-chart .pt-legend {
  margin-bottom: 6px;
}

.sales-branch-line-chart {
  height: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}
.sales-branch-line-chart svg {
  flex: 1;
  min-height: 0;
}
.sales-branch-line-chart .pt-legend {
  margin-bottom: 6px;
}
.branch-sales-line-panel {
  margin-top: 20px;
}
.pb-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.pb-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--teal-900);
}
.pb-track {
  background: rgba(21, 53, 48, 0.1);
  border-radius: 6px;
  height: 28px;
  overflow: hidden;
}
.pb-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-700), var(--teal-500));
  border-radius: 6px;
  display: flex;
  align-items: center;
  min-width: 4%;
  transition: width 0.3s ease;
}
.pb-bar-value {
  padding-left: 8px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}
.pb-meta {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 700;
}

/* ── Patient Mix shift colours ───────────────────────────────────────────── */
.pm-legend-morning,
.pm-seg-morning { background: #137165; }

.pm-legend-evening,
.pm-seg-evening { background: #d89a2b; }

.pm-legend-night,
.pm-seg-night   { background: #3d7bd9; }

.pm-morning-text { color: #0e5d54; }
.pm-evening-text { color: #92580a; }
.pm-night-text   { color: #1d4ed8; }

/* The labels row needs to show 3 items */
.pm-labels,
.pm-values {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 900;
}
.pm-labels { margin-bottom: 5px; }
.pm-values { margin-top: 5px; }

/* ── Patient report table ─────────────────────────────────────────────────── */
.patient-report-table {
  min-width: 700px;
  table-layout: auto;
}
.patient-report-table th {
  text-align: center;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  vertical-align: bottom;
}
.patient-report-table td:nth-child(1),
.patient-report-table th:nth-child(1) { min-width: 100px; }
.patient-report-table td:nth-child(2),
.patient-report-table th:nth-child(2) { min-width: 130px; }

/* dark mode adjustments */
body.dark-mode .pb-track   { background: rgba(255,255,255,0.1); }
body.dark-mode .pb-label   { color: #e2f8f4; }
body.dark-mode .pm-morning-text { color: #34d399; }
body.dark-mode .pm-evening-text { color: #fbbf24; }
body.dark-mode .pm-night-text   { color: #818cf8; }

/* ══════════════════════════════════════════════════════════════════════════
   DOCTOR ON DUTY REPORT
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.doctor-report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 0;
  padding-bottom: 2px;
  border-bottom: 1px solid #dbe5e2;
}

.doctor-report-tab-button {
  border: 1px solid rgba(21,53,48,0.12);
  background: #f4f9f8;
  color: #426b64;
  border-radius: 6px 6px 0 0;
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.doctor-report-tab-button.active {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}

.doctor-report-tab-panel { display: none; }
.doctor-report-tab-panel.active { display: block; }

/* ── KPI section ─────────────────────────────────────────────────────── */
.doctor-kpi-section { margin-top: 18px; }

/* ── Overview branch summary ─────────────────────────────────────────── */
.doctor-branch-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.doctor-branch-summary-card {
  flex: 1 1 220px;
  background: #f4f9f8;
  border: 1px solid #dbe5e2;
  border-radius: 10px;
  padding: 14px 16px;
}

.doctor-branch-summary-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #143d38;
  margin-bottom: 8px;
}

.doctor-branch-summary-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.doctor-branch-summary-stats span { font-size: 0.75rem; color: #52706b; }
.doctor-branch-summary-stats strong { color: #0f766e; font-weight: 800; }

/* ── Top workload list ────────────────────────────────────────────────── */
.doctor-top-workload-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

.doctor-top-workload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doctor-rank { font-size: 0.72rem; font-weight: 800; color: #52706b; min-width: 22px; }

.doctor-name-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #143d38;
  min-width: 150px;
}

.doctor-mini-bar-track {
  flex: 1;
  height: 10px;
  background: #e5eeeb;
  border-radius: 5px;
  overflow: hidden;
}

.doctor-mini-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
  border-radius: 5px;
}

.doctor-hours-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f766e;
  min-width: 60px;
  text-align: right;
}

/* ── Monthly Calendar ─────────────────────────────────────────────────── */
.doctor-monthly-calendar-wrap { padding-top: 6px; }

.doctor-cal-month-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: #143d38;
  margin-bottom: 10px;
}

.doctor-cal-scroll-wrap { overflow-x: auto; }

.doctor-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 4px;
  min-width: 910px;
}

.doctor-cal-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #52706b;
  padding: 6px 0;
  background: #f4f9f8;
  border-radius: 4px;
}

.doctor-cal-cell {
  background: #fff;
  border: 1px solid #dbe5e2;
  border-radius: 7px;
  padding: 6px 7px 7px;
  min-height: 90px;
  vertical-align: top;
}

.doctor-cal-empty { background: #f8fbfa; border-color: #f0f4f3; }
.doctor-cal-weekend { background: #f7faf9; }

.doctor-cal-day-num {
  font-size: 0.8rem;
  font-weight: 800;
  color: #143d38;
  margin-bottom: 4px;
}

.doctor-cal-branch-group { margin-top: 4px; }

.doctor-cal-branch-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: #52706b;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}

.doctor-cal-shift {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.doctor-cal-shift-badge {
  font-size: 0.58rem;
  font-weight: 800;
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  margin-top: 1px;
}

.doctor-cal-shift-morning .doctor-cal-shift-badge { background: #0f766e; color: #fff; }
.doctor-cal-shift-evening .doctor-cal-shift-badge { background: #d97706; color: #fff; }
.doctor-cal-shift-night   .doctor-cal-shift-badge { background: #2563eb; color: #fff; }

.doctor-cal-doctor-names { font-size: 0.65rem; color: #143d38; line-height: 1.35; }
.doctor-cal-no-data { font-size: 0.64rem; color: #aaa; font-style: italic; margin-top: 4px; }

/* ── Doctor Hours Chart ───────────────────────────────────────────────── */
.doctor-hours-chart { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.doctor-hours-row { display: flex; align-items: center; gap: 10px; }

.doctor-hours-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #143d38;
  min-width: 160px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doctor-hours-bar-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; }

.doctor-hours-bar-track {
  display: flex;
  height: 14px;
  background: #e5eeeb;
  border-radius: 7px;
  overflow: hidden;
}

.doctor-hours-bar-seg { height: 100%; min-width: 0; }
.seg-morning { background: #0f766e; }
.seg-evening { background: #d97706; }
.seg-night   { background: #2563eb; }

.doctor-hours-bar-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.dh-total { font-size: 0.78rem; font-weight: 800; color: #0f766e; }

.dh-detail {
  display: flex;
  gap: 8px;
  font-size: 0.69rem;
  color: #52706b;
  flex-wrap: wrap;
}

.dh-m { color: #0f766e; font-weight: 700; }
.dh-e { color: #d97706; font-weight: 700; }
.dh-n { color: #2563eb; font-weight: 700; }

.doctor-hours-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 0.72rem; font-weight: 700; }
.dhl-m { color: #0f766e; }
.dhl-e { color: #d97706; }
.dhl-n { color: #2563eb; }
.dhl-m::before, .dhl-e::before, .dhl-n::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.dhl-m::before { background: #0f766e; }
.dhl-e::before { background: #d97706; }
.dhl-n::before { background: #2563eb; }

/* ── Workload Fairness ────────────────────────────────────────────────── */
.doctor-fairness-wrap { margin-top: 10px; }

.doctor-fairness-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.doctor-fairness-badge {
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 20px;
  padding: 5px 14px;
}

.fair-balanced { background: #dcfce7; color: #166534; }
.fair-slight   { background: #fef9c3; color: #854d0e; }
.fair-high     { background: #fee2e2; color: #991b1b; }

.doctor-fairness-metrics { display: flex; gap: 20px; flex-wrap: wrap; }

.doctor-fairness-metrics > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.doctor-fairness-metrics span { font-size: 0.68rem; font-weight: 700; color: #52706b; text-transform: uppercase; }
.doctor-fairness-metrics strong { font-size: 0.88rem; font-weight: 800; color: #143d38; }

.doctor-fairness-lists { display: flex; gap: 20px; flex-wrap: wrap; }
.doctor-fairness-group { flex: 1 1 200px; }

.dfl-title { font-size: 0.72rem; font-weight: 800; color: #52706b; margin-bottom: 6px; text-transform: uppercase; }

.dfl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  margin-bottom: 3px;
  font-size: 0.76rem;
}

.dfl-above { background: #f0fdf4; }
.dfl-above strong { color: #16a34a; font-weight: 800; }
.dfl-below { background: #fef9c3; }
.dfl-below strong { color: #a16207; font-weight: 800; }
.dfl-row span { color: #143d38; }

/* ── Branch Coverage Cards ────────────────────────────────────────────── */
.doctor-branch-coverage-list { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.doctor-branch-cov-card {
  background: #fff;
  border: 1px solid #dbe5e2;
  border-radius: 10px;
  padding: 16px 18px;
}

.doctor-branch-cov-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.doctor-branch-cov-name { font-size: 0.85rem; font-weight: 800; color: #143d38; }

.doctor-badge { font-size: 0.66rem; font-weight: 800; border-radius: 10px; padding: 2px 9px; }
.badge-top  { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fee2e2; color: #991b1b; }

.doctor-branch-cov-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.doctor-branch-cov-bar-track {
  flex: 1;
  height: 10px;
  background: #e5eeeb;
  border-radius: 5px;
  overflow: hidden;
}

.doctor-branch-cov-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
  border-radius: 5px;
}

.doctor-branch-cov-bar-label { font-size: 0.76rem; font-weight: 800; color: #0f766e; min-width: 60px; text-align: right; }

.doctor-branch-cov-stats { display: flex; flex-wrap: wrap; gap: 14px; }
.doctor-branch-cov-stats > div { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.doctor-branch-cov-stats span { font-size: 0.67rem; font-weight: 700; color: #52706b; text-transform: uppercase; }
.doctor-branch-cov-stats strong { font-size: 0.82rem; font-weight: 800; color: #143d38; }

/* ── Shift Coverage Alerts ────────────────────────────────────────────── */
.doctor-cov-filter-row { display: flex; gap: 6px; flex-wrap: wrap; }

.doctor-cov-filter-btn {
  border: 1px solid rgba(21,53,48,0.15);
  background: #f4f9f8;
  color: #426b64;
  border-radius: 5px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.doctor-cov-filter-btn.active { background: #0f766e; color: #fff; border-color: #0f766e; }

.doctor-shift-alerts-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.doctor-alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
}

.doctor-alert-uncovered { background: #fef2f2; border: 1px solid rgba(220,38,38,0.2); }
.doctor-alert-overlap   { background: #fffbeb; border: 1px solid rgba(217,119,6,0.2); }
.doctor-alert-understaffed { background: #fff7ed; border: 1px solid rgba(234,88,12,0.2); }
.doctor-alert-icon { font-size: 0.9rem; flex-shrink: 0; }
.doctor-alert-uncovered .doctor-alert-icon { color: #dc2626; }
.doctor-alert-overlap   .doctor-alert-icon { color: #d97706; }
.doctor-alert-understaffed .doctor-alert-icon { color: #ea580c; }
.doctor-alert-msg { flex: 1; color: #143d38; }

.doctor-alert-badge { font-size: 0.65rem; font-weight: 800; border-radius: 8px; padding: 2px 8px; flex-shrink: 0; }
.doctor-alert-uncovered .doctor-alert-badge { background: #fee2e2; color: #991b1b; }
.doctor-alert-overlap   .doctor-alert-badge { background: #fef9c3; color: #854d0e; }
.doctor-alert-understaffed .doctor-alert-badge { background: #ffedd5; color: #9a3412; }

/* ── Detailed Table ────────────────────────────────────────────────────── */
/* Staff on duty report */
.staff-report-filters { align-items: end; }

.staff-overview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.staff-cal-grid { min-width: 980px; }
.staff-cal-cell { min-height: 112px; }

.staff-cal-status-understaffed,
.staff-cal-status-uncovered,
.staff-cal-status-overlap {
  padding-left: 4px;
}

.staff-cal-status-understaffed { border-left: 3px solid #ea580c; }
.staff-cal-status-uncovered { border-left: 3px solid #dc2626; }
.staff-cal-status-overlap { border-left: 3px solid #d97706; }

.staff-coverage-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.staff-status-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.staff-status-covered { background: #d1fae5; color: #065f46; }
.staff-status-understaffed { background: #ffedd5; color: #9a3412; }
.staff-status-uncovered { background: #fee2e2; color: #991b1b; }
.staff-status-overlap { background: #fef9c3; color: #854d0e; }

.doctor-report-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 0.78rem; }

.doctor-report-table th {
  background: #f4f9f8;
  color: #52706b;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 2px solid #dbe5e2;
  text-align: left;
  white-space: nowrap;
}

.doctor-report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf1f0;
  color: #143d38;
  vertical-align: middle;
}

.doctor-report-table tbody tr:hover { background: #f8fbfa; }

.doctor-shift-tag { font-size: 0.68rem; font-weight: 800; border-radius: 4px; padding: 2px 7px; }
.shift-morning { background: #d1fae5; color: #065f46; }
.shift-evening { background: #fef9c3; color: #854d0e; }
.shift-night   { background: #dbeafe; color: #1e40af; }

.doctor-status-tag { font-size: 0.68rem; font-weight: 800; border-radius: 4px; padding: 2px 7px; }
.status-scheduled { background: #e0f2fe; color: #0369a1; }

/* ── Dark mode adjustments ───────────────────────────────────────────── */
body.dark-mode .doctor-report-tab-button { background: rgba(255,255,255,0.05); color: #9fc8bf; border-color: rgba(255,255,255,0.1); }
body.dark-mode .doctor-report-tab-button.active { background: #0f766e; color: #fff; }
body.dark-mode .doctor-cal-cell { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.08); }
body.dark-mode .doctor-cal-empty { background: rgba(255,255,255,0.01); }
body.dark-mode .doctor-cal-day-num { color: #e2f8f4; }
body.dark-mode .doctor-cal-doctor-names { color: #c8e6e0; }
body.dark-mode .doctor-branch-summary-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); }
body.dark-mode .doctor-branch-summary-name { color: #e2f8f4; }
body.dark-mode .doctor-hours-bar-track { background: rgba(255,255,255,0.08); }
body.dark-mode .doctor-mini-bar-track { background: rgba(255,255,255,0.08); }
body.dark-mode .doctor-name-label { color: #e2f8f4; }
body.dark-mode .doctor-hours-name { color: #e2f8f4; }
body.dark-mode .doctor-branch-cov-card { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.08); }
body.dark-mode .doctor-branch-cov-name { color: #e2f8f4; }
body.dark-mode .doctor-branch-cov-stats strong { color: #e2f8f4; }
body.dark-mode .doctor-alert-uncovered { background: rgba(220,38,38,0.1); border-color: rgba(220,38,38,0.2); }
body.dark-mode .doctor-alert-overlap   { background: rgba(217,119,6,0.1); border-color: rgba(217,119,6,0.2); }
body.dark-mode .doctor-alert-msg { color: #e2f8f4; }
body.dark-mode .doctor-report-table th { background: rgba(255,255,255,0.04); color: #9fc8bf; }
body.dark-mode .doctor-report-table td { color: #c8e6e0; border-bottom-color: rgba(255,255,255,0.06); }
body.dark-mode .doctor-report-table tbody tr:hover { background: rgba(255,255,255,0.04); }
body.dark-mode .dfl-above { background: rgba(22,163,74,0.12); }
body.dark-mode .dfl-below { background: rgba(161,98,7,0.12); }
body.dark-mode .dfl-row span { color: #c8e6e0; }
body.dark-mode .doctor-fairness-metrics strong { color: #e2f8f4; }

/* ── Duty group badges ────────────────────────────────────────────────── */
.duty-group-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.dg-resident-normal { background: #d1fae5; color: #065f46; }
.dg-resident-locum  { background: #fef9c3; color: #854d0e; }
.dg-locum-doctor    { background: #dbeafe; color: #1e40af; }
.dg-company-doctor  { background: #ede9fe; color: #5b21b6; }
.dg-unknown         { background: #f1f5f9; color: #475569; }

/* ── Doctor category badges ──────────────────────────────────────────── */
.dr-category-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.drc-resident { background: #d1fae5; color: #065f46; }
.drc-company  { background: #ede9fe; color: #5b21b6; }
.drc-locum    { background: #dbeafe; color: #1e40af; }
.drc-unknown  { background: #f1f5f9; color: #475569; }

/* ── Overview duty breakdown bars ────────────────────────────────────── */
.dov-breakdown { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.dov-bar-row { display: flex; align-items: center; gap: 10px; }

.dov-bar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 185px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #143d38;
}

.dov-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dov-bar-track {
  flex: 1;
  height: 12px;
  background: #e5eeeb;
  border-radius: 6px;
  overflow: hidden;
}

.dov-bar-fill { height: 100%; border-radius: 6px; }

.dov-bar-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 90px;
}

.dov-bar-stats strong { font-size: 0.78rem; font-weight: 800; color: #143d38; }
.dov-bar-stats small  { font-size: 0.67rem; color: #52706b; }

/* ── Locum compare chart ──────────────────────────────────────────────── */
.locum-compare-wrap { display: flex; flex-direction: column; gap: 10px; }

.locum-compare-row { display: flex; align-items: center; gap: 10px; }

.lcr-label {
  min-width: 140px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #143d38;
}

.lcr-bar-track {
  flex: 1;
  height: 14px;
  background: #e5eeeb;
  border-radius: 7px;
  overflow: hidden;
}

.lcr-bar-fill { height: 100%; border-radius: 7px; }

.lcr-value { font-size: 0.76rem; font-weight: 800; color: #143d38; min-width: 120px; text-align: right; }

/* Dark mode */
body.dark-mode .dov-bar-label { color: #e2f8f4; }
body.dark-mode .dov-bar-stats strong { color: #e2f8f4; }
body.dark-mode .dov-bar-track { background: rgba(255,255,255,0.08); }
body.dark-mode .lcr-label { color: #e2f8f4; }
body.dark-mode .lcr-bar-track { background: rgba(255,255,255,0.08); }
body.dark-mode .lcr-value { color: #e2f8f4; }

/* ── Expense Report ─────────────────────────────────────────────────────── */
.expense-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.expense-bar {
  height: 8px;
  background: var(--teal-500, #37b5a3);
  border-radius: 4px;
  min-width: 2px;
  max-width: 100px;
  transition: width 0.3s ease;
}

.expense-bar-wrap span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal-900, #143d38);
  white-space: nowrap;
}

body.dark-mode .expense-bar-wrap span { color: #e2f8f4; }
body.dark-mode .expense-bar { background: #37b5a3; }

.expense-report-filters { align-items: end; }
.expense-section { margin-top: 18px; }
.expense-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.expense-kpi-card { border-top: 3px solid #c2410c; }

.expense-svg-scroll {
  width: 100%;
  overflow-x: auto;
  padding: 6px 0 2px;
}

.expense-svg-scroll svg {
  width: 100%;
  min-width: 640px;
  height: auto;
  display: block;
}

.expense-vs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.expense-vs-metric {
  background: #f8fbfa;
  border: 1px solid #dbe5e2;
  border-radius: 8px;
  padding: 12px 14px;
}

.expense-vs-metric span {
  display: block;
  color: #52706b;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.expense-vs-metric strong {
  color: #143d38;
  font-size: 1rem;
  font-weight: 900;
}

.expense-comparison-bars,
.expense-analysis-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.expense-analysis-card {
  background: #fff;
  border: 1px solid #dbe5e2;
  border-radius: 8px;
  padding: 13px 15px;
}

.expense-analysis-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.expense-analysis-main h5 {
  margin: 0 0 3px;
  color: #143d38;
  font-size: 0.88rem;
  font-weight: 900;
}

.expense-analysis-main p {
  margin: 0;
  color: #52706b;
  font-size: 0.74rem;
}

.expense-analysis-main strong,
.expense-analysis-value {
  color: #c2410c;
  font-weight: 900;
  white-space: nowrap;
}

.expense-analysis-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.expense-analysis-label {
  color: #143d38;
  font-size: 0.78rem;
  font-weight: 800;
  min-width: 90px;
}

.expense-analysis-bar-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: #e5eeeb;
  overflow: hidden;
}

.expense-analysis-bar {
  height: 100%;
  min-width: 2px;
  border-radius: 5px;
}

.expense-analysis-row span {
  color: #52706b;
  font-size: 0.72rem;
  font-weight: 800;
  min-width: 70px;
  text-align: right;
}

.expense-analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.expense-analysis-meta span {
  background: #f4f9f8;
  border: 1px solid #dbe5e2;
  border-radius: 999px;
  color: #52706b;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
}

.expense-sort-control {
  min-width: 210px;
  margin: 0;
}

.expense-report-table { min-width: 1120px; }

body.dark-mode .expense-vs-metric,
body.dark-mode .expense-analysis-card {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
}

body.dark-mode .expense-vs-metric strong,
body.dark-mode .expense-analysis-main h5,
body.dark-mode .expense-analysis-label { color: #e2f8f4; }

body.dark-mode .expense-analysis-bar-track { background: rgba(255,255,255,0.08); }
body.dark-mode .expense-analysis-meta span {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

/* ── Expense Settings sub-tabs (Categories / Payees / Commission) ─────────── */
.expset-tabs {
  margin-top: 4px;
  margin-bottom: 16px;
}

.expset-tab-button {
  border: 1px solid rgba(21, 53, 48, 0.12);
  border-radius: 8px;
  background: #f7fbfa;
  color: #426b64;
  font-weight: 800;
  padding: 8px 12px;
  cursor: pointer;
}

.expset-tab-button.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

body.dark-mode .expset-tab-button {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #9fc8bf;
}

body.dark-mode .expset-tab-button.active {
  background: #0f766e;
  border-color: #14b8a6;
  color: #fff;
}

.expset-tab-panel {
  display: none;
}

.expset-tab-panel.active {
  display: block;
}

@media (max-width: 640px) {
  .expset-tab-button {
    flex: 1 1 calc(50% - 8px);
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE AUDIT FIXES
   Appended last on purpose: equal-specificity rules below override the
   earlier breakpoints they refine. Layout only — no theme/colour changes.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Overflow safety: the page itself must never scroll sideways.
      `clip` (not `hidden`) so the sticky sidebar keeps working. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* ── Long names / emails / payees wrap instead of pushing layout wider */
tbody td,
.entry-field,
.entry-card-branch,
.duty-person-main strong,
.duty-name-list li,
.duty-name-row,
.name-item span,
.doctor-cal-doctor-names,
.payment-method-name,
.pie-legend-label,
.summary-tile strong,
.kpi-value,
.doctor-alert-msg {
  overflow-wrap: break-word;
}

/* ── Modals always fit the viewport and scroll inside themselves */
.modal-box {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.login-overlay {
  overflow-y: auto;
}

/* ── Wide desktop (≥1760px): cap the shell so cards don't stretch endlessly */
@media (min-width: 1760px) {
  .app-shell {
    max-width: 1720px;
    margin: 0 auto;
  }
}

/* ── New Entry modal uses the full width on tablet/mobile (was 75vw) */
@media (max-width: 1024px) {
  .panel.is-modal {
    padding: 16px 10px;
  }

  .panel.is-modal .form-card {
    width: 100%;
  }
}

/* ── Tablet (≤940px): dashboard chart columns can no longer fit side by side
      next to the sidebar without overflowing — stack them earlier. */
@media (max-width: 940px) {
  .dashboard-chart-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Form rows inside the entry form: 2 columns on tablet, 1 on phones
      (the old rule jumped from 3–4 columns straight to 1 at 660px). */
@media (max-width: 900px) {
  .form-grid.three-col,
  .form-grid.four-col,
  .doctor-row-grid,
  .expense-row-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doctor-row-grid .clear-doctor-btn,
  .expense-row-grid .clear-expense-btn {
    justify-self: end;
  }
}

@media (max-width: 520px) {
  .form-grid.two-col,
  .form-grid.three-col,
  .form-grid.four-col,
  .doctor-row-grid,
  .expense-row-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Branch sales chart rows overflowed between 661–800px:
      the minmax(300px) bar column couldn't shrink. Stack sooner. */
@media (max-width: 800px) {
  .sales-chart-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .sales-chart-row strong {
    text-align: left;
  }
}

/* ── Mobile (≤660px): summary tiles in 2 readable columns instead of one
      very tall single-column stack; sidebar rail stays tap-friendly. */
@media (max-width: 660px) {
  .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .summary-tile {
    min-height: 122px;
    padding: 13px;
  }

  .summary-tile strong {
    font-size: 1.3rem;
  }

  .app-shell .menu-item {
    min-height: 44px;
  }

  .sidebar-toggle {
    min-height: 40px;
  }
}

/* ── Mobile (≤640px): comfortable tap targets (~40–44px) and ≥16px inputs
      so iOS doesn't zoom on focus. Replaces the old "compact buttons" rule. */
@media (max-width: 640px) {
  .entry-action {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 0.8rem;
  }

  .dt-btn {
    min-height: 38px;
    padding: 7px 12px;
  }

  .month-step-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  .page-nav-btn {
    min-width: 44px;
    min-height: 40px;
  }

  .modal-close-btn {
    min-width: 40px;
    min-height: 40px;
  }

  .list-filter-item select,
  .list-filter-item input[type="date"],
  .list-filter-item input[type="month"],
  .list-search-wrap input[type="search"],
  .field input,
  .field select,
  .settings-form-row input,
  .login-card input {
    font-size: 16px;
  }
}

/* ── Horizontal bar charts (doctor hours, workload, locum compare):
      fixed-width labels squeezed the bars to nothing on phones — wrap the
      label onto its own line and let the bar use the full width. */
@media (max-width: 560px) {
  .doctor-hours-row,
  .doctor-top-workload-row,
  .dov-bar-row,
  .locum-compare-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .doctor-hours-name,
  .doctor-name-label,
  .dov-bar-label,
  .lcr-label {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
  }

  .lcr-value,
  .dov-bar-stats {
    min-width: 0;
  }

  .dov-bar-stats {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
}

/* ── Small mobile (≤520px): filters stack vertically, label above control */
@media (max-width: 520px) {
  .list-filter-item,
  .sales-summary-filter {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
  }

  .list-filter-item select,
  .list-filter-item input[type="date"],
  .list-filter-item input[type="month"] {
    width: 100%;
  }

  .month-stepper {
    min-width: 0;
    width: 100%;
  }

  .period-tabs {
    display: flex;
    width: 100%;
  }

  .period-btn {
    flex: 1;
  }

  .list-search-item {
    flex-basis: 100%;
  }

  .list-search-wrap {
    flex-wrap: wrap;
    min-width: 0;
  }

  .list-search-wrap input[type="search"] {
    min-width: 0;
    flex: 1 1 160px;
  }

  .list-search-wrap .form-btn {
    flex: 1 1 auto;
  }

  .expense-sort-control,
  .dashboard-branch-filter {
    min-width: 0;
  }

  .entry-card-head .entry-actions {
    width: 100%;
  }

  .entry-card-head .entry-actions .entry-action {
    flex: 1 1 auto;
  }

  .list-pagination {
    justify-content: center;
  }
}

/* ── Tiny phones (≤400px): trim shell padding so content keeps ~250px,
      and the summary grid drops to a single column. */
@media (max-width: 400px) {
  .app-shell {
    padding: 6px;
    gap: 6px;
  }

  .sidebar {
    top: 6px;
    max-height: calc(100vh - 12px);
  }

  .card {
    padding: 14px;
  }

  .topbar {
    padding: 12px;
  }

  .login-card {
    padding: 24px 18px;
  }

  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }

  #newEntryBtn.form-btn.primary {
    width: 100%;
  }
}
