/* Colors and type match the lead dashboard (metrics.refugememorial.com), which follows the Refuge agent portal. */
:root {
  color-scheme: light;
  --page: #f6f4ee;          /* portal cream */
  --surface: #ffffff;
  --ink: #0b1a3d;           /* portal navy */
  --ink-2: #5b6474;
  --muted: #7f8a9e;
  --hairline: #e7e3d8;
  --card-border: #d7dfea;
  --control-border: #7f8a9e;
  --brand: #2447f0;         /* portal blue */
  --brand-tint: #e7ebfc;
  --critical: #ef4444;
  --critical-text: #b91c1c;
  --good: #15803d;
  --good-tint: #e4f3ea;
  --warn: #b45309;
  --warn-tint: #fbf0dc;
  --shadow: 0 4px 16px rgba(11, 26, 61, 0.12);
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

* { 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 28px/1.15 var(--serif); letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 17px; font-weight: 500; }
.sub { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--surface); border: 1px solid var(--brand); border-radius: 16px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { padding-left: 14px; border-left: 1px solid var(--hairline); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.logo { display: block; height: 40px; width: auto; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-size: 12px; font-weight: 600; }

/* Controls */
.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); color: #fff; }
.btn[aria-pressed="true"]:hover, .btn-primary:hover { background: var(--brand); opacity: 0.9; }
.btn-big { width: 100%; min-height: 48px; font-size: 16px; }
.btn-danger { border-color: var(--critical); color: var(--critical-text); }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 8%, var(--surface)); }
.icon-btn { flex: none; width: 36px; height: 36px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font-size: 26px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--brand-tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

input, select, textarea {
  min-height: 36px; padding: 0 10px; border: 1px solid var(--control-border); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { padding: 8px 10px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input[type="checkbox"] { min-height: 0; accent-color: var(--brand); }
input[type="range"] { padding: 0; min-height: 0; accent-color: var(--brand); border: 0; }

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

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; margin-bottom: 12px; }
.view-toggle { display: flex; gap: 8px; }
.controls input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.field { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.field.check { cursor: pointer; }

#banner:not(:empty) { margin-bottom: 12px; }
.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 16px; border: 1px solid var(--critical); border-radius: 16px; background: color-mix(in srgb, var(--critical) 8%, var(--surface)); }
.banner span { color: var(--critical-text); }

.quick { display: flex; gap: 8px; padding: 10px 12px; margin-bottom: 16px; }
.quick input { flex: 1; border-color: transparent; }
.quick input:focus { border-color: var(--brand); }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--hairline); color: var(--ink-2); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.s-in-progress { background: var(--brand-tint); color: var(--brand); }
.s-on-hold { background: var(--warn-tint); color: var(--warn); }
.s-done { background: var(--good-tint); color: var(--good); }
.flag { display: inline-block; margin-right: 4px; }

/* List view */
.group { margin-bottom: 16px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--card-border); background: none; width: 100%; border-top: 0; border-left: 0; border-right: 0; font: inherit; cursor: pointer; text-align: left; color: var(--ink); }
.group-head h2 { font-size: 15px; font-weight: 600; }
.group-count { color: var(--ink-2); }
.group-caret { margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.group.collapsed .group-caret { transform: rotate(-90deg); }
.group.collapsed .rows { display: none; }
.group.collapsed .group-head { border-bottom: 0; }
.rows-head, .row { display: grid; grid-template-columns: minmax(200px, 3fr) 1.2fr 1.1fr 1.6fr; gap: 12px; align-items: center; padding: 0 16px; }
.rows-head { color: var(--ink-2); font-size: 12px; font-weight: 600; padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--card-border); }
.row { min-height: 44px; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover, .row:focus-visible { background: color-mix(in srgb, var(--brand-tint) 50%, transparent); outline-offset: -2px; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title .note-count { margin-left: 8px; color: var(--muted); font-weight: 400; font-size: 12px; }
.row .owner { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.empty-group { padding: 16px; color: var(--muted); }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }

.meter { display: flex; align-items: center; gap: 8px; }
.meter-track { flex: 1; height: 8px; border-radius: 999px; background: var(--hairline); overflow: hidden; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.s-done-fill { background: var(--good); }
.meter-num { width: 34px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 12px; }

/* Board view */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.column { padding: 10px; min-height: 120px; }
.column.drop { background: var(--brand-tint); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.board-card { display: block; width: 100%; text-align: left; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--card-border); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; cursor: grab; }
.board-card:hover { border-color: var(--brand); }
.board-card.dragging { opacity: 0.4; }
.board-card .t { font-weight: 500; margin-bottom: 8px; }
.board-card .m { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: 12px; margin-top: 8px; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(11, 26, 61, 0.45); }
.drawer-panel { position: relative; width: 100%; max-width: 520px; height: 100%; overflow-y: auto; border-radius: 16px 0 0 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.drawer-head { display: flex; align-items: center; gap: 8px; }
.d-title { flex: 1; min-width: 0; border-color: transparent; font: 500 22px/1.2 var(--serif); padding: 6px 8px; min-height: 0; }
.d-title:hover { border-color: var(--card-border); }
.d-title:focus { border-color: var(--brand); }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-field { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: 13px; }
.d-field input, .d-field select { width: 100%; color: var(--ink); font-size: 14px; }
.progress-row { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.progress-row input { flex: 1; }
.progress-row output { width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.notes-block { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; border-top: 1px solid var(--hairline); }
.note-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note { padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--page); }
.note-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.note-meta strong { color: var(--ink); font-weight: 600; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-del { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.note-del:hover { color: var(--critical-text); }
.drawer-foot { position: sticky; bottom: -20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: auto -20px -20px; padding: 12px 20px; border-top: 1px solid var(--hairline); background: var(--surface); border-radius: 0 0 0 16px; }
.drawer-foot .sub { margin-left: auto; font-size: 12px; }

/* Login / name prompt */
.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: var(--serif); font-size: 22px; }
.login-card .logo { align-self: flex-start; height: 28px; margin-bottom: 4px; }
.login-card .sub { margin: -6px 0 0; }
.choice-row { display: flex; gap: 8px; }
.choice-row .btn { flex: 1; }
.login-error { min-height: 1.4em; margin: 0; color: var(--critical-text); }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles .tile:nth-child(odd):last-child { grid-column: span 2; }
  .rows-head { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "title status" "meta meta"; padding: 10px 16px; gap: 4px 12px; }
  .row .c-title { grid-area: title; }
  .row .c-status { grid-area: status; }
  .row .c-owner, .row .c-progress { display: none; }
  .row .c-meta { grid-area: meta; display: flex; gap: 12px; flex-wrap: wrap; color: var(--ink-2); font-size: 12px; }
  .board { grid-template-columns: repeat(4, 260px); }
  .drawer-panel { border-radius: 16px 16px 0 0; max-width: none; margin-top: 48px; height: calc(100% - 48px); align-self: flex-end; }
  .drawer { align-items: flex-end; }
}
@media (min-width: 861px) { .c-meta { display: none; } }
@media (max-width: 480px) { .d-grid { grid-template-columns: 1fr; } .brand h1 { display: none; } }
@media (min-width: 1280px) {
  .page { max-width: 1360px; }
  body { font-size: 15px; }
  .tile-value { font-size: 34px; }
}
