:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --brand: #1f6feb; --brand-d: #1857c4;
  --ok: #15803d; --warn: #b45309; --err: #b91c1c; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; }
.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: var(--ink); text-decoration: none; padding: 6px 4px; border-bottom: 2px solid transparent; }
.nav a:hover { border-color: var(--brand); }
.logout-form { margin: 0; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { color: var(--err); }

.container { max-width: 940px; margin: 0 auto; padding: 18px 14px 60px; }
.page-title { font-size: 1.35rem; margin: 6px 0 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.success { border-color: #bbf7d0; background: #f0fdf4; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.05rem; margin: 0; }
.card-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; }
.grid .col-2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; font-size: .82rem; color: var(--muted); gap: 4px; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.vat-toggle .switch { display: flex; align-items: center; gap: 8px; padding-top: 6px; color: var(--ink); }
.vat-toggle input { width: auto; }

.btn { font: inherit; cursor: pointer; border-radius: 8px; padding: 9px 16px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.primary:disabled { background: #9db8e8; border-color: #9db8e8; cursor: not-allowed; }
.btn.ghost { background: #fff; }

.actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin: 4px 0 16px; }
.geocode-opt { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.geocode-opt input { width: auto; }

.trip { border: 1px solid var(--line); border-radius: 9px; padding: 12px; margin-bottom: 12px; background: #fcfcfd; }
.trip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.trip-no { font-weight: 600; }

.addr-field { position: relative; }
.autocomplete-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 0 0 8px 8px; box-shadow: var(--shadow); z-index: 30; max-height: 220px; overflow: auto; }
.autocomplete-list .item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f1f1f1; font-size: .85rem; }
.autocomplete-list .item:hover { background: #eef4ff; }
.autocomplete-list .item .sub { color: var(--muted); font-size: .75rem; }
.reuse { position: relative; min-width: 220px; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: .9rem; }
.alert.error { background: #fef2f2; color: var(--err); border: 1px solid #fecaca; }
.alert.warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

.muted { color: var(--muted); } .small { font-size: .8rem; }

.preview-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.preview-row .route { font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.high { background: #dcfce7; color: var(--ok); }
.badge.medium { background: #fef9c3; color: #854d0e; }
.badge.low { background: #ffedd5; color: var(--warn); }
.badge.none { background: #fee2e2; color: var(--err); }
.price-edit { width: 130px; text-align: right; }
.warn-line { color: var(--warn); font-size: .8rem; margin-top: 4px; }
.totals { text-align: right; font-size: 1.05rem; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.totals .grand { font-weight: 700; font-size: 1.2rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { min-width: 220px; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 12px; }

.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg,#eef2ff,#f4f6f9); }
.login-card { background: #fff; padding: 28px 26px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.1); width: min(360px, 92vw); }
.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .nav { gap: 10px; font-size: .9rem; }
  .container { padding: 12px 10px 50px; }
}
