/* PlanQuokka admin — apricot palette, light/dark. */
:root {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #f5ece3;
  --text: #2b2420;
  --muted: #7a6d63;
  --border: #eadfd5;
  --accent: #a8541b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d3;
  --ok: #3f7d4e;
  --ok-soft: #e1f0e4;
  --danger: #b3261e;
  --danger-soft: #f9dedc;
  --warn-soft: #fff1d6;
  --c0: #a8541b; --c1: #4f7a94; --c2: #7d8f45; --c3: #c99a2e; --c4: #8d5f91; --c5: #3f8f84; --c6: #b85c5c;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1815; --surface: #26201c; --surface-2: #2f2823; --text: #f3ebe4; --muted: #b3a597;
    --border: #3d332b; --accent: #e08a4f; --accent-ink: #1c1815; --accent-soft: #4a3020;
    --ok: #8fcf9d; --ok-soft: #22382a; --danger: #f2a39c; --danger-soft: #4a2321; --warn-soft: #4a3a1a;
    --c0: #e08a4f; --c1: #7fb0cc; --c2: #b2c56f; --c3: #e6c062; --c4: #c597c9; --c5: #6fc4b8; --c6: #e08b8b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
}
body.booting { visibility: hidden; }
[hidden] { display: none !important; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1.02rem; margin: 0 0 10px; }
h4 { font-size: .95rem; margin: 16px 0 8px; color: var(--muted); }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; word-break: break-all; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 10px; }
.warn { background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.empty { color: var(--muted); padding: 8px 0; }
.offscreen { position: fixed; left: -9999px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); display: inline-block; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }

/* Layout */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
#who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; max-width: 1080px; margin: 0 auto; overflow-x: auto; }
.tabs button { flex: 0 0 auto; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.content { max-width: 1080px; margin: 0 auto; padding: 12px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* Forms */
.field { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.field > span { font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 12px; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: .9rem; color: var(--muted); padding: 0 4px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px 12px; }
.check-row { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-bottom: 6px; }
.stack { display: grid; gap: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.search-row { display: flex; gap: 8px; }
.range { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.range .field { flex: 1 1 140px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
textarea.codes { resize: vertical; line-height: 1.7; margin-bottom: 10px; }

/* Buttons */
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.wide { width: 100%; }

/* Lists & tables */
.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.user-row { width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.user-row:hover { border-color: var(--accent); }
.user-email { font-weight: 600; overflow-wrap: anywhere; }
.user-meta { font-size: .82rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }

/* Phone: tables become stacked cards. */
@media (max-width: 640px) {
  .card { padding: 14px 12px; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin-bottom: 8px; }
  td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; text-align: left; flex: 0 0 auto; }
  td.actions::before { content: none; }
  td.num { text-align: right; }
  .search-row .btn { flex: 0 0 auto; }
}

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: .78rem; }
.tile-split { display: grid; grid-template-columns: 1fr auto; margin: 4px 0 0; gap: 0 8px; font-variant-numeric: tabular-nums; }
.tile-split dt { color: var(--muted); font-size: .85rem; }
.tile-split dd { margin: 0; font-weight: 700; text-align: right; }
.chart-plot { width: 100%; min-height: 190px; }
.chart { display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; }
.chart .s0, .swatch.s0 { fill: var(--c0); background: var(--c0); }
.chart .s1, .swatch.s1 { fill: var(--c1); background: var(--c1); }
.chart .s2, .swatch.s2 { fill: var(--c2); background: var(--c2); }
.chart .s3, .swatch.s3 { fill: var(--c3); background: var(--c3); }
.chart .s4, .swatch.s4 { fill: var(--c4); background: var(--c4); }
.chart .s5, .swatch.s5 { fill: var(--c5); background: var(--c5); }
.chart .s6, .swatch.s6 { fill: var(--c6); background: var(--c6); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 6px 0 10px; font-size: .82rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Docs */
.doc-card { padding-bottom: 8px; }
.doc-frame { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: block; }

/* Dialog & toast */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 18px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-body p { margin: 0 0 6px; overflow-wrap: anywhere; }
dialog .form-actions { margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
