/* ==========================================================================
   marron ADMIN — design system
   Rules held globally here (never re-declared per page):
   · every table cell centred, ruled on all four sides, header identical to body
   · one --line token = one border weight/colour everywhere
   · the window never scrolls; only the table body does
   · 10px is the only spacing step between elements
   ========================================================================== */

:root {
  --ink: #1c1a17;
  --ink-2: #56514a;
  --ink-3: #8b847b;
  --ink-4: #b3aca2;

  --line: #ddd7cd;          /* the ONE border colour for every rule in the UI */
  --line-2: #ece7de;        /* inner hairlines (panel splits) */
  --bw: 1px;                /* the ONE border width */

  --canvas: #f6f3ee;
  --surface: #ffffff;
  --head: #f0ebe2;          /* fully opaque: sticky header must not show through */
  --zebra: #fbf9f6;
  --hover: #f3efe8;
  --sel: #f6f0e4;

  --brand: #1c1a17;
  --accent: #b08d57;
  --gold-bg: #fbf3db; --gold-fg: #8a6a1f;
  --green-bg: #edf3ec; --green-fg: #346538;
  --red-bg: #fdebec; --red-fg: #9f2f2d;
  --blue-bg: #e6eff5; --blue-fg: #1f6c9f;
  --grey-bg: #eeebe6; --grey-fg: #56514a;
  --violet-bg: #efe9f3; --violet-fg: #5c4a6b;

  --gap: 10px;
  --r: 8px;
  --r-sm: 5px;
  --side: 232px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t1: 160ms;
  --t2: 240ms;
  --shadow: 0 2px 10px rgba(60, 46, 32, 0.05);
  --shadow-lift: 0 10px 34px rgba(60, 46, 32, 0.14);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;              /* the page itself never scrolls */
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, 'Apple SD Gothic Neo', 'Helvetica Neue', sans-serif;
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: #e7dcc6; }

/* scrollbars — one look everywhere */
* { scrollbar-width: thin; scrollbar-color: #cfc7ba transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cfc7ba; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b9b0a1; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   shell
   ========================================================================== */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--side) 1fr;
  overflow: hidden;
}

