/* portal-ui-v1: shared page components (Status, Access, Practice rails, Payer rails, Toll recovery, Login).
   Map uses atlas.css instead, because its panel/chip/legend classes mean different things. */

main, .wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
.lead { color: var(--quiet); margin: 0 0 16px; max-width: 980px; }
.quiet, .muted { color: var(--quiet); }
.muted { font-size: 12px; }
.bad { color: var(--bad); }
.good { color: var(--ok); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-size: 12px; }
.err { color: var(--bad); }
.note { font-size: 12px; color: var(--quiet); margin-top: 8px; line-height: 1.5; }
.empty { padding: 18px 16px; color: var(--quiet); font-size: 13px; }
code { font-size: 12px; }
small { color: var(--quiet); }

/* Buttons */
.btn { font: inherit; font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line);
       background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn:disabled { opacity: .45; cursor: default; }

/* Forms */
input[type=search], input[type=text], input[type=email], input[type=password], input:not([type]), select, textarea {
  font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info); outline-offset: 0; border-color: transparent; }
label { color: var(--quiet); }

/* Tiles: number tiles (.tiles) and status tiles (.grid), coloured on the left by state */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--r);
        padding: 12px 14px; text-align: left; font: inherit; color: inherit; width: 100%; }
.tile.ok { border-left-color: var(--ok); } .tile.warn { border-left-color: var(--warn); }
.tile.crit, .tile.bad { border-left-color: var(--bad); } .tile.error { border-left-color: var(--muted); }
.tile .k, .tile .l { color: var(--quiet); font-size: 12px; }
.tile .v, .tile .n { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .n { margin-top: 0; }
.tile .s { color: var(--quiet); font-size: 12px; margin-top: 2px; }
.tile .act { margin-top: 8px; }
.tile.bad .v { color: var(--bad); } .tile.warn .v { color: var(--warn); }
.grid .tile { cursor: pointer; }
.grid .tile:hover { border-color: var(--faint); }
.grid .tile.warn { background: var(--warn-bg); } .grid .tile.crit { background: var(--bad-bg); }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tile-name { font-weight: 600; font-size: 13px; }
.tile-val { font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ok .tile-val { color: var(--ok); } .warn .tile-val { color: var(--warn); } .crit .tile-val { color: var(--bad); } .error .tile-val { color: var(--muted); }
.tile-sum { font-size: 12px; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }
.tile-since { font-size: 11px; color: var(--quiet); margin-top: 6px; }

/* Status page */
.overall { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--panel);
           border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 24px; flex-wrap: wrap; }
.overall-main { display: flex; align-items: center; gap: 14px; }
.big-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.overall h1 { font-size: 18px; font-weight: 600; }
.overall .meta { font-size: 12px; color: var(--quiet); margin-top: 3px; }
.counts { display: flex; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.cat { margin-bottom: 24px; }
.cat-label { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; }
.cat-label span { font-weight: 400; font-size: 12px; }
.stale { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-line); border-radius: var(--r);
         padding: 10px 14px; margin-bottom: 16px; font-size: 13px; display: none; }
.strip { display: flex; gap: 2px; margin: 6px 0 14px; }
.strip span { flex: 1; height: 18px; border-radius: 2px; min-width: 4px; }
.s-ok { background: var(--ok); } .s-warn { background: var(--warn); } .s-crit { background: var(--bad); } .s-error { background: var(--muted); }
.add { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.add input[name=address] { min-width: 240px; flex: 1; }
.result-bad { color: var(--bad); font-size: 12px; } .result-ok { color: var(--ok); font-size: 12px; }
.toggle { width: 34px; height: 20px; border-radius: 20px; border: none; cursor: pointer; position: relative; background: var(--faint); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
                 background: var(--panel); transition: left .15s; }
.toggle.on { background: var(--ok); } .toggle.on::after { left: 17px; }

/* Badges: .pill (Status, Access) and .state (rails) share one look */
.pill, .state { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
                white-space: nowrap; background: var(--muted-bg); color: var(--ink-2); }
.pill { font-size: 11px; }
.pill.ok, .st-flowing, .st-validated { color: var(--ok); background: var(--ok-bg); }
.pill.warn, .st-stuck, .st-partial { color: var(--warn); background: var(--warn-bg); }
.pill.crit, .st-broken { color: var(--bad); background: var(--bad-bg); }
.pill.info, .st-setup { color: var(--info); background: var(--info-bg); }
.st-not_testable, .st-quiet, .st-unvalidated { color: var(--muted); background: var(--muted-bg); }
.st-simulation { color: var(--muted); background: var(--muted-bg); font-style: italic; }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }

/* Panels: flush (header + table) by default, .pad for prose panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.panel.pad { padding: 16px 18px; overflow: visible; }
.panel h2 { font-size: 15px; font-weight: 600; }
.panel.pad h2 { margin: 0 0 4px; }
.panel.pad h3 { font-size: 13px; margin: 0 0 10px; color: var(--quiet); font-weight: 500; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
              align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; }
.panel-head p { font-size: 12px; color: var(--quiet); margin-top: 2px; }
.panel-head .sub { font-size: 12px; color: var(--quiet); }
.panel > .note, .panel > .msg { padding: 0 16px 12px; margin-top: 0; }
.panel > .msg:empty { padding: 0; }
.panel.pad > .note, .panel.pad > .msg { padding: 0; }
.msg { font-size: 12px; min-height: 16px; margin-top: 8px; }
.msg.err { color: var(--bad); } .msg.good { color: var(--ok); }
.banner { border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; line-height: 1.5; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }

/* Tables */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel .tablewrap { border: none; border-radius: 0; }
.panel.pad .tablewrap { border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: 12px; color: var(--quiet); font-weight: 500; border-bottom-color: var(--line); background: var(--panel); }
.tablewrap th { position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap td, .tablewrap th { white-space: nowrap; }
tbody tr[data-id], tbody tr[data-key], tr.click { cursor: pointer; }
tbody tr[data-id]:hover, tbody tr[data-key]:hover, tr.click:hover td { background: var(--hover); }
tbody tr.sel, tbody tr.sel td { background: var(--info-bg); }
tr.sub td { background: var(--bg); font-size: 13px; }
tr.sub td:first-child { padding-left: 30px; }
tr.sub.sel td { background: var(--info-bg); }
table.m { table-layout: fixed; }
table.m td:nth-child(1), table.m th:nth-child(1) { width: 32%; } table.m td:nth-child(2), table.m th:nth-child(2) { width: 20%; }
table.m td:nth-child(3), table.m th:nth-child(3) { width: 14%; } table.m td:nth-child(4), table.m th:nth-child(4) { width: 12%; }
table.m td { overflow: hidden; text-overflow: ellipsis; }

/* Access page */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { font: inherit; font-size: 13px; font-weight: 500; background: none; border: none; border-bottom: 2px solid transparent;
               padding: 9px 14px; color: var(--quiet); cursor: pointer; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.org { border-top: 1px solid var(--line-soft); }
.org-head { padding: 10px 16px; background: var(--bg); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.org-head b { font-size: 13px; }
.filters { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 46px; padding: 10px 16px 0; }
.chart div { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; min-width: 3px; max-width: 22px; }
.chart .ok { background: var(--ok); opacity: .55; } .chart .f { background: var(--bad); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; margin: 0 0 14px; }
.kv dt { color: var(--quiet); } .kv dd { margin: 0; }
.section { font-size: 12px; font-weight: 600; color: var(--quiet); margin: 16px 0 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Dialogs */
dialog { margin: auto; border: 1px solid var(--line); border-radius: 10px; padding: 0; max-width: 760px; width: calc(100% - 32px);
         background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: var(--backdrop); }
.dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
            align-items: flex-start; gap: 12px; }
.dlg-head h3 { font-size: 16px; }
.dlg-body { padding: 14px 18px; max-height: 72vh; overflow: auto; }
pre { font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px;
      white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }

/* Practice rails / Payer rails */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 10px; font-size: 12px;
        cursor: pointer; color: var(--ink); font-family: inherit; }
.chip.on { border-color: var(--ink); }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input[type=search] { min-width: 240px; }
.toolbar label { font-size: 13px; }
.rail { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage { flex: 1 0 150px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.stage .n { font-size: 20px; font-weight: 600; }
.stage .k, .stage .s { font-size: 12px; color: var(--quiet); }
.stage .s { margin-top: 4px; }
.stage.bad { border-color: var(--bad); } .stage.warn { border-color: var(--warn); } .stage.ok { border-color: var(--ok); }
.svgchart svg { width: 100%; height: auto; max-height: 200px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--quiet); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.dots i.on { background: var(--ok); } .dots i.part { background: var(--warn); }
.expand { color: var(--quiet); font-size: 12px; margin-left: 6px; }
#detail, #drill { margin-top: 20px; }
#detail[hidden], #drill[hidden] { display: none; }

/* Toll recovery */
.page-toll .panel.pad { margin: 0 0 16px; }
.page-toll form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-toll form label { width: 100%; font-size: 13px; }
.page-toll #charge { width: min(440px, 100%); }
.page-toll button { font: inherit; font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line);
                    background: var(--panel); color: var(--ink); cursor: pointer; }
.page-toll button:hover { border-color: var(--faint); }
.page-toll button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.page-toll button:disabled { opacity: .45; cursor: default; }
.page-toll #rows button { padding: 4px 10px; font-size: 12px; }
.page-toll #actions button { margin: 8px 10px 8px 0; }
.page-toll #message { min-height: 22px; margin: 0 0 12px; font-size: 13px; }
.page-toll .error { color: var(--bad); }
.page-toll #details dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; margin: 10px 0; font-size: 13px; }
.page-toll #details dt { color: var(--quiet); }
.page-toll #details dd { margin: 0; overflow-wrap: anywhere; }
.page-toll details { margin-top: 12px; } .page-toll summary { cursor: pointer; color: var(--quiet); font-size: 13px; }
.page-toll dialog { max-width: 480px; padding: 22px; }
.page-toll dialog h2 { font-size: 16px; margin-bottom: 8px; }
.page-toll dialog p { margin-bottom: 16px; color: var(--ink-2); line-height: 1.5; }

/* Login */
.page-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: 100%; max-width: 360px; }
.card .brand { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.card .sub { color: var(--quiet); font-size: 13px; margin-bottom: 18px; }
.card label { display: block; font-size: 12px; font-weight: 500; margin: 14px 0 6px; }
.card input { width: 100%; font-size: 14px; padding: 9px 11px; }
.card button { margin-top: 20px; width: 100%; padding: 10px; border: none; border-radius: 6px; background: var(--ink); color: var(--bg);
               font: inherit; font-weight: 600; cursor: pointer; }
.card .err { margin-top: 14px; font-size: 13px; }

@media (max-width: 700px) {
  main, .wrap { padding: 16px 16px 40px; }
  .overall { flex-direction: column; align-items: flex-start; }
  table.m td:nth-child(n), table.m th:nth-child(n) { width: auto; }
  table.m { table-layout: auto; }
  .kv, .page-toll #details dl { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
