/* 복미식당 장부 — same stone-and-celadon palette and type as the owner's intro page (bokmi.pages.dev). */
:root {
  --stone: #EEEBE6;
  --paper: #F7F5F2;
  --ink: #2B2A27;
  --muted: #6F6B64;
  --line: #D8D3CB;
  --celadon: #4E7268;
  --celadon-soft: #DCE5E0;
  --wood: #A8703F;
  --wood-soft: #EFE3D6;
  --danger: #A3473A;
  --f-display: "Gowun Batang", "AppleMyungjo", "Nanum Myeongjo", serif;
  --f-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stone: #1C1D1B; --paper: #242623; --ink: #ECE8E1; --muted: #A39E95; --line: #3A3C38;
    --celadon: #8FB5A9; --celadon-soft: #2A3632; --wood: #CF9A68; --wood-soft: #3A3026; --danger: #E08A7C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --stone: #1C1D1B; --paper: #242623; --ink: #ECE8E1; --muted: #A39E95; --line: #3A3C38;
  --celadon: #8FB5A9; --celadon-soft: #2A3632; --wood: #CF9A68; --wood-soft: #3A3026; --danger: #E08A7C;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--stone); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.6;
  word-break: keep-all; overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--celadon); outline-offset: 2px; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--celadon); }
[hidden] { display: none !important; }

