:root {
  color-scheme: dark;
  --bg: #06111a;
  --panel: transparent;
  --panel-strong: #102536;
  --text: #bfd0d8;
  --muted: #8ca7b5;
  --line: rgba(119, 191, 194, 0.16);
  --accent: #1ea7a1;
  --accent-strong: #72d1ca;
  --success: #42c58a;
  --danger: #f06c6c;
  --radius: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(30, 167, 161, 0.2), transparent 26%),
    radial-gradient(circle at top right, rgba(34, 111, 168, 0.22), transparent 30%),
    radial-gradient(circle at bottom, rgba(22, 67, 116, 0.22), transparent 34%),
    linear-gradient(180deg, #07131d 0%, #041019 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.hero-card,
.panel {
  background: var(--panel);
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  border-radius: var(--radius);
}

.hero-card {
  padding: 0 0 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.hero-card h1,
.panel h2 {
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.hero-card h1 {
  font-size: 1.3rem;
  color: #d5e7ee;
}

.hero-copy,
.status-line,
.subtle,
.summary-card p,
.summary-card span,
.field span,
.empty-state {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 1px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.64rem;
  color: var(--accent-strong);
}

.panel {
  padding: 12px 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.quick-add-panel {
  background: rgba(0, 0, 0, 0.14);
  padding: 12px;
  margin: 8px 0;
}

.summary-panel {
  padding-top: 0;
}

.history-panel {
  border-bottom: 0;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-head.compact {
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 14px;
  border: 0;
}

.summary-card {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  min-width: 0;
}

.summary-card p {
  margin: 0 0 3px;
}

.summary-card span {
  display: block;
  margin-top: 3px;
}

.summary-card::after {
  content: "";
  display: block;
  width: 100%;
  margin-top: 9px;
  border-bottom: 1px solid rgba(119, 191, 194, 0.08);
}

.summary-card:nth-last-child(-n + 2)::after {
  display: none;
}

.summary-card strong {
  display: block;
  margin: 0;
  font-size: 1rem;
  line-height: 1.05;
  color: #d7e4ea;
}

.summary-card p,
.summary-card span {
  font-size: 0.78rem;
  line-height: 1.15;
}

.summary-card .summary-detail {
  font-size: 0.88rem;
}

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

.compact-grid {
  margin-top: 10px;
}

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

.field span {
  font-size: 0.76rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 4px;
  padding: 10px 12px;
  min-height: 40px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(30, 167, 161, 0.2);
  border-color: rgba(114, 209, 202, 0.64);
}

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

.primary-button,
.danger-button {
  border: 0;
  border-radius: 4px;
  min-height: 32px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.84rem;
}

.primary-button {
  background: var(--accent);
  color: #04202a;
}

.danger-button {
  background: rgba(240, 108, 108, 0.1);
  color: var(--danger);
}

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

.form-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 4px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

.history-header h2 {
  margin: 0;
}

.history-list {
  display: grid;
  gap: 0;
  margin-top: 0;
}

.history-item {
  border-top: 0;
  border-bottom: 1px solid rgba(119, 191, 194, 0.12);
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0 11px;
}

.history-main,
.history-side {
  display: flex;
  min-width: 0;
}

.history-main {
  flex-direction: column;
  gap: 1px;
}

.history-topline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.history-side {
  align-items: start;
  gap: 10px;
}

.history-liters {
  font-size: 0.95rem;
  line-height: 1;
  color: #d7e4ea;
}

.history-fuel {
  font-size: 0.82rem;
  color: #d7e4ea;
}

.history-date {
  font-size: 0.7rem;
  color: var(--muted);
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  min-height: 0;
  min-width: 0;
  line-height: 1;
  cursor: pointer;
  font-size: 1rem;
}

.icon-button:hover {
  color: var(--danger);
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.history-item .compact-grid {
  padding: 0 0 10px;
}

.history-item .compact-grid .history-edit-pair {
  grid-column: span 1;
}

.login-panel .primary-button {
  width: fit-content;
}

#statusHeadline {
  font-size: 0.92rem;
  max-width: none;
  white-space: normal;
  color: #d7e4ea;
}

#draftStatus,
#loginStatus,
.subtle,
.empty-state {
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(18px);
  min-width: 180px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(4, 20, 30, 0.96);
  color: var(--text);
  text-align: center;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.84rem;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.ok {
  background: rgba(14, 73, 57, 0.96);
}

.toast.error {
  background: rgba(102, 27, 27, 0.96);
}

[data-tone="pending"] {
  color: var(--accent-strong);
}

[data-tone="ok"] {
  color: var(--success);
}

[data-tone="error"] {
  color: var(--danger);
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 12px 22px;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .history-meta,
  .history-actions,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .history-row {
    align-items: center;
  }

  .history-item .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .history-item .compact-grid .field:first-child {
    grid-column: 1 / -1;
  }

  .hero-card {
    padding: 0 0 10px;
  }

  .panel {
    padding: 12px 0;
  }

  .summary-panel .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 12px;
  }

  .summary-card {
    padding: 0;
  }

  .summary-card strong {
    font-size: 0.96rem;
  }

  .summary-card p,
  .summary-card span,
  #draftStatus,
  #loginStatus,
  .subtle,
  .empty-state {
    font-size: 0.76rem;
  }
}
