:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #d9e1ea;
  --text: #1d2733;
  --muted: #5f6e7f;
  --accent: #176f8f;
  --accent-dark: #0e526b;
  --accent-soft: #e8f5f8;
  --danger: #b42318;
  --ok: #067647;
  --green: #15803d;
  --green-soft: #edf7ee;
  --amber: #b7791f;
  --amber-soft: #fff7e6;
  --blue: #2563a5;
  --blue-soft: #edf4ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
button, .button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-dark); }
.button.secondary {
  background: #eef4f8;
  color: var(--text);
  border: 1px solid var(--line);
}
.button.secondary:hover { background: #e4edf4; }
.topbar {
  height: 56px;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 800; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar form { display: flex; gap: 0.75rem; align-items: center; margin: 0; color: var(--muted); }
.inline-action { margin: 0; }
main { padding: 1rem; max-width: 1480px; margin: 0 auto; }
.page-head { margin-bottom: 1rem; }
.page-head.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
p { color: var(--muted); }
.page-subtitle { margin: 0.35rem 0 0; }
.login-panel, .panel, .split > div, .metrics > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}
.login-panel { max-width: 360px; margin: 4rem auto; }
form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  min-height: 38px;
  background: white;
}
.login-panel form, .panel { display: grid; gap: 0.8rem; }
.messages { margin-bottom: 1rem; }
.message { padding: 0.7rem 0.9rem; border-radius: 6px; background: #eef6ff; border: 1px solid var(--line); }
.message.error { background: #fff1f0; color: var(--danger); }
.message.success { background: #ecfdf3; color: var(--ok); }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.metrics span { display: block; color: var(--muted); font-size: 0.85rem; }
.metrics strong { display: block; margin-top: 0.25rem; font-size: 1.35rem; }
.metrics > div { border-top: 3px solid var(--accent); }
.metrics > div:nth-child(2) { border-top-color: var(--green); }
.metrics > div:nth-child(3) { border-top-color: var(--blue); }
.metrics > div:nth-child(4) { border-top-color: var(--amber); }
.metrics > div:nth-child(5) { border-top-color: var(--danger); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.panel-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.panel-head p { margin: -0.35rem 0 0; }
.fleet-panel { margin-bottom: 1rem; padding: 0; overflow: hidden; }
.fleet-panel .panel-head { padding: 1rem 1rem 0.8rem; }
.fleet-table-wrap {
  border-top: 1px solid var(--line);
  overflow: auto;
}
.fleet-table { min-width: 1400px; }
.fleet-table th, .fleet-table td { text-align: right; }
.fleet-table th:first-child, .fleet-table td:first-child,
.fleet-table th:nth-child(2), .fleet-table td:nth-child(2),
.fleet-table th:nth-child(3), .fleet-table td:nth-child(3) {
  text-align: left;
}
.fleet-table thead tr:first-child th {
  background: #f4f8fb;
  border-bottom: 1px solid var(--line);
}
.fleet-table thead tr:nth-child(2) th {
  font-size: 0.78rem;
  color: var(--muted);
}
.fleet-sticky {
  left: 0;
  position: sticky;
  z-index: 2;
}
th.fleet-sticky { z-index: 4; }
td.fleet-sticky { background: var(--panel); }
tbody tr:nth-child(even) td.fleet-sticky { background: #fbfcfe; }
.fleet-name {
  min-width: 210px;
  white-space: normal;
}
.fleet-name strong,
.fleet-name span {
  display: block;
}
.fleet-name span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.provider-pill {
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.18rem 0.5rem;
}
.metric-band { text-align: center !important; }
.metric-cell { font-variant-numeric: tabular-nums; font-weight: 650; }
.metric-hours { background: #f1f5f9; color: #334155; }
.metric-km { background: var(--accent-soft); color: var(--accent-dark); }
.metric-fuel { background: var(--amber-soft); color: #8a5a12; }
.metric-drill { background: var(--green-soft); color: var(--green); }
.metric-water { background: var(--blue-soft); color: var(--blue); }
.empty { color: var(--muted); font-weight: 500; }
.schema-group { margin-bottom: 1.25rem; }
.schema-group > header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 0.6rem;
  color: var(--muted);
}
.schema-group > header h2 { margin: 0; color: var(--text); }
.table-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.75rem; }
.table-list a { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; color: var(--text); display: grid; gap: 0.35rem; }
.table-list a:hover { border-color: #9fb4c5; box-shadow: 0 4px 14px rgba(29, 39, 51, 0.08); }
.table-list span, .table-list small { color: var(--muted); }
.table-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.table-stats > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}
.table-stats > div:nth-child(2) { border-left-color: var(--green); }
.table-stats > div:nth-child(3) { border-left-color: var(--blue); }
.table-stats span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}
.table-stats strong {
  display: block;
  font-size: 1.15rem;
  margin-top: 0.2rem;
}
.filters { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem; }
.filters label { min-width: 150px; }
.data-table { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.65rem; text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: #eef4f8; z-index: 1; }
th small { display: block; margin-top: 0.2rem; color: var(--muted); font-weight: 500; }
.sort-link { color: var(--text); display: inline-flex; align-items: center; gap: 0.25rem; }
.filter-row th { top: 42px; background: #f7fafc; }
.column-filter { min-width: 140px; width: 100%; min-height: 30px; padding: 0.35rem 0.45rem; font-size: 0.82rem; }
tbody tr:nth-child(even) { background: #fbfcfe; }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 0.5rem; }
.check input { min-height: auto; }
.dashboard-note { margin-bottom: 1rem; align-items: start; }
.wiki-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.wiki-sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.wiki-root-link {
  display: block;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.wiki-sidebar nav { display: grid; gap: 0.15rem; }
.wiki-sidebar nav a, .wiki-sidebar nav span {
  border-radius: 6px;
  color: var(--text);
  display: block;
  padding: 0.45rem 0.55rem;
}
.wiki-sidebar nav a:hover, .wiki-sidebar nav a.active { background: #eef4f8; }
.wiki-article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  min-width: 0;
}
.wiki-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.wiki-search input { flex: 1; }
.wiki-meta {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  font-size: 0.85rem;
}
.wiki-content {
  line-height: 1.62;
  max-width: 920px;
}
.wiki-content h2, .wiki-content h3, .wiki-content h4, .wiki-content h5 {
  color: var(--text);
  margin: 1.2rem 0 0.45rem;
}
.wiki-content p, .wiki-content li { color: var(--text); }
.wiki-content code {
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.25rem;
}
.wiki-content pre {
  background: #13212b;
  border-radius: 8px;
  color: white;
  overflow: auto;
  padding: 0.8rem;
}
.wiki-content pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}
.wiki-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}
.wiki-list a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem;
}
.wiki-list a:hover { border-color: #9fb4c5; box-shadow: 0 4px 14px rgba(29, 39, 51, 0.08); }
.wiki-list span { color: var(--muted); }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.wiki-edit textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  padding: 0.7rem;
  resize: vertical;
}
.form-actions { display: flex; gap: 0.75rem; }
@media (max-width: 900px) {
  .topbar { height: auto; align-items: flex-start; flex-direction: column; padding: 0.75rem; }
  .metrics, .split, .wiki-layout { grid-template-columns: 1fr; }
  .wiki-sidebar { position: static; max-height: none; }
}
