/* Same look as the Refuge Memorial metrics dashboard (portal cream, navy, blue). */
:root {
  color-scheme: light;
  --page: #f6f4ee;
  --surface: #ffffff;
  --ink: #0b1a3d;
  --ink-2: #5b6474;
  --muted: #7f8a9e;
  --hairline: #e7e3d8;
  --card-border: #d7dfea;
  --control-border: #7f8a9e;
  --brand: #2447f0;
  --brand-tint: #e7ebfc;
  --critical-text: #b91c1c;
  --series-call: #2447f0;  /* calls: portal blue */
  --series-text: #d9822b;  /* texts: warm amber, validated against blue for colorblind separation */
  --grid: #ece9e1;
  --shadow: 0 4px 16px rgba(11, 26, 61, 0.12);
  --card-surface: linear-gradient(180deg, #ffffff 0%, #fbfaf6 100%);
  --card-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(20, 40, 140, 0.06), 0 6px 16px rgba(20, 40, 140, 0.07);
  --card-shadow-hover: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 6px rgba(20, 40, 140, 0.08), 0 12px 24px rgba(20, 40, 140, 0.11);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, sans-serif;
}

h1, h2, h3 { margin: 0; }
h2 { font-size: 17px; font-weight: 500; }
h3 { font-size: 15px; font-weight: 600; }
.page-title { font: 500 26px/1.15 ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.01em; padding-left: 14px; border-left: 1px solid var(--hairline); }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 56px; }
.sub { margin: 4px 0 0; color: var(--ink-2); }
.card { background: var(--surface); background-image: var(--card-surface); border: 1px solid var(--brand); border-radius: 16px; box-shadow: var(--card-shadow); }
.tile { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-hover); }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.head-actions .sub { margin: 0; }
.logo { display: block; height: 40px; width: auto; }

/* Buttons and inputs */
.btn {
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--brand); border-radius: 6px;
  background: var(--surface); color: var(--brand);
  font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--brand-tint); }
.btn[aria-pressed="true"], .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn[aria-pressed="true"]:hover, .btn-primary:hover { background: var(--brand); opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input {
  min-height: 36px; padding: 0 10px;
  border: 1px solid var(--control-border); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit;
}
input:focus { border-color: var(--brand); }

/* Filters */
.controls { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin-bottom: 16px; }
.presets, .pool-toggle { display: flex; flex-wrap: wrap; gap: 8px; }
.fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.field { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.pool-toggle { margin-left: auto; }

/* Progress while accounts load */
.progress { margin-bottom: 16px; }
.progress-text { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 13px; margin-bottom: 6px; }
.progress-track { height: 4px; border-radius: 999px; background: var(--brand-tint); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width 0.25s ease; }

/* Banner */
#banner:not(:empty) { margin-bottom: 16px; }
.banner { padding: 12px 16px; border: 1px solid var(--brand); border-radius: 16px; background: var(--surface); box-shadow: var(--card-shadow); }
.banner strong { display: block; font-weight: 600; }
.banner span { color: var(--ink-2); }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { padding: 14px 16px; }
.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { margin-top: 4px; font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-sub { margin-top: 4px; color: var(--ink-2); font-size: 12px; }

/* Cards with a header */
.chart-card, .table-card, .detail-card { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 14px 16px 8px; }

/* Chart */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch-call { background: var(--series-call); }
.swatch-text { background: var(--series-text); }
.chart { padding: 0 16px 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--card-border); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--brand-tint) 55%, transparent); }
.chart-empty { padding: 40px 0; text-align: center; color: var(--ink-2); }

/* Table */
.table-card { padding-bottom: 8px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
table { width: 100%; min-width: 980px; border-collapse: collapse; }
th { padding: 8px 12px; border-bottom: 1px solid var(--card-border); color: var(--ink-2); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; vertical-align: bottom; }
td { padding: 0 12px; border-bottom: 1px solid var(--hairline); height: 40px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: color-mix(in srgb, var(--brand-tint) 55%, transparent); }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
tfoot td { border-top: 1px solid var(--card-border); border-bottom: 0; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.th-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: inherit; }
.th-btn:hover { color: var(--ink); }
th[aria-sort="ascending"] .th-btn::after { content: " \25B2"; font-size: 9px; }
th[aria-sort="descending"] .th-btn::after { content: " \25BC"; font-size: 9px; }
.th-tag { display: block; margin-top: 1px; font-size: 10px; font-weight: 500; color: var(--muted); }
.agent-name { font-weight: 500; }
.agent-pool { margin-left: 6px; color: var(--muted); font-size: 12px; }
.cell-sub { color: var(--muted); font-size: 12px; margin-left: 4px; }
.dash { color: var(--muted); }
.row-error td { color: var(--ink-2); }
.mini { display: inline-flex; height: 8px; width: 120px; border-radius: 0 3px 3px 0; overflow: hidden; vertical-align: middle; gap: 2px; }
.mini span { display: block; height: 100%; }
.mini .m-call { background: var(--series-call); }
.mini .m-text { background: var(--series-text); border-radius: 0 3px 3px 0; }
.empty, .error { padding: 32px 16px; text-align: center; color: var(--ink-2); }
.error .btn { margin-top: 12px; }

/* Agent detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 16px 4px; }
.detail-head h2 { font: 500 22px/1.2 ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 16px 16px; }
.detail-block h3 { margin-bottom: 8px; }
.detail-block .sub { margin: -4px 0 8px; font-size: 13px; }
.list { max-height: 420px; overflow: auto; border: 1px solid var(--card-border); border-radius: 12px; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 12px; border-bottom: 1px solid var(--hairline); }
.list-row:last-child { border-bottom: 0; }
.list-row a { color: var(--ink); font-weight: 500; text-decoration: none; }
.list-row a:hover { color: var(--brand); text-decoration: underline; }
.list-meta { color: var(--ink-2); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.list-body { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; }
.list-empty { padding: 20px 12px; color: var(--ink-2); text-align: center; }

.notes { margin-top: 8px; color: var(--ink-2); font-size: 13px; max-width: 90ch; }
.notes p { margin: 6px 0; }
.notes strong { color: var(--ink); font-weight: 600; }

/* Tooltip */
.tooltip { position: fixed; top: 0; left: 0; z-index: 20; max-width: 280px; padding: 8px 10px; border: 1px solid var(--card-border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; pointer-events: none; }
.tooltip strong { display: block; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles .tile:nth-child(odd):last-child { grid-column: span 2; }
  .detail-grid { grid-template-columns: 1fr; }
  .pool-toggle { margin-left: 0; }
}
@media (max-width: 720px) {
  .logo { height: 32px; }
  .page-title { font-size: 21px; padding-left: 10px; }
  th, td { padding-left: 8px; padding-right: 8px; }
  .col-hide-sm, .mini, .agent-pool { display: none; }
  table { min-width: 0; }
  td:first-child { white-space: normal; min-width: 110px; }
}

@media (min-width: 1280px) {
  .page { max-width: 1360px; padding: 28px 20px 54px; }
  body { font-size: 15px; }
  h2 { font-size: 20px; }
  .logo { height: 48px; }
  .page-title { font-size: 30px; }
  .btn { min-height: 41px; padding: 0 17px; }
  input { min-height: 41px; padding: 0 12px; }
  .controls { padding: 19px; }
  .tile { padding: 19px 20px; }
  .tile-label { font-size: 14px; }
  .tile-value { font-size: 34px; }
  th { padding: 10px 14px; font-size: 13px; }
  td { padding: 0 14px; height: 44px; }
}
