/* Fecon Insights design tokens and components. Moved verbatim from the Mulcher Tool Life dashboard (Phase 1). */
/* =====================================================================
   BRAND TOKENS: PLACEHOLDER VALUES
   Drop real Fecon brand colors in here. Everything else derives from them.
   ===================================================================== */
:root{
  --brand-red:#c4161c;            /* Fecon red: primary buttons, utility strip, chart accent */
  --brand-red-dark-ui:#ff6b63;    /* red used as text/lines on dark surfaces                 */
  --brand-chrome:#0a0a0a;         /* black top bar                                           */
}
/* ===================== end brand block ===================== */

/* ---------- Design tokens: light (default) ---------- */
:root{
  color-scheme:light;
  --font:"Roboto",system-ui,-apple-system,"Segoe UI","Helvetica Neue",Arial,sans-serif;
  --font-display:"Roboto Condensed","Roboto","Arial Narrow",system-ui,sans-serif;
  --radius:2px;
  --bg:#e9e9e9; --surface:#ffffff; --surface-2:#f4f4f4;
  --border:#dcdcdc; --border-strong:#bdbdbd;
  --text:#111111; --text-2:#3d3d3d; --text-3:#666666;
  --accent:var(--brand-red); --accent-weak:#fbe8e8; --on-accent:#ffffff; --focus:#c4161c;
  --primary:var(--brand-red); --chrome:var(--brand-chrome); --chrome-text:#ffffff; --chrome-text-2:#a8a8a8;
  /* status: always paired with icon + label */
  --ok:#17723a; --ok-bg:#e5f4ea; --watch:#7d5300; --watch-bg:#fff1cc; --bad:#a3141a; --bad-bg:#fdeceb; --unk:#666666; --unk-bg:#eeeeee;
  /* charts */
  --grid:#ececec; --map-empty:#e3e3e3; --map-line:#ffffff;
  --seq-1:#fde0de; --seq-2:#f4a39f; --seq-3:#e2574f; --seq-4:#b81b1f; --seq-5:#7a0f12;
  --cat-1:#c4161c; --cat-2:#3d4a5c; --cat-3:#1baf7a; --cat-4:#eda100; --cat-5:#2a78d6; --cat-6:#6250d6; --cat-7:#e87ba4; --cat-8:#008300;
  --evt-tool:#111111; --evt-swap:#6250d6; --evt-site:#008300;
  --band-alpha:.08;
  --shadow:none;
}
/* ---------- Dark (follows OS unless the user forces light) ---------- */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme:dark;
    --bg:#0d0d0d; --surface:#171717; --surface-2:#1f1f1f; --border:#2c2c2c; --border-strong:#404040;
    --text:#ededed; --text-2:#bdbdbd; --text-3:#9a9a9a;
    --accent:var(--brand-red-dark-ui); --accent-weak:#3a1515; --on-accent:#ffffff; --focus:#ff8a84;
    --primary:#d42a24; --chrome:#000000;
    --ok:#5cc77a; --ok-bg:#13301d; --watch:#efc14f; --watch-bg:#33280c; --bad:#ff8077; --bad-bg:#3b1614; --unk:#a8a8a8; --unk-bg:#262626;
    --grid:#262626; --map-empty:#262626; --map-line:#171717;
    --seq-1:#4a1214; --seq-2:#7f1a1c; --seq-3:#c4302b; --seq-4:#ef6a62; --seq-5:#f9b4ae;
    --cat-1:#ff6b63; --cat-2:#8b9bb0; --cat-3:#199e70; --cat-4:#c98500; --cat-5:#3987e5; --cat-6:#9085e9; --cat-7:#d55181; --cat-8:#2fa82f;
    --evt-tool:#ededed; --evt-swap:#9085e9; --evt-site:#2fa82f;
    --band-alpha:.16; --shadow:none;
  }
}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0d0d0d; --surface:#171717; --surface-2:#1f1f1f; --border:#2c2c2c; --border-strong:#404040;
  --text:#ededed; --text-2:#bdbdbd; --text-3:#9a9a9a;
  --accent:var(--brand-red-dark-ui); --accent-weak:#3a1515; --on-accent:#ffffff; --focus:#ff8a84;
  --primary:#d42a24; --chrome:#000000;
  --ok:#5cc77a; --ok-bg:#13301d; --watch:#efc14f; --watch-bg:#33280c; --bad:#ff8077; --bad-bg:#3b1614; --unk:#a8a8a8; --unk-bg:#262626;
  --grid:#262626; --map-empty:#262626; --map-line:#171717;
  --seq-1:#4a1214; --seq-2:#7f1a1c; --seq-3:#c4302b; --seq-4:#ef6a62; --seq-5:#f9b4ae;
  --cat-1:#ff6b63; --cat-2:#8b9bb0; --cat-3:#199e70; --cat-4:#c98500; --cat-5:#3987e5; --cat-6:#9085e9; --cat-7:#d55181; --cat-8:#2fa82f;
  --evt-tool:#ededed; --evt-swap:#9085e9; --evt-site:#2fa82f;
  --band-alpha:.16; --shadow:none;
}

