:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1f2523;
  --muted: #69736f;
  --line: #dfe6e2;
  --dark: #17201d;
  --green: #287450;
  --green-dark: #1f5f40;
  --gold: #b7791f;
  --red: #b42318;
  --blue: #265d9b;
  --shadow: 0 14px 36px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--dark);
  color: #eef6f1;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #f4c04e;
  color: var(--dark);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: #b7c8c0;
  font-size: 13px;
  margin-top: 3px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  min-height: 42px;
  text-align: left;
  padding: 0 12px;
  font-weight: 750;
}

.nav-btn.active {
  background: #eef6f1;
  color: var(--dark);
}

.side-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.side-card span,
.side-card small {
  display: block;
  color: #b7c8c0;
  font-size: 13px;
}

.side-card strong {
  display: block;
  font-size: 26px;
  margin: 6px 0 3px;
}

.main {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.topbar,
.actions,
.panel-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.month-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.month-control select,
.month-control input {
  width: 150px;
  min-height: 36px;
  padding: 7px 10px;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 25px;
  margin-top: 2px;
}

.data-status {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  flex-wrap: wrap;
  margin-top: -4px;
}

.data-status span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf8;
  padding: 4px 9px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn,
.accent-btn,
.save-btn,
.close-btn {
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.primary-btn {
  background: var(--green);
  color: #fff;
}

.primary-btn:hover {
  background: var(--green-dark);
}

.ghost-btn {
  background: #edf3ef;
  color: #26302c;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 0;
  min-height: 0;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-btn {
  background: #fff0ee;
  color: var(--red);
}

.icon-btn {
  background: #f1f4f2;
  color: var(--ink);
  min-width: 36px;
}

.accent-btn {
  background: #eaf2ff;
  color: var(--blue);
}

.save-btn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(40, 116, 80, 0.22);
}

.close-btn {
  background: #f1f4f2;
  color: var(--ink);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

textarea {
  resize: vertical;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.summary-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 9px 12px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  font-size: 19px;
  margin-top: 2px;
}

.summary-card small {
  color: var(--muted);
}

.panel {
  padding: 14px;
  min-width: 0;
}

.history-head {
  margin-bottom: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

#dashboardView .dashboard-grid {
  gap: 8px;
}

#dashboardView .panel {
  padding: 10px 12px;
}

#dashboardView .panel h3 {
  font-size: 18px;
}

#dashboardView .panel-head {
  min-height: 24px;
}

#dashboardView .table-wrap {
  max-height: 230px;
  overflow: auto;
}

#dashboardView table {
  min-width: 760px;
}

#dashboardView th,
#dashboardView td {
  padding: 7px 8px;
}

.wide {
  grid-column: 1 / -1;
}

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

dialog {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(23, 32, 29, 0.42);
}

.dialog-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(23, 32, 29, 0.22);
  padding: 16px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.detail-dialog {
  display: grid;
  gap: 12px;
}

.detail-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.detail-summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  padding: 10px;
}

.detail-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-summary-item strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

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

.detail-dialog table {
  min-width: 620px;
}

.dialog-card.form-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
}

.dialog-card label {
  grid-column: span 6;
  gap: 5px;
  font-size: 14px;
}

#deliveryForm label {
  border: 1px solid #edf2ee;
  border-radius: 8px;
  background: #fbfdfc;
  padding: 7px;
  position: relative;
}

#deliveryForm .required-field {
  border-color: #d7e5dd;
}

#deliveryForm .required-field::before {
  content: "필수";
  position: absolute;
  top: 7px;
  right: 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: var(--green);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
}

#deliveryForm .important-field {
  background: #f6fbf8;
}

#deliveryForm .important-field input {
  border-color: #a9cbb9;
}

#deliveryForm .amount-field,
#deliveryForm .cost-field {
  grid-column: span 3;
}

#deliveryForm .settlement-field {
  grid-column: span 4;
}

#deliveryForm .memo-field {
  grid-column: span 8;
}

#deliveryForm label:focus-within {
  border-color: #b8d5c6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(40, 116, 80, 0.08);
}

.dialog-card input,
.dialog-card select,
.dialog-card textarea {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 750;
  border-color: #cfd9d4;
}

.dialog-card input::placeholder,
.dialog-card textarea::placeholder {
  color: #737c78;
  font-weight: 750;
}

.dialog-card textarea {
  min-height: 70px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: -18px;
  z-index: 2;
  background: var(--panel);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 0;
  font-size: 21px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
  margin-top: 1px;
}

.form-section-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #dfe8e3;
}

.fee-field {
  align-self: start;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 1px;
}

.check-line input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--green);
}

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

.calc-box {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  background: #f0f6f3;
  border: 1px solid #cfe0d6;
  border-radius: 8px;
  padding: 8px 10px;
}

.calc-item {
  min-width: 0;
}

.calc-item span,
.stat-row span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.calc-item strong,
.stat-row strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  color: #111715;
}

.delivery-warning {
  border: 1px solid #cfd9d4;
  border-left-width: 6px;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 15px;
  font-weight: 900;
}

.delivery-warning.neutral {
  background: #f8faf8;
  color: var(--muted);
}

.delivery-warning.good {
  border-color: #cfe6d8;
  background: #f0f8f4;
  color: var(--green);
}

.delivery-warning.warn {
  border-color: #f2dfb8;
  background: #fffaf0;
  color: var(--gold);
}

