/* Repair Relay — shared visual design system (instrument-panel aesthetic).
   Two finishes, one system: dark is the default, :root[data-theme="light"]
   overrides to light. Everything reads a token — no screen hard-codes a color.
   This file is the single source of truth for look & feel; per-page <style>
   blocks should only hold true one-off layout, never colors/fonts. */

/* ---- Typeface: IBM Plex, self-hosted (no CDN). Latin subset, the three
   weights the system uses. font-display:swap so text paints immediately in the
   fallback and re-flows to Plex when it arrives. ---- */
@font-face{font-family:"IBM Plex Sans";font-style:normal;font-weight:400;font-display:swap;src:url("fonts/ibm-plex-sans-400.woff2") format("woff2");}
@font-face{font-family:"IBM Plex Sans";font-style:normal;font-weight:500;font-display:swap;src:url("fonts/ibm-plex-sans-500.woff2") format("woff2");}
@font-face{font-family:"IBM Plex Sans";font-style:normal;font-weight:600;font-display:swap;src:url("fonts/ibm-plex-sans-600.woff2") format("woff2");}
@font-face{font-family:"IBM Plex Mono";font-style:normal;font-weight:400;font-display:swap;src:url("fonts/ibm-plex-mono-400.woff2") format("woff2");}
@font-face{font-family:"IBM Plex Mono";font-style:normal;font-weight:500;font-display:swap;src:url("fonts/ibm-plex-mono-500.woff2") format("woff2");}
@font-face{font-family:"IBM Plex Mono";font-style:normal;font-weight:600;font-display:swap;src:url("fonts/ibm-plex-mono-600.woff2") format("woff2");}

:root{
  /* shared, theme-independent */
  --r:8px; --r-sm:6px;
  --font:"IBM Plex Sans",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,"SFMono-Regular",Menlo,monospace;

  /* DARK — the default finish (carbon fiber) */
  --bg:#0a0b0d; --panel:#15171c; --panel-2:#1f232a; --panel-inset:#101216;
  --ink:#f3f5f7; --ink-2:#aeb5be; --muted:#767e88;
  --line:rgba(255,255,255,.125); --line-2:rgba(255,255,255,.065);
  --brand:#060708; --brand-2:#15181d; --brand-ink:#f3f5f7; --brand-ink-2:#8a919b; --brand-line:#000;
  --amber:#e2a844; --amber-soft:rgba(226,168,68,.16); --amber-hi:#eeb857; --amber-ink:#20160a;
  --chip:#232830; --chip-ink:#aab1bb;
  --good:#3bc57f; --good-bg:rgba(59,197,127,.14);
  --warn:#e0a840; --warn-bg:rgba(224,168,64,.15);
  --info:#5f9ce4; --info-bg:rgba(95,156,228,.15);
  --crit:#e56a5c; --crit-bg:rgba(229,106,92,.15);
  --shadow:0 16px 40px rgba(0,0,0,.42), 0 1px 0 rgba(255,255,255,.04) inset, 0 0 0 1px rgba(0,0,0,.4);
  --tex:rgba(255,255,255,.014);
  /* carbon-fiber weave, used by body::before in dark mode */
  --weave:
    repeating-linear-gradient(45deg,  rgba(255,255,255,.021) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.30)         0 1px, transparent 1px 5px),
    radial-gradient(135% 100% at 50% 38%, transparent 58%, rgba(0,0,0,.55) 100%);
  --sheen:linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,0) 46%);
}
:root[data-theme="light"]{
  --weave:none; --sheen:none;
  --bg:#f4f5f6; --panel:#ffffff; --panel-2:#f7f8f9; --panel-inset:#f0f2f4;
  --ink:#1a1c1f; --ink-2:#565a60; --muted:#8b9097;
  --line:rgba(24,27,31,.11); --line-2:rgba(24,27,31,.06);
  --brand:#181c22; --brand-2:#232932; --brand-ink:#f3f4f6; --brand-ink-2:#9aa1ab; --brand-line:#0b0d10;
  --amber:#b27d22; --amber-soft:rgba(178,125,34,.12); --amber-hi:#c68e2c; --amber-ink:#fff;
  --chip:#eceef0; --chip-ink:#5b616a;
  --good:#1c8f4e; --good-bg:#e7f1ea;
  --warn:#976c15; --warn-bg:#f2e9d3;
  --info:#2c69b3; --info-bg:#e8eff8;
  --crit:#b23a30; --crit-bg:#f6e8e6;
  --shadow:0 12px 28px rgba(24,27,31,.07), 0 1px 0 rgba(255,255,255,.7) inset;
  --tex:rgba(24,27,31,.022);
}