/* ---------- Base ---------- */
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font:14px/1.5 var(--font);font-variant-numeric:tabular-nums;overflow-x:hidden}
h1,h2,h3,p{margin:0}
h1{font-family:var(--font-display);font-size:30px;line-height:1.1;font-weight:800;text-transform:uppercase;letter-spacing:0}
h2{font-size:15px;line-height:1.3;font-weight:700}
h3{font-size:12px;font-weight:650;color:var(--text-2);text-transform:uppercase;letter-spacing:.05em}
a{color:var(--accent)}
.sr-only{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.skip{position:absolute;left:-9999px;top:8px;z-index:100;background:var(--surface);color:var(--text);padding:8px 12px;border-radius:8px;border:1px solid var(--border)}
.skip:focus{left:16px}
:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.muted{color:var(--text-3)}
.ic{width:16px;height:16px;flex:none;fill:currentColor}
.wrap{max-width:1440px;margin:0 auto;padding:0 24px}
@media (max-width:640px){.wrap{padding:0 16px}}

/* ---------- Header & filters ---------- */
.utility{background:var(--primary);color:#fff}
.utility .wrap{display:flex;justify-content:flex-end;align-items:center;min-height:24px}
.updated{font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#fff}
.app-header{background:var(--chrome);color:var(--chrome-text)}
.titlebar{display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:56px;padding:8px 0;flex-wrap:wrap}
.brand{display:flex;gap:16px;align-items:center;min-width:0}
.wordmark{font-family:var(--font-display);font-weight:900;font-style:italic;font-size:26px;letter-spacing:.01em;line-height:1;color:#fff}
.brand .divider{width:1px;height:20px;background:#3a3a3a}
.product{font-size:11px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;color:var(--chrome-text-2)}
.app-header .btn{background:transparent;color:#fff;border-color:#fff}
.app-header .btn:hover{background:rgba(255,255,255,.1)}
.pagehead{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap;padding:24px 0 16px}
.sub{margin-top:4px;color:var(--text-3);font-size:13px}
.header-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.filters{display:flex;flex-wrap:wrap;gap:12px 16px;align-items:flex-end;padding:0 0 4px}
.field{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--text-2);font-weight:500}
.field.grow{flex:1 1 220px}
.field[hidden]{display:none}
select,input[type=date],input[type=search]{font:inherit;font-size:13px;color:var(--text);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius);height:34px;padding:0 10px;min-width:0;max-width:100%}
select{min-width:150px}
input[type=search]{width:100%}
.range-custom{display:flex;gap:8px;align-items:flex-end}
.range-custom[hidden]{display:none}
.filter-note{font-size:12px;color:var(--text-3);align-self:center}
.btn{font:inherit;font-size:12px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:34px;padding:0 12px;border-radius:var(--radius);border:1px solid var(--text);background:var(--surface);color:var(--text);cursor:pointer;white-space:nowrap}
.btn:hover{background:var(--surface-2)}
.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn.primary:hover{filter:brightness(1.1)}
.btn.lg{height:40px;padding:0 18px;font-size:14px}
.btn.lg .ic{width:20px;height:20px}
.btn.sm{height:24px;padding:0 8px;font-size:10.5px;font-weight:500;letter-spacing:.06em;border-color:var(--text-3)}
.btn.ghost{border-color:transparent;background:transparent;color:var(--accent)}
.btn.ghost:hover{background:var(--accent-weak)}
.btn[aria-pressed="true"]{background:var(--accent-weak);border-color:var(--accent);color:var(--accent)}
.chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 4px 0 10px;border-radius:999px;background:var(--accent-weak);color:var(--accent);font-size:12px;font-weight:600}
.chip button{all:unset;cursor:pointer;width:20px;height:20px;display:grid;place-items:center;border-radius:50%}
.chip button:hover{background:rgba(127,127,127,.18)}
.chip button:focus-visible{outline:2px solid var(--focus)}

/* ---------- Banner ---------- */
.banner{margin:16px 0 0;padding:12px 16px;border-radius:8px;border:1px solid var(--border-strong);background:var(--surface);display:flex;gap:12px;align-items:flex-start;flex-wrap:wrap;font-size:13px}
.banner.sample{border-color:var(--watch);background:var(--watch-bg)}
.banner .tag{font-weight:800;letter-spacing:.08em;color:var(--watch);font-size:12px;padding-top:1px}
.banner .msg{flex:1 1 320px;color:var(--text)}
.banner code{font-size:12px;background:var(--surface-2);padding:1px 4px;border-radius:4px}

/* ---------- Layout ---------- */
main{display:flex;flex-direction:column;gap:20px}
main.wrap{padding-top:20px;padding-bottom:48px}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 20px;box-shadow:var(--shadow);min-width:0}
@media (max-width:640px){.card{padding:16px}}
.card-head{display:flex;justify-content:space-between;align-items:flex-start;gap:8px 16px;margin-bottom:16px;flex-wrap:wrap}
.card-head .actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.hint{margin-top:2px;color:var(--text-3);font-size:12px}
.grid-2{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:24px}
@media (max-width:1100px){.grid-2{grid-template-columns:minmax(0,1fr)}}

/* ---------- KPI cards ---------- */
.kpis{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:16px}
@media (max-width:1200px){.kpis{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:760px){.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:430px){.kpis{grid-template-columns:minmax(0,1fr)}}
.kpi{display:flex;flex-direction:column;gap:4px;padding:16px;min-height:150px}
.kpi{border-color:transparent}
.kpi-label{font-size:13px;color:var(--text);font-weight:400}
.kpi-value{font-size:30px;font-weight:700;letter-spacing:-.01em;line-height:1.15}
.kpi-value .unit{font-size:14px;font-weight:500;color:var(--text-3);margin-left:4px;letter-spacing:0}
.kpi-delta{font-size:12px;color:var(--text-2)}
.kpi-sub{font-size:12px;color:var(--text-3)}
.kpi .spark{margin-top:auto}
.spark{display:block;width:100%;height:32px;overflow:visible}
.spark .line{fill:none;stroke:var(--accent);stroke-width:1.75;vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round}
.spark .area{fill:var(--accent);opacity:.08}
.spark .bar{fill:var(--accent);opacity:.6}
.spark .base{stroke:var(--border-strong);stroke-width:1;vector-effect:non-scaling-stroke}
.spark-empty{margin-top:auto;font-size:11px;color:var(--text-3);height:32px;display:flex;align-items:flex-end}
.mini-spark{width:88px;height:22px;display:inline-block;vertical-align:middle}
.mini-spark .line{stroke:var(--text-3);stroke-width:1.5}
.mini-spark .ref{stroke:var(--border-strong);stroke-dasharray:2 2;stroke-width:1;vector-effect:non-scaling-stroke}

/* ---------- Charts ---------- */
.chart-wrap{position:relative}
.chart{width:100%;height:340px}
.chart.map{height:380px}
.chart.short{height:260px}
@media (max-width:640px){.chart{height:280px}.chart.map{height:250px}.chart.short{height:220px}}
.chart-wrap .skel-fill{position:absolute;inset:0;display:none}
.chart-wrap.loading .skel-fill{display:block}
.chart-wrap.loading .chart{visibility:hidden}
.empty{padding:32px 16px;text-align:center;color:var(--text-2);border:1px dashed var(--border-strong);border-radius:8px;background:var(--surface-2);font-size:13px}
.empty strong{display:block;color:var(--text);margin-bottom:4px;font-size:14px}
.chart-note{font-size:12px;color:var(--text-3);margin-top:8px}
.stat-line{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;color:var(--text-2)}
.stat-line b{color:var(--text);font-weight:650}
.toggle{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--text-2);cursor:pointer}
.toggle input{width:16px;height:16px;accent-color:var(--accent)}

/* ---------- Tables ---------- */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--border);border-radius:var(--radius);max-width:100%}
.table-wrap.tall{max-height:640px;overflow-y:auto}
table{border-collapse:collapse;width:100%;font-size:12.5px}
th,td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--border);white-space:nowrap;vertical-align:middle}
thead th{position:sticky;top:0;background:var(--surface-2);font-size:12px;font-weight:500;color:var(--text);z-index:1}
td.act{text-align:right;width:1%}
th.num,td.num{text-align:right}
tbody tr:last-child td{border-bottom:0}
tbody tr{cursor:pointer}
tbody tr:hover{background:var(--surface-2)}
tbody tr.selected{background:var(--accent-weak)}
tbody tr.static{cursor:default}
tbody tr.static:hover{background:transparent}
button.sort{all:unset;cursor:pointer;display:inline-flex;gap:4px;align-items:center;border-radius:4px}
button.sort:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
button.sort .ind{font-size:10px;color:var(--text-3);width:8px}
th[aria-sort] button.sort{color:var(--text)}
th[aria-sort] .ind{color:var(--accent)}
.rowlink{all:unset;cursor:pointer;color:var(--text);font-weight:500;border-radius:2px}
.rowlink:hover{color:var(--accent);text-decoration:underline}
.rowlink:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.cell-sub{font-size:11px;color:var(--text-3)}
.wearcell{display:inline-flex;align-items:center;gap:8px;justify-content:flex-end}
.wearcell .v{min-width:28px;text-align:right;font-weight:650}
.pill{display:inline-flex;align-items:center;gap:4px;padding:2px 8px 2px 6px;border-radius:2px;font-size:12px;font-weight:650;line-height:18px}
.pill .ic{width:14px;height:14px}
.pill.ok{color:var(--ok);background:var(--ok-bg)}
.pill.watch{color:var(--watch);background:var(--watch-bg)}
.pill.bad{color:var(--bad);background:var(--bad-bg)}
.pill.unk{color:var(--unk);background:var(--unk-bg)}
.conf{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--text-2)}
.conf .bars{display:inline-flex;gap:2px;align-items:flex-end;height:12px}
.conf .bars i{display:block;width:3px;border-radius:1px;background:var(--border-strong)}
.conf .bars i:nth-child(1){height:5px}.conf .bars i:nth-child(2){height:8px}.conf .bars i:nth-child(3){height:12px}
.conf .bars i.on{background:var(--text-2)}
.rangecell{display:inline-flex;align-items:center;gap:8px}
.rangecell svg{display:block}
.rangecell .rb-track{stroke:var(--border-strong);stroke-width:1}
.rangecell .rb-bar{fill:var(--accent);opacity:.35}
.rangecell .rb-med{stroke:var(--accent);stroke-width:2}
.lifebar{display:inline-flex;align-items:center;gap:8px;justify-content:flex-end}
.lifebar .track{width:56px;height:6px;border-radius:3px;background:var(--surface-2);border:1px solid var(--border);overflow:hidden;display:inline-block}
.lifebar .fill{display:block;height:100%;background:var(--text-3)}
.lifebar .fill.watch{background:var(--watch)}
.lifebar .fill.bad{background:var(--bad)}
.table-foot{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-top:8px;font-size:12px;color:var(--text-3)}
.evt{display:inline-flex;align-items:center;gap:6px;font-weight:600}
.evt.tool .ic{color:var(--evt-tool)}
.evt.swap .ic{color:var(--evt-swap)}
.evt.site .ic{color:var(--evt-site)}
.status-counts{display:flex;gap:8px;flex-wrap:wrap}

