:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4ff;
  --text: #122033;
  --muted: #64748b;
  --line: #d8e0eb;
  --brand: #0b5cff;
  --brand-dark: #0844ba;
  --accent: #c7f45d;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.11);
  --radius: 8px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(216, 224, 235, 0.82);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); font-size: 0.8rem; }

.tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  overflow-x: auto;
  padding: 4px;
  border-radius: var(--radius);
  background: #eef3fb;
}

.tabs a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a.active {
  color: var(--brand);
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 900;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 26px rgba(11, 92, 255, 0.22);
}

.primary-button:hover { background: var(--brand-dark); }
.ghost-button { background: #eef3fb; color: var(--text); }
.full { width: 100%; }

.auth-screen {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
}

.auth-card,
.work-panel,
.metric-card,
.stack-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(520px, 100%);
  padding: 22px;
}

.page-heading {
  margin: 12px 0 18px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.04; }
h2 { margin-bottom: 12px; font-size: 1.16rem; }
p { color: var(--muted); line-height: 1.6; }

.view { display: none; }
.view.active { display: block; }

.dashboard-grid,
.management-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.management-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.staff-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.work-panel,
.metric-card { padding: 16px; }

.metric-card span {
  color: var(--muted);
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 2.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.single { grid-template-columns: 1fr; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

label,
.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(11, 92, 255, 0.12);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

hr {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--line);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.compact {
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.stack-item,
.empty-state {
  padding: 12px;
  box-shadow: none;
}

.stack-item strong,
.stack-item span,
.text-link {
  display: block;
}

.stack-item span,
.empty-state {
  color: var(--muted);
  line-height: 1.45;
}

.text-link {
  margin-top: 7px;
  color: var(--brand);
  font-weight: 900;
  text-decoration: none;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 12px 0;
}

.map-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: #fbfdff;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  aspect-ratio: 10 / 7;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

.map-line {
  stroke: #9db4d8;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.route-line {
  stroke: var(--brand);
  stroke-width: 3.3;
  stroke-linecap: round;
  stroke-dasharray: 6 4;
}

.map-point {
  fill: #fff;
  stroke: var(--brand);
  stroke-width: 2.4;
}

.map-point.start {
  fill: var(--accent);
  stroke: #355400;
}

.map-point.route {
  fill: var(--accent);
}

.point-label {
  fill: #17233a;
  font-size: 3.1px;
  font-weight: 800;
}

.fineprint {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.route-summary {
  margin-top: 14px;
  padding: 13px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
}

.steps {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding-left: 20px;
}

.step-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.step-item strong,
.step-item span { display: block; }
.step-item span { color: var(--muted); margin-top: 4px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(430px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .tabs { grid-column: 1 / -1; justify-content: start; }
  .dashboard-grid,
  .management-grid,
  .staff-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 18px, 1220px); padding-top: 9px; }
  .topbar { padding: 9px; }
  .brand small { display: none; }
  h1 { font-size: 2.05rem; }
  .two-cols,
  .upload-row { grid-template-columns: 1fr; }
  .work-panel,
  .metric-card,
  .auth-card { padding: 14px; }
}
