/*
 * LDPI Atlas design tokens and components. One stylesheet, no build step.
 * Filament provides the frame (navigation, forms, tables, dark mode toggle); this file provides the
 * vocabulary every page speaks: cards, tiles, tables of numbers, callouts, provenance. Colours come
 * from Filament's per-client primary palette (--primary-*) so the accent follows the client.
 */

:root {
  --atlas-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --atlas-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --atlas-bg: #f6f7f9;
  --atlas-card: #ffffff;
  --atlas-soft: #f1f3f6;
  --atlas-line: #e4e7ec;
  --atlas-text: #101828;
  --atlas-muted: #667085;
  --atlas-faint: #98a2b3;

  --atlas-ok: #12854f;    --atlas-ok-bg: #e7f6ee;
  --atlas-warn: #b45309;  --atlas-warn-bg: #fdf3e2;
  --atlas-bad: #b42318;   --atlas-bad-bg: #fdecea;
  --atlas-info: #175cd3;  --atlas-info-bg: #e8f0fd;

  --atlas-accent: var(--primary-600);                 /* Filament 4 emits oklch() colours, not rgb triplets */
  --atlas-accent-soft: var(--primary-50);

  --atlas-radius: 12px;
  --atlas-radius-sm: 8px;
  --atlas-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --atlas-gap: 16px;
}

.dark {
  --atlas-bg: #0b0f17;
  --atlas-card: #111827;
  --atlas-soft: #1a2233;
  --atlas-line: #253046;
  --atlas-text: #f2f4f7;
  --atlas-muted: #98a2b3;
  --atlas-faint: #667085;

  --atlas-ok: #4ade80;    --atlas-ok-bg: #0f2d1f;
  --atlas-warn: #fbbf24;  --atlas-warn-bg: #3a2a0c;
  --atlas-bad: #f87171;   --atlas-bad-bg: #3b1412;
  --atlas-info: #60a5fa;  --atlas-info-bg: #12233d;

  --atlas-accent: var(--primary-400);
  --atlas-accent-soft: color-mix(in oklch, var(--primary-400) 14%, transparent);
  --atlas-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

/* ---- layout ---------------------------------------------------------------------------- */
.atlas-stack { display: grid; gap: var(--atlas-gap); }
.atlas-grid { display: grid; gap: var(--atlas-gap); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.atlas-grid-2 { display: grid; gap: var(--atlas-gap); grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---- card ------------------------------------------------------------------------------ */
.atlas-card {
  background: var(--atlas-card); border: 1px solid var(--atlas-line); border-radius: var(--atlas-radius);
  box-shadow: var(--atlas-shadow); color: var(--atlas-text); font-family: var(--atlas-font); overflow: hidden;
}
.atlas-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.atlas-card-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; text-wrap: balance; }
.atlas-card-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--atlas-muted); }
.atlas-card-body { padding: 16px 20px 18px; }
.atlas-card-body.tight { padding: 0; }
.atlas-prose { font-size: 14px; line-height: 1.6; max-width: 68ch; }
.atlas-prose p { margin: 0 0 .75em; } .atlas-prose p:last-child { margin-bottom: 0; }
.atlas-prose ul, .atlas-prose ol { margin: 0 0 .75em; padding-left: 1.25em; }
.atlas-prose code { font-family: var(--atlas-mono); font-size: .92em; background: var(--atlas-soft); padding: 1px 5px; border-radius: 4px; }

/* ---- badges ---------------------------------------------------------------------------- */
.atlas-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; line-height: 1.5;
  background: var(--atlas-soft); color: var(--atlas-muted);
}
.atlas-badge.ok { background: var(--atlas-ok-bg); color: var(--atlas-ok); }
.atlas-badge.warn { background: var(--atlas-warn-bg); color: var(--atlas-warn); }
.atlas-badge.bad { background: var(--atlas-bad-bg); color: var(--atlas-bad); }
.atlas-badge.info { background: var(--atlas-info-bg); color: var(--atlas-info); }
.atlas-badge.accent { background: var(--atlas-accent-soft); color: var(--atlas-accent); }