/* ---------- Skeletons ---------- */
.skel{background:linear-gradient(90deg,var(--surface-2) 25%,var(--border) 37%,var(--surface-2) 63%);background-size:400% 100%;animation:shimmer 1.4s ease infinite;border-radius:6px}
.skel.line{height:12px;margin:6px 0}
.skel.big{height:28px;width:55%;margin:8px 0}
@keyframes shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}
@media (prefers-reduced-motion:reduce){.skel{animation:none}}

/* ---------- Methodology ---------- */
details.method summary{cursor:pointer;font-weight:650;font-size:16px;list-style:none;display:flex;align-items:center;gap:8px}
details.method summary::-webkit-details-marker{display:none}
details.method summary .chev{transition:transform .15s}
details.method[open] summary .chev{transform:rotate(90deg)}
details.method .body{margin-top:12px;color:var(--text-2);max-width:880px;display:flex;flex-direction:column;gap:8px}
.legend-keys{display:flex;flex-wrap:wrap;gap:8px 16px;font-size:12px;color:var(--text-2)}
.legend-keys span{display:inline-flex;align-items:center;gap:6px}
.key-line{width:18px;height:0;border-top:2px solid var(--evt-tool)}
.key-line.dash{border-top:2px dashed var(--evt-swap)}
.key-line.dot{border-top:2px dotted var(--evt-site)}
.key-band{width:16px;height:12px;border-radius:2px;background:var(--cat-1);opacity:.25}

