:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
  padding: 0 18px; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 6px; overflow-x: auto; }
.brand { font-weight: 800; font-size: 16px; color: var(--text); margin-right: 12px; white-space: nowrap; display:flex; align-items:center; gap:8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--primary); display: inline-block; }
.nav-link {
  padding: 6px 12px; border-radius: 7px; font-weight: 500; color: #334155; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: #f1f5f9; }
.nav-link.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pill-ok { background: #dcfce7; color: #166534; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-err { background: #fee2e2; color: #991b1b; }
.pill-blue { background: #dbeafe; color: #1e40af; }
.pill-gray { background: #f1f5f9; color: #475569; }

.container { max-width: 1440px; margin: 0 auto; padding: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.04);
  padding: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 14px; border-radius: 7px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
  background: #f1f5f9; color: var(--text);
}
.btn:hover { filter: brightness(0.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-outline { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}
.kanban-col {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15,23,42,.05); overflow: hidden;
}
.kanban-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.kanban-count { font-size: 14px; font-weight: 700; color: var(--muted); }
.kanban-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.race-card {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; background: #fafcff;
}
.race-card.calling { border-color: #f59e0b; background: #fffbeb; }
.race-card.should-return { border: 2px solid #dc2626; background: #fef2f2; animation: pulseBorder 1.5s infinite; }
@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
@keyframes lapFlash {
  0% { background: #dcfce7; box-shadow: 0 0 0 3px rgba(22,163,74,.35); }
  100% { background: #fafcff; box-shadow: none; }
}
.lap-flash { animation: lapFlash 1.4s ease-out; }
.timer-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px; background: #e2e8f0; color: #0f172a;
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 12px;
}
.timer-pill.overtime { background: #fee2e2; color: #991b1b; }
.race-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qnum { font-size: 18px; font-weight: 800; color: var(--primary); }
.car-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: #0f172a; color: #fff; font-weight: 800; font-size: 13px;
}
.meta-row { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-val { font-size: 26px; font-weight: 800; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eef2f6; }
th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; }
tr:hover td { background: #f8fafc; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: #475569; }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], select, textarea {
  padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; background: #fff;
}
input:focus, select:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; max-width: 540px; width: 100%;
  padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.mb-3 { margin-bottom: 12px; }
.mt-3 { margin-top: 12px; }
.flex-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