/* ---- stat tile & kpi tile ------------------------------------------------------------- */
.atlas-stat { padding: 16px 18px; }
.atlas-stat .lbl { font-size: 12.5px; color: var(--atlas-muted); font-weight: 500; }
.atlas-stat .val { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.atlas-stat .val .delta { font-size: 13px; font-weight: 600; margin-left: 8px; vertical-align: 2px; }
.atlas-stat .val .delta.up { color: var(--atlas-ok); } .atlas-stat .val .delta.down { color: var(--atlas-bad); }
.atlas-stat .note { font-size: 12px; color: var(--atlas-muted); margin-top: 4px; }

.atlas-kpi { padding: 16px 18px; border-left: 3px solid var(--atlas-line); }
.atlas-kpi.done { border-left-color: var(--atlas-ok); }
.atlas-kpi.part { border-left-color: var(--atlas-warn); }
.atlas-kpi.none { border-left-color: var(--atlas-faint); }
.atlas-kpi .code { font-size: 12px; font-weight: 600; color: var(--atlas-muted); display: flex; gap: 8px; align-items: center; }
.atlas-kpi .val { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.atlas-kpi .val .delta { font-size: 13px; font-weight: 600; margin-left: 8px; vertical-align: 2px; }
.atlas-kpi .val .delta.up { color: var(--atlas-ok); } .atlas-kpi .val .delta.down { color: var(--atlas-bad); }
.atlas-kpi .target { font-size: 12px; color: var(--atlas-muted); margin-top: 2px; }

/* ---- provenance: every measured number carries this ---------------------------------- */
.atlas-prov { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--atlas-muted); }
.atlas-prov .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--atlas-faint); flex: none; }
.atlas-prov .dot.fresh { background: var(--atlas-ok); }
.atlas-prov .dot.stale { background: var(--atlas-warn); }
.atlas-prov .dot.failed { background: var(--atlas-bad); }
.atlas-prov .dot.provided { background: var(--atlas-info); }

/* ---- table ----------------------------------------------------------------------------- */
.atlas-tablewrap { overflow-x: auto; }
/* The client's own row among its competitors, tinted so it is found without reading. */
.atlas-row-client > td, .atlas-row-client > th { background: var(--atlas-accent-soft) !important; }
.atlas-row-client td:first-child { box-shadow: inset 3px 0 0 var(--atlas-accent); }

.atlas-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.atlas-table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--atlas-muted); padding: 10px 20px; border-bottom: 1px solid var(--atlas-line); background: var(--atlas-soft); }
.atlas-table td { padding: 11px 20px; border-bottom: 1px solid var(--atlas-line); vertical-align: top; }
.atlas-table tr:last-child td { border-bottom: 0; }
.atlas-table .num, .atlas-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.atlas-table tr.hl td { background: var(--atlas-accent-soft); }
.atlas-table .sub { font-size: 12px; color: var(--atlas-muted); margin-top: 2px; }

/* ---- callout --------------------------------------------------------------------------- */
.atlas-callout { border: 1px solid var(--atlas-line); border-left-width: 4px; border-radius: var(--atlas-radius-sm); padding: 12px 16px; font-size: 14px; line-height: 1.55; background: var(--atlas-card); }
.atlas-callout .ttl { font-weight: 600; margin-bottom: 2px; }
.atlas-callout.info { border-left-color: var(--atlas-info); background: var(--atlas-info-bg); }
.atlas-callout.warn { border-left-color: var(--atlas-warn); background: var(--atlas-warn-bg); }
.atlas-callout.bad { border-left-color: var(--atlas-bad); background: var(--atlas-bad-bg); }
.atlas-callout.ok { border-left-color: var(--atlas-ok); background: var(--atlas-ok-bg); }

