/* Rory Admin portal — web mirror of the Rory look (ultramarine + neutrals).
   Member app tokens live in app/lib/style.dart; this is an internal tool and
   deliberately does not share the tenant theming contract. */

:root {
  --rory-blue: #2e3dff;      /* Electric Ultramarine */
  --rory-blue-deep: #1B24C4;
  --rory-foam: #eaecff;
  --rory-periwinkle: #98a2ff;
  --ink: #14161f;
  --ink-2: #565b6b;
  --line: #e4e6ee;
  --bg: #f6f7fb;
  --card: #ffffff;
  --danger: #E5484D;
  --danger-deep: #C13640;    /* text-safe on light tints */
  --warning: #F59E0B;
  --warning-deep: #8a6116;   /* text-safe on light tints */
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.error { color: var(--danger-deep); }
h1, h2 { margin: 0; font-weight: 650; }
h2 { font-size: 17px; }

/* Login gate */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 36px; width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.gate-mark { width: 56px; height: 56px; margin: 0 auto; border-radius: 15px; background: var(--rory-blue); color: #fff; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gate-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gate-card .env-chip { margin: 0 auto; }
.gate-card input { text-align: center; }

/* Shell */
.topbar { display: flex; align-items: center; gap: 24px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--rory-blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.env-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 999px; }
.env-chip.staging { background: #fdf3df; color: var(--warning-deep); }
.env-chip.production { background: #fbeaea; color: #a63a3f; }
.env-chip.local { background: var(--bg); color: var(--ink-2); }
.env-switch { width: auto; font-size: 12px; padding: 6px 8px; border-radius: 8px; color: var(--ink-2); }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 999px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.tab.active { background: var(--rory-foam); color: var(--rory-blue-deep); font-weight: 600; }

.view { display: flex; gap: 24px; padding: 24px; align-items: flex-start; }
.list-pane { flex: 1; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }

/* Table */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); font-weight: 600; background: #fafbfe; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f6f8ff; }
.table tbody tr.selected { background: var(--rory-foam); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.inst-cell { display: flex; align-items: center; gap: 12px; }
.inst-mark { width: 34px; height: 34px; border-radius: 10px; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.inst-name { font-weight: 600; }
.inst-sub { color: var(--ink-2); font-size: 12px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.12); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--rory-foam); color: var(--rory-blue-deep); }
.badge.live { background: #e8f6ee; color: #1c7a4b; }
/* Lifecycle law: green means money moved or a thing completed. Everything
   else that just needs emphasis wears the brand foam. */
.badge.brand { background: var(--rory-foam); color: var(--rory-blue-deep); }

/* Editor */
.editor { width: 460px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow-y: auto; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.field.small { flex: 0 0 90px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-2); font-size: 11px; }
.field-row { display: flex; gap: 12px; }
.field-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.field-group legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 6px; }
input, select { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--rory-periwinkle); border-color: var(--rory-blue); }
input:disabled { background: var(--bg); color: var(--ink-2); }
.color-pair { display: flex; gap: 8px; align-items: center; }
.color-pair input[type="color"] { width: 40px; height: 36px; padding: 2px; flex: none; cursor: pointer; }
.color-pair .hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Brand preview */
.preview { display: flex; gap: 12px; margin-bottom: 18px; }
.preview-card { flex: 1; border-radius: var(--radius); padding: 14px; border: 1px solid var(--line); }
.preview-card.dark { background: #171921; border-color: #171921; }
.preview-lockup { display: flex; align-items: center; gap: 10px; }
.preview-logo { width: 30px; height: 30px; border-radius: 9px; color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.preview-fi { font-weight: 650; font-size: 13px; }
.preview-card.light .preview-fi { color: var(--ink); }
.preview-card.dark .preview-fi { color: #f2f3f8; }
.preview-chip { margin-top: 10px; display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.preview-note { margin-top: 10px; font-size: 11px; }
.preview-card.light .preview-note { color: var(--ink-2); }
.preview-card.dark .preview-note { color: #9aa0b2; }

/* Logo upload */
.logo-upload { display: flex; align-items: center; gap: 10px; }
.logo-upload small { flex: 1; }
.preview-logo-img { width: 30px; height: 30px; border-radius: 9px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.preview-logo-img.broken { visibility: hidden; }

/* Users navigator */
.user-filters { display: flex; gap: 10px; flex: 1; max-width: 520px; }
.user-filters select { width: auto; flex: none; max-width: 200px; }
#view-users .user-filters { max-width: 760px; justify-content: flex-end; }
#view-users .user-filters input { min-width: 220px; }
.user-filters .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }
.detail-kind { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 16px 0 4px; }
.detail-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.detail-row:last-child { border-bottom: 0; }
.detail-label { font-weight: 500; flex: none; }
.detail-value { text-align: right; }
.detail-value code { background: var(--bg); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* Buttons */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--rory-periwinkle); }
.btn.primary { background: var(--rory-blue); border-color: var(--rory-blue); color: #fff; }
.btn.primary:hover { background: var(--rory-blue-deep); }
.btn.ghost { border: 0; background: none; color: var(--ink-2); }
.btn.danger { background: none; border-color: #f0d4d4; color: var(--danger-deep); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small-remove { border: 0; background: none; color: var(--danger-deep); }
.editor-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }
.spacer { flex: 1; }

/* Keyboard focus: tabs, buttons, and clickable table rows all show the ring. */
.tab:focus-visible,
.btn:focus-visible,
.table tbody tr:focus-visible { outline: 2px solid var(--rory-blue); outline-offset: 2px; }

/* Banno cards */
.banno-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.banno-card .fields { margin-top: 12px; }
.banno-head { display: flex; align-items: center; gap: 10px; }
.banno-head code { background: var(--rory-foam); color: var(--rory-blue-deep); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.secret-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); }

/* Task toggles */
.task-note { font-size: 11px; margin: 0; }
.task-kind { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 6px 0 2px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row input[type="checkbox"] { width: 16px; height: 16px; flex: none; accent-color: var(--rory-blue); cursor: pointer; }
.task-row .task-label { flex: 1; font-weight: 500; }
.task-row.off .task-label { color: var(--ink-2); text-decoration: line-through; }
.task-row .task-verify { flex: none; font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: inherit; cursor: pointer; }
.task-meta { color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.task-fuel { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink-2); }

/* Vehicle VIN editor */
.vin-row { margin: 8px 0 6px; }
.vin-row > input, .vin-row > select { flex: 1 1 auto; min-width: 0; }
.vin-row > .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }
.vin-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.vin-photo { max-width: 100%; max-height: 170px; display: block; margin: 10px auto 0; }

/* Verification queue */
.review-card { display: flex; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.review-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.review-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-reason { font-size: 13px; }
.review-evidence { width: 170px; flex: none; display: flex; align-items: center; justify-content: center; }
.review-evidence img { max-width: 170px; max-height: 130px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.carart-renders { width: 300px; flex-direction: column; gap: 8px; }
.carart-renders img { max-width: 300px; max-height: none; object-fit: contain; background: #fff; }
.carart-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.carart-photos img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.badge.danger-badge { background: #fbeaea; color: var(--danger-deep); }

/* Learn & earn lesson editor */
.lesson-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.lesson-card.off { opacity: 0.65; }
.lesson-card textarea { resize: vertical; font: inherit; }
.lesson-actions { display: flex; align-items: center; gap: 8px; }
.lesson-actions .task-row { border-bottom: 0; padding: 0; }

/* Offer art picker: thumbnails from the bundled card art collection. */
.offer-art { display: flex; gap: 8px; flex-wrap: wrap; }
.offer-art .art-choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: 11px; color: var(--ink-2); min-width: 72px; }
.offer-art .art-choice img { width: 44px; height: 44px; object-fit: contain; }
.offer-art .art-choice.none { justify-content: center; }
.offer-art input[type=radio] { display: none; }
.offer-art .art-choice:has(input:checked) { border-color: var(--rory-blue); outline: 2px solid var(--rory-blue); outline-offset: -2px; }

/* Full-page institution editor: editing hides the list so the tenant gets
   the whole page to work from. */
.view.editing .list-pane { display: none; }
.view.editing .editor { width: 100%; position: static; max-height: none; }
.view.editing .editor .fields { max-width: 900px; }
.lesson-head .field.small { max-width: 110px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 20; }
.toast.error { background: var(--danger-deep); }

@media (max-width: 980px) {
  .view { flex-direction: column; }
  .editor { width: 100%; position: static; max-height: none; }
  #view-users .pane-head { align-items: flex-start; }
  #view-users .user-filters { flex-wrap: wrap; }
}

/* Palette contrast verdicts (where the tenant brand may show) */
.palette-checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.palette-checks:empty { display: none; }
.pcheck { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; }
.pcheck em { font-style: normal; font-weight: 500; opacity: 0.85; }
.pcheck.pass { background: #e5f6ec; color: #17734a; }
.pcheck.warn { background: #fdf3df; color: var(--warning-deep); }
.pcheck.fail { background: #fdeaea; color: #a63a3f; }

/* Institution editor sections collapse (the page was getting crowded).
   Brand opens by default; everything else expands on demand. */
details.field-group > summary { font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 7px; user-select: none; }
details.field-group > summary::-webkit-details-marker { display: none; }
details.field-group > summary::before { content: "▸"; font-size: 10px; transition: transform 0.12s; }
details.field-group[open] > summary::before { transform: rotate(90deg); }
details.field-group > summary:hover { color: var(--ink); }

/* Reconciliation panel: attention without alarm — warning accent, ink text. */
.recon-card { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--warning); border-radius: var(--radius); margin-bottom: 16px; padding: 12px 16px; }
.recon-card table { width: 100%; margin-top: 8px; font-size: 12px; }

/* Expanded payment row */
.pay-detail td { background: #fafbfe; cursor: default; padding: 16px 18px; }
.pd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 18px; margin-bottom: 14px; }
.pd-cell { display: flex; flex-direction: column; gap: 2px; }
.pd-key { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); }
.pd-val { font-size: 13px; }
.pd-val code, .pd-event code { background: var(--rory-foam); border-radius: 5px; padding: 1px 5px; font-size: 11px; word-break: break-all; }
.pd-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); margin: 12px 0 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.pd-event { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; font-size: 12.5px; flex-wrap: wrap; }
.pd-event-at { color: var(--ink-2); font-size: 11.5px; white-space: nowrap; }
.pd-event-bits { flex: 1; min-width: 200px; }

/* Demo state personas (user editor) */
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.btn.persona { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; height: auto; }
.btn.persona small { font-weight: 400; line-height: 1.3; }

.pm-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pm-actions .btn { padding: 4px 10px; font-size: 12px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* A link's QR, small in its row; the download is full size. */
.link-qr svg { width: 56px; height: 56px; display: block; }