/* ---- base ---- */
*{box-sizing:border-box;}
html,body{margin:0;}
body{font-family:var(--font); background:var(--bg); color:var(--ink); font-size:14px; line-height:1.45;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;}
/* Carbon-fiber weave — a fixed, subtle overlay behind all content. Dark only;
   light mode sets --weave:none and keeps a faint dot texture. */
body::before{content:""; position:fixed; inset:0; z-index:-1; pointer-events:none;
  background-color:var(--bg); background-image:var(--weave);
  background-size:5px 5px, 5px 5px, 100% 100%;}
:root[data-theme="light"] body::before{
  background-image:radial-gradient(var(--tex) 1px, transparent 0); background-size:5px 5px;}
a{color:inherit; text-decoration:none;}
:focus-visible{outline:2px solid var(--amber); outline-offset:2px; border-radius:3px;}
.mono{font-family:var(--mono); font-variant-numeric:tabular-nums;}
.tnum{font-variant-numeric:tabular-nums;}

/* ---- Header (brand bar) ---- */
.hdr{background:var(--brand); color:var(--brand-ink); height:58px; display:flex; align-items:center; justify-content:space-between; padding:0 22px; border-bottom:1px solid var(--brand-line);}
.brand{display:flex; align-items:center; gap:12px;}
.brand .logo{width:30px; height:30px; border-radius:7px; background:linear-gradient(180deg,#20252d,#161a20); display:flex; align-items:center; justify-content:center; box-shadow:inset 0 0 0 1px rgba(255,255,255,.08), inset 0 1px 0 rgba(255,255,255,.06); flex:0 0 auto;}
.brand .logo svg{width:17px; height:17px; stroke:var(--amber); fill:none;}
.brand .name{font-weight:600; font-size:14.5px; color:var(--brand-ink);}
.brand .sub{font-size:9.5px; color:var(--brand-ink-2); margin-top:2px; font-weight:600; letter-spacing:1.7px; font-family:var(--mono); text-transform:uppercase;}
.hdr-right{display:flex; align-items:center; gap:6px;}
/* padding:0 is explicit so a page-level `button{padding:…}` rule can't crush the
   fixed 32px box and shrink the icon to a sliver (box-sizing:border-box). */
.icobtn{width:32px; height:32px; padding:0; display:flex; align-items:center; justify-content:center; border-radius:7px; color:var(--brand-ink-2); cursor:pointer; border:1px solid transparent; background:transparent; flex:0 0 auto;}
.icobtn:hover{background:rgba(255,255,255,.07); color:var(--brand-ink);}
.icobtn svg{width:16px; height:16px; flex:0 0 auto; stroke:currentColor; fill:none;}
.who{display:flex; align-items:center; gap:9px; padding-left:8px; margin-left:4px; border-left:1px solid rgba(255,255,255,.10);}
.who .av{width:28px; height:28px; border-radius:7px; background:var(--brand-2); color:var(--brand-ink); display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:600; font-family:var(--mono); box-shadow:inset 0 0 0 1px rgba(255,255,255,.06); flex:0 0 auto;}
.who .nm{font-size:13px; color:var(--brand-ink); font-weight:500; line-height:1.15;}
.who .rl{font-size:9.5px; color:var(--brand-ink-2); letter-spacing:1.1px; font-family:var(--mono); text-transform:uppercase;}

/* Theme toggle: show the sun in dark mode, the moon in light mode. */
.icobtn .i-moon{display:none;}
:root[data-theme="light"] .icobtn .i-sun{display:none;}
:root[data-theme="light"] .icobtn .i-moon{display:block;}

/* ---- Primary nav (tab bar with amber active underline) ---- */
.nav{background:var(--panel); border-bottom:1px solid var(--line); padding:0 22px; display:flex; align-items:center; height:50px; overflow-x:auto;}
.nav a.t{display:flex; align-items:center; gap:8px; padding:0 15px; height:50px; color:var(--ink-2); font-weight:500; font-size:13px; border-bottom:2px solid transparent; margin-bottom:-1px; white-space:nowrap;}
.nav a.t:first-child{padding-left:0;}
.nav a.t svg{width:15px; height:15px; stroke:currentColor; fill:none; opacity:.65;}
.nav a.t:hover{color:var(--ink);}
.nav a.t.on{color:var(--ink); border-bottom-color:var(--amber); font-weight:600;}
.nav a.t.on svg{opacity:1; stroke:var(--amber);}
.nav .spacer{flex:1;}

/* ---- Overflow "More" menu — button + popover, NEVER a native <select> ---- */
.more{position:relative;}
.more>button{display:flex; align-items:center; gap:7px; height:33px; padding:0 12px; border:1px solid var(--line); background:var(--panel); color:var(--ink-2); border-radius:7px; font:inherit; font-size:13px; font-weight:500; cursor:pointer;}
.more>button:hover{background:var(--panel-2); color:var(--ink);}
.more>button svg{width:13px; height:13px; stroke:currentColor; fill:none;}
.menu{position:absolute; right:0; top:42px; background:var(--panel); border:1px solid var(--line); border-radius:9px; box-shadow:0 12px 30px rgba(0,0,0,.18); padding:6px; min-width:172px; z-index:20; display:none;}
.menu.open{display:block;}
.menu a{display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:6px; color:var(--ink); font-size:13px;}
.menu a svg{width:15px; height:15px; stroke:var(--muted); fill:none;}
.menu a:hover{background:var(--panel-2);}

/* ---- Page shell ---- */
.wrap{max-width:1180px; margin:0 auto; padding:26px 22px 64px;}
.page-h{display:flex; align-items:flex-end; justify-content:space-between; margin:0 2px 20px; gap:16px; flex-wrap:wrap;}
.page-h .greet{font-size:22px; font-weight:600; margin:0; letter-spacing:-.4px;}
.page-h .sub{font-size:12.5px; color:var(--ink-2); margin-top:3px;}
.page-h .sub b{color:var(--ink); font-weight:600;}
.stamp{text-align:right; font-family:var(--mono); font-size:11px; color:var(--muted); letter-spacing:.4px; line-height:1.5;}
.stamp .d{color:var(--ink-2); font-weight:500;}

/* Layout helpers */
.grid-2{display:grid; grid-template-columns:1fr 1fr; gap:16px;}
.grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:16px;}
@media(max-width:820px){.grid-2,.grid-3{grid-template-columns:1fr;}}
.stack{display:flex; flex-direction:column; gap:16px;}
.row{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}

/* ---- Instrument cluster (KPI readout — ONE panel, hairline-divided cells) ---- */
.cluster{background:var(--panel); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow); display:grid; grid-template-columns:repeat(6,1fr); overflow:hidden; margin-bottom:16px;}
@media(max-width:960px){.cluster{grid-template-columns:repeat(3,1fr);}}
@media(max-width:560px){.cluster{grid-template-columns:repeat(2,1fr);}}
.gauge{padding:15px 17px 16px; border-left:1px solid var(--line-2); position:relative;}
.gauge:first-child{border-left:0;}
.gauge .lab{font-size:9.5px; font-weight:600; letter-spacing:1px; color:var(--muted); font-family:var(--mono); text-transform:uppercase; display:flex; align-items:center; gap:6px; margin-bottom:12px;}
.gauge .lab svg{width:13px; height:13px; stroke:currentColor; fill:none; opacity:.85;}
.gauge .val{font-family:var(--mono); font-size:27px; font-weight:500; line-height:1; color:var(--ink); font-variant-numeric:tabular-nums; letter-spacing:-.5px;}
.gauge .val .u{font-size:15px; color:var(--muted); font-weight:400;}
.gauge .foot{margin-top:9px; font-size:10.5px; font-family:var(--mono); color:var(--muted); letter-spacing:.2px; display:flex; align-items:center; gap:5px; min-height:13px;}
.gauge .foot.up{color:var(--good);} .gauge .foot.attn{color:var(--warn);}
.gauge .foot svg{width:11px; height:11px; stroke:currentColor; fill:none;}
.gauge.hot::before{content:""; position:absolute; left:-1px; top:14px; bottom:14px; width:2px; background:var(--amber); border-radius:2px;}