/* ---- lists: timeline, steps, checklist -------------------------------------------------- */
.atlas-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.atlas-timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 14px; font-size: 14px; }
.atlas-timeline .when { color: var(--atlas-muted); font-size: 12.5px; padding-top: 2px; }
.atlas-timeline .ttl { font-weight: 600; }
.atlas-timeline .body { color: var(--atlas-muted); font-size: 13px; margin-top: 2px; }

.atlas-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.atlas-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; }
.atlas-steps .n { flex: none; min-width: 30px; text-align: center; padding: 1px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--atlas-soft); color: var(--atlas-muted); }
.atlas-steps .n.p1 { background: var(--atlas-bad-bg); color: var(--atlas-bad); }
.atlas-steps .n.p2 { background: var(--atlas-warn-bg); color: var(--atlas-warn); }
.atlas-steps .n.p3 { background: var(--atlas-info-bg); color: var(--atlas-info); }

.atlas-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.atlas-check li { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; }
.atlas-check .ic { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 2px; }
.atlas-check .ic.ok { background: var(--atlas-ok-bg); color: var(--atlas-ok); }
.atlas-check .ic.wip { background: var(--atlas-warn-bg); color: var(--atlas-warn); }
.atlas-check .ic.next { background: var(--atlas-soft); color: var(--atlas-muted); }
.atlas-check .ic.bad { background: var(--atlas-bad-bg); color: var(--atlas-bad); }

/* ---- states: empty, loading, error, unavailable ---------------------------------------- */
.atlas-empty { padding: 28px 20px; text-align: center; color: var(--atlas-muted); font-size: 14px; }
.atlas-empty .ttl { font-weight: 600; color: var(--atlas-text); margin-bottom: 4px; }
.atlas-loading { padding: 16px 20px; display: grid; gap: 10px; }
.atlas-loading .bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--atlas-soft), var(--atlas-line), var(--atlas-soft)); background-size: 200% 100%; animation: atlas-shimmer 1.4s infinite; }
.atlas-loading .bar.w60 { width: 60%; } .atlas-loading .bar.w40 { width: 40%; } .atlas-loading .bar.w80 { width: 80%; }
@keyframes atlas-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .atlas-loading .bar { animation: none; } }
.atlas-error { border: 1px solid var(--atlas-bad); border-radius: var(--atlas-radius-sm); padding: 12px 16px; background: var(--atlas-bad-bg); color: var(--atlas-bad); font-size: 13.5px; }
.atlas-error .ttl { font-weight: 600; }
.atlas-unavailable { border: 1px dashed var(--atlas-line); border-radius: var(--atlas-radius-sm); padding: 12px 16px; color: var(--atlas-muted); font-size: 13px; }
.atlas-unavailable .ttl { font-weight: 600; color: var(--atlas-text); }

/* ---- footer line ----------------------------------------------------------------------- */
.atlas-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--atlas-muted); padding: 12px 0 4px; }

