:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2129; --muted: #6b7280; --line: #e3e6eb;
  --accent: #4f5bd5; --accent-text: #ffffff; --ok: #1f9d55; --warn: #c2410c; --chip: #fdecec; --chip-text: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161b; --card: #1e2128; --text: #e7e9ee; --muted: #9aa1ad; --line: #2e323b;
    --accent: #7d87ff; --accent-text: #0e1020; --ok: #4ade80; --warn: #fb923c; --chip: #3a1f22; --chip-text: #fca5a5; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
header { background: var(--card); border-bottom: 1px solid var(--line); padding: 16px 16px 0; position: sticky; top: 0; z-index: 5; }
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.sub { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }
nav { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 10px 12px; font: inherit; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.hidden { display: none !important; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.req { color: var(--warn); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.item-field { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.item-field label { font-weight: 600; }
.item-field .parsed { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -4px; min-height: 1em; }
.item-field .parsed.bad { color: var(--warn); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.small { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg .mode { flex: 1; border: 0; background: none; }
.seg .mode.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.score-preview { margin-right: auto; color: var(--muted); }
.msg { min-height: 1.5em; margin: 8px 0 0; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--warn); }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select { width: auto; }
.badge { font-size: 12px; background: var(--chip); color: var(--chip-text); border-radius: 99px; padding: 1px 8px; }
.badge.ok { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--chip); color: var(--chip-text); border-radius: 99px; padding: 3px 10px; font-size: 14px; }
.done-all { color: var(--ok); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
th small { display: block; font-weight: 400; }
td.score { font-weight: 700; }
tr.stale td { color: var(--muted); }
.preview-table td:first-child { color: var(--muted); }
.warn-list { color: var(--warn); font-size: 13px; padding-left: 18px; margin: 8px 0 0; }
table.edit td { text-align: left; padding: 4px; }
table.edit input { padding: 6px 8px; }
table.edit input.coef { width: 90px; }
table.edit input.id { width: 110px; font-family: ui-monospace, monospace; font-size: 13px; }
.icon-btn { padding: 4px 8px; font-size: 13px; }
@media (max-width: 520px) {
  .item-field { grid-template-columns: 1fr; }
  .item-field .parsed { grid-column: 1; }
}

.sub-label { display: block; font-size: 13px; font-weight: 600; margin: 4px 0; color: var(--muted); }
.actions.left { justify-content: flex-start; margin: 0 0 10px; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
table.sheet { border: 1px solid var(--line); }
table.sheet th, table.sheet td { border: 1px solid var(--line); }
table.sheet th { background: var(--bg); cursor: default; }
table.sheet th[data-sort] { cursor: pointer; }
table.sheet th[data-sort]:hover { color: var(--accent); }
table.sheet tr.missing td { background: var(--chip); color: var(--chip-text); }
table.sheet tr.total td { font-weight: 700; background: var(--bg); }
table.sheet td.na { color: var(--line); text-align: center; }
.days { display: flex; gap: 2px; }
.days label { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); }
.days input { width: auto; margin: 0; }
table.edit input[data-k=name] { min-width: 96px; }
table.edit input[data-k=aliases] { min-width: 110px; }

h3 { font-size: 14px; margin: 16px 0 8px; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.total-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.total-box span { display: block; font-size: 12px; color: var(--muted); }
.total-box b { font-size: 18px; }
.total-box small { margin-left: 6px; color: var(--muted); }
