:root {
  --green-950: #0b3d2a;
  --green-800: #166534;
  --green-700: #198754;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --lime: #c8e64a;
  --ink: #162019;
  --muted: #68736b;
  --line: #dfe5df;
  --surface: #ffffff;
  --canvas: #f3f6f3;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(17, 52, 34, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -10%, rgba(200, 230, 74, 0.18), transparent 28rem),
    var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 72px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  background: var(--green-950);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--green-950);
  background: var(--lime);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -1px;
}

.brand div {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 16px;
}

.brand div span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.button {
  min-height: 40px;
  padding: 0 17px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--green-800);
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
  background: var(--green-700);
}

.button.ghost {
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: inherit;
  background: transparent;
}

.button.ghost:hover {
  background: rgba(255, 255, 255, 0.09);
}

.print-button {
  color: var(--green-950);
  background: var(--lime);
}

.print-button:hover {
  background: #d8f45d;
}

.file-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 85% 10%, rgba(200, 230, 74, 0.24), transparent 25rem),
    var(--green-950);
}

.login-card {
  width: min(430px, 100%);
  padding: 38px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.login-card .brand-mark {
  margin-bottom: 24px;
}

.login-card h1 {
  margin-bottom: 8px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.login-card form {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: #425048;
  font-size: 12px;
  font-weight: 750;
}

.login-card .submit-button {
  margin-top: 4px;
}

.login-error {
  margin: 20px 0 0;
  padding: 11px 13px;
  border-radius: 9px;
  color: var(--danger);
  background: #fff0ee;
  font-size: 13px;
  font-weight: 700;
}

.shell {
  width: min(1500px, 92vw);
  margin: 32px auto 64px;
}

.vehicle-hero {
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid rgba(22, 101, 52, 0.1);
  border-radius: var(--radius);
  background: linear-gradient(120deg, white 55%, #edf9dc);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.vehicle-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.vehicle-title-row h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.05em;
}

.plate {
  padding: 7px 12px;
  border: 1px solid #cbd5ce;
  border-radius: 9px;
  color: #213229;
  background: white;
  font-weight: 850;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

#storageStatus.connected {
  color: var(--green-700);
  font-weight: 750;
}

#storageStatus.error {
  color: var(--danger);
  font-weight: 750;
}

.odometer-card {
  min-width: 230px;
  padding: 18px 20px;
  display: grid;
  gap: 5px;
  border-left: 3px solid var(--lime);
  border-radius: 8px 14px 14px 8px;
  background: rgba(255, 255, 255, 0.8);
}

.odometer-card span {
  color: var(--muted);
  font-size: 12px;
}

.odometer-card strong {
  font-size: 24px;
}

.text-button {
  width: fit-content;
  padding: 2px 0;
  border: 0;
  color: var(--green-700);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

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

.stat-card {
  min-width: 0;
  padding: 20px;
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.stat-card.primary {
  color: white;
  border-color: var(--green-800);
  background: var(--green-800);
}

.stat-card span,
.stat-card small {
  color: var(--muted);
  font-size: 12px;
}

.stat-card.primary span,
.stat-card.primary small {
  color: rgba(255, 255, 255, 0.75);
}

.stat-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  white-space: nowrap;
}

.stat-card strong b {
  font-size: 26px;
}

.workspace {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs {
  min-height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  padding: 0 2px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.tab.active {
  color: var(--green-800);
}

.tab.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--green-700);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.entry-panel,
.records-panel {
  padding: 28px;
}

.entry-panel {
  border-bottom: 1px solid var(--line);
  background: #fbfdfb;
}

.section-heading,
.records-toolbar {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.records-toolbar h2 {
  margin-bottom: 0;
  font-size: 21px;
  letter-spacing: -0.03em;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.quick-grid {
  grid-template-columns: 1.1fr 1fr 1.2fr 1.2fr;
  align-items: end;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: #425048;
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid #ccd5ce;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: white;
}

input:focus,
select:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
}

.span-2 {
  grid-column: span 2;
}

.submit-button {
  min-height: 43px;
}

.advanced {
  margin-top: 16px;
  border-top: 1px dashed #d6ded8;
}

.advanced summary {
  padding: 15px 0 0;
  color: var(--green-700);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style-position: inside;
}

.advanced summary span {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 500;
}

.advanced-grid {
  margin-top: 16px;
  grid-template-columns: repeat(4, 1fr);
}

.records-toolbar {
  align-items: center;
}

.period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  padding: 3px;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f6f4;
}

.segmented button {
  min-height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}

.segmented button.active {
  color: var(--green-800);
  background: white;
  box-shadow: 0 2px 5px rgba(20, 40, 27, 0.08);
}

.period-controls input,
.period-controls select {
  width: 150px;
  min-height: 38px;
  font-size: 13px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.records-table th {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #f7f9f7;
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
}

.records-table td {
  padding: 15px 10px;
  border-bottom: 1px solid #edf0ed;
  vertical-align: middle;
}

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

.records-table .number {
  text-align: right;
}

.records-table td.number {
  font-weight: 800;
  white-space: nowrap;
}

.route {
  max-width: 240px;
  color: #455149;
}

.route span {
  color: #9aa39d;
}

.badge {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--green-800);
  background: var(--green-50);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.personal {
  color: #7b4215;
  background: #fff4e6;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.icon-button {
  padding: 5px 7px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}

.icon-button:hover {
  color: var(--green-800);
  background: var(--green-50);
}

.icon-button.delete:hover {
  color: var(--danger);
  background: #fff0ee;
}

.actions-column {
  width: 96px;
  text-align: right !important;
}

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

.empty-state span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-700);
  background: var(--green-100);
  font-size: 21px;
  font-weight: 800;
}

.empty-state strong {
  color: #455149;
}

.empty-state p {
  margin-bottom: 0;
  font-size: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(340px, 0.75fr) minmax(550px, 1.25fr);
}

.two-column .entry-panel {
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

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

.compact {
  min-width: 0;
}

.settings-panel {
  max-width: 980px;
  margin: 0 auto;
  border: 0;
  background: white;
}

.settings-grid {
  grid-template-columns: repeat(3, 1fr);
}

.setting-note {
  margin: 20px 0;
  padding: 15px 17px;
  border-left: 3px solid var(--lime);
  border-radius: 5px 10px 10px 5px;
  background: var(--green-50);
}

.setting-note strong {
  color: var(--green-800);
  font-size: 13px;
}

.setting-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-save {
  min-width: 180px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 13px 17px;
  border-radius: 11px;
  color: white;
  background: var(--green-950);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

dialog {
  width: min(390px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(7, 28, 17, 0.45);
}

dialog form {
  padding: 24px;
}

dialog h3 {
  margin-bottom: 8px;
}

dialog p {
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

dialog .button.ghost {
  border-color: var(--line);
  color: var(--ink);
}

.button.danger {
  background: var(--danger);
}

.print-sheet {
  display: none;
}

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

  .quick-grid,
  .advanced-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .two-column .entry-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 680px) {
  .topbar {
    padding: 12px 16px;
    align-items: flex-start;
    gap: 12px;
  }

  .brand div span,
  .top-actions .file-button,
  .top-actions .logout-button {
    display: none;
  }

  .button {
    min-height: 38px;
    padding: 0 12px;
    font-size: 12px;
  }

  .shell {
    width: min(100% - 24px, 1500px);
    margin-top: 18px;
  }

  .vehicle-hero {
    padding: 22px;
    align-items: stretch;
    flex-direction: column;
  }

  .vehicle-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .odometer-card {
    min-width: 0;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-card strong b {
    font-size: 21px;
  }

  .tabs {
    padding: 0 18px;
    gap: 20px;
  }

  .entry-panel,
  .records-panel {
    padding: 22px 18px;
  }

  .quick-grid,
  .advanced-grid,
  .fuel-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .advanced summary span {
    display: none;
  }

  .records-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .period-controls input,
  .period-controls select {
    width: 100%;
  }
}

@page {
  size: A4 landscape;
  margin: 9mm;
}

@media print {
  body {
    background: white;
  }

  body > :not(.print-sheet) {
    display: none !important;
  }

  .print-sheet {
    display: block;
    color: #111;
    font-family: "Malgun Gothic", sans-serif;
  }

  .print-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }

  .print-title {
    flex: 1;
    text-align: center;
  }

  .print-title p {
    margin-bottom: 2mm;
    font-size: 10pt;
  }

  .print-title h1 {
    margin: 0 0 4mm;
    font-size: 19pt;
    letter-spacing: 0.08em;
  }

  .approval-table {
    width: 42mm;
    margin-bottom: 3mm;
    border-collapse: collapse;
  }

  .approval-table th,
  .approval-table td {
    width: 21mm;
    height: 8mm;
    border: 0.4mm solid #333;
    font-size: 8pt;
    text-align: center;
  }

  .print-meta {
    margin-bottom: 2mm;
    display: flex;
    justify-content: space-between;
    font-size: 8pt;
  }

  .official-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 6.5pt;
  }

  .official-table th,
  .official-table td {
    height: 8mm;
    padding: 1mm;
    border: 0.35mm solid #222;
    overflow-wrap: anywhere;
    text-align: center;
    vertical-align: middle;
  }

  .official-table thead th {
    background: #f5f8d7 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .official-table tbody tr {
    break-inside: avoid;
  }

  .official-table tfoot th,
  .official-table tfoot td {
    font-weight: 700;
    background: #f2f2f2 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .print-footnote {
    margin-top: 2mm;
    font-size: 6.5pt;
  }
}
