:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1f3a5f;
  --ok: #15803d;   --ok-bg: #dcfce7;
  --low: #c2410c;  --low-bg: #ffedd5;
  --out: #b91c1c;  --out-bg: #fee2e2;
  --wait: #4b5563; --wait-bg: #eef0f3;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { margin-left: auto; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--brand); color: #fff;
}
.brand { font-weight: 800; letter-spacing: .5px; text-decoration: none; }
.brand span { font-weight: 400; opacity: .8; }
.topbar nav { display: flex; gap: 4px; order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { text-decoration: none; padding: 5px 11px; border-radius: 6px; opacity: .85; white-space: nowrap; }
.topbar nav a.on { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who a { text-decoration: none; }
@media (min-width: 720px) {
  .topbar { flex-wrap: nowrap; }
  .topbar nav { order: 0; width: auto; }
  .who { order: 4; }
}
button.link { background: none; border: 0; color: #fff; opacity: .75; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card { background: var(--card); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 14px; margin-bottom: 14px; }

.sup-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pill { border-radius: 10px; padding: 8px 12px; background: var(--card); border-left: 4px solid var(--wait); font-size: 13px; }
.pill b { display: block; font-size: 14px; }
.pill.ok { border-color: var(--ok); }
.pill.stale { border-color: var(--out); background: var(--out-bg); }
.pill.off { border-color: var(--line); }

.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--wait-bg); color: var(--wait); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.stale { background: var(--out-bg); color: var(--out); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input { flex: 1 1 160px; }
input {
  font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }

.seg { display: inline-flex; background: #e6e8ec; border-radius: 9px; padding: 3px; gap: 2px; }
.seg.wide { display: flex; margin-bottom: 12px; }
.seg.wide a { flex: 1; text-align: center; }
.seg button, .seg a {
  border: 0; background: none; font: inherit; font-size: 14px; padding: 6px 11px;
  border-radius: 7px; cursor: pointer; text-decoration: none; color: var(--muted); white-space: nowrap;
}
.seg .on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
table.stock { width: 100%; border-collapse: collapse; }
table.stock th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.stock td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.stock tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; white-space: nowrap; }
.qty { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.badge.out { background: var(--out-bg); color: var(--out); }
.badge.low { background: var(--low-bg); color: var(--low); }

table.input input { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
table.input input.changed { background: #fffbe6; border-color: #f2c94c; }

.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1; }
.btn {
  font: inherit; font-size: 16px; font-weight: 600; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 8px; }

.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--out-bg); color: var(--out); }

.login { max-width: 340px; margin: 12vh auto 0; background: var(--card); padding: 28px 24px; border-radius: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.login h1 { font-size: 24px; letter-spacing: 1px; color: var(--brand); }
.login p.muted { margin: 2px 0 18px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login label input { margin-top: 4px; color: var(--text); }

tr.sub td { background: #f7f4ee; font-weight: 600; font-size: 13.5px; padding: 7px 8px; }
.badge.jw { background: #ede9fe; color: #6d28d9; font-size: 11px; padding: 1px 6px; vertical-align: 1px; }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge:not(.out):not(.low):not(.jw):not(.done) { background: var(--wait-bg); color: var(--wait); }
.eta { font-size: 12.5px; color: #1d4ed8; margin-top: 2px; }

.filters .seg { flex-wrap: wrap; }
.add-form summary { font-weight: 700; cursor: pointer; color: var(--brand); }
.add-form[open] summary { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label { font-size: 13px; color: var(--muted); display: block; }
.form-grid label input, .form-grid label select { margin-top: 4px; color: var(--text); }
.form-grid .full { grid-column: 1 / -1; }
select {
  font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%; color: var(--text);
}
.btn.danger { background: #fff; color: var(--out); border-color: #f3c4c4; }
table.arrivals td { vertical-align: top; }
table.arrivals td.wk { width: 64px; font-weight: 700; color: var(--brand); white-space: nowrap; }
table.arrivals tr.dim { opacity: .45; }
table.arrivals .num a { margin-left: 6px; }

a.pill { text-decoration: none; display: block; }
.alert.pw { background: #fef9c3; color: #713f12; font-weight: 600; word-break: break-all; }
.admin-tabs { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: 12px; padding: 12px 14px; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kpi b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.bad b { color: var(--out); }
.card h2 + p.muted { margin: 2px 0 6px; }

.req { padding: 12px 14px; margin-bottom: 10px; border-left: 4px solid transparent; }
.req.mine { border-left-color: var(--brand); }
.req.st-출고완료, .req.st-취소 { opacity: .6; }
.req-top { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.req-top .qty { font-size: 17px; }
.req .dealer { color: var(--text); }
.req .memo { font-size: 14px; margin-top: 4px; background: #f7f7f9; padding: 6px 9px; border-radius: 7px; }
.req-stock { margin-top: 6px; color: var(--muted); }
.req-stock.short { color: var(--out); }
.req-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.s-접수 { background: #dbeafe; color: #1d4ed8; }
.s-확인 { background: #fef3c7; color: #92400e; }
.s-출고완료 { background: var(--ok-bg); color: var(--ok); }
.s-취소 { background: var(--wait-bg); color: var(--wait); }
.btn.sm { font-size: 13.5px; padding: 6px 12px; border-radius: 8px; }
.btn.sm.s-접수, .btn.sm.s-확인, .btn.sm.s-출고완료, .btn.sm.s-취소 { border-color: transparent; font-weight: 700; }

form.inline { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
table.users td { vertical-align: middle; }
tr.dim, details.dim { opacity: .5; }
.color-item { padding: 10px 14px; margin-bottom: 8px; }
.color-item summary { cursor: pointer; list-style: none; }
.color-item[open] summary { margin-bottom: 12px; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.form-grid label.check input { width: auto; margin: 0; }
.form-grid h2 { margin-bottom: 2px; }
.steps { margin: 0; padding-left: 18px; }
.steps li { margin-bottom: 3px; }
.chats { display: flex; flex-wrap: wrap; gap: 6px; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11.5px; }
svg.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { fill: var(--brand); }
svg.chart .lastval { fill: var(--brand); font-size: 13px; font-weight: 700; }

.notice { background: #fff7e6; border: 1px solid #f5d9a8; color: #7a4b00; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.jw-note { color: #7a4b00; font-weight: 500; margin-top: 2px; }

fieldset.ship { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
fieldset.ship legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
@media (max-width: 480px) { fieldset.ship { grid-template-columns: 1fr; } }
.ship-info { margin-top: 6px; padding: 7px 10px; background: #eef4ff; border-radius: 8px; line-height: 1.6; }
.ship-info .warn { color: var(--out); font-weight: 600; }

/* ───────── 터치 기기 공통: 손가락으로 누르기 쉽게 ───────── */
html { -webkit-tap-highlight-color: rgba(31, 58, 95, .15); }
a, button, select, summary, input { touch-action: manipulation; }   /* 두 번 탭 확대 지연 제거 */
.seg button, .seg a { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.btn.sm { min-height: 40px; }
.who a, button.link { padding: 8px 2px; }
.topbar nav a { padding: 9px 12px; }
.add-form summary, .color-item summary { padding: 6px 0; }
table.arrivals .num a, a.edit-link {
  display: inline-block; padding: 6px 12px; margin-top: 4px; border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; color: var(--brand); font-weight: 600;
}
.ship-info a { display: inline-block; padding: 6px 0; font-weight: 600; color: var(--brand); }

/* ───────── 휴대폰 화면 (폭 600px 이하) 자동 적용 ───────── */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .small { font-size: 13.5px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .wrap { padding: 12px; }
  .card { padding: 14px 12px; border-radius: 14px; }
  input, select { min-height: 46px; }
  .btn { min-height: 48px; }
  table.stock td { padding: 11px 4px; }
  table.stock th { font-size: 13px; }
  .qty { font-size: 17px; }
  .badge { font-size: 13px; padding: 3px 9px; }
  .eta { font-size: 13.5px; }
  .pill { padding: 10px 12px; }
  /* 요청 상태 버튼은 한 줄을 나눠 크게 */
  .req-actions .btn.sm { flex: 1; min-height: 44px; font-size: 15px; }
  .req-top .qty { font-size: 19px; }
  .memo { font-size: 15px; }
  /* 재고 입력칸 크게 */
  table.input input { width: 104px; min-height: 48px; font-size: 18px; }
  /* 필터 버튼이 넘치면 좌우로 밀어서 보기 */
  .filters .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .filters .seg::-webkit-scrollbar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi b { font-size: 28px; }
  svg.chart .tick { font-size: 13px; }
}

/* 아주 작은 폰 (폭 360px 이하) */
@media (max-width: 360px) {
  .topbar nav a { padding: 9px 9px; font-size: 14.5px; }
  table.input input { width: 88px; }
}

.notice p { margin: 0 0 4px; line-height: 1.55; }
.notice p:last-child { margin-bottom: 0; }
.notice .eg { color: #9a6a1e; }
.notice .mgr { font-weight: 700; white-space: nowrap; }
.notice .caution { color: #a31515; font-weight: 700; }

.demand h3 { font-size: 14px; margin: 14px 0 2px; color: var(--muted); }
.demand .total { color: var(--brand); font-size: 16px; }
.demand-months { margin: 6px 0 4px; }
.bar { height: 5px; background: #eef0f3; border-radius: 3px; margin-top: 5px; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* 변경 이력 */
.badge.badge.edited { background: #fde68a; color: #92400e; font-size: 11.5px; }
.hist-box { margin-top: 8px; font-size: 13.5px; }
.hist-box summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.hist-box.edited summary { color: #92400e; font-weight: 700; }
ol.history { list-style: none; margin: 4px 0 0; padding: 0; border-left: 2px solid var(--line); }
ol.history li { padding: 4px 0 4px 10px; display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 13.5px; }
ol.history .h-when { color: var(--muted); white-space: nowrap; }
ol.history .h-who { font-weight: 600; }
ol.history .h-what { flex-basis: 100%; }
ol.history li.h-수정 .h-what { color: #b45309; font-weight: 700; }
ol.history li.h-상태 .h-what { color: var(--brand); }
.req-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.dealer-row { border-bottom: 1px solid var(--line); }
.dealer-row summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 2px; }
.dealer-row summary::-webkit-details-marker { display: none; }
.dealer-row summary::before { content: "▸"; color: var(--muted); }
.dealer-row[open] summary::before { content: "▾"; }
.dealer-row .d-name { flex: 1; }
.dealer-row .d-total { text-align: right; white-space: nowrap; }
.dealer-row .d-total .bar { display: block; }
.dealer-row[open] { background: #fafbfc; }
.d-items { margin: 0 0 8px 18px; width: calc(100% - 18px); }