.side {
  background: var(--surface);
  border-right: var(--bw) solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.side-brand {
  padding: 18px 20px;
  border-bottom: var(--bw) solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.side-brand img { width: 96px; height: auto; display: block; }
.side-nav { flex: 1; min-height: 0; overflow-y: auto; padding: var(--gap); display: flex; flex-direction: column; gap: 2px; }
.side-sec {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  position: relative;
  transition: background var(--t1) ease-out, color var(--t1) ease-out;
}
.side-nav a svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; flex: none; }
.side-nav a:hover { background: var(--hover); color: var(--ink); }
.side-nav a.on { background: var(--ink); color: #fff; }
.side-nav a .count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.side-nav a.on .count { color: rgba(255, 255, 255, 0.6); }
.side-foot {
  border-top: var(--bw) solid var(--line);
  padding: var(--gap);
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.side-foot .who { min-width: 0; }
.side-foot .who b { display: block; font-size: 12px; font-weight: 600; }
.side-foot .who span { font-size: 10.5px; color: var(--ink-3); }

.avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: var(--gold-bg);
  color: var(--gold-fg);
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; font-size: 12px; font-weight: 700;
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar {
  height: 54px;
  flex: none;
  background: var(--surface);
  border-bottom: var(--bw) solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 var(--gap) 0 16px;
}
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .crumb { font-size: 11px; color: var(--ink-3); }
.topbar .sp { flex: 1; }

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap);
  overflow: hidden;
  position: relative;
}
.content.scrolls { overflow-y: auto; }

/* view swap — no ghost of the previous page */
.view { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; flex: 1; }
/* On a scrolling page the blocks must keep their natural height; without this
   flex shrinks them below their content and the cards overlap on narrow screens. */
.content.scrolls .view { flex: 0 0 auto; }
.content.scrolls .view > * { flex: 0 0 auto; }
.view.enter { animation: viewIn 260ms var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   cards — 10px gap, 10px rhythm
   ========================================================================== */
.card {
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--gap); }
.card-hd {
  padding: var(--gap) 14px;
  border-bottom: var(--bw) solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
}
.card-hd h2 { font-size: 13px; font-weight: 600; }
.card-hd .sp { flex: 1; }
.card-bd { padding: var(--gap); }

.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.grid-cards { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: var(--gap); grid-template-columns: repeat(3, 1fr); }

/* stat tile */
.stat { padding: 14px; display: flex; flex-direction: column; gap: 6px; transition: transform var(--t2) var(--ease), box-shadow var(--t2) var(--ease); }
.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60, 46, 32, 0.08); }
.stat .lbl { font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }
.stat .val { font-size: 23px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.stat .sub { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.stat .up { color: var(--green-fg); }
.stat .down { color: var(--red-fg); }

/* ==========================================================================
   buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--t1) ease-out, border-color var(--t1) ease-out, color var(--t1) ease-out, transform 110ms ease-out;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.975); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #33302b; border-color: #33302b; }
.btn.danger { color: var(--red-fg); border-color: #eccdcd; background: #fff; }
.btn.danger:hover { background: var(--red-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 11.5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 26px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* the ? guide button, present on every page */
.help-btn {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: var(--bw) solid var(--line);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
  font-size: 13px; font-weight: 700;
  color: var(--ink-2);
  transition: background var(--t1) ease-out, color var(--t1) ease-out, transform var(--t2) var(--ease);
}
.help-btn:hover { background: var(--gold-bg); color: var(--gold-fg); transform: translateY(-1px); }
.help-btn::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0;
  animation: helpPulse 3.6s var(--ease) infinite;
  pointer-events: none;
}
@keyframes helpPulse {
  0%, 70%, 100% { opacity: 0; transform: scale(0.85); }
  78% { opacity: 0.5; transform: scale(1); }
  92% { opacity: 0; transform: scale(1.18); }
}

/* ==========================================================================
   chips — text centred on both axes
   ========================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  min-width: 21px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;                 /* box height == font box, flex centres it exactly */
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--grey-bg);
  color: var(--grey-fg);
}
.chip > * { line-height: 1; display: block; }
.chip.green { background: var(--green-bg); color: var(--green-fg); }
.chip.red { background: var(--red-bg); color: var(--red-fg); }
.chip.gold { background: var(--gold-bg); color: var(--gold-fg); }
.chip.blue { background: var(--blue-bg); color: var(--blue-fg); }
.chip.violet { background: var(--violet-bg); color: var(--violet-fg); }
.chip.line { background: transparent; border: var(--bw) solid var(--line); color: var(--ink-2); }

/* 원문자 — circled numeral / letter, perfectly centred */
.circ {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px; height: 19px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  background: var(--ink);
  color: #fff;
  flex: none;
}
.circ.line { background: transparent; border: var(--bw) solid var(--line); color: var(--ink-2); }
.circ.gold { background: var(--gold-bg); color: var(--gold-fg); }
.circ.lg { width: 24px; height: 24px; font-size: 12px; }

