/* Doctor admin: one look for every page. Light and dark themes follow the system setting. */
:root { --bg: #f4f6fa; --card: #ffffff; --ink: #1b2233; --muted: #667086; --line: #e0e5ee; --soft: #eef2f8; --brand: #1f6feb; --brand-ink: #ffffff; --danger: #c62828; --ok: #1b7f3b; --warn: #b26a00; --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 60, .06); }
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151c; --card: #1b202b; --ink: #e8ebf2; --muted: #98a1b4; --line: #2d3443; --soft: #232a38; --brand: #5b9bff; --brand-ink: #0c1220; --danger: #ef6b6b; --ok: #4cc27a; --warn: #e0a23b; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .3rem; line-height: 1.25; } h2 { font-size: 1.15rem; margin: 0; } h3 { font-size: 1rem; margin: 0 0 .3rem; } h4 { margin: 1rem 0 .3rem; font-size: .9rem; }
small, .muted { color: var(--muted); font-weight: 400; } .small { font-size: .82rem; }
code { font-size: .78em; word-break: break-all; }
p { margin: .25rem 0; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 8px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; color: var(--ink); letter-spacing: .2px; } .brand:hover { text-decoration: none; }
.menu { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.menu > a, .more > summary { color: var(--ink); padding: 6px 11px; border-radius: 8px; cursor: pointer; list-style: none; }
.menu > a:hover, .more > summary:hover { background: var(--soft); text-decoration: none; }
.menu a.current, .more > summary.current { background: var(--soft); color: var(--brand); font-weight: 600; }
.more { position: relative; } .more > summary::-webkit-details-marker { display: none; }
.more-list { position: absolute; top: 110%; left: 0; min-width: 160px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); display: flex; flex-direction: column; z-index: 30; }
.more-list a { color: var(--ink); padding: 7px 10px; border-radius: 6px; } .more-list a:hover { background: var(--soft); text-decoration: none; } .more-list a.current { color: var(--brand); font-weight: 600; }
.search { display: flex; gap: 6px; flex: 1 1 240px; max-width: 460px; margin-left: auto; } .search input { flex: 1; }
.page { max-width: 1240px; margin: 0 auto; padding: 20px; }

/* controls */
input, select, button, textarea { font: inherit; color: var(--ink); }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.btn { display: inline-block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 13px; cursor: pointer; color: var(--ink); text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--brand); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

/* cards, banners, headings */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.banner { padding: 9px 14px; border-radius: 10px; margin: 10px 0; }
.banner.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.banner.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.head-row, .section-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 6px 0 12px; }
.section-head { margin-top: 24px; }
.pill { font-size: .72rem; padding: 1px 9px; border-radius: 99px; border: 1px solid var(--line); margin-left: 4px; white-space: nowrap; }
.pill.done, .pill.create, .pill.parsed { color: var(--ok); } .pill.failed, .pill.delete { color: var(--danger); } .pill.manual, .pill.update { color: var(--brand); }
.badge { display: inline-block; vertical-align: middle; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.missing { color: var(--danger); font-weight: 600; }

/* tables: dense with a hover row */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .93rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--soft); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; } .table tbody tr:hover { background: var(--soft); }
.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; display: inline-block; vertical-align: middle; background: var(--soft); }
.thumb.big { width: 76px; height: 76px; border-radius: 10px; } .thumb.empty { background: var(--soft); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 8px 0 14px; }
.filters label { display: flex; flex-direction: column; font-size: .76rem; color: var(--muted); gap: 2px; }
.chip { align-self: flex-end; padding: 4px 11px; background: var(--card); } .chip a { margin-left: 4px; }

