:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #17202a;
  --muted: #697583;
  --line: #dce3ea;
  --accent: #1f7a8c;
  --accent-dark: #165a67;
  --warn: #b8671d;
  --danger: #b23a48;
  --success: #217a52;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.09);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(31, 122, 140, 0.10), transparent 28rem),
    linear-gradient(315deg, rgba(39, 85, 111, 0.08), transparent 22rem),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #18202a;
  color: #f6f8fa;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 52px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #ffcc66;
  color: #18202a;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #b8c2cf;
  font-size: 0.84rem;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d8e0e9;
  background: transparent;
  text-align: left;
  padding: 0 12px;
}

.nav-tab span:first-child {
  display: grid;
  place-items: center;
  font-weight: 800;
}

.nav-tab:hover,
.nav-tab.active {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.sync-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sync-box span,
.sync-box strong {
  display: block;
}

.sync-box span {
  color: #b8c2cf;
  font-size: 0.82rem;
}

.sync-box strong {
  margin-top: 4px;
  font-size: 0.95rem;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-wrap {
  display: grid;
  grid-template-columns: 24px minmax(220px, 380px);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 30px rgba(23, 32, 42, 0.05);
}

.search-wrap span {
  color: var(--muted);
  font-weight: 800;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.ghost-btn {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
  font-size: 1.2rem;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

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

.stat-card,
.panel,
.vehicle-card,
.knowledge-card,
.timeline-item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
  min-height: 120px;
  display: grid;
  align-content: space-between;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.stat-card em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 700;
  font-size: 0.82rem;
}

.content-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  padding: 18px;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.section-head {
  margin-bottom: 18px;
}

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

.mini-row,
.result-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-row strong,
.result-item strong {
  word-break: break-word;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.result-grid,
.vehicle-grid,
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.vehicle-card,
.knowledge-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.vehicle-title,
.card-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.vehicle-title strong,
.knowledge-card strong {
  display: block;
  font-size: 1.05rem;
}

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

.meta-grid div,
.detail-block {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.meta-grid span,
.detail-block span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 4px;
}

.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.status.resolved {
  color: var(--success);
  background: rgba(33, 122, 82, 0.10);
  border-color: rgba(33, 122, 82, 0.22);
}

.status.watch {
  color: var(--warn);
  background: rgba(184, 103, 29, 0.10);
  border-color: rgba(184, 103, 29, 0.22);
}

.status.pending {
  color: var(--danger);
  background: rgba(178, 58, 72, 0.10);
  border-color: rgba(178, 58, 72, 0.22);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: 0;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.timeline-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.timeline-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 32px 80px rgba(23, 32, 42, 0.24);
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.46);
}

.modal-form {
  padding: 18px;
  background: var(--surface);
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.modal-head {
  margin-bottom: 16px;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--surface-2);
  color: var(--ink);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 150px;
  gap: 6px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .section-head,
  .card-actions,
  .panel-head button {
    display: none !important;
  }

  .app-shell,
  .main {
    display: block;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  .print-target {
    display: block !important;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-tab {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .sync-box {
    display: none;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .search-wrap {
    grid-template-columns: 24px minmax(0, 1fr);
    flex: 1 1 100%;
  }

  .stats-grid,
  .two-columns,
  .timeline-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

  .brand {
    align-items: flex-start;
  }

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

  .nav-tab {
    min-height: 42px;
    padding: 0 10px;
  }

  .stats-grid,
  .two-columns,
  .timeline-details,
  .form-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .panel-head,
  .timeline-top,
  .vehicle-title,
  .card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-btn,
  .ghost-btn {
    width: 100%;
  }
}