/* ---- kind marking: measured / provided / editorial (visible only with the staff overlay) -- */
.atlas-overlay [data-kind] { position: relative; outline: 1px dashed rgba(120, 120, 120, .45); outline-offset: 4px; margin-top: 14px; }
.atlas-overlay [data-kind]::before { content: attr(data-kind); position: absolute; top: -12px; left: 8px; font: 600 10px/1.4 var(--atlas-mono); letter-spacing: .05em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; background: var(--atlas-faint); color: #fff; z-index: 2; }
.atlas-overlay [data-kind="measured"]::before { background: var(--atlas-ok); }
.atlas-overlay [data-kind="provided"]::before { background: var(--atlas-info); }

/* ---- Workspace documents ----------------------------------------------------------------- */
.atlas-doc { display: flex; flex-direction: column; gap: 16px; }
.atlas-block { position: relative; }
.atlas-doc .atlas-card-body { display: flex; flex-direction: column; gap: 14px; }
.atlas-doc .atlas-card-body.tight { display: block; }
.atlas-prose h3, .atlas-prose h4 { margin: 14px 0 6px; font-weight: 600; }
.atlas-prose a { color: var(--atlas-accent); text-decoration: underline; }
.atlas-prose blockquote { margin: 0 0 .75em; padding-left: 12px; border-left: 3px solid var(--atlas-line); color: var(--atlas-muted); }
.atlas-prose table { border-collapse: collapse; margin: 6px 0 12px; }
.atlas-prose th, .atlas-prose td { border: 1px solid var(--atlas-line); padding: 6px 10px; font-size: 13.5px; }
.atlas-doc-overlay .atlas-block { outline: 1px dashed rgba(120, 120, 120, .45); outline-offset: 4px; margin-top: 14px; }
.atlas-doc-overlay .atlas-card-body .atlas-block { margin-top: 10px; }
.atlas-block-tag { position: absolute; top: -12px; right: 8px; z-index: 2; font: 600 10px/1.4 var(--atlas-mono); letter-spacing: .05em; text-transform: uppercase; color: #fff; background: var(--atlas-faint); padding: 1px 6px; border-radius: 3px; }
.atlas-block[data-kind="measured"] > .atlas-block-tag { background: var(--atlas-ok); }
.atlas-block[data-kind="provided"] > .atlas-block-tag { background: var(--atlas-info); }
.atlas-pre { white-space: pre-wrap; font: 12.5px/1.5 var(--atlas-mono); background: var(--atlas-soft); border-radius: 8px; padding: 12px; max-height: 640px; overflow: auto; }

/* Home: what needs attention, and the compact rows inside an area card */
.atlas-attention { list-style: none; margin: 0; padding: 0; }
.atlas-attention li { display: flex; align-items: center; gap: 10px; padding: 11px 20px; border-bottom: 1px solid var(--atlas-line); font-size: 13.5px; }
.atlas-attention li:last-child { border-bottom: 0; }
.atlas-attention li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--atlas-warn); flex: none; }
.atlas-attention li.bad .dot { background: var(--atlas-bad); }
.atlas-attention li.info .dot { background: var(--atlas-muted); }
.atlas-attention li .txt { flex: 1; }
.atlas-attention li a { font-size: 12.5px; color: var(--atlas-accent); text-decoration: none; white-space: nowrap; }
.atlas-attention li a:hover { text-decoration: underline; }

.atlas-home-rows { list-style: none; margin: 0; padding: 0; }
.atlas-home-rows li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--atlas-line); }
.atlas-home-rows li:last-child { border-bottom: 0; }
.atlas-home-rows .lbl { font-size: 13px; color: var(--atlas-muted); }
.atlas-home-rows .val { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.atlas-home-rows .val .delta { font-size: 12px; font-weight: 600; margin-left: 6px; }
.atlas-home-rows .val .delta.up { color: var(--atlas-ok); }
.atlas-home-rows .val .delta.down { color: var(--atlas-bad); }
.atlas-link { color: var(--atlas-accent); text-decoration: none; font-size: 13px; font-weight: 500; }
.atlas-link:hover { text-decoration: underline; }

/* A table is one frame: title and note in its header, the provenance in its footer, no card around it */
.atlas-tableframe { background: var(--atlas-card); border: 1px solid var(--atlas-line); border-radius: var(--atlas-radius); box-shadow: var(--atlas-shadow); overflow: hidden; }
.atlas-tableframe .fi-ta-ctn { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.atlas-tableframe .fi-ta-header { padding: 16px 20px 4px; }
.atlas-tableframe .fi-ta-header-heading { font-size: 15px; font-weight: 600; line-height: 1.35; }
.atlas-tableframe .fi-ta-header-description { font-size: 13px; color: var(--atlas-muted); }
.atlas-tablefoot { display: flex; justify-content: flex-end; padding: 8px 20px 12px; border-top: 1px solid var(--atlas-line); }
.atlas-tablefoot .atlas-prov { margin-top: 0; }