/* ---- Panels (every card in the app) ---- */
.panel{background:var(--panel); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow);}
.panel .ph{display:flex; align-items:center; justify-content:space-between; padding:13px 16px; border-bottom:1px solid var(--line-2); gap:10px;}
.panel .ph h2{font-size:11px; font-weight:600; margin:0; letter-spacing:1.1px; text-transform:uppercase; color:var(--ink-2); font-family:var(--mono);}
.panel .ph .lnk{font-size:11.5px; color:var(--info); font-weight:600; font-family:var(--mono); display:flex; align-items:center; gap:4px; cursor:pointer;}
.panel .pb{padding:7px;}
.panel .pb.pad{padding:16px;}

/* ---- List/attention rows ---- */
.att{display:flex; align-items:center; gap:12px; padding:11px 10px; border-radius:7px; cursor:pointer;}
.att:hover{background:var(--panel-2);}
.att + .att{border-top:1px solid var(--line-2);}
.att .ic{width:30px; height:30px; border-radius:7px; display:flex; align-items:center; justify-content:center; flex:0 0 auto;}
.att .ic svg{width:15px; height:15px; fill:none;}
.att .ic.warn{background:var(--warn-bg);} .att .ic.warn svg{stroke:var(--warn);}
.att .ic.info{background:var(--info-bg);} .att .ic.info svg{stroke:var(--info);}
.att .ic.crit{background:var(--crit-bg);} .att .ic.crit svg{stroke:var(--crit);}
.att .ic.good{background:var(--good-bg);} .att .ic.good svg{stroke:var(--good);}
.att .tx{flex:1; min-width:0;} .att .tx .t{font-size:13px; font-weight:500; color:var(--ink);} .att .tx .s{font-size:11px; color:var(--muted); margin-top:1px;}
.att .ct{font-family:var(--mono); font-size:17px; font-weight:500; color:var(--ink); font-variant-numeric:tabular-nums; min-width:18px; text-align:center;}
.att .chev{stroke:var(--muted); width:15px; height:15px; fill:none;}

