:root {
  --topbar-height: 104px;
  --bg: #f3f6fb;
  --bg-accent: #e8eef8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --line: #d9e2ef;
  --line-strong: #c4d2e4;
  --text: #172033;
  --muted: #61708a;
  --primary: #1f5eff;
  --primary-dark: #1748c9;
  --primary-soft: #eaf0ff;
  --nav-bg: #0f1f33;
  --nav-bg-2: #132845;
  --nav-line: rgba(255,255,255,0.08);
  --nav-text: #dbe7fb;
  --nav-muted: #9fb0cf;
  --success: #127c4f;
  --warn: #a15c00;
  --shadow: 0 16px 38px rgba(16, 38, 74, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(31,94,255,0.08), transparent 24%),
    linear-gradient(180deg, #f7f9fd 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-height);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #12253d 0%, #18345a 55%, #204475 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(6, 16, 32, 0.22);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, #3d7bff 0%, #6b9cff 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 10px 18px rgba(0,0,0,0.18);
}
.topbar h1 { margin: 0 0 0.15rem; font-size: 1.4rem; }
.topbar .muted { color: #c5d5f1; }
.topbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.user-chip {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #eef4ff;
  font-size: 0.92rem;
}
.topbar .button.secondary {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
}

.sidebar {
  width: 252px;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  padding: 1.2rem 1rem;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  border-right: 1px solid var(--nav-line);
  overflow-y: auto;
}
.nav-group + .nav-group { margin-top: 1.1rem; }
.nav-label {
  margin: 0 0 0.5rem;
  padding: 0 0.65rem;
  color: var(--nav-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar a {
  display: block;
  padding: 0.82rem 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--nav-text);
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 600;
  transition: 0.18s ease;
}
.sidebar a:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.08);
  text-decoration: none;
  transform: translateX(2px);
}
.sidebar-foot {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--nav-line);
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.content {
  margin-left: 252px;
  padding: 1.6rem;
}
.content-wide {
  margin-left: 0;
  max-width: 520px;
  margin: 3rem auto;
  padding: 0 1rem;
}
.content > section:last-child,
.content > div:last-child { margin-bottom: 1.2rem; }

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.surface-soft {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.05rem;
}
.hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 1rem;
  align-items: center;
}
.hero h2 { margin: 0.2rem 0 0.45rem; font-size: 1.7rem; }
.hero p { margin: 0; }
.hero-actions {
  display: grid;
  gap: 0.65rem;
  justify-items: end;
}
.eyebrow {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  font-size: 0.78rem;
}
.grid { display: grid; gap: 1rem; }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.three-col { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

.stat-card {
  padding: 1.1rem 1.1rem 1rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--primary);
  opacity: 0.95;
}
.stat-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.stat-card .big {
  margin: 0;
}
.stat-note {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.accent-blue::before { background: #1f5eff; }
.accent-teal::before { background: #0f9f8f; }
.accent-amber::before { background: #d68a00; }
.accent-violet::before { background: #6c4dff; }
.accent-slate::before { background: #50627d; }

.page-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h2, .page-head h3 { margin: 0; }
.page-head p { margin: 0.35rem 0 0; }
.button-row, .inline-form, .pill-row, .metric-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}
.button-row { justify-content: flex-start; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 0.72rem 1.05rem;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(31, 94, 255, 0.18);
}
.button:hover { text-decoration: none; filter: brightness(1.02); }
.button.secondary {
  background: #edf3fb;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}
.button.ghost {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  border: 1px solid var(--line-strong);
}

.muted { color: var(--muted); }
.big { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.82rem;
}
.pill.subtle {
  background: rgba(255,255,255,0.08);
  color: #d8e6ff;
  border: 1px solid rgba(255,255,255,0.09);
}
.note {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid #d7e4fb;
  color: #2d476f;
}
.kv-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.kv-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.kv-list li:last-child { border-bottom: none; }
.kv-list .label { color: var(--muted); }
.kv-list .value { font-weight: 700; text-align: right; }

.table-wrap { overflow-x: auto; margin-top: 0.75rem; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 620px;
}
th, td {
  text-align: left;
  padding: 0.8rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: #34425d;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 800;
  background: #f6f8fc;
  position: sticky;
  top: 0;
}
table tr:hover td { background: #fbfdff; }
.table-compact table { min-width: 0; }

.doc-list, .clean-list {
  margin: 0;
  padding-left: 1.15rem;
}
.doc-list li, .clean-list li { margin: 0.45rem 0; }

label { font-weight: 700; color: #24324c; }
input, select, textarea {
  width: 100%;
  padding: 0.72rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-top: 0.25rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7ea4ff;
  box-shadow: 0 0 0 4px rgba(31,94,255,0.12);
}
form p { margin-bottom: 1rem; }
form ul.errorlist {
  margin: 0 0 0.45rem;
  padding-left: 1.2rem;
  color: #b42318;
}

.flash {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}
.flash.success { border-color: #abefc6; background: #ecfdf3; color: #05603a; }
.flash.error { border-color: #fecdca; background: #fef3f2; color: #b42318; }
.flash.warning { border-color: #fedf89; background: #fffaeb; color: #93370d; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}
.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.inline-form p { margin: 0; }

@media (max-width: 960px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 0.9rem 1rem;
    border-right: none;
  }
  .content {
    margin-left: 0;
    padding: 1rem;
  }
  .topbar {
    position: static;
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-actions {
    justify-items: stretch;
  }
}

@media (max-width: 640px) {
  .topbar-left {
    align-items: flex-start;
  }
  .brand-mark {
    width: 42px;
    height: 42px;
  }
  .big {
    font-size: 1.6rem;
  }
  th, td {
    padding: 0.7rem 0.55rem;
  }
}
.status-badge,
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-submitted, .status-acknowledged { background: #eef4ff; color: #1748c9; }
.status-vendor_assigned, .status-scheduled { background: #ecfdf3; color: #05603a; }
.status-in_progress, .status-waiting_parts { background: #fffaeb; color: #93370d; }
.status-completed { background: #e6f9f0; color: #05603a; }
.status-cancelled { background: #f2f4f7; color: #475467; }
.priority-low { background: #f2f4f7; color: #475467; }
.priority-normal { background: #eef4ff; color: #1748c9; }
.priority-high { background: #fff4ed; color: #c4320a; }
.priority-urgent { background: #fef3f2; color: #b42318; }

.timeline {
  display: grid;
  gap: 0.75rem;
}
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: #fbfdff;
}
.timeline-meta {
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 0.4rem;
}
