:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --border: #334155;
  --ok: #34d399;
  --warn: #fbbf24;
  --fuel: #3b82f6;
  --service: #f59e0b;
  --bill: #10b981;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

header.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

header .sub {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

.meta-chip {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.chip strong {
  color: var(--text);
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.file-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-btn:hover,
.ghost-btn:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.file-btn {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}

.lang-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.lang-label select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  min-width: 4.5rem;
}

.dataset-label select {
  min-width: 14rem;
  max-width: min(22rem, 70vw);
}

.chip-filter {
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.chip-filter strong {
  color: #bae6fd;
}

.quick-search {
  margin-bottom: 1rem;
}

.quick-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.quick-search-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 220px;
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 200px;
}

.quick-search-field input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  width: 100%;
}

.quick-search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.type-chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.type-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.type-chip.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.5);
  color: #bae6fd;
  font-weight: 600;
}

.quick-hint {
  margin: 0.55rem 0 0;
}

.offline-banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.update-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  color: #bae6fd;
}

.update-banner .update-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.loading {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* PWA standalone: safer top inset on notched phones */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.card .label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.card .value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card .hint {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-2.equal {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-2.equal {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.chart-box {
  position: relative;
  height: 280px;
}

.chart-box.tall {
  height: 320px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  align-items: center;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.filters select,
.filters input[type='search'] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  min-width: 140px;
  font: inherit;
}

.filters input[type='search'] {
  min-width: 200px;
}

.filters .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table.entries {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.entries th,
table.entries td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.entries th {
  background: rgba(15, 23, 42, 0.55);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

table.entries tbody tr:hover {
  background: rgba(51, 65, 85, 0.35);
}

table.entries .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.entries .mono {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.85rem;
}

table.entries .empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-refuel {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-service_record {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.badge-bill {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.error.status-ok {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.error .linkish,
.offline-banner .linkish {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
  margin: 0 0.15rem;
}

.hash-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  word-break: break-all;
}

.offline-banner.info-banner {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.compact-table {
  margin-top: 0.75rem;
  max-height: 220px;
  overflow: auto;
}

footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer .footer-sep {
  margin: 0 0.35rem;
}
