:root {
  --bg: #f4f7f1;
  --surface: #ffffff;
  --surface-soft: #f7faf2;
  --surface-track: #e9eef1;
  --border: #d7ded6;
  --border-strong: #aeb8ad;
  --text: #111315;
  --muted: #5f6872;
  --primary: #bfff00;
  --primary-soft: #efffc2;
  --primary-dark: #6f9500;
  --accent-blue: #129df0;
  --accent-blue-soft: #dff3ff;
  --ink: #050607;
  --graphite: #201e22;
  --carbon: #050607;
  --amber: #bfff00;
  --success: #11864f;
  --warning: #a87300;
  --danger: #c73b47;
  --shadow: 0 14px 34px rgba(5, 6, 7, 0.12);
  --race-stripe: repeating-linear-gradient(45deg, #050607 0 10px, #ffffff 10px 20px, #bfff00 20px 24px, #129df0 24px 28px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top right, rgba(18, 157, 240, 0.16), transparent 28rem),
    linear-gradient(135deg, rgba(5, 6, 7, 0.04) 0 25%, transparent 25% 50%, rgba(191, 255, 0, 0.07) 50% 75%, transparent 75%),
    var(--bg);
  background-size: auto, 34px 34px, auto;
  color: var(--text);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
  background: repeating-linear-gradient(0deg, rgba(17, 24, 39, 0.025) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

a { color: inherit; text-decoration: none; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--primary); color: #fff; padding: .6rem .8rem; z-index: 9999; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(191, 255, 0, 0.18), transparent 18rem),
    var(--carbon);
  border-right: 1px solid rgba(255,255,255,.08);
  color: #f8fafc;
  padding: 1.1rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 14px 0 34px rgba(17, 24, 39, .18);
}
.sidebar::after {
  content: "";
  display: block;
  height: 8px;
  margin: 1rem .5rem 0;
  background: var(--race-stripe);
  border: 1px solid rgba(255,255,255,.18);
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .65rem .55rem .95rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand img { width: 38px; height: 38px; filter: drop-shadow(0 0 12px rgba(18, 157, 240, .45)); }
.brand strong { display:block; font-size: 1.02rem; letter-spacing: -.02em; }
.brand small { color: #aab2c0; display:block; margin-top:.08rem; text-transform: uppercase; letter-spacing: .12em; font-size: .66rem; }

.nav-group { margin-top: 1rem; }
.nav-group-title {
  color: #8d99aa;
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .14em;
  margin: .8rem .55rem .55rem;
}
.nav-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  padding: .72rem .75rem;
  border-radius: 0;
  color: #d8dee8;
  margin-bottom: .28rem;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}
.nav-link::before {
  content: "";
  width: 4px;
  align-self: stretch;
  background: transparent;
  margin: -.72rem 0 -.72rem -.75rem;
}
.nav-link:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(191,255,0,.18), rgba(255,255,255,.05));
  color: #fff;
  font-weight: 700;
  border-color: rgba(18,157,240,.46);
}
.nav-link.active::before { background: var(--primary); box-shadow: 0 0 14px rgba(191,255,0,.52); }

.main { min-width: 0; }

.topbar {
  min-height: 72px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.35rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 1.12rem; text-transform: uppercase; letter-spacing: .08em; }
.topbar p { color: var(--muted); font-size: .88rem; margin-top:.16rem; }
.topbar::after {
  content: "LIVE PIT WALL";
  color: var(--primary-dark);
  border: 1px solid var(--primary);
  background: var(--primary-soft);
  font-size: .68rem;
  letter-spacing: .12em;
  padding: .34rem .55rem;
  font-weight: 800;
}

.mobile-toggle {
  display: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 0;
  padding: .48rem .65rem;
  color: var(--ink);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.content { padding: 1.2rem; }

.page-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.96));
  border: 1px solid var(--border);
  border-top: 4px solid var(--graphite);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, transparent 50%, rgba(18,157,240,.13) 50%);
  pointer-events: none;
}
.card h2, .card h3 {
  text-transform: uppercase;
  letter-spacing: .045em;
}
.card.full:first-child {
  background:
    linear-gradient(115deg, rgba(5,6,7,.97) 0 68%, rgba(18,157,240,.95) 68% 72%, rgba(191,255,0,.92) 72% 74%, rgba(32,30,34,.96) 74%),
    var(--surface);
  color: #fff;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-top-color: var(--primary);
}
.card.full:first-child p { max-width: 650px; }
.card.full:first-child p,
.card.full:first-child span { color: #d6dde8 !important; }
.card.full:first-child h2 { font-size: clamp(1.35rem, 2vw, 2.1rem); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: .8rem;
}
.kpi { border-top-color: var(--primary); }
.kpi .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing:.08em; }
.kpi .value { font-size: 1.75rem; font-weight: 900; margin-top: .18rem; letter-spacing: -.04em; }
.kpi .delta { font-size: .8rem; margin-top: .35rem; font-weight: 700; }
.delta.up { color: var(--success); }
.delta.warn { color: var(--warning); }
.delta.down { color: var(--danger); }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: .62rem .4rem;
  font-size: .9rem;
}
.table tr:hover td { background: rgba(18,157,240,.055); }
.table th { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing:.07em; font-size:.72rem; }
.table td:last-child { font-weight: 700; }

.badge { display:inline-block; padding:.24rem .48rem; border-radius:0; font-size:.72rem; font-weight:800; text-transform:uppercase; letter-spacing:.055em; border:1px solid currentColor; }
.badge.ok { background:#e8f7ef; color:#126b43; }
.badge.warn { background:#fff4dd; color:#9a6700; }
.badge.alert { background:#fdecee; color:#a61e2d; }

.split-2 { grid-column: span 6; }
.split-3 { grid-column: span 4; }
.split-4 { grid-column: span 3; }
.full { grid-column: 1 / -1; }

.footer {
  color: var(--muted);
  font-size: .85rem;
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--primary-dark); font-weight: 800; }

.muted-copy {
  color: var(--muted);
  margin-top: .45rem;
  line-height: 1.5;
}

.mechanic-slot {
  margin-left: auto;
}
.mechanic-switcher {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.mechanic-switcher select {
  appearance: none;
  border: 1px solid var(--accent-blue);
  border-radius: 0;
  background: linear-gradient(90deg, var(--primary-soft), #fff);
  color: var(--ink);
  font-weight: 900;
  padding: .46rem 2rem .46rem .65rem;
  box-shadow: 0 0 0 3px rgba(18,157,240,.08);
}
.settings-profile {
  margin-top: .85rem;
}
.settings-profile .mechanic-switcher {
  align-items: flex-start;
  flex-direction: column;
}
.mechanic-task-table tr.is-my-task td {
  background: linear-gradient(90deg, rgba(191,255,0,.25), rgba(18,157,240,.08));
  border-bottom-color: rgba(18,157,240,.28);
  font-weight: 800;
}
.mechanic-task-table tr.is-my-task td:first-child {
  box-shadow: inset 4px 0 0 var(--primary);
}
.mechanic-focus {
  color: var(--text);
  margin-top: .55rem;
  font-weight: 800;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    width: 270px;
    z-index: 50;
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-block; }
  .topbar::after { display:none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-2, .split-3, .split-4 { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .content { padding: .85rem; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: .96rem; }
  .kpi-grid { grid-template-columns: 1fr; }
  .card.full:first-child { background: linear-gradient(180deg, var(--carbon), #07131b); }
}