.delivery-warning.bad {
  border-color: #f0c7c2;
  background: #fff5f3;
  color: var(--red);
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(210px, 1.15fr) repeat(8, minmax(96px, 0.72fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.filter-grid label {
  gap: 5px;
  font-size: 12px;
}

.filter-grid input,
.filter-grid select {
  min-height: 36px;
  padding: 8px 9px;
}

.quick-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf8;
  color: var(--ink);
  min-height: 30px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 850;
}

.filter-chip:hover {
  border-color: #cfe6d8;
  background: #f0f8f4;
}

.filter-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.filter-summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  padding: 8px 10px;
}

.filter-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.filter-summary-item strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 850;
  background: #f8faf8;
}

.route {
  font-weight: 800;
}

.subtext {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.monthly-metric {
  display: grid;
  gap: 3px;
}

.monthly-metric strong {
  font-size: 13px;
}

.trend {
  font-size: 11px;
  font-weight: 850;
}

.trend.up {
  color: var(--green);
}

.trend.down {
  color: var(--red);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.good {
  background: #e8f5ee;
  color: var(--green);
}

.badge.warn {
  background: #fff7e8;
  color: var(--gold);
}

.badge.bad {
  background: #fff0ee;
  color: var(--red);
}

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

.two-col {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.settings-platforms {
  grid-column: 1 / -1;
}

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

.compact-list .item-card {
  padding: 11px;
  gap: 6px;
}

.platform-card .item-head {
  align-items: start;
}

.platform-card .row-actions {
  flex-wrap: nowrap;
}

.platform-memo {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-summary {
  margin-top: 8px;
}

.settings-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.settings-summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
}

.settings-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.settings-summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  grid-template-rows: minmax(250px, auto) minmax(220px, 1fr);
  gap: 12px;
  height: calc(100vh - 248px);
  min-height: 560px;
  overflow: hidden;
}

.vehicle-grid > .panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.compact-form {
  gap: 12px;
}

.compact-form .panel-head {
  margin-bottom: 2px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.vehicle-summary {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-height: 0;
  overflow: auto;
}

.vehicle-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.vehicle-summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8faf8;
  min-width: 0;
}

.vehicle-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.vehicle-summary-item strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.vehicle-alert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  min-height: 0;
  overflow: auto;
}

.vehicle-alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8faf8;
}

.vehicle-alert span,
.vehicle-alert small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vehicle-alert strong {
  display: block;
  margin: 3px 0 2px;
  font-size: 16px;
}

.vehicle-alert.good {
  border-color: #cfe6d8;
  background: #f0f8f4;
}

.vehicle-alert.warn {
  border-color: #f2dfb8;
  background: #fffaf0;
}

.vehicle-alert.bad {
  border-color: #f0c7c2;
  background: #fff5f3;
}

.insight-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f8faf8;
}

.insight-card.good {
  border-color: #cfe6d8;
  background: #f0f8f4;
}

.insight-card.bad {
  border-color: #f0c7c2;
  background: #fff5f3;
}

.insight-card strong,
.insight-card span {
  display: block;
}

.insight-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.insight-metric {
  text-align: right;
  white-space: nowrap;
}

.dashboard-alerts {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.mini-alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #f8faf8;
  min-width: 0;
}

.mini-alert.good {
  border-color: #cfe6d8;
  background: #f0f8f4;
}

.mini-alert.warn {
  border-color: #f2dfb8;
  background: #fffaf0;
}

.mini-alert.bad {
  border-color: #f0c7c2;
  background: #fff5f3;
}

.mini-alert span,
.mini-alert small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-alert strong {
  display: block;
  margin: 2px 0 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-form,
.card-list {
  display: grid;
  gap: 12px;
}

.vehicle-grid .card-list,
.vehicle-grid .table-wrap {
  min-height: 0;
  overflow: auto;
}

.vehicle-grid .card-list {
  gap: 8px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.vehicle-grid .item-card {
  padding: 10px;
  gap: 5px;
}

.vehicle-grid table {
  min-width: 720px;
}

.vehicle-grid th,
.vehicle-grid td {
  padding: 8px 7px;
}

.item-card .item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.item-card strong {
  font-size: 16px;
}

.bar-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 170px) 1fr minmax(92px, auto);
  gap: 10px;
  align-items: center;
}

.bar-label {
  min-width: 0;
}

.bar-label strong,
.bar-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf2ef;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  min-width: 4px;
}

.empty {
  color: var(--muted);
  padding: 22px 8px;
  text-align: center;
}

.negative {
  color: var(--red);
}

.positive {
  color: var(--green);
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-card {
    margin-top: 0;
  }

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

  .vehicle-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .vehicle-grid > .panel {
    max-height: none;
    overflow: visible;
  }

  .dashboard-alerts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .compact-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

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

  .actions,
  .form-actions {
    width: 100%;
  }

  .actions > *,
  .form-actions > * {
    flex: 1;
  }

  .summary-grid,
  .dashboard-grid,
  .form-grid,
  .filter-grid,
  .two-col,
  .settings-grid,
  .settings-summary-grid,
  .detail-summary-grid,
  .detail-two-col,
  .filter-summary,
  .vehicle-grid,
  .vehicle-alert-grid,
  .vehicle-summary-grid,
  .dashboard-alerts,
  .calc-box {
    grid-template-columns: 1fr;
  }

  #deliveryForm .amount-field,
  #deliveryForm .cost-field,
  #deliveryForm .settlement-field,
  #deliveryForm .memo-field {
    grid-column: auto;
  }

  .span-2,
  .wide {
    grid-column: auto;
  }

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

  .bar-row {
    grid-template-columns: 1fr;
  }
}
