:root {
  --brand-blue: #1BA0E2;
  --brand-red: #E52521;
  --brand-green: #8DC63F;
  --brand-orange: #F7941D;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --text: #15171a;
  --text-2: #5b616b;
  --text-3: #8b929c;
  --border: #e4e7eb;
  --border-strong: #cfd4da;
  --primary: #15171a;
  --on-primary: #ffffff;

  --orange-bg: #fff2e2; --orange-fg: #a85a00;
  --blue-bg: #e3f3fc;   --blue-fg: #0b6a9c;
  --green-bg: #ecf6df;  --green-fg: #3f6d10;
  --red-bg: #fde7e6;    --red-fg: #b3201d;
  --gray-bg: #eef0f3;   --gray-fg: #4b525c;
  --purple-bg: #efeafd; --purple-fg: #5a3fb8;

  --radius: 12px;
  --radius-sm: 8px;
  --nav-h: 64px;
  --side-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
.ti { font-size: 20px; line-height: 1; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  background: rgba(255,255,255,0.92); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { height: 34px; display: block; }
.brand span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.dot {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--brand-red); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--text-3);
}
.bottomnav a.on { color: var(--text); font-weight: 600; }
.bottomnav a .ti { font-size: 22px; }

.sidenav { display: none; }

@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 56px; height: calc(100vh - 56px);
    padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidenav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    color: var(--text-2); font-size: 14px;
  }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
  .sidenav .sep { height: 1px; background: var(--border); margin: 8px 4px; }
  .sidenav .grp { font-size: 12px; color: var(--text-3); padding: 8px 12px 4px; }
  .bottomnav { display: none; }
  .main { padding: 28px 32px 48px; }
}

/* ---------- building blocks ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.section { margin-top: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 13px; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 13px; color: var(--text-2); }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; letter-spacing: -0.02em; }
.kpi.orange .value { color: #d97a06; }
.kpi.blue .value { color: #1580b8; }
.kpi.red .value { color: #d0201c; }
.kpi.green .value { color: #5a9a1a; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: #2c3036; }
.btn.danger { color: var(--red-fg); border-color: #f2b8b6; }
.btn.danger:hover { background: var(--red-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 52px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-requested { background: var(--orange-bg); color: var(--orange-fg); }
.st-accepted { background: var(--blue-bg); color: var(--blue-fg); }
.st-dispatched { background: var(--green-bg); color: var(--green-fg); }
.st-cancelled { background: var(--red-bg); color: var(--red-fg); }
.st-review { background: var(--purple-bg); color: var(--purple-fg); }
.b-gray { background: var(--gray-bg); color: var(--gray-fg); }
.b-target { background: var(--purple-bg); color: var(--purple-fg); }
.b-red { background: var(--red-bg); color: var(--red-fg); }
.b-orange { background: var(--orange-bg); color: var(--orange-fg); }
.b-green { background: var(--green-bg); color: var(--green-fg); }

/* lists */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-item { display: block; padding: 14px 16px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: #fafbfc; }
.req-title { font-weight: 600; }
.req-lines { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.req-meta { color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* tables (admin) */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 10px 12px; background: #fafbfc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafbfc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
}
textarea.input { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(21,23,26,0.08); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.error { color: var(--red-fg); font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* quantity stepper */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.stepper button { width: 36px; height: 38px; border: 0; background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stepper button:hover { background: var(--surface-2); }
.stepper input { width: 56px; height: 38px; border: 0; text-align: center; font-weight: 700; outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.item-row { padding: 14px 16px; border-top: 1px solid var(--border); }
.item-row:first-child { border-top: 0; }
.item-row.off { opacity: 0.55; }

/* modal */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15,17,20,0.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; padding: 24px; } }
.modal.wide { max-width: 720px; }
.modal-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.modal-icon.red { background: var(--red-bg); color: var(--red-fg); }
.modal-icon.blue { background: var(--blue-bg); color: var(--blue-fg); }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions .btn { flex: 1; height: 46px; }
.infobox { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.infobox + .infobox { margin-top: 8px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #15171a; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.18); max-width: calc(100% - 32px); }
@media (min-width: 960px) { .toast { bottom: 32px; } }

/* timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 4px 0 14px; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.tl-item.requested::before { border-color: var(--brand-orange); }
.tl-item.accepted::before { border-color: var(--brand-blue); }
.tl-item.dispatched::before { border-color: var(--brand-green); background: var(--brand-green); }
.tl-item.cancelled::before { border-color: var(--brand-red); }
.tl-item.review::before { border-color: #7a5af0; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .logo { display: block; width: 220px; margin: 0 auto 8px; }
.brandbar { display: flex; height: 4px; border-radius: 2px; overflow: hidden; }
.brandbar i { flex: 1; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 3px; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-3); }
.empty .ti { font-size: 32px; display: block; margin: 0 auto 8px; }
@media (max-width: 719px) { .hide-mobile { display: none !important; } }
@media (min-width: 720px) { .hide-desktop { display: none !important; } }
