/* Design tokens + components shared by the owner screen and the customer order page.
   Layout idea: calm neutral canvas, white surfaces, one green for actions; status colors carry meaning only. */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --line: #E4E7EC;
  --line-strong: #D0D5DD;
  --text: #101828;
  --muted: #667085;
  --primary: #16794A;
  --primary-hover: #126640;
  --primary-soft: #E7F4EC;
  --on-primary: #FFFFFF;
  --danger: #D92D20;
  --danger-soft: #FEF3F2;
  --warn: #B54708;
  --warn-soft: #FFFAEB;
  --info: #175CD3;
  --info-soft: #EFF8FF;
  --violet: #6941C6;
  --violet-soft: #F4F3FF;
  --orange: #C4320A;
  --orange-soft: #FFF6ED;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C111D; --surface: #161B26; --surface-2: #1F242F; --line: #2A303C; --line-strong: #3B4250;
    --text: #F5F5F6; --muted: #94969C; --primary: #3CCB7F; --primary-hover: #57D891; --primary-soft: #0F2E1F; --on-primary: #0C111D;
    --danger: #F97066; --danger-soft: #3A1512; --warn: #FDB022; --warn-soft: #3A2A0B; --info: #53B1FD; --info-soft: #102A47;
    --violet: #9E77ED; --violet-soft: #241A3F; --orange: #F38744; --orange-soft: #3A1E0E;
    --shadow: none; --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 52px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); min-width: 0; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; background: var(--surface); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px 0; }
.card-body { padding: 16px 18px 18px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.notice { white-space: pre-wrap; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.error-box { white-space: pre-wrap; padding: 12px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }

/* Badges: status colors */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.s10 { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.s20 { background: var(--info-soft); color: var(--info); border-color: transparent; }
.s22 { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.s24 { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.s30 { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.s40 { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.unpaid { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.paid { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.open { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.selected td { background: var(--primary-soft); }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 700; background: var(--surface-2); }

/* Segmented tabs */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.tab b { font-weight: 600; font-size: 12px; color: var(--muted); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

/* Toast + dialog */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); white-space: pre-line; }
.toast.error { background: var(--danger); color: #fff; }
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(420px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal-body { padding: 22px 22px 8px; display: flex; flex-direction: column; gap: 8px; }
.modal-body p { margin: 0; color: var(--muted); white-space: pre-wrap; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* Bar chart (SVG) */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line); }
.chart .bar { fill: var(--primary); }
.chart .bar.dim { fill: var(--primary-soft); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