/* ==========================================================================
   form controls
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.field > label .req { color: var(--red-fg); margin-left: 3px; }

.inp {
  height: 32px;
  width: 100%;
  padding: 0 10px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 12.5px;
  transition: border-color var(--t1) ease-out, box-shadow var(--t1) ease-out;
}
.inp:hover { border-color: #cbc3b6; }
.inp:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.12); }
.inp[readonly] { background: var(--zebra); color: var(--ink-2); }
.inp.err { border-color: #d99b9b; box-shadow: 0 0 0 3px rgba(159, 47, 45, 0.08); }
textarea.inp { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.inp.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 금액/수량 입력에는 스피너를 넣지 않는다 */
.inp[type='number'] { -moz-appearance: textfield; appearance: textfield; }
.inp[type='number']::-webkit-outer-spin-button,
.inp[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.help-txt { font-size: 10.5px; color: var(--ink-3); }
.err-txt { font-size: 10.5px; color: var(--red-fg); display: none; }
.field.is-err .err-txt { display: block; }

.affix { position: relative; display: flex; align-items: center; }
.affix .inp { padding-right: 34px; }
.affix .unit {
  position: absolute; right: 10px;
  font-size: 11.5px; color: var(--ink-3);
  pointer-events: none;
  line-height: 1;
}

/* checkbox — one drawing, used in tables, dropdowns and forms */
.cb {
  appearance: none;
  width: 16px; height: 16px;
  flex: none;
  margin: 0;
  border: var(--bw) solid #c7bfb2;
  border-radius: 4px;
  background: var(--surface);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: background var(--t1) ease-out, border-color var(--t1) ease-out, transform 110ms ease-out;
}
.cb::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 1.8px solid #fff;
  border-bottom: 1.8px solid #fff;
  transform: rotate(-45deg) scale(0.4);
  opacity: 0;
  transition: transform 160ms var(--ease), opacity 120ms ease-out;
  margin-top: -2px;
}
.cb:checked, .cb:indeterminate { background: var(--ink); border-color: var(--ink); }
.cb:checked::after { opacity: 1; transform: rotate(-45deg) scale(1); }
.cb:indeterminate::after {
  opacity: 1; width: 9px; height: 0; margin-top: 0;
  border-left: 0; border-bottom: 1.8px solid #fff; transform: none;
}
.cb:active { transform: scale(0.9); }
.cb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.swi { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.swi input { position: absolute; opacity: 0; pointer-events: none; }
.swi i {
  width: 34px; height: 19px; border-radius: 999px; background: #d8d1c5; position: relative;
  transition: background var(--t2) var(--ease);
  flex: none;
}
.swi i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform var(--t2) var(--ease);
}
.swi input:checked + i { background: var(--ink); }
.swi input:checked + i::after { transform: translateX(15px); }

/* image field */
.img-field { display: flex; gap: var(--gap); align-items: flex-start; }
.img-prev {
  position: relative;
  width: 108px; height: 144px;
  flex: none;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--zebra);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.img-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-empty { font-size: 10.5px; color: var(--ink-4); text-align: center; padding: 0 8px; line-height: 1.5; }
