:root {
  --bg: #f5f4ef; --card: #ffffff; --text: #1c1c1a; --muted: #66655f; --border: #dedcd3;
  --primary: #2d5f95; --on-primary: #ffffff; --soft: #eceae3; --brand: #1d3552; --gold: #d9a81e;
  --ok-bg: #dff1e3; --ok-fg: #1d6b34; --warn-bg: #fbecc8; --warn-fg: #7a5200; --bad-bg: #f9dcdc; --bad-fg: #9a2323;
  --teal-bg: #cdefe3; --teal-fg: #0b5a45; --violet-bg: #ddd9fa; --violet-fg: #3d3491;
  --orange-bg: #fbd9cc; --orange-fg: #7d3215; --blue-bg: #d2e6f9; --blue-fg: #0f4a85;
  --pink-bg: #f8d3e0; --pink-fg: #7d2647; --green-bg: #dcecc2; --green-fg: #33580f;
  --amber-bg: #fbe3b5; --amber-fg: #6e4307; --red-bg: #f9d0d0; --red-fg: #862222;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --card: #20201f; --text: #ededea; --muted: #a5a49d; --border: #36362f;
    --primary: #7fb0e3; --on-primary: #0b1f33; --soft: #2a2a28;
    --ok-bg: #173522; --ok-fg: #8fd6a4; --warn-bg: #3d2f0c; --warn-fg: #f0c869; --bad-bg: #441a1a; --bad-fg: #f1a3a3;
    --teal-bg: #0f4636; --teal-fg: #a8ecd4; --violet-bg: #322c73; --violet-fg: #cfcaf8;
    --orange-bg: #63290f; --orange-fg: #f8c9b6; --blue-bg: #103e6e; --blue-fg: #bcdaf7;
    --pink-bg: #631f39; --pink-fg: #f6c5d6; --green-bg: #2a470e; --green-fg: #cfe5ab;
    --amber-bg: #573606; --amber-fg: #f8d897; --red-bg: #691c1c; --red-fg: #f6c2c2;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.err { color: var(--bad-fg); font-size: 14px; min-height: 1.4em; }

header.top {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff;
  background: linear-gradient(rgba(22, 40, 64, 0.9), rgba(22, 40, 64, 0.9)), var(--brand) url(/bg/hero-2.jpg) center 40% / cover;
}
header.top h1 { flex: none; white-space: nowrap; }
header.top .who { flex: 1; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #cfdbe8; }
header.top .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
header.top .btn:hover { background: rgba(255, 255, 255, 0.14); }
/* 로고 그림에서 심볼 부분만 보이게 자른다 */
.mark { flex: none; width: 60px; height: 28px; overflow: hidden; }
.mark img { display: block; height: 62.25px; width: auto; max-width: none; margin: -13px 0 0 -8px; }

.login-bg { position: fixed; inset: 0; z-index: -1; background: var(--brand) url(/bg/hero-1.jpg) center / cover; }
.login-bg .s { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; }
.login-bg .s2 { background-image: url(/bg/hero-2.jpg); animation: bg2 24s infinite; }
.login-bg .s3 { background-image: url(/bg/hero-4.jpg); animation: bg3 24s infinite; }
.login-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(14, 28, 46, 0.5), rgba(14, 28, 46, 0.82)); }
@keyframes bg2 { 0%, 28% { opacity: 0; } 34%, 94% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bg3 { 0%, 61% { opacity: 0; } 67%, 94% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .login-bg .s { animation: none; } }
main.login { max-width: 440px; min-height: 100vh; align-content: center; justify-items: stretch; }
main.login .brand { width: min(340px, 86%); height: auto; justify-self: center; margin: -8px 0 -20px; }
.login-title { color: #fff; font-size: 22px; font-weight: 600; text-align: center; letter-spacing: 0.06em; }
nav.tabs {
  display: flex; gap: 4px; padding: 6px 12px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; overflow-x: auto;
}
nav.tabs button {
  flex: 1; min-width: 72px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 15px; padding: 10px 8px; border-radius: 8px; cursor: pointer;
}
nav.tabs button[aria-current="page"] { background: var(--soft); color: var(--text); font-weight: 600; box-shadow: inset 0 -3px 0 var(--gold); }
main { max-width: 640px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
main.wide { max-width: 1180px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: grid; gap: 12px; }
.center { text-align: center; justify-items: center; }
.row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.list > .row { border-bottom: 1px solid var(--border); padding: 6px 0; }
.list > .row:last-child { border-bottom: 0; }
.wrap { flex-wrap: wrap; }
.row.wrap > .grow { min-width: 8em; }
.row.wrap > h3.grow { min-width: max-content; }

.btn {
  font: inherit; font-size: 15px; padding: 10px 14px; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.block { width: 100%; }
.btn.big { font-size: 18px; padding: 14px; }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 6px 4px; min-height: 36px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, nav.tabs button:focus-visible, td.cell:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 2px;
}

label.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); text-align: left; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 220px; font-size: 14px; }
.code-input {
  width: 240px; max-width: 100%; text-align: center; font-size: 48px; font-weight: 700;
  letter-spacing: 0.3em; padding: 12px 0 12px 0.3em; font-variant-numeric: tabular-nums;
}
.code-show { font-size: 64px; font-weight: 700; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.msg { min-height: 1.5em; font-size: 15px; }
.msg.ok { color: var(--ok-fg); } .msg.bad { color: var(--bad-fg); }

.pill, .badge { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge.plain { background: var(--soft); color: var(--muted); font-weight: 400; }
.c-teal { background: var(--teal-bg); color: var(--teal-fg); } .c-violet { background: var(--violet-bg); color: var(--violet-fg); }
.c-orange { background: var(--orange-bg); color: var(--orange-fg); } .c-blue { background: var(--blue-bg); color: var(--blue-fg); }
.c-pink { background: var(--pink-bg); color: var(--pink-fg); } .c-green { background: var(--green-bg); color: var(--green-fg); }
.c-amber { background: var(--amber-bg); color: var(--amber-fg); } .c-red { background: var(--red-bg); color: var(--red-fg); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; background: var(--card); color: var(--text); padding: 8px 10px; min-width: 40px; min-height: 40px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.out { opacity: 0.5; text-decoration: line-through; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.metric { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.metric .label { font-size: 13px; color: var(--muted); }
.metric .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .num.warn { color: var(--warn-fg); }
.navrow { display: flex; align-items: center; justify-content: center; gap: 8px; }
.navrow strong { min-width: 150px; text-align: center; font-size: 17px; }

details.site { border-bottom: 1px solid var(--border); }
details.site:last-child { border-bottom: 0; }
details.site summary { list-style: none; cursor: pointer; }
details.site summary::-webkit-details-marker { display: none; }
details.site .people { padding: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }

.gridwrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.grid { border-collapse: collapse; font-size: 13px; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 6px 2px; text-align: center; min-width: 30px; }
table.grid th { background: var(--soft); font-weight: 600; }
table.grid .name { position: sticky; left: 0; background: var(--card); text-align: left; padding: 6px 10px; min-width: 84px; white-space: nowrap; z-index: 1; }
table.grid thead .name, table.grid tfoot .name { background: var(--soft); }
table.grid td.sum, table.grid tfoot td { font-weight: 700; }
table.grid tfoot td { background: var(--soft); }
td.cell.pend { outline: 2px dashed var(--warn-fg); outline-offset: -3px; }
td.cell.edit { cursor: pointer; }

dialog { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--card); color: var(--text); width: min(92vw, 440px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { display: grid; gap: 12px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
details.demo > summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 28px; }
.demo-note { background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; width: 100%; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
