:root {
  --brand: #0f4c81;
  --accent: #e4a11b;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7a8a;
  --line: #e1e6ec;
  --ok: #1a7f4b;
  --warn: #b7791f;
  --danger: #b42318;
  /* Tableau-10 palette for bars */
  --c0: #4e79a7; --c1: #f28e2b; --c2: #e15759; --c3: #76b7b2; --c4: #59a14f;
  --c5: #edc948; --c6: #b07aa1; --c7: #ff9da7; --c8: #9c755f; --c9: #bab0ac;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code.otp { font-size: 18px; letter-spacing: .08em; background: #fff; padding: 2px 8px; border: 1px dashed var(--warn); border-radius: 4px; }

/* top nav: white so the clinic logo (white background, yellow/red mark) sits naturally; brand blue for state */
.topnav { background: #fff; color: var(--text); border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(15,76,129,.06); border-top: 3px solid var(--brand); }
.topnav-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 64px; }
.nav-brand { display: flex; align-items: center; color: var(--brand); text-decoration: none; font-weight: 600; flex-shrink: 0; }
.nav-logo { height: 44px; width: auto; display: block; }
.nav-logo-text { font-size: 16px; }
.nav-menu { display: flex; gap: 4px; flex: 1; }
.nav-menu a { color: var(--brand); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.nav-menu a:hover { background: #eef3f9; }
.nav-menu a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-user { position: relative; }
.nav-user summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 6px; color: var(--brand); font-weight: 500; }
.nav-user summary::-webkit-details-marker { display: none; }
.nav-user summary:hover, .nav-user[open] summary { background: #eef3f9; }
.nav-user-menu { position: absolute; right: 0; top: 100%; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 8px; min-width: 190px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 20; }
.nav-user-menu a, .nav-user-menu button.linklike { display: block; width: 100%; text-align: left; padding: 8px 10px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; border-radius: 6px; }
.nav-user-menu a:hover, .nav-user-menu button.linklike:hover { background: var(--bg); }

/* layout */
.page { max-width: 1400px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .topnav-inner { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px 16px; } .nav-logo { height: 34px; } .nav-menu { order: 3; flex-basis: 100%; flex-wrap: wrap; } .page-head { flex-direction: column; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.subcards .card { margin-bottom: 0; background: #fafbfc; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* date bar */
.datebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.datebar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.datebar input[type=date] { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.datebar .quick { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.datebar .quick a { padding: 5px 10px; border-radius: 999px; text-decoration: none; color: var(--brand); border: 1px solid transparent; }
.datebar .quick a:hover { border-color: var(--line); }
.datebar .quick a.active { background: var(--brand); color: #fff; }

/* buttons, forms */
.btn { display: inline-block; font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #b9c2cc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: #f1b8b4; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.input-sm { font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; width: 130px; }
.stack label { display: block; margin-bottom: 10px; color: var(--muted); }
.stack input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 0 4px 4px 0; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert-error { background: #fdf2f1; border-color: #f1b8b4; color: var(--danger); }
.alert-ok { background: #eef8f1; border-color: #bfe3cb; color: var(--ok); }
.alert-warn { background: #fff8e8; border-color: #f3dca0; color: #7a5a0e; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #e9eef3; color: var(--muted); }
.tag-ok { background: #e3f3e8; color: var(--ok); }
.tag-off { background: #f1f1f1; color: #777; }
.tag-warn { background: #fff1d6; color: var(--warn); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.total td { font-weight: 700; border-top: 2px solid var(--brand); }
.table tr.muted td { color: var(--muted); }
.table tbody tr:hover td { background: #fafbfd; }
.kpi-table td:first-child { font-weight: 600; }
.kpi-table tr.kpi-net_sales td, .kpi-table tr.kpi-total_collections td { background: #f6f9fc; }
.actions { white-space: nowrap; }

/* bars */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr minmax(70px, auto); align-items: center; gap: 10px; padding: 4px 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f5; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--c0); }
.bar-fill.neg { background: var(--danger) !important; }
.bar-fill.c0 { background: var(--c0); } .bar-fill.c1 { background: var(--c1); } .bar-fill.c2 { background: var(--c2); }
.bar-fill.c3 { background: var(--c3); } .bar-fill.c4 { background: var(--c4); } .bar-fill.c5 { background: var(--c5); }
.bar-fill.c6 { background: var(--c6); } .bar-fill.c7 { background: var(--c7); } .bar-fill.c8 { background: var(--c8); } .bar-fill.c9 { background: var(--c9); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-total { display: flex; justify-content: space-between; font-weight: 700; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.synced { text-align: right; }

/* login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 10px 30px rgba(15,76,129,.08); }
.login-card h1 { font-size: 20px; color: var(--brand); }
.login-logo { text-align: center; margin: -4px 0 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.login-logo-img { max-width: 100%; height: auto; max-height: 82px; }
.login-logo-img-text { font-weight: 600; color: var(--brand); }
.login-card label { display: block; margin: 12px 0; color: var(--muted); }
.login-card input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; }
.login-card .btn { margin-top: 8px; }

/* accounting drill-down groups */
.group-row td { background: #f6f9fc; font-weight: 600; cursor: pointer; }
.group-row .toggle { display: inline-block; width: 18px; color: var(--brand); }
.group-lines { display: none; }
.group-lines.open { display: table-row-group; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin: 10px 0; }
.card h2 a { text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.table a.drill { text-decoration: none; border-bottom: 1px dotted var(--brand); }

/* dropdown under a main menu item: hover or keyboard focus on desktop, inline on phones */
.nav-group { position: relative; }
.nav-group-label { display: inline-flex; align-items: center; gap: 6px; }
.nav-group-label .caret { font-size: 10px; opacity: .8; }
.nav-menu .nav-group-label { color: var(--brand); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.nav-menu .nav-group-label:hover { background: #eef3f9; }
.nav-menu .nav-group-label.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-submenu { display: none; position: absolute; left: 0; top: 100%; padding: 6px; margin-top: 4px; min-width: 240px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(15,76,129,.14); z-index: 30; }
.nav-submenu::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.nav-group:hover .nav-submenu, .nav-group:focus-within .nav-submenu { display: block; }
.nav-menu .nav-submenu a { display: block; color: var(--text); font-weight: 500; padding: 9px 12px; border-radius: 6px; border-left: 3px solid transparent; }
.nav-menu .nav-submenu a:hover { background: #eef3f9; color: var(--brand); }
.nav-menu .nav-submenu a.active { background: #eef3f9; color: var(--brand); border-left-color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  .nav-group { width: 100%; }
  .nav-submenu { display: block; position: static; box-shadow: none; border: 0; padding: 2px 0 4px 12px; margin: 0; min-width: 0; }
  .nav-submenu::before { display: none; }
  .nav-group-label .caret { display: none; }
}

/* campaign page */
.crumb { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.crumb a { color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr; } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; border-top: 3px solid var(--line); }
.tile-brand { border-top-color: var(--brand); }
.tile-accent { border-top-color: var(--accent); }
.tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 26px; font-weight: 700; color: var(--text); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-sub { font-size: 12px; color: var(--muted); }
.table.daily .bar-cell { width: 40%; }
.table.daily .bar-track { display: block; }
/* main menu item that only opens its submenu (a button, not a link) */
button.nav-group-label { background: none; border: 0; font: inherit; cursor: pointer; }
button.nav-group-label:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* revenue grouped by package */
.pkg-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 6px; margin-bottom: 12px; background: #fafbfc; }
.pkg-group-extra { background: #fff; border-style: dashed; }
.pkg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.pkg-name { font-weight: 700; color: var(--brand); }
.pkg-meta { display: flex; align-items: center; gap: 10px; flex: 1; }
.pkg-total { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.pkg-total .unit { font-size: 11px; color: var(--muted); font-weight: 600; }
.pkg-sub { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 2px; padding: 4px 8px; background: #eef3f9; border-radius: 6px; }
.pkg-sub-name { font-weight: 600; color: var(--brand); font-size: 13px; }
.pkg-sub-total { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
/* Two cards stacked in one grid cell; the last one stretches so the column bottom lines up with its neighbour. */
.card-stack { display: flex; flex-direction: column; }
.card-stack > .card:last-child { flex: 1 1 auto; }