.shell {
  max-width: 1080px; margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* top bar */
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--stone) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}
.top-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; min-height: 44px; }
.top h1 { font-size: 20px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1 small { font-family: var(--f-body); font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 6px; }
.back {
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  display: grid; place-items: center; cursor: pointer; flex: none; font-size: 18px; line-height: 1;
}

/* bottom tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--paper); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.tabs nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs a {
  display: grid; justify-items: center; gap: 2px; padding: 6px 4px; text-decoration: none; color: var(--muted);
  font-size: 12px; border-radius: var(--radius); position: relative;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--celadon); font-weight: 600; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--wood); color: var(--paper); font: 600 11px/18px var(--f-mono); text-align: center;
}

/* generic surfaces */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-title h2 { font-size: 21px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font-weight: 500; font-size: 15px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--celadon); }
.btn.primary { background: var(--celadon); border-color: var(--celadon); color: var(--paper); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); font-size: 16px; /* 16px stops iOS zooming on focus */
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.6; }
.input:focus { outline: none; border-color: var(--celadon); box-shadow: 0 0 0 3px var(--celadon-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; }
.seg button {
  border: 0; background: none; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
  display: inline-flex; gap: 6px; align-items: baseline;
}
.seg button small { font-family: var(--f-mono); font-size: 11px; font-weight: 400; }
.seg button[aria-pressed="true"] { background: var(--celadon); color: var(--paper); }
.seg.wide { display: flex; border-radius: var(--radius); }
.seg.wide button { flex: 1; border-radius: 3px; justify-content: center; }

/* ---------- calendar ---------- */
.month-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 14px; }
.month-head h2 { font-size: clamp(26px, 4vw, 34px); font-variant-numeric: tabular-nums; }
.month-nav { display: flex; gap: 6px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.summary > div { background: var(--paper); padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.summary span { font-size: 12px; color: var(--muted); }
.summary b { font-family: var(--f-mono); font-weight: 500; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary .neg { color: var(--danger); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); overflow: hidden; }
.cal .dow { padding: 8px 0; text-align: center; font-size: 12px; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--stone); }
.cal .dow.sun, .day.sun .d { color: var(--danger); }
.cal .dow.sat, .day.sat .d { color: var(--celadon); }
.day {
  min-height: 112px; padding: 8px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--paper); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.day:hover { background: color-mix(in srgb, var(--celadon-soft) 45%, var(--paper)); }
.day.out { background: var(--stone); }
.day.out .d { opacity: .4; }
.day .d { font-family: var(--f-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.day.today .d { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: var(--ink); color: var(--paper) !important; }
.day.sel { box-shadow: inset 0 0 0 2px var(--celadon); }
.day .ln { font-size: 12px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.day .ln b { font-family: var(--f-mono); font-weight: 500; color: var(--ink); }
.day .ln.sales b { color: var(--celadon); }
.day .ln.exp b { color: var(--wood); }
.day .dots { display: none; gap: 3px; }
.day .dots i { width: 6px; height: 6px; border-radius: 999px; }
.i-res { background: var(--celadon); } .i-exp { background: var(--wood); } .i-cook { background: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 999px; margin-right: 5px; vertical-align: 1px; }

.notice { display: grid; gap: 10px; padding: 16px 18px; background: var(--celadon-soft); border-radius: var(--radius); margin-top: 18px; }
.notice h3 { font-size: 17px; }
.notice .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--celadon) 25%, transparent); }

/* ---------- day sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(20 20 18 / .35); animation: fade .18s ease-out; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto;
  background: var(--stone); border-radius: 14px 14px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: rise .24s cubic-bezier(.2,.8,.2,1);
}
.sheet .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 520px; border-radius: 10px; padding: 24px; animation: pop .2s ease-out; }
  .sheet .grip { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%); } }
.sheet h2 { font-size: 24px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.menu5 { display: grid; gap: 8px; margin-top: 18px; }
.menu5 a {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink);
}
.menu5 a:hover { border-color: var(--celadon); }
.menu5 .no { font-family: var(--f-mono); font-size: 12px; color: var(--celadon); }
.menu5 b { font-family: var(--f-display); font-size: 18px; }
.menu5 em { font-style: normal; font-size: 13px; color: var(--muted); font-family: var(--f-mono); text-align: right; }

/* ---------- sales ---------- */
.lvl1 { margin-top: 18px; }
.lvl2 { margin-top: 10px; }
.menu-rows { margin-top: 14px; display: grid; }
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.mrow:last-child { border-bottom: 1px solid var(--line); }
.mrow .name { font-family: var(--f-display); font-size: 17px; font-weight: 700; }
.mrow .price { font-size: 12px; color: var(--muted); font-family: var(--f-mono); }
.mrow .counters { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.counter { display: grid; gap: 4px; justify-items: center; }
.counter > small { font-size: 11px; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.stepper button { width: 40px; height: 42px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.stepper button:active { background: var(--celadon-soft); }
.stepper input { width: 48px; height: 42px; border: 0; border-inline: 1px solid var(--line); text-align: center; background: none; font: 500 17px var(--f-mono); }
.stepper input:focus { outline: none; background: var(--celadon-soft); }
.stepper.has input { color: var(--celadon); font-weight: 600; }
.mrow .sub-amt { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-family: var(--f-mono); text-align: right; margin-top: -4px; }

.totals {
  position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 10; margin-top: 18px;
  background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.totals .parts { display: flex; gap: 14px; flex: 1; min-width: 0; flex-wrap: wrap; font-size: 12px; opacity: .85; }
.totals .parts b { font-family: var(--f-mono); font-weight: 500; }
.totals .sum { font: 600 20px var(--f-mono); font-variant-numeric: tabular-nums; }
.totals .btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .totals { background: var(--celadon-soft); color: var(--ink); }
  :root:not([data-theme="light"]) .totals .btn.primary { background: var(--celadon); color: var(--stone); border-color: var(--celadon); }
}

.breakdown { display: grid; gap: 0; margin-top: 8px; }
.breakdown div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.breakdown div b { font-family: var(--f-mono); font-weight: 500; }
.breakdown .grp { font-weight: 600; border-top-style: solid; }

/* ---------- lists ---------- */
.list { display: grid; }
.li { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.li:last-child { border-bottom: 1px solid var(--line); }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; }
.li .s { font-size: 13px; color: var(--muted); }
.amt { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--celadon-soft); color: var(--celadon); white-space: nowrap; }
.chip.wood { background: var(--wood-soft); color: var(--wood); }
.chip.gray { background: var(--stone); color: var(--muted); border: 1px solid var(--line); }
.empty { padding: 28px 0; text-align: center; color: var(--muted); font-size: 14px; }

/* reservation menu picker */
.picks { display: grid; gap: 8px; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.pick:first-child { border-top: 0; }

/* cooking: menu buttons */
.cook-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.cook {
  display: grid; gap: 8px; align-content: space-between; min-height: 116px; padding: 14px; text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.cook b { font-family: var(--f-display); font-size: 17px; line-height: 1.35; }
.cook .q { font: 500 28px var(--f-mono); color: var(--line); }
.cook.on { border-color: var(--celadon); background: var(--celadon-soft); }
.cook.on .q { color: var(--celadon); }
.cook small { font-size: 12px; color: var(--muted); }

/* shopping */
.check { width: 26px; height: 26px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--paper); display: grid; place-items: center; cursor: pointer; flex: none; }
.check.on { background: var(--celadon); border-color: var(--celadon); color: var(--paper); }
.li.done .t { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { border: 1px dashed var(--line); background: none; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.suggest button:hover { border-color: var(--celadon); color: var(--celadon); }
.suggest button small { color: var(--muted); font-family: var(--f-mono); font-size: 11px; margin-left: 4px; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpis > div { background: var(--paper); padding: 16px; display: grid; gap: 4px; min-width: 0; }
.kpis span { font-size: 13px; color: var(--muted); }
.kpis b { font: 500 22px var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis em { font-style: normal; font-size: 12px; color: var(--muted); }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(84px, 140px) 1fr auto; align-items: center; gap: 12px; font-size: 14px; }
.bar .track { height: 10px; background: var(--stone); border-radius: 2px; overflow: hidden; display: flex; }
.bar .fill { height: 100%; background: var(--celadon); }
.bar .fill.wood { background: var(--wood); }
.bar .fill.light { background: color-mix(in srgb, var(--celadon) 45%, var(--paper)); }
.bar .v { font-family: var(--f-mono); font-size: 13px; white-space: nowrap; text-align: right; min-width: 72px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.cols > * { min-width: 0; }
.card h3 { font-size: 18px; margin-bottom: 4px; }
.card .hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.months { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; overflow-x: auto; }
.mcol { flex: 1 0 34px; display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; }
.mcol .pair { display: flex; align-items: flex-end; gap: 3px; justify-content: center; }
.mcol .pair i { width: 12px; border-radius: 2px 2px 0 0; min-height: 1px; }
.mcol .pair .s { background: var(--celadon); } .mcol .pair .e { background: var(--wood); }
.mcol span { font-size: 11px; color: var(--muted); text-align: center; font-family: var(--f-mono); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t td.n, table.t th.n { white-space: nowrap; text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); display: grid; gap: 16px; }
.login h1 { font-size: 34px; }
.err { color: var(--danger); font-size: 14px; min-height: 1.4em; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 14px; animation: fade .2s;
  max-width: calc(100vw - 32px);
}
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------- phone ---------- */
@media (max-width: 640px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .day { min-height: 64px; padding: 5px 4px; gap: 2px; }
  .day .ln { display: none; }
  .day .ln.sales { display: block; font-size: 11px; }
  .day .ln.sales span { display: none; }
  .day .dots { display: flex; }
  .day .d { font-size: 12px; }
  .day.today .d { width: 21px; height: 21px; }
  .grid2 { grid-template-columns: 1fr; }
  .mrow { grid-template-columns: 1fr; }
  .mrow .counters { justify-content: flex-start; }
  .bar { grid-template-columns: 84px 1fr auto; gap: 8px; }
}
@media (min-width: 641px) { .legend { display: none; } }

.cooktbl tr.main td { border-bottom: 0; }
.field > .counter { justify-items: start; }
.lockbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 6px;
  background: var(--wood-soft); color: var(--ink); border-radius: var(--radius); font-size: 14px; }
.lockbar.open { background: var(--celadon-soft); }
