:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #d9dee5;
  --accent: #284b8c;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --warn: #9a6400;
  --bad: #b3261e;
  --code: #eef1f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1a2028;
    --text: #e4e8ee;
    --muted: #9aa5b4;
    --line: #2f3843;
    --accent: #7ea2e6;
    --accent-text: #0e1420;
    --ok: #5cc28f;
    --warn: #e0a83d;
    --bad: #f07067;
    --code: #232b35;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1a2028; --text: #e4e8ee; --muted: #9aa5b4; --line: #2f3843;
  --accent: #7ea2e6; --accent-text: #0e1420; --ok: #5cc28f; --warn: #e0a83d; --bad: #f07067; --code: #232b35;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 17px; margin: 0; }
.who { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
main.narrow { max-width: 420px; }
h2 { font-size: 15px; margin: 24px 0 8px; }
.tabs {
  display: flex; gap: 2px; overflow-x: auto; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 0 8px; scrollbar-width: none;
}
.tabs button {
  flex: 0 0 auto; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; color: var(--muted); padding: 10px 12px; min-height: 44px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
button, select, input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; min-height: 40px;
}
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
input { width: 100%; }
label { display: block; color: var(--muted); font-size: 14px; }
label input, label select { margin-top: 4px; color: var(--text); }
form.stack > * + * { margin-top: 12px; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline input[type="text"], form.inline input:not([type]) { flex: 1 1 200px; width: auto; }
form.inline input[type="file"] { flex: 1 1 220px; width: auto; }
label.check { display: inline-flex; gap: 6px; align-items: center; }
label.check input { width: auto; min-height: 0; margin: 0; }
#login-form > * + * { margin-top: 12px; }
#login-form button { width: 100%; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.status-row { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { min-width: 88px; }
.label { margin: 0; color: var(--muted); font-size: 13px; }
.state { margin: 2px 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0; }
.note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warn); padding: 10px 12px; border-radius: 6px; }
.banner { margin: 0; padding: 10px 16px; }
.error { color: var(--bad); }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
.address { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.address code { font-size: 18px; padding: 8px 10px; word-break: break-all; flex: 1 1 240px; }
code { background: var(--code); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.count { color: var(--muted); font-weight: normal; }
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
table.grid tr:last-child td, table.grid tr:last-child th { border-bottom: 0; }
table.grid th { color: var(--muted); font-weight: 600; white-space: nowrap; }
table.diag th { width: 40%; }
.scroll { overflow-x: auto; }
.errors { padding-left: 20px; margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.errors li { margin-bottom: 6px; word-break: break-word; }
.log { background: var(--code); padding: 12px; border-radius: 6px; font-size: 12px; line-height: 1.45; overflow: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-word; }
.party { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
dialog { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog .actions { justify-content: flex-end; margin-top: 12px; }
@media (max-width: 600px) {
  main { padding: 12px; }
  .status-row { flex-direction: column; align-items: stretch; }
  .actions button { flex: 1; }
  table.grid th, table.grid td { padding: 7px 8px; font-size: 13px; }
}
table.diag td:last-child { width: 1%; white-space: nowrap; }
table.diag button { white-space: nowrap; }
button.primary:disabled { background: var(--surface); color: var(--muted); border-color: var(--line); opacity: 1; }
