:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #edf3f5;
  --text: #102226;
  --muted: #65767d;
  --line: #d9e2e6;
  --primary: #155e75;
  --primary-strong: #0f4a5c;
  --accent: #c2410c;
  --danger: #b42318;
  --success: #167647;
  --shadow: 0 10px 24px rgba(16, 34, 38, .08);
  --shadow-soft: 0 3px 10px rgba(16, 34, 38, .06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101618;
  --panel: #182326;
  --panel-soft: #223033;
  --text: #edf5f7;
  --muted: #a6b8be;
  --line: #304146;
  --primary: #26a6c8;
  --primary-strong: #67cbe0;
  --accent: #f59e0b;
  --danger: #f97066;
  --success: #32d583;
  --shadow: none;
  --shadow-soft: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; letter-spacing: 0; }
body {
  margin: 0;
  min-height: 100%;
  padding: env(safe-area-inset-top) 0 calc(60px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; height: auto; }
.app { width: min(980px, 100%); margin: 0 auto; padding: 14px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 16px; }
.brand span, .muted { color: var(--muted); font-size: 12px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.panel { padding: 16px; margin-bottom: 14px; }
.card { padding: 14px; box-shadow: var(--shadow-soft); }
.grid.four .card,
.grid.three .card {
  border-top: 3px solid color-mix(in srgb, var(--primary) 70%, var(--accent));
}
.stat-value { display: block; margin-top: 6px; font-size: 24px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.form-grid { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea, button, .button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: var(--primary-strong);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.button.secondary, button.secondary { background: var(--panel-soft); color: var(--text); border-color: var(--line); box-shadow: none; }
.button.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.button.ghost, button.ghost { background: transparent; color: var(--primary); border-color: transparent; }
.notice {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  margin-bottom: 12px;
}
.notice.error { border-color: color-mix(in srgb, var(--danger), var(--line)); color: var(--danger); }
.notice.success { border-color: color-mix(in srgb, var(--success), var(--line)); color: var(--success); }
.panel-soft {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.check-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}
.check-card input { width: 18px; min-height: 18px; }
.check-card small { display: block; margin-top: 3px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: var(--panel); }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.bottom-nav a {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.bottom-nav a.active { background: color-mix(in srgb, var(--primary) 12%, var(--panel)); color: var(--primary); }
.nav-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
  color: currentColor;
}
.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  display: block;
  box-sizing: border-box;
}
.nav-home::before { left: 4px; top: 8px; width: 14px; height: 10px; border: 2px solid currentColor; border-top: 0; border-radius: 2px; }
.nav-home::after { left: 5px; top: 3px; width: 12px; height: 12px; border-left: 2px solid currentColor; border-top: 2px solid currentColor; transform: rotate(45deg); border-radius: 2px 0 0 0; }
.nav-clock::before { left: 3px; top: 3px; width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; }
.nav-clock::after { left: 10px; top: 6px; width: 6px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.nav-car::before { left: 3px; top: 8px; width: 16px; height: 8px; border: 2px solid currentColor; border-radius: 5px 5px 3px 3px; }
.nav-car::after { left: 5px; top: 15px; width: 4px; height: 4px; background: currentColor; border-radius: 50%; box-shadow: 8px 0 0 currentColor; }
.nav-fuel::before { left: 5px; top: 4px; width: 9px; height: 15px; border: 2px solid currentColor; border-radius: 3px; }
.nav-fuel::after { left: 13px; top: 7px; width: 6px; height: 9px; border-right: 2px solid currentColor; border-top: 2px solid currentColor; border-radius: 0 5px 0 0; }
.nav-file::before { left: 5px; top: 3px; width: 12px; height: 16px; border: 2px solid currentColor; border-radius: 2px; }
.nav-file::after { left: 11px; top: 3px; width: 6px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; background: var(--panel); }
.nav-chart::before { left: 4px; bottom: 4px; width: 3px; height: 8px; background: currentColor; border-radius: 2px; box-shadow: 6px -4px 0 currentColor, 12px -8px 0 currentColor; }
.nav-chart::after { left: 2px; bottom: 2px; width: 18px; border-bottom: 2px solid currentColor; }
.nav-label { font-size: 10px; line-height: 1.1; }
.file-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.inline-form { display: inline; }
.chart-bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 92px 1fr 82px; gap: 8px; align-items: center; font-size: 13px; }
.bar span:nth-child(2) { height: 12px; border-radius: 99px; background: var(--panel-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); }
.progress {
  height: 9px;
  margin: 10px 0 6px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--panel-soft);
}
.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.nav-goal::before { left: 3px; top: 3px; width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; }
.nav-goal::after { left: 8px; top: 8px; width: 6px; height: 6px; border: 2px solid currentColor; border-radius: 50%; }

@media (max-width: 720px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  body { font-size: 15px; padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .topbar { align-items: center; padding: 7px 8px; }
  .brand strong { font-size: 14px; }
  .brand span { display: none; }
  .actions { justify-content: flex-end; }
  .topbar .actions { gap: 4px; flex-wrap: nowrap; }
  .topbar .button, .topbar button { min-height: 34px; padding: 6px 8px; font-size: 12px; }
  .app { padding: 10px; }
  .panel { padding: 12px; margin-bottom: 10px; }
  .card { padding: 11px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .stat-value { font-size: 20px; }
  input, select, textarea, button, .button { min-height: 40px; }
  .bottom-nav { padding-top: 4px; }
  .bottom-nav a { min-height: 42px; }
  .nav-label { display: none; }
  table { min-width: 620px; }
}
