[hidden] { display: none !important; }

/* Layout: 상단 사업장 선택 + 탭 바, 개요는 요약 → 상세 순, 나머지 탭은 입력 폼 위 / 목록 아래 */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef4;
  --fg: #1b1e2b;
  --muted: #646a80;
  --line: #d9dce6;
  --accent: #3343c4;
  --accent-soft: #e3e6fa;
  --foil: #b8892a;
  --good: #1f8a5b;
  --warn: #b26a00;
  --bad: #c2392f;
  --font-display: "Gothic A1", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #12141c; --surface: #1a1d28; --surface-2: #232736; --fg: #e8eaf2; --muted: #9298ae; --line: #2e3345;
  --accent: #8a96ff; --accent-soft: #262c52; --foil: #ddb35a; --good: #4cc48d; --warn: #e8a33c; --bad: #ef6b60; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #12141c; --surface: #1a1d28; --surface-2: #232736; --fg: #e8eaf2; --muted: #9298ae; --line: #2e3345;
  --accent: #8a96ff; --accent-soft: #262c52; --foil: #ddb35a; --good: #4cc48d; --warn: #e8a33c; --bad: #ef6b60; color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; line-height: 1.5; }
.wrap { max-width: 1080px; margin: 0 auto; padding-block: 20px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

header.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.site-sel { font-family: var(--font-display); font-size: 24px; font-weight: 800; border: 0; padding: 2px 28px 2px 0; background: transparent; width: auto; max-width: 100%; cursor: pointer; }
.site-tag { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sync { font-size: 12px; color: var(--muted); }
.sync.err { color: var(--bad); }

nav.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; gap: 4px; margin-top: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.tabs button { appearance: none; border: 0; background: none; color: var(--muted); font: 600 14px var(--font-body); padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
nav.tabs button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

section.panel { padding-top: 20px; display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 small { font: 500 12px var(--font-body); color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 4px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .val { font-family: var(--font-num); font-size: 22px; font-weight: 500; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat .val.bad { color: var(--bad); } .stat .val.warn { color: var(--warn); }
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 5px; }
.bar i.over { background: var(--bad); }
.bar-row .amt { font-family: var(--font-num); font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

.list { display: grid; gap: 0; }
.li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.li .meta { font-size: 12px; color: var(--muted); }

.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { color: var(--good); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }
.chip.foil { color: var(--foil); border: 1px solid currentColor; background: none; }

form.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; align-items: end; }
form.grid .span2 { grid-column: span 2; } form.grid .span3 { grid-column: span 3; } form.grid .span-all { grid-column: 1 / -1; }
form.grid.two { grid-template-columns: 1fr 1fr; } form.grid .span4 { grid-column: 1 / -1; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
input, select, textarea { font: 14px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 38px; }
.btn { appearance: none; font: 600 13px var(--font-body); border-radius: 7px; padding: 9px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg); white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { font-size: 12px; color: var(--muted); }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; white-space: nowrap; }
td.r, th.r { text-align: right; }
td.amt { font-family: var(--font-num); white-space: nowrap; }
tfoot td { font-weight: 600; border-bottom: 0; }
tr.editing td { background: var(--accent-soft); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toolbar select { width: auto; }

.phase { display: grid; gap: 0; }
.phase + .phase { margin-top: 14px; }
.phase h3 { font-size: 13px; font-weight: 700; color: var(--muted); display: flex; gap: 8px; align-items: center; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.task { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.task .t { min-width: 0; overflow-wrap: anywhere; }
.task.done .t .name { text-decoration: line-through; color: var(--muted); }
.task .note { font-size: 12px; color: var(--muted); }
.task input[type=date] { width: 140px; padding: 4px 6px; font-size: 12px; }
.task select { width: auto; padding: 4px 6px; font-size: 12px; }
.task .ctl { display: flex; gap: 6px; align-items: center; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; flex: 1; max-width: 120px; }
.progress i { display: block; height: 100%; background: var(--good); }

.rc { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 20px; align-items: start; }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; min-height: 260px; display: grid; place-items: center; text-align: center; padding: 16px; background: var(--surface-2); cursor: pointer; position: relative; overflow: hidden; }
.drop img { max-height: 420px; width: 100%; object-fit: contain; border-radius: 6px; }
.drop .big { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--fg); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.scan { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--accent); font-weight: 600; }
.scan.err { color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3 } to { opacity: 1 } }
.req::after { content: " *"; color: var(--bad); }
.reason { font-size: 12px; color: var(--fg); }
.reason.missing { color: var(--warn); }
.rlink { font-size: 12px; }
.empty { padding: 22px 8px; text-align: center; color: var(--muted); font-size: 13px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 20; }
.ro-note { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); }

@media (max-width: 760px) {
  .rc { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  form.grid { grid-template-columns: 1fr 1fr; }
  form.grid .span2, form.grid .span3 { grid-column: 1 / -1; }
  .stats.five { grid-template-columns: repeat(2, 1fr); }
  .task { grid-template-columns: auto 1fr; }
  .task .ctl { grid-column: 2; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: no-preference) { .bar i, .progress i { transition: width .4s ease; } }

:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html, body { margin: 0; }
.site-fixed { font-size: 24px; font-weight: 800; }
.who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.login { min-height: 100vh; display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-card h1 { font-size: 24px; }
.login-card #lgErr { color: var(--bad); margin: 0; min-height: 1em; }
.h3 { font-size: 13px; margin: 6px 0 2px; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
input.cb { width: auto; }
.pr { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.pr + .pr { margin-top: 10px; }
.pr-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; justify-content: space-between; }
.pr-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.pr-amt { font-family: var(--font-num); font-size: 18px; }
.pr-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.acct { font-family: var(--font-num); color: var(--fg); }
.pr-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 4px; border-top: 1px dashed var(--line); }
.pr-act select, .pr-act input { width: auto; padding: 5px 8px; font-size: 12px; }
.pr.paid { opacity: .75; }
.pr .reason { font-size: 13px; }

.star { appearance: none; border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--line); padding: 2px 4px; }
.star.on { color: var(--foil); }
.qty-cell { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.qty-cell b { font-family: var(--font-num); min-width: 2.5em; text-align: right; }
.qty-cell b.low { color: var(--bad); }
.qty-cell input { width: 70px; text-align: right; padding: 4px 6px; }
.btn.xs { padding: 2px 7px; font-size: 12px; }
tr.hist td { background: var(--surface-2); font-size: 12px; }
.mv { display: flex; gap: 10px; padding: 2px 0; }
.mv .d { font-family: var(--font-num); min-width: 3.5em; text-align: right; }
.mv .d.plus { color: var(--good); } .mv .d.minus { color: var(--bad); }
tr.counted td { background: var(--accent-soft); }

/* 빠른 작업 · 확인할 일 · 검색 */
.gsearch { flex: 1 1 260px; max-width: 420px; min-width: 0; align-self: center; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.qbtn { appearance: none; text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 12px; padding: 14px 16px; cursor: pointer; display: grid; gap: 2px; font: inherit; }
.qbtn b { font-family: var(--font-display); font-size: 16px; }
.qbtn span { font-size: 12px; color: var(--muted); }
.qbtn.primary { background: var(--accent); border-color: var(--accent); }
.qbtn.primary b, .qbtn.primary span { color: var(--surface); }
.qbtn:hover { border-color: var(--accent); }
.quick.big .qbtn { padding: 22px 18px; min-height: 96px; }
.quick.big .qbtn b { font-size: 20px; }
.todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.todo-item { appearance: none; text-align: left; font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.todo-item:hover { border-color: var(--line); }
.todo-item .n { font-family: var(--font-num); font-size: 18px; }
.todo-item.warn .n { color: var(--warn); } .todo-item.bad .n { color: var(--bad); } .todo-item.ok .n { color: var(--good); }
.sr-group + .sr-group { margin-top: 16px; }
.sr-group h3 { font-size: 13px; color: var(--muted); margin: 0 0 4px; display: flex; justify-content: space-between; }
mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
.done-all { color: var(--good); font-size: 13px; padding: 8px 2px; }
@media (max-width: 760px) {
  input, select, textarea { font-size: 16px; } /* iOS 확대 방지 */
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 7px 11px; }
  .gsearch { order: 3; flex-basis: 100%; max-width: none; }
  .quick { grid-template-columns: 1fr 1fr; }
}

.bell { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 99px; padding: 4px 6px 4px 12px; font: 600 12px var(--font-body); display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.bell b { font-family: var(--font-num); background: var(--warn); color: var(--surface); border-radius: 99px; min-width: 22px; padding: 1px 7px; text-align: center; }
.push-nudge { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }

/* 재고: 분류 칩 · 한 줄 등록 · 바로 수정 */
.catbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.catchip { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 99px; padding: 6px 12px; font: 600 13px var(--font-body); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.catchip small { font-family: var(--font-num); color: var(--muted); font-weight: 500; }
.catchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.catchip[aria-pressed="true"] small { color: var(--surface); opacity: .8; }
.catchip.manage { border-style: dashed; color: var(--muted); }
.cat-edit { background: var(--surface-2); border-radius: 10px; padding: 12px; margin-bottom: 12px; display: grid; gap: 10px; }
.cat-row { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.cat-row input { max-width: 240px; }
.cat-row .hint { min-width: 60px; }
.quick-add { display: grid; grid-template-columns: auto minmax(110px, 1fr) minmax(160px, 2fr) 80px 110px 110px 80px auto auto; gap: 8px; align-items: center; padding: 10px; border: 1px dashed var(--accent); border-radius: 10px; margin-bottom: 12px; }
.quick-add select#qaSite[hidden] { display: none; }
.stock-tbl input.cell { width: 96px; text-align: right; padding: 4px 6px; font-family: var(--font-num); font-size: 13px; background: transparent; border-color: transparent; }
.stock-tbl input.cell:hover { border-color: var(--line); }
.stock-tbl input.cell:focus { background: var(--surface); border-color: var(--accent); }
.margin { font-family: var(--font-num); font-size: 12px; }
.margin.neg { color: var(--bad); } .margin.pos { color: var(--good); }
@media (max-width: 760px) {
  .quick-add { grid-template-columns: 1fr 1fr; }
  .quick-add #qaName { grid-column: 1 / -1; }
  .stock-tbl input.cell { width: 80px; }
}

.ob-card { max-width: 420px; }
.ob-card #obErr { color: var(--bad); margin: 0; min-height: 1em; }
.uinfo { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* 메시지 */
.bell.msg b { background: var(--accent); }
.msg-compose { display: grid; gap: 12px; }
.to-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.to-chip { display: inline-flex; gap: 4px; align-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 13px; font-weight: 600; }
.to-chip button { appearance: none; border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0 6px; }
.to-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: grid; gap: 2px; }
.to-group { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; padding: 6px 0 2px; display: flex; justify-content: space-between; }
.to-item { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; cursor: pointer; }
.to-item input { width: auto; }
.seg .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.msg-item { border-bottom: 1px solid var(--line); padding: 10px 2px; display: grid; gap: 4px; }
.msg-item.unread .who::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.msg-item .who { font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg-item .when { font-size: 12px; color: var(--muted); font-weight: 400; }
.msg-item .body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msg-item .act { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rcpt { font-size: 12px; display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.rcpt.read { color: var(--good); } .rcpt.unread { color: var(--muted); }
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 20, .55); z-index: 30; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); color: var(--fg); border-radius: 14px; border: 1px solid var(--line); width: 100%; max-width: 480px; max-height: 80vh; overflow: auto; padding: 20px; display: grid; gap: 14px; }
.mm-list { display: grid; gap: 10px; }
.mm-list .msg-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }

.remember { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }

.site-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; }
.site-checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--fg); cursor: pointer; }
.site-checks input { width: auto; }
details.sites-edit summary { cursor: pointer; font-size: 13px; list-style: none; }
details.sites-edit summary::-webkit-details-marker { display: none; }
details.sites-edit summary::after { content: " ▾"; color: var(--muted); }
details.sites-edit[open] .site-checks { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 6px; display: grid; gap: 4px; }

.ymd { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; }

/* ===== 핸드폰 화면 (760px 이하) ===== */
.site-sel { field-sizing: content; }
@media (max-width: 760px) {
  .wrap { padding-block: 12px 48px; }
  header.top { gap: 8px; }
  .site-sel, .site-fixed { font-size: 22px; }
  .who { width: 100%; justify-content: flex-start; }
  .stat { padding: 12px; }
  .stat .val { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat .sub { font-size: 11px; }
  .card { padding: 14px 12px; border-radius: 12px; }
  .card h2 { font-size: 15px; flex-wrap: wrap; }
  .toolbar { gap: 8px; }
  .toolbar > .actions { width: 100%; }
  .toolbar select, .toolbar input[type=search] { flex: 1 1 140px; width: auto !important; min-width: 0; }
  nav.tabs { margin-top: 12px; scrollbar-width: none; }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs button { padding: 10px 12px; }
  .bar-row { grid-template-columns: 76px 1fr; }
  .bar-row .amt { grid-column: 1 / -1; text-align: left; }
  .pr-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .pr-act { gap: 6px; }
  .pr-act input, .pr-act select { flex: 1 1 120px; }
  .rc { gap: 12px; }
  .drop { min-height: 180px; }

  /* 체크리스트 한 줄 정리 */
  .task { gap: 6px 10px; }
  .task .ctl select, .task .ctl input[type=date] { flex: 1 1 120px; }
}

@media (max-width: 1024px) { .toolbar > .tb-main { order: -1; justify-content: flex-end; } }
@media (max-width: 1024px) {
  /* 재고 카드 정리: [★ 상품명] / [단위 · 수량] / [매입 · 판매 · 마진] / [버튼] */
  #skTable td:nth-child(2) { order: 1; flex: 1 1 calc(100% - 40px); }
  #skTable td:nth-child(3) { order: 2; }
  #skTable td:nth-child(4) { order: 2; margin-left: auto; }
  #skTable td:nth-child(5), #skTable td:nth-child(6) { order: 3; flex: 1 1 calc(50% - 30px); }
  #skTable td:nth-child(5) input.cell, #skTable td:nth-child(6) input.cell { flex: 1; width: auto; min-width: 0; }
  #skTable td:nth-child(7) { order: 3; }
  #skTable td:nth-child(8) { order: 3; }
  #skTable td:nth-child(9) input { flex: 1 1 60px; }
  #usTable td:nth-child(3):empty { display: none; }
}

/* 넓은 모니터는 app.js 의 자동 배율(zoom)로 키움 — 배율이 같아 글자가 밀리지 않음 */
.wrap { max-width: 1480px; }

/* 표 → 카드: 칸이 좁아져 글자가 쪼개지기 전에(1024px 이하) 카드로 */
@media (max-width: 1024px) {
  /* 표 → 카드: 한 건이 한 장의 카드 */
  .tbl-wrap:has(.rtable) { overflow: visible; }
  table.rtable, .rtable tbody { display: block; }
  .rtable thead { display: none; }
  .rtable tfoot { display: block; }
  .rtable tfoot tr { display: flex; justify-content: space-between; padding: 10px 0 0; }
  .rtable tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  .rtable tbody td { display: block; border: 0; padding: 0; text-align: left !important; font-size: 12px; color: var(--muted); min-width: 0; }
  .rtable tbody td.amt, .rtable tbody td b { color: var(--fg); }
  .rtable tbody tr.editing { background: var(--accent-soft); border-radius: 8px; }
  .rtable tbody tr.editing td { background: none; }
  .rtable tbody td[colspan] { flex-basis: 100%; }
  .rtable .hint, .rtable .reason { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .rtable .hint.open, .rtable .reason.open { -webkit-line-clamp: unset; display: block; }

  /* 지출: 제목·사유 / 금액 / 날짜·분류·거래처·결제·증빙 / 버튼 */
  #exTable td:nth-child(4) { order: 1; flex: 1 1 60%; font-size: 14px; color: var(--fg); }
  #exTable td:nth-child(8) { order: 2; margin-left: auto; font-size: 15px; font-weight: 600; }
  #exTable td:nth-child(1), #exTable td:nth-child(2), #exTable td:nth-child(3), #exTable td:nth-child(5), #exTable td:nth-child(6), #exTable td:nth-child(7) { order: 3; }
  #exTable td:nth-child(9) { order: 4; flex-basis: 100%; display: flex; justify-content: flex-end; }
  /* 집기 */
  #eqTable td:nth-child(1) { order: 1; flex: 1 1 60%; font-size: 14px; color: var(--fg); }
  #eqTable td:nth-child(7) { order: 2; margin-left: auto; font-size: 15px; font-weight: 600; }
  #eqTable td:nth-child(n+2):nth-child(-n+6), #eqTable td:nth-child(8) { order: 3; }
  #eqTable td:nth-child(5)::before { content: "수량 "; } #eqTable td:nth-child(6)::before { content: "단가 "; }
  #eqTable td:nth-child(9) { order: 4; flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  /* 자산 */
  #asTable td:nth-child(1) { order: 1; flex: 1 1 60%; font-size: 14px; color: var(--fg); }
  #asTable td:nth-child(6) { order: 2; margin-left: auto; font-size: 15px; font-weight: 600; }
  #asTable td:nth-child(n+2):nth-child(-n+5), #asTable td:nth-child(7), #asTable td:nth-child(8) { order: 3; }
  #asTable td:nth-child(5)::before { content: "수량 "; }
  #asTable td:nth-child(9) { order: 4; flex-basis: 100%; display: flex; justify-content: flex-end; }
  /* 거래처 */
  #vdTable td:nth-child(1) { order: 1; flex: 1 1 60%; font-size: 14px; color: var(--fg); }
  #vdTable td:nth-child(7) { order: 2; margin-left: auto; text-align: right !important; }
  #vdTable td:nth-child(n+2):nth-child(-n+6) { order: 3; flex-basis: calc(50% - 6px); }
  #vdTable td:nth-child(8) { order: 4; flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  /* 재고: ★ 상품명 / 수량 / 가격·마진 / 버튼 */
  #skTable td:nth-child(1) { order: 0; }
  #skTable td:nth-child(2) { order: 1; flex: 1 1 50%; min-width: 0 !important; }
  #skTable td:nth-child(4) { order: 2; margin-left: auto; }
  #skTable td:nth-child(3) { order: 1; }
  #skTable td:nth-child(5), #skTable td:nth-child(6) { order: 3; display: flex; align-items: center; gap: 4px; }
  #skTable td:nth-child(5)::before { content: "매입"; } #skTable td:nth-child(6)::before { content: "판매"; }
  #skTable td:nth-child(7), #skTable td:nth-child(8) { order: 3; }
  #skTable td:nth-child(9) { order: 4; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
  #skTable tr.hist { display: block; } #skTable tr.hist td { display: block; }
  #skTable input.cell { width: 88px; border-color: var(--line); }
  /* 계정 */
  #usTable td:nth-child(1) { order: 1; font-size: 14px; color: var(--fg); }
  #usTable td:nth-child(2) { order: 1; }
  #usTable td:nth-child(6) { order: 2; margin-left: auto; }
  #usTable td:nth-child(3) { order: 3; flex-basis: 100%; }
  #usTable td:nth-child(4), #usTable td:nth-child(5) { order: 4; }
  #usTable td:nth-child(7) { order: 5; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
  /* 활동 로그 */
  #lgTable td:nth-child(5) { order: 1; flex-basis: 100%; font-size: 13px; color: var(--fg); }
  #lgTable td:nth-child(4) { order: 0; }
  #lgTable td:nth-child(1), #lgTable td:nth-child(2), #lgTable td:nth-child(3), #lgTable td:nth-child(6) { order: 2; }

}

@media (min-width: 761px) and (max-width: 1024px) {
  .rtable tbody td { font-size: 13px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
  .quick-add { grid-template-columns: 1fr 1fr 1fr; }
  .quick-add #qaName { grid-column: span 2; }
}

.rrn { display: grid; grid-template-columns: 1fr auto 1.2fr; gap: 6px; align-items: center; }
.rrn span { color: var(--muted); }
.od-grp { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.od-grp + .od-grp { margin-top: 10px; }
.od-head { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: space-between; align-items: baseline; }
.od-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.od-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px 12px; flex-wrap: wrap; }
.od-who { display: flex; flex-wrap: wrap; gap: 6px; }
.od-p { font-size: 12px; border-radius: 8px; padding: 4px 8px; background: var(--surface-2); display: inline-flex; gap: 6px; align-items: center; }
.od-p.done { color: var(--good); } .od-p.new { color: var(--warn); }
.task.order { background: var(--accent-soft); border-radius: 8px; padding: 8px; border-bottom: 0; margin-bottom: 6px; }

/* 지출내역 상단 요약 */
.ex-sum { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; margin-bottom: 14px; }
.ex-today, .ex-period { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; align-content: start; }
.ex-today .label { font-size: 12px; color: var(--muted); }
.ex-today b { font-size: 22px; white-space: nowrap; }
.ex-period b { font-size: 18px; white-space: nowrap; }
.ex-today .sub, .ex-period .sub { font-size: 12px; color: var(--muted); }
.ex-period .seg .btn { min-width: 56px; }
@media (max-width: 760px) { .ex-sum { grid-template-columns: 1fr; } .ex-today b { font-size: 20px; } }

/* 주소 검색 */
.addr-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.addr-detail { margin-top: 6px; }
.pc-modal { max-width: 520px; height: min(560px, 85vh); grid-template-rows: auto 1fr; padding: 14px; }
.pc-box { min-height: 0; border-radius: 8px; overflow: hidden; background: #fff; }

/* 개요: 자산 가치 */
.asset-card { display: grid; grid-template-columns: minmax(220px, 1fr) 2.2fr; gap: 16px; align-items: center; }
.av-main { display: grid; gap: 4px; justify-items: start; }
.av-main .label { font-size: 12px; color: var(--muted); }
.av-main b { font-size: 26px; white-space: nowrap; color: var(--foil); }
.av-main .sub { font-size: 12px; color: var(--muted); }
.av-parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.av-part { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.av-part span { font-size: 12px; color: var(--muted); }
.av-part b { font-family: var(--font-num); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-part.wait b { color: var(--warn); }
@media (max-width: 760px) { .asset-card { grid-template-columns: 1fr; } .av-main b { font-size: 22px; } .av-parts { grid-template-columns: 1fr 1fr; } }