/* doctor page: hero card + chamber cards */
.hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.portrait { width: 112px; height: 112px; object-fit: cover; border-radius: 14px; background: var(--soft); flex: none; }
.hero-main { flex: 1 1 320px; min-width: 0; } .lead { font-size: 1.05rem; font-weight: 600; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 140px; text-align: center; }
.chamber-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.chamber-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.chamber-card.wide { grid-column: 1 / -1; }
.days { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.day { font-size: .72rem; padding: 2px 8px; border-radius: 6px; border: 1px dashed var(--line); color: var(--muted); }
.day.open { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); font-weight: 600; }
.day.closed { text-decoration: line-through; border-style: solid; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.edit-area { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--line); }
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; padding: 0 16px; }
.section > summary { cursor: pointer; padding: 12px 0; font-weight: 600; } .section[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.section .card { box-shadow: none; }

/* forms inside the pages */
.row-editor { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.row-editor label { display: flex; flex-direction: column; font-size: .76rem; color: var(--muted); gap: 2px; }
.row-editor label input { min-width: 130px; } .row-editor .f-tri select { min-width: 72px; } .row-editor .f-tri span { text-transform: capitalize; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; } .upload input { font-size: .8rem; }
.hits { list-style: none; padding: 0; margin: 6px 0; } .hits li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hits li a { color: var(--ink); } .hits li a:hover { color: var(--brand); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .diff pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--bg); padding: 8px; border-radius: 8px; max-height: 280px; overflow: auto; }
.pickers { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; } .picker { display: flex; flex-direction: column; gap: 4px; position: relative; max-width: 320px; }
.options { list-style: none; margin: 0; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow: auto; }
.options button { width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; cursor: pointer; border-radius: 6px; } .options button:hover { background: var(--soft); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; } .inline { display: flex; gap: 6px; margin: 8px 0; }
.login-box { max-width: 350px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); }
.login-box label, .narrow label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; } .login-box .btn { width: 100%; } .narrow { max-width: 440px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; margin: 10px 0 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; display: flex; flex-direction: column; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand); text-decoration: none; } .stat b { font-size: 1.65rem; line-height: 1.2; } .stat span { color: var(--muted); font-size: .85rem; }
.stat.issue b { color: var(--danger); } .stat.issue.zero b { color: var(--ok); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr auto; gap: 10px; align-items: center; margin: 4px -6px; padding: 3px 6px; font-size: .9rem; border-radius: 8px; }
a.bar-row { color: var(--ink); text-decoration: none; } a.bar-row:hover { background: var(--soft); }
.bar { background: var(--soft); border-radius: 99px; height: 10px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

.nav-toggle { display: none; }
img { max-width: 100%; }

/* ---- phone and small tablet (up to 720px) ---- */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  body { font-size: 16px; }
  .page { padding: 12px; min-width: 0; }
  h1 { font-size: 1.35rem; }

  /* top bar: brand + Menu button, search always visible, the rest folds away */
  .topbar { padding: 8px 12px; gap: 8px 10px; }
  .brand { order: 1; flex: 1; }
  .nav-toggle { display: inline-block; order: 2; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
  .search { order: 3; max-width: none; flex: 1 1 100%; margin-left: 0; }
  .search input { min-height: 40px; }
  .menu, .account, #logout { display: none; }
  .topbar.nav-open .menu { order: 4; display: flex; flex-direction: column; align-items: stretch; flex: 1 1 100%; gap: 0; }
  .topbar.nav-open .account, .topbar.nav-open #logout { display: block; order: 5; padding: 8px 4px; }
  .menu > a, .more > summary { padding: 11px 10px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .more-list { position: static; box-shadow: none; border: 0; padding: 0 0 0 14px; }
  .more-list a { padding: 11px 10px; }

  /* easy to hit with a finger */
  .btn, input, select, button { min-height: 40px; }
  input, select, textarea { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; }
  .filters label, .row-editor label { flex: 1 1 140px; } .filters input, .filters select, .row-editor input, .row-editor select { width: 100%; }
  .row-editor label input { min-width: 0; }
  .head-row .btn, .section-head .btn { flex: none; }
  .pager { gap: 8px; } .pager .btn { flex: 1; }
  .actions-bar .actions { display: flex; flex-direction: column; gap: 8px; } .actions-bar .actions .btn { width: 100%; }
  .actions-bar .note-field { max-width: none; }
  .hero { padding: 14px; gap: 12px; } .portrait { width: 84px; height: 84px; }
  .hero-actions { flex-direction: row; flex-wrap: wrap; width: 100%; } .hero-actions .btn { flex: 1; }
  .chamber-grid { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; } .stat b { font-size: 1.35rem; }
  .bar-row { grid-template-columns: minmax(70px, 40%) 1fr auto; }
  .section { padding: 0 12px; } .card { padding: 12px; }
  .login-box { margin: 6vh 12px; }
  .pickers { gap: 12px; } .picker { max-width: none; width: 100%; }

  /* plain tables become a list of cards: each cell shows its column name (labels come from mobile.js) */
  .table:not(.cmp), .table:not(.cmp) tbody, .table:not(.cmp) tr, .table:not(.cmp) td { display: block; }
  .table:not(.cmp) { border: 0; background: transparent; overflow: visible; }
  .table:not(.cmp) thead { display: none; }
  .table:not(.cmp) tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; margin: 0 0 10px; box-shadow: var(--shadow); }
  .table:not(.cmp) td { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; padding: 6px 0; border: 0; border-bottom: 1px dashed var(--line); min-width: 0; overflow-wrap: anywhere; }
  .table:not(.cmp) td:last-child { border-bottom: 0; }
  .table:not(.cmp) td::before { content: attr(data-label); flex: none; max-width: 42%; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
  .table:not(.cmp) td[data-label=""] { display: inline-flex; justify-content: flex-start; margin-right: 14px; border-bottom: 0; }
  .table:not(.cmp) td[data-label=""]:last-child { display: flex; margin-right: 0; padding-top: 8px; } .table:not(.cmp) td[data-label=""]::before { display: none; }
  .table:not(.cmp) td:empty { display: none; }
  .table:not(.cmp) tbody tr:hover { background: var(--card); }
  .table:not(.cmp) .btn { min-width: 44%; text-align: center; }

  /* review page: doctors on top as small cards, then one card per field with a line per doctor */
  .cmp-wrap { overflow: visible; margin: 8px 0; }
  .cmp, .cmp thead, .cmp tbody, .cmp tr, .cmp th, .cmp td { display: block; }
  .cmp { border: 0; background: transparent; overflow: visible; }
  .cmp thead th:not(.memberhead) { display: none; }
  .cmp thead tr { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .cmp th.memberhead { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; width: auto !important; min-width: 0; text-transform: none; letter-spacing: 0; }
  .cmp tbody tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
  .cmp tbody tr:hover { background: var(--card); }
  .cmp th.fieldname { width: auto !important; min-width: 0; padding: 7px 12px; }
  .cmp td { display: flex; gap: 10px; align-items: flex-start; min-width: 0; padding: 8px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  .cmp td:last-child { border-bottom: 0; }
  .cmp td::before { content: attr(data-label); flex: 0 0 22px; font-weight: 700; color: var(--muted); }
  .cmp td[data-label="Refined"] { display: block; background: var(--soft); } .cmp td[data-label="Refined"]::before { display: block; margin-bottom: 4px; content: "Refined value"; font-size: .72rem; text-transform: uppercase; }
  .cmp td[data-label="Refined"] select { width: 100%; }
  .cmp td:empty { display: none; }
}

.table th:empty { width: 56px; }

.good { color: var(--ok); } .stat b.good { color: var(--ok); }

#refine-home-app h2 { margin: 26px 0 8px; }

/* refine: group list and side-by-side review */
.badge-s { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); }
.badge-s.likely_same { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge-s.check { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.badge-s.probably_different, .badge-s.conflict { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pill.merged { color: var(--ok); } .pill.not_same { color: var(--danger); } .pill.skipped { color: var(--warn); }
.cmp-wrap { overflow-x: auto; margin: 12px 0; }
.cmp th, .cmp td { vertical-align: top; min-width: 150px; } .cmp th.fieldname { font-size: .78rem; color: var(--muted); text-transform: uppercase; background: var(--soft); min-width: 100px; }
.member-head { display: flex; gap: 6px; align-items: flex-start; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink); }
.cmp .off { opacity: .4; } .cmp td.pickcell { background: color-mix(in srgb, var(--ok) 11%, transparent); }
.cmp .pick { background: color-mix(in srgb, var(--ok) 14%, transparent); border-radius: 6px; padding: 3px 7px; margin-top: 4px; }
.ev { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; } .ev-chip { padding: 3px 11px; border-radius: 99px; border: 1px solid var(--line); font-size: .85rem; }
.ev-chip.good { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.ev-chip.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); font-weight: 600; }
.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border-radius: 10px; padding: 8px 14px; margin: 10px 0; }
.actions-bar .note-field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); max-width: 560px; margin-bottom: 10px; }

.banner.warn-banner { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--ink); }
ul.tight { margin: 4px 0 0; padding-left: 18px; }
.banner ul.tight li { margin: 2px 0; }

.inline-check { flex-direction: row !important; align-items: center; gap: 6px !important; padding-bottom: 6px; }
.photos { margin-top: 12px; } .photos .choice { cursor: pointer; margin-right: 8px; border: 2px solid transparent; } .photos .choice.picked { border-color: var(--ok); }
.source-link { margin-right: 12px; }

.progress { display: block; height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 6px; } .progress i { display: block; height: 100%; background: var(--ok); }
