:root {
  --accent: #ff6a00;
  --accent-soft: #fff1e6;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --bg: #f2f2f7;
  --card: #ffffff;
  --pass: #1f9d55;
  --fail: #d92d20;
  --warn: #d97706;
  --blue: #2563eb;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 80px 20px; text-align: center; color: var(--muted); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; display: block; flex: none; }
.brand-logo.big { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 6px 20px rgba(15, 35, 70, .25); }
.brand.stacked { flex-direction: column; gap: 12px; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
}
.btn:hover { background: #f7f7f9; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ec6200; }
.btn.danger { color: var(--fail); }
.btn.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Sign in */
.signin {
  max-width: 400px; margin: 8vh auto 0; padding: 32px;
  background: var(--card); border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.signin .brand { justify-content: center; margin-bottom: 8px; font-size: 18px; }
.signin p { text-align: center; margin: 0 0 24px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text], input[type=search], select {
  width: 100%; padding: 11px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.signin .btn.primary { width: 100%; margin-top: 22px; padding: 12px; font-size: 16px; }
.form-error { color: var(--fail); font-size: 14px; margin-top: 12px; }
.form-note { color: var(--pass); font-size: 14px; margin-top: 12px; }
.signin .foot { text-align: center; margin-top: 16px; font-size: 14px; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.crumbs { font-size: 14px; margin-bottom: 6px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; background: #e9e9ee; border-radius: 10px; padding: 3px; }
.seg button { border: none; background: none; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--ink); }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Job cards */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.job-card { display: block; background: var(--card); border-radius: var(--radius); padding: 18px; color: var(--ink); border: 1px solid transparent; }
.job-card:hover { text-decoration: none; border-color: var(--accent); }
.job-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-card .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.job-card .facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.job-card .facts .bad { color: var(--fail); }

.bar { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.bar .track { flex: 1; height: 8px; background: #ececf0; border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar .pct { font-weight: 700; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

/* Pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.pill.planned { background: #e8f0fe; color: var(--blue); }
.pill.onhold { background: #fef3c7; color: var(--warn); }
.pill.complete { background: #e7f6ec; color: var(--pass); }
.pill.pass { background: #e7f6ec; color: var(--pass); }
.pill.fail { background: #fdecea; color: var(--fail); }
.pill.retest { background: #fef3c7; color: var(--warn); }
.pill.none { background: #f0f0f3; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #f0f0f3; font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-weight: 500; opacity: .8; }

/* Cards / panels */
.panel { background: var(--card); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.panel h3 { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
dl.specs { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
dl.specs dt { color: var(--muted); }
dl.specs dd { margin: 0; }

/* Tables */
.table-wrap { background: var(--card); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafafc; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; }
tr.group td { background: #f7f7f9; font-weight: 700; font-size: 13px; }
.legs { display: flex; gap: 2px; flex-wrap: wrap; max-width: 220px; }
.leg { width: 10px; height: 10px; border-radius: 2px; background: #e2e2e7; }
.leg.pass { background: var(--pass); }
.leg.fail { background: var(--fail); }
.leg.retest { background: var(--warn); }

/* Logs and faults */
.entry { background: var(--card); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px; }
.entry .head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.entry pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }
.entry .field { margin-top: 8px; font-size: 14px; }
.entry .field b { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Crew */
.crew-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crew-row:last-child { border-bottom: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.crew-row .grow { flex: 1; }
.code { font: 700 28px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--card); border-radius: var(--radius); }
.banner { background: #fff8e6; border: 1px solid #f5d38a; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .brand span:last-child b { display: none; }
  h1 { font-size: 24px; }
  dl.specs { grid-template-columns: 1fr; }
}

td .bar { margin-top: 0; }
.stat .bar { margin-top: 10px; }
td b, td.muted { white-space: nowrap; }
