/* Colors and type follow the Refuge Memorial agent portal (app.refugememorial.com). */
:root {
  color-scheme: light;
  --page: #f6f4ee;          /* portal cream */
  --surface: #ffffff;
  --ink: #0b1a3d;           /* portal navy */
  --ink-2: #5b6474;
  --muted: #7f8a9e;
  --hairline: #e7e3d8;      /* warm divider, as under the portal header */
  --card-border: #d7dfea;   /* portal --border; set to var(--brand) for the portal's blue-outlined cards */
  --control-border: #7f8a9e;
  --brand: #2447f0;         /* portal blue */
  --brand-tint: #e7ebfc;
  --critical: #ef4444;      /* portal --destructive */
  --critical-text: #b91c1c;
  --good: #15803d;          /* portal green, darkened so the small icon stays legible */
  --shadow: 0 4px 16px rgba(11, 26, 61, 0.12);
}

* { 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 { margin: 0; font: 500 32px/1.15 ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 17px; font-weight: 500; }

.page { max-width: 1040px; margin: 0 auto; padding: 24px 16px 56px; }
.sub { margin: 4px 0 0; color: var(--ink-2); }
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: 16px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.head-actions .sub { margin: 0; }

.logo { display: block; height: 32px; width: auto; margin-bottom: 14px; }

.chip { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-size: 12px; font-weight: 600; }

/* 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; }
: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); }
.mult { width: 72px; }

/* Filters */
.controls { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin-bottom: 16px; }
.presets { 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); }

/* Banner */
#banner:not(:empty) { margin-bottom: 16px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border: 1px solid var(--card-border); border-radius: 16px; background: var(--surface); }
.banner svg { flex: none; margin-top: 2px; }
.banner strong { display: block; font-weight: 600; }
.banner span { color: var(--ink-2); }
.banner-critical { border-color: var(--critical); background: color-mix(in srgb, var(--critical) 8%, var(--surface)); }
.banner-critical svg { color: var(--critical); }
.banner-good svg { color: var(--good); }

/* Summary tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 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; }

/* Table */
.table-card { padding: 4px 0 8px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 20px; padding: 10px 16px 6px; color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.key-bar { width: 16px; height: 8px; border-radius: 0 4px 4px 0; background: var(--brand); }
.key-line { width: 2px; height: 14px; background: var(--ink-2); }
.key-line.critical { background: var(--critical); }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
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; }
td { padding: 0 12px; border-bottom: 1px solid var(--hairline); height: 36px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--brand-tint) 50%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.th-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.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; }

.col-agent { width: 26%; }
.col-leads { width: 70px; }
.col-ratio { width: 84px; }
.col-status { width: 140px; }

td.col-agent { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-name { font-weight: 500; }
tr.flagged, tr.flagged:hover { background: color-mix(in srgb, var(--critical) 8%, transparent); }
tr.flagged .agent-name, tr.flagged .num { font-weight: 700; }

/* Bars: 36px-tall track so the reference lines read as continuous down the column */
.track { position: relative; height: 36px; }
.bar { position: absolute; left: 0; top: 11px; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--brand); }
tr.flagged .bar { background: var(--critical); }
.ref-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink-2); opacity: 0.55; }
.ref-line.critical { background: var(--critical); opacity: 1; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.status svg { flex: none; }
.status-flag svg { color: var(--critical); }
.status-flag { color: var(--ink); font-weight: 600; }

.empty, .error { padding: 32px 16px; text-align: center; color: var(--ink-2); }
.error .btn { margin-top: 12px; }
#results[aria-busy="true"] { opacity: 0.5; transition: opacity 0.15s; }

.notes { margin-top: 12px; color: var(--ink-2); font-size: 13px; }
.notes p { margin: 4px 0; }

/* 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; }

/* Login */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 26, 61, 0.45); }
.login-card { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; padding: 24px; box-shadow: var(--shadow); }
.login-card h2 { font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 22px; }
.login-card .logo { align-self: flex-start; height: 28px; margin-bottom: 4px; }
.login-card .sub { margin: -6px 0 0; }
.login-error { min-height: 1.4em; margin: 0; color: var(--critical-text); }

@media (max-width: 720px) {
  h1 { font-size: 26px; }
  .logo { height: 28px; margin-bottom: 10px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  th, td { padding-left: 8px; padding-right: 8px; }
  .col-ratio { display: none; }
  .col-agent { width: 116px; }
  .col-leads { width: 48px; }
  .col-status { width: 36px; }
  /* Icon-only status on phones; keep the words for screen readers. */
  .status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