/* ---- Schedule / timeline rows ---- */
.srow{display:flex; align-items:center; gap:13px; padding:12px 10px; border-radius:7px;}
.srow:hover{background:var(--panel-2);} .srow + .srow{border-top:1px solid var(--line-2);}
.srow .tm{font-family:var(--mono); font-size:11.5px; color:var(--ink-2); font-weight:500; width:52px; text-align:right; flex:0 0 auto; font-variant-numeric:tabular-nums;}
.srow .tm .live{color:var(--amber); font-weight:600;}
.srow .rail{width:9px; height:9px; border-radius:50%; flex:0 0 auto; position:relative;}
.srow .rail.on{background:var(--amber);} .srow .rail.on::after{content:""; position:absolute; inset:-4px; border-radius:50%; border:1px solid var(--amber); opacity:.4;}
.srow .rail.next{background:transparent; box-shadow:inset 0 0 0 1.5px var(--muted);}
.srow .mid{flex:1; min-width:0;} .srow .mid .t{font-size:13px; font-weight:600; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} .srow .mid .c{font-size:11.5px; color:var(--muted); margin-top:1px;}
.srow .tech{font-size:11.5px; color:var(--ink-2); display:flex; align-items:center; gap:7px; flex:0 0 auto;}
.srow .tech .d{width:22px; height:22px; border-radius:6px; background:var(--chip); color:var(--chip-ink); font-size:9.5px; font-weight:600; font-family:var(--mono); display:flex; align-items:center; justify-content:center;}

/* ---- Status pills (map to job lifecycle) ---- */
.pill{display:inline-flex; align-items:center; gap:5px; font-size:9.5px; font-weight:600; padding:4px 8px; border-radius:6px; letter-spacing:.7px; text-transform:uppercase; font-family:var(--mono);}
.pill .dot{width:5px; height:5px; border-radius:50%;}
.pill.onsite{background:var(--info-bg); color:var(--info);} .pill.onsite .dot{background:var(--info);}
.pill.sched{background:var(--chip); color:var(--chip-ink);} .pill.sched .dot{background:var(--muted);}
.pill.good{background:var(--good-bg); color:var(--good);} .pill.good .dot{background:var(--good);}
.pill.warn{background:var(--warn-bg); color:var(--warn);} .pill.warn .dot{background:var(--warn);}
.pill.crit{background:var(--crit-bg); color:var(--crit);} .pill.crit .dot{background:var(--crit);}
.pill.info{background:var(--info-bg); color:var(--info);} .pill.info .dot{background:var(--info);}

