:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5d6b78;
  --line: #d9e0e6;
  --brand: #0b5e7e;
  --brand-ink: #ffffff;
  --in: #1f7a4d;
  --out: #b4441f;
  --adj: #6a4bb3;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5300;
  --err-bg: #fde8e6;
  --err-ink: #a3261a;
  --ok-bg: #e3f4ea;
  --ok-ink: #1f6b43;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.edu-banner {
  background: #2d3a45; color: #fff; text-align: center;
  font-size: 13px; padding: 6px 12px; letter-spacing: .02em;
}
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; color: var(--muted); }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.ops main { max-width: 640px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.note { font-size: 13px; color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn.big { width: 100%; min-height: 52px; font-size: 18px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 4px; text-decoration: underline; }

input[type=text], input[type=password], input[type=search], input[type=date], input[inputmode], select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; background: #fff; width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }

.msg { border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 15px; }
.msg.err { background: var(--err-bg); color: var(--err-ink); }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); }

.login { max-width: 360px; margin: 40px auto; }
.pin { font-size: 24px; letter-spacing: .3em; text-align: center; }

/* 운영화면: 항목 카드 */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 14px; min-height: 36px; }
.chip[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: #fff; }
.items { display: grid; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.item:hover { border-color: var(--brand); }
.item .nm { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); }
.item .q { font-size: 20px; font-weight: 700; white-space: nowrap; }
.item .q small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.badge { display: inline-block; font-size: 12px; border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: middle; }
.badge.low { background: var(--err-bg); color: var(--err-ink); }
.badge.check { background: var(--warn-bg); color: var(--warn-ink); }
.badge.hidden { background: #e7eaee; color: var(--muted); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.seg button { min-height: 48px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed=true][data-kind=입고] { background: var(--in); border-color: var(--in); color: #fff; }
.seg button[aria-pressed=true][data-kind=출고] { background: var(--out); border-color: var(--out); color: #fff; }
.seg button[aria-pressed=true][data-kind=실사조정] { background: var(--adj); border-color: var(--adj); color: #fff; }
.mt { margin-top: 16px; }
.cur { font-size: 18px; margin: 6px 0 12px; }
.qtyinput { font-size: 28px; text-align: center; font-weight: 700; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 25, 35, .45); }
dialog .dlg { padding: 16px; }
dialog h3 { margin: 0 0 4px; font-size: 18px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 12px; }
.dlg-actions .btn { flex: 1; }

/* 기록 */
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log li:last-child { border-bottom: 0; }
.kind { font-weight: 700; }
.kind.k-입고 { color: var(--in); }
.kind.k-출고 { color: var(--out); }
.kind.k-실사조정 { color: var(--adj); }
.kind.k-취소, .kind.k-시작 { color: var(--muted); }
.struck { text-decoration: line-through; color: var(--muted); }

/* 관리자 표 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-size: 15px; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected=true] { border-bottom-color: var(--brand); font-weight: 700; color: var(--brand); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--err-bg); color: var(--err-ink); font-size: 12px; margin-left: 4px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: middle; }
th { background: #eef2f5; font-weight: 600; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-low td { background: #fff7f6; }
tr.is-hidden td { color: var(--muted); }
td input.mini { width: 90px; min-height: 32px; padding: 4px 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar .field { margin: 0; min-width: 140px; }
.updated { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #17212b; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; z-index: 50;
  max-width: calc(100vw - 32px);
}

@media (max-width: 600px) {
  main { padding: 12px; }
  .topbar h1 { font-size: 16px; }
}