/* ---------- Drawer ---------- */
.backdrop{position:fixed;inset:0;background:rgba(10,14,20,.42);z-index:40}
.drawer{position:fixed;top:0;right:0;bottom:0;width:min(860px,100vw);background:var(--bg);border-left:1px solid var(--border);z-index:41;display:flex;flex-direction:column;box-shadow:-12px 0 40px rgba(0,0,0,.14)}
.drawer[hidden],.backdrop[hidden]{display:none}
.drawer-head{padding:16px 20px;background:var(--surface);border-bottom:1px solid var(--border);display:flex;gap:12px;align-items:flex-start;justify-content:space-between}
.drawer-head h2{font-family:var(--font-display);font-size:24px;font-weight:800;text-transform:uppercase}
.drawer-head .meta{color:var(--text-3);font-size:13px;margin-top:2px}
.drawer-body{overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:16px}
@media (max-width:640px){.drawer-body{padding:16px}.drawer-head{padding:12px 16px}}
.summary{font-size:15px;line-height:1.6;background:var(--surface);border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:8px;padding:12px 16px}
.summary p+p{margin-top:4px}
.summary .small{font-size:13px;color:var(--text-2)}
.mini-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
@media (max-width:560px){.mini-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
.mini-kpi{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:8px 12px}
.mini-kpi .l{font-size:11px;color:var(--text-3);font-weight:600}
.mini-kpi .v{font-size:18px;font-weight:700}
body.drawer-open{overflow:hidden}

/* ---------- Drag & drop ---------- */
.drop-overlay{position:fixed;inset:0;z-index:60;background:rgba(20,60,120,.18);backdrop-filter:blur(2px);display:grid;place-items:center;pointer-events:none}
.drop-overlay[hidden]{display:none}
.drop-overlay .box{background:var(--surface);border:2px dashed var(--accent);border-radius:12px;padding:32px 40px;text-align:center;max-width:520px;color:var(--text)}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--text);color:var(--bg);padding:10px 16px;border-radius:8px;font-size:13px;z-index:70;max-width:calc(100vw - 32px)}
.toast[hidden]{display:none}
@media (forced-colors:active){.pill,.chip{border:1px solid CanvasText}}