/* ---- Buttons ---- */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; height:40px; padding:0 16px; border-radius:8px; font:inherit; font-size:13px; font-weight:600; cursor:pointer; border:1px solid transparent; transition:background .13s ease, box-shadow .13s ease, transform .04s ease;}
.btn svg{width:16px; height:16px; stroke:currentColor; fill:none;}
.btn:active{transform:translateY(1px);}
/* Primary = the amber accent, so the main action always reads first. */
.btn.primary{background:var(--amber); color:var(--amber-ink); box-shadow:inset 0 1px 0 rgba(255,255,255,.28), 0 4px 14px rgba(226,168,68,.24);}
.btn.primary:hover{background:var(--amber-hi);}
.btn.primary svg{stroke:var(--amber-ink);}
/* Dark, understated action (former primary look) for secondary emphasis. */
.btn.dark{background:var(--brand); color:var(--brand-ink); box-shadow:inset 0 1px 0 rgba(255,255,255,.07);}
.btn.dark:hover{background:var(--brand-2);}
.btn.ghost{background:var(--panel); color:var(--ink); border-color:var(--line);}
.btn.ghost:hover{background:var(--panel-2); border-color:var(--muted);} .btn.ghost svg{stroke:var(--muted);}
.btn.danger{background:var(--crit); color:#fff; box-shadow:0 4px 14px rgba(229,106,92,.22);}
.btn.sm{height:32px; padding:0 11px; font-size:12.5px; border-radius:7px;}
.btn.block{width:100%;}
.btn:disabled{opacity:.55; cursor:default;}

/* ---- Forms — inputs + the native-select fix ---- */
.field{display:flex; flex-direction:column; gap:6px; margin-bottom:14px;}
.field label{font-size:10.5px; font-weight:600; letter-spacing:.6px; text-transform:uppercase; color:var(--muted); font-family:var(--mono);}
.input,.select select,textarea.input{background:var(--panel-inset); border:1px solid var(--line); border-radius:var(--r-sm); color:var(--ink); height:38px; padding:0 11px; font:inherit; font-size:14px; width:100%;}
textarea.input{height:auto; padding:10px 11px; resize:vertical;}
.input::placeholder{color:var(--muted);}
.input:focus,.select select:focus,textarea.input:focus{outline:none; border-color:var(--amber); box-shadow:0 0 0 3px var(--amber-soft);}
/* GLOBAL native-select fix — every <select> anywhere (wrapped in .select or not,
   any page, both themes) is appearance:none with a custom caret, so no OS spinner
   arrows ever render. Bare selects get a data-URI caret; .select-wrapped selects
   drop it in favor of the .select::after triangle (no double caret). */
select{-webkit-appearance:none; -moz-appearance:none; appearance:none; padding-right:30px; cursor:pointer;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5l3 3 3-3' stroke='%238b9097' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat:no-repeat; background-position:right 11px center; background-size:10px;}
.select{position:relative;}
.select select{padding-right:34px; background-image:none;}
.select::after{content:""; position:absolute; right:13px; top:50%; width:9px; height:9px; margin-top:-6px; pointer-events:none;
  border-right:1.6px solid var(--muted); border-bottom:1.6px solid var(--muted); transform:rotate(45deg);}
.hint{font-size:11.5px; color:var(--muted); margin-top:2px;}
.err{font-size:12.5px; color:var(--crit); font-weight:500;}
.ok{font-size:12.5px; color:var(--good); font-weight:500;}

/* ---- Data tables ---- */
.tbl{width:100%; border-collapse:collapse; font-size:13px;}
.tbl th{font-family:var(--mono); font-size:10px; font-weight:600; letter-spacing:.8px; text-transform:uppercase; color:var(--muted); text-align:left; padding:10px 12px; border-bottom:1px solid var(--line);}
.tbl td{padding:11px 12px; border-bottom:1px solid var(--line-2); color:var(--ink);}
.tbl tr:hover td{background:var(--panel-2);}
.tbl .num{font-family:var(--mono); font-variant-numeric:tabular-nums; text-align:right;}
.tbl-wrap{overflow-x:auto;}

/* ---- Empty states ---- */
.empty{padding:40px 20px; text-align:center; color:var(--muted);}
.empty svg{width:34px; height:34px; stroke:var(--muted); fill:none; opacity:.5; margin-bottom:10px;}

/* ---- Auth / single-panel screens ---- */
.auth-plane{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;}
.auth-card{width:100%; max-width:400px;}
.auth-card .panel{padding:26px 24px;}
.auth-card .brand{justify-content:center; margin-bottom:20px;}
.auth-h{font-size:19px; font-weight:600; margin:0 0 4px; letter-spacing:-.3px;}
.auth-sub{font-size:12.5px; color:var(--ink-2); margin:0 0 20px;}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce){
  *{animation:none !important; transition:none !important;}
  .srow .rail.on::after{animation:none !important;}
}

/* ---- carbon-fiber finish: brushed sheen on cards (dark only via --sheen).
   Placed at the end so it layers over the .panel/.cluster background color
   without the earlier `background:` shorthand resetting it. ---- */
.panel, .cluster, .menu{ background-image:var(--sheen); background-repeat:no-repeat; }