.img-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.tbl .thumb-cell {
  width: 30px; height: 40px;
  border-radius: 3px;
  border: var(--bw) solid var(--line);
  object-fit: cover;
  display: block;
}
/* stand-in swatch until a real photograph is uploaded */
.ph-mini { --a: #cdb99f; --b: #f3ebdf; }
.ph-mini { background: linear-gradient(158deg, var(--b), var(--a)); }
.ph-mini[data-tone='1'] { --a: #a9bcc2; --b: #e8f0f2; }
.ph-mini[data-tone='2'] { --a: #b2c0a4; --b: #ecf1e6; }
.ph-mini[data-tone='3'] { --a: #d9b8b1; --b: #f7ebe8; }
.ph-mini[data-tone='4'] { --a: #bfa992; --b: #ece0d2; }
.ph-mini[data-tone='5'] { --a: #cabfaa; --b: #f4efe4; }
.ph-mini[data-tone='6'] { --a: #b6a8c1; --b: #ece7f1; }
.ph-mini[data-tone='7'] { --a: #c8b28c; --b: #f0e6d2; }

/* ==========================================================================
   custom dropdown (native <select> is never used)
   ========================================================================== */
.dd { position: relative; min-width: 0; }
.dd-btn {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 10px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  text-align: left;
  transition: border-color var(--t1) ease-out, box-shadow var(--t1) ease-out;
  position: relative;
}
.dd-btn:hover { border-color: #cbc3b6; }
.dd.open .dd-btn, .dd-btn:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.12); }
.dd-btn .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn .txt.ph { color: var(--ink-4); }
.dd-btn .caret {
  position: absolute; right: 10px; width: 9px; height: 9px;
  border-right: 1.4px solid var(--ink-3); border-bottom: 1.4px solid var(--ink-3);
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--t2) var(--ease);
}
.dd.open .dd-btn .caret { transform: translateY(2px) rotate(-135deg); }
.dd-btn .n {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; line-height: 1;
  border-radius: 999px; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 700;
  flex: none;
}

.dd-pop {
  position: fixed;
  z-index: 900;
  width: 250px;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: top center;
  animation: ddIn 180ms var(--ease) both;
}
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
.dd-pop.out { animation: ddOut 140ms ease-in both; }
@keyframes ddOut { to { opacity: 0; transform: translateY(-4px) scale(0.985); } }

.dd-search { padding: 8px; border-bottom: var(--bw) solid var(--line-2); }
.dd-search input {
  width: 100%; height: 30px; padding: 0 10px;
  border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: var(--zebra); font-size: 12.5px;
}
.dd-search input:focus { outline: 0; border-color: var(--accent); background: #fff; }

.dd-list { max-height: 224px; overflow-y: auto; padding: 5px; }
.dd-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 12.5px;
  transition: background var(--t1) ease-out;
}
.dd-opt:hover, .dd-opt.cursor { background: var(--hover); }
.dd-opt .lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-opt .cnt { font-size: 10.5px; color: var(--ink-4); }
.dd-empty { padding: 18px 10px; text-align: center; color: var(--ink-4); font-size: 12px; }

/* 전체선택 / 전체해제 — always at the bottom of the list */
.dd-foot {
  display: flex;
  border-top: var(--bw) solid var(--line-2);
  background: var(--zebra);
}
.dd-foot button {
  flex: 1;
  height: 34px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background var(--t1) ease-out, color var(--t1) ease-out;
}
.dd-foot button:hover { background: var(--hover); color: var(--ink); }
.dd-foot button + button { border-left: var(--bw) solid var(--line-2); }

/* ==========================================================================
   date picker (native date input is never used)
   ========================================================================== */
.dp { position: relative; }
.dp .inp { padding-right: 32px; }
.dp .cal-ico {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 30px;
  display: grid; place-items: center; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  transition: background var(--t1) ease-out;
}
.dp .cal-ico:hover { background: var(--hover); }
.dp .cal-ico svg { width: 14px; height: 14px; stroke: var(--ink-3); fill: none; stroke-width: 1.5; }

.cal {
  position: fixed;
  z-index: 900;
  width: 252px;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lift);
  padding: var(--gap);
  animation: ddIn 180ms var(--ease) both;
  user-select: none;
}
.cal-hd { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.cal-hd .nav {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  transition: background var(--t1) ease-out;
  flex: none;
}
.cal-hd .nav:hover { background: var(--hover); }
.cal-hd .nav svg { width: 13px; height: 13px; stroke: var(--ink-2); fill: none; stroke-width: 1.7; }
.cal-hd .ttl {
  flex: 1; text-align: center; font-size: 12.5px; font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.cal-hd .ttl button {
  padding: 3px 7px; border-radius: var(--r-sm); line-height: 1;
  transition: background var(--t1) ease-out;
}
.cal-hd .ttl button:hover { background: var(--hover); }

.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow span {
  height: 24px; display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; font-size: 10.5px; color: var(--ink-3); font-weight: 600;
}
.cal-dow span:first-child { color: #b6706e; }
.cal-dow span:last-child { color: #7b8fa6; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-grid button {
  height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
  font-size: 12px;
  border-radius: var(--r-sm);
  transition: background var(--t1) ease-out, color var(--t1) ease-out, transform 110ms ease-out;
  font-variant-numeric: tabular-nums;
}
.cal-grid button:hover { background: var(--hover); }
.cal-grid button:active { transform: scale(0.9); }
.cal-grid button.mute { color: var(--ink-4); }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-grid button.on { background: var(--ink); color: #fff; }
.cal-grid button.sun { color: #b6706e; }
.cal-grid button.sat { color: #7b8fa6; }
.cal-grid button.on.sun, .cal-grid button.on.sat { color: #fff; }

.cal-ym { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cal-ym button {
  height: 34px; border-radius: var(--r-sm); font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t1) ease-out;
}
.cal-ym button:hover { background: var(--hover); }
.cal-ym button.on { background: var(--ink); color: #fff; }

.cal-ft {
  display: flex; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: var(--bw) solid var(--line-2);
}
.cal-ft button {
  flex: 1; height: 28px; border-radius: var(--r-sm); font-size: 11.5px; line-height: 1;
  border: var(--bw) solid var(--line);
  transition: background var(--t1) ease-out;
}
.cal-ft button:hover { background: var(--hover); }

.dp-range { display: flex; align-items: center; gap: 6px; }
.dp-range .dp { flex: 1; min-width: 0; }
.dp-range .tilde { color: var(--ink-4); flex: none; }

/* ==========================================================================
   DATA TABLE — the 12 table rules live here and nowhere else
   ========================================================================== */
.tbl-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;                 /* keeps the rounded corner over the scroller */
}
.tbl-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: var(--gap);
  border-bottom: var(--bw) solid var(--line);
  flex-wrap: wrap;
}
.tbl-bar .sp { flex: 1; }
.tbl-bar .cnt { font-size: 11.5px; color: var(--ink-3); }
.tbl-bar .cnt b { color: var(--ink); font-weight: 650; }

/* only this element scrolls */
.tbl-scroll { flex: 1; min-height: 0; overflow: auto; }

table.tbl {
  width: 100%;
  border-collapse: separate;        /* NOT collapse: keeps sticky-header borders painted */
  border-spacing: 0;
  table-layout: fixed;
}

table.tbl th,
table.tbl td {
  text-align: center;                          /* every cell centred */
  vertical-align: middle;
  padding: 0 8px;
  height: 38px;
  border-right: var(--bw) solid var(--line);   /* vertical rules */
  border-bottom: var(--bw) solid var(--line);  /* the last row draws its own line */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* header and body rules read from the same token — they cannot diverge */
table.tbl th:last-child,
table.tbl td:last-child { border-right: 0; }
table.tbl tbody tr:last-child td { border-bottom: var(--bw) solid var(--line); }

table.tbl thead th {
  position: sticky;                 /* fixed header */
  top: 0;
  z-index: 3;
  background: var(--head);          /* opaque — rows never show through */
  background-clip: padding-box;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-2);
  letter-spacing: 0.01em;
  height: 40px;
  border-bottom: var(--bw) solid var(--line);
}
/* a sticky cell's own bottom rule can hairline-crack at some zoom levels;
   this sits exactly on it so the line is never interrupted */
table.tbl thead th::after {
  content: '';
  position: absolute;
  left: 0; right: -1px; bottom: -1px;
  height: var(--bw);
  background: var(--line);
}
table.tbl thead th.sortable { cursor: pointer; user-select: none; transition: background var(--t1) ease-out; }
table.tbl thead th.sortable:hover { background: #e9e3d8; }
table.tbl thead th .th-in {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  line-height: 1; height: 100%;
}
table.tbl thead th .arw { width: 8px; height: 8px; opacity: 0; flex: none; transition: opacity var(--t1) ease-out, transform var(--t2) var(--ease); }
table.tbl thead th .arw path { stroke: currentColor; stroke-width: 2; fill: none; }
table.tbl thead th.sorted .arw { opacity: 1; }
table.tbl thead th.sorted.asc .arw { transform: rotate(180deg); }

table.tbl tbody tr { transition: background var(--t1) ease-out; }
table.tbl tbody tr:nth-child(even) td { background: var(--zebra); }
table.tbl tbody tr:hover td { background: var(--hover); }
table.tbl tbody tr.sel td { background: var(--sel); }
table.tbl tbody td { font-size: 12px; }

/* every cell's content is itself centred, whatever it holds */
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  min-width: 0;
}
.cell.l { justify-content: flex-start; }
.cell > span, .cell > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.num { font-variant-numeric: tabular-nums; }

/* select column: a checkbox only — never the word 선택 */
table.tbl th.col-sel, table.tbl td.col-sel { width: 42px; padding: 0; }
table.tbl th.col-sel .th-in, table.tbl td.col-sel .cell { justify-content: center; }
/* edit/delete column header reads 관리 */
table.tbl th.col-man, table.tbl td.col-man { width: 104px; padding: 0 6px; }
table.tbl th.col-no, table.tbl td.col-no { width: 56px; color: var(--ink-3); }

.tbl-empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: var(--gap);
}
.tbl-empty svg { width: 40px; height: 40px; stroke: var(--ink-4); fill: none; stroke-width: 1.2; }

/* row enter — staggered, capped so a 100-row page stays snappy */
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
table.tbl tbody tr.anim { animation: rowIn 260ms var(--ease) both; animation-delay: calc(var(--i, 0) * 12ms); }

/* pagination */
.pager {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--gap);
  border-top: var(--bw) solid var(--line);
  flex-wrap: wrap;
}
.pager .pg {
  min-width: 28px; height: 28px; padding: 0 8px;
  border: var(--bw) solid transparent;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  transition: background var(--t1) ease-out, color var(--t1) ease-out, border-color var(--t1) ease-out;
}
.pager .pg:hover { background: var(--hover); }
.pager .pg.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.pager .pg[disabled] { opacity: 0.35; pointer-events: none; }
.pager .gap { color: var(--ink-4); padding: 0 2px; }
.pager .jump { display: flex; align-items: center; gap: 6px; margin-left: 6px; font-size: 11.5px; color: var(--ink-3); }
.pager .jump input {
  width: 52px; height: 28px; text-align: center;
  border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.pager .jump input:focus { outline: 0; border-color: var(--accent); }

/* ==========================================================================
   scoped loading — only the region that is actually loading
   ========================================================================== */
.loading { position: relative; }
.load-veil {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(1.5px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: veilIn 140ms ease-out both;
  border-radius: inherit;
}
@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }
.load-veil.out { animation: veilOut 180ms ease-in both; }
@keyframes veilOut { to { opacity: 0; } }

.spinner { display: flex; flex-direction: column; align-items: center; gap: var(--gap); }
.spinner .mark {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  position: relative;
}
.spinner .mark .logo { width: 40px; height: auto; animation: markPulse 1.7s var(--ease) infinite; }
@keyframes markPulse { 0%, 100% { opacity: 0.35; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1); } }
.spinner .ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.6px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner .txt { font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; }

/* skeleton keeps the table's geometry while data arrives */
.sk { display: block; height: 11px; border-radius: 4px; background: linear-gradient(90deg, #ece7de 25%, #f6f3ee 37%, #ece7de 63%); background-size: 400% 100%; animation: skShine 1.3s ease-in-out infinite; }
@keyframes skShine { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ==========================================================================
   modal
   ========================================================================== */
.modal-root { position: fixed; inset: 0; z-index: 800; display: none; }
.modal-root.on { display: block; }
.modal-scrim {
  position: absolute; inset: 0;
  background: rgba(35, 29, 22, 0.42);
  backdrop-filter: blur(2px);
  animation: scrimIn 200ms ease-out both;
}
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
.modal-root.closing .modal-scrim { animation: scrimOut 180ms ease-in both; }
@keyframes scrimOut { to { opacity: 0; } }

.modal {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 260ms var(--ease) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)) scale(0.985); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-root.closing .modal { animation: modalOut 180ms ease-in both; }
@keyframes modalOut { to { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.99); } }
.modal.wide { width: min(1080px, calc(100vw - 32px)); }
.modal.tall { height: calc(100dvh - 40px); }

.modal-hd {
  flex: none;
  padding: 14px 16px;
  border-bottom: var(--bw) solid var(--line);
  display: flex; align-items: center; gap: var(--gap);
}
.modal-hd h2 { font-size: 14px; font-weight: 650; }
.modal-hd .sp { flex: 1; }
.modal-x {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  transition: background var(--t1) ease-out, transform var(--t2) var(--ease);
  flex: none;
}
.modal-x:hover { background: var(--hover); transform: rotate(90deg); }
.modal-x svg { width: 14px; height: 14px; stroke: var(--ink-2); stroke-width: 1.7; fill: none; }
.modal-bd { flex: 1; min-height: 0; overflow-y: auto; padding: var(--gap); }
.modal-ft {
  flex: none;
  padding: var(--gap);
  border-top: var(--bw) solid var(--line);
  display: flex; align-items: center; gap: var(--gap);
}
.modal-ft .sp { flex: 1; }

.form-grid { display: grid; gap: var(--gap); grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }

/* ==========================================================================
   guide modal — sidebar + search + animated tutorial
   ========================================================================== */
.guide { display: grid; grid-template-columns: 234px 1fr; flex: 1; min-height: 0; }
.guide-side {
  border-right: var(--bw) solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  background: var(--zebra);
}
.guide-search { padding: var(--gap); border-bottom: var(--bw) solid var(--line); }
.guide-search input {
  width: 100%; height: 30px; padding: 0 10px;
  border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: #fff; font-size: 12.5px;
}
.guide-search input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.12); }
.guide-list { flex: 1; min-height: 0; overflow-y: auto; padding: var(--gap); }
.guide-list .grp { font-size: 10px; letter-spacing: 0.12em; color: var(--ink-4); font-weight: 700; padding: 12px 8px 5px; }
.guide-list button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
  transition: background var(--t1) ease-out, color var(--t1) ease-out;
}
.guide-list button:hover { background: var(--hover); color: var(--ink); }
.guide-list button.on { background: var(--ink); color: #fff; }
.guide-list button .k { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-list mark { background: #f6e6bf; color: inherit; border-radius: 2px; padding: 0 1px; }

.guide-body { min-height: 0; overflow-y: auto; padding: 16px 18px 20px; }
.guide-body h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; }
.guide-body .lead { color: var(--ink-2); font-size: 12.5px; margin-bottom: var(--gap); }
.guide-body h4 { font-size: 12.5px; font-weight: 650; margin: 16px 0 6px; }
.guide-body p { font-size: 12.5px; color: var(--ink-2); line-height: 1.75; }
.guide-body ul { margin: 6px 0 0; padding-left: 17px; }
.guide-body li { font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.guide-body code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11.5px; background: var(--zebra);
  border: var(--bw) solid var(--line-2); border-radius: 4px; padding: 1px 5px;
}
.guide-sec { animation: viewIn 240ms var(--ease) both; }

.guide-steps { display: flex; flex-direction: column; gap: var(--gap); margin-top: var(--gap); }
.g-step {
  display: grid; grid-template-columns: 26px 1fr; gap: var(--gap);
  padding: var(--gap);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color var(--t2) var(--ease), box-shadow var(--t2) var(--ease), transform var(--t2) var(--ease);
}
.g-step.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.1); transform: translateX(2px); }
.g-step .b { font-size: 12.5px; font-weight: 600; }
.g-step .d { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* the little animated diagram that plays inside a guide */
.g-demo {
  position: relative;
  height: 168px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  background:
    linear-gradient(var(--line-2) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--zebra);
  overflow: hidden;
  margin-top: var(--gap);
}
.g-demo .bar { position: absolute; left: 10px; right: 10px; top: 10px; height: 26px; border-radius: 5px; background: var(--head); border: var(--bw) solid var(--line); }
.g-demo .box {
  position: absolute;
  border: var(--bw) solid var(--line);
  border-radius: 5px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--ink-2); line-height: 1;
  transition: all 520ms var(--ease);
}
.g-demo .cursor {
  position: absolute; width: 15px; height: 15px; z-index: 4;
  transition: transform 620ms var(--ease);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.g-demo .cursor svg { width: 15px; height: 15px; }
.g-demo .halo {
  position: absolute; z-index: 3;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  background: rgba(176, 141, 87, 0.1);
  opacity: 0;
  transition: all 520ms var(--ease), opacity 240ms ease-out;
  pointer-events: none;
}
.g-demo .halo.on { opacity: 1; }
.g-demo .ripple { position: absolute; z-index: 5; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0; pointer-events: none; }
.g-demo .ripple.go { animation: ripple 520ms var(--ease); }
@keyframes ripple { from { opacity: 0.9; transform: scale(0.4); } to { opacity: 0; transform: scale(3.4); } }

.g-play { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.g-play .prog { flex: 1; height: 3px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.g-play .prog i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 400ms var(--ease); }
.g-play .cur { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* the real-screen walkthrough spotlight */
.spot-root { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.spot-hole {
  position: absolute;
  border-radius: var(--r);
  box-shadow: 0 0 0 9999px rgba(28, 22, 16, 0.55);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: left 520ms var(--ease), top 520ms var(--ease), width 520ms var(--ease), height 520ms var(--ease);
}
.spot-tip {
  position: absolute;
  max-width: 300px;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lift);
  padding: var(--gap) 12px;
  pointer-events: auto;
  transition: left 520ms var(--ease), top 520ms var(--ease);
}
.spot-tip .n { font-size: 10.5px; color: var(--accent); font-weight: 700; letter-spacing: 0.08em; }
.spot-tip .t { font-size: 12.5px; font-weight: 650; margin-top: 2px; }
.spot-tip .d { font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.65; }
.spot-tip .row { margin-top: var(--gap); }

/* ==========================================================================
   toast
   ========================================================================== */
.toasts {
  position: fixed;
  right: var(--gap); bottom: var(--gap);
  z-index: 1100;
  display: flex; flex-direction: column; gap: var(--gap);
  pointer-events: none;
}
.toast {
  min-width: 210px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r);
  padding: var(--gap) 13px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lift);
  animation: toastIn 260ms var(--ease) both;
  pointer-events: auto;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 200ms ease-in both; }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(0.98); } }
.toast .dot { width: 6px; height: 6px; border-radius: 50%; background: #9fd0a2; flex: none; }
.toast.err .dot { background: #e08c8a; }

/* ==========================================================================
   dashboard chart (inline svg, no library)
   ========================================================================== */
.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.chart .axis { stroke: var(--line-2); stroke-width: 1; }
.chart .lbl { font-size: 9.5px; fill: var(--ink-3); }
.chart .linePath { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: rgba(176, 141, 87, 0.1); }
.chart .dot { fill: #fff; stroke: var(--accent); stroke-width: 1.6; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bars .b { display: grid; grid-template-columns: 84px 1fr 52px; gap: var(--gap); align-items: center; }
.bars .b .k { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b .t { height: 7px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bars .b .t i { display: block; height: 100%; border-radius: 99px; background: var(--accent); width: 0; transition: width 720ms var(--ease); }
.bars .b .v { font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ==========================================================================
   responsive
   ========================================================================== */
.side-toggle { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 700;
    transform: translateX(-100%);
    transition: transform var(--t2) var(--ease);
    box-shadow: var(--shadow-lift);
  }
  body.side-open .side { transform: none; }
  body.side-open::after {
    content: ''; position: fixed; inset: 0; z-index: 690;
    background: rgba(35, 29, 22, 0.4);
  }
  .side-toggle { display: inline-flex; }
  .guide { grid-template-columns: 1fr; }
  .guide-side { border-right: 0; border-bottom: var(--bw) solid var(--line); max-height: 170px; }
  .form-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .modal { width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* images field (gallery / detail page) */
.imgs-field { display: grid; grid-template-columns: 1fr 210px; gap: var(--gap); align-items: start; }
.imgs-list { position: relative; min-height: 120px; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; }
.imgs-item { position: relative; width: 88px; }
.imgs-item img { width: 88px; height: 110px; object-fit: cover; border-radius: 4px; display: block; background: var(--hover); }
.imgs-no { position: absolute; left: 4px; top: 4px; font-size: 10px; background: rgba(28, 26, 23, 0.7); color: #fff; border-radius: 3px; padding: 1px 5px; }
.imgs-tools { display: flex; justify-content: center; gap: 2px; margin-top: 4px; }
.imgs-tools button { width: 26px; height: 22px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 13px; line-height: 1; cursor: pointer; }
.imgs-tools button:disabled { opacity: 0.35; cursor: default; }
.imgs-tools button[data-a='del'] { color: #9f2f2d; }
.imgs-side { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 760px) { .imgs-field { grid-template-columns: 1fr; } }
