:root {
  --navy-900: #0b1526;
  --navy-800: #122036;
  --navy-700: #1b2d4a;
  --navy-line: #25395a;
  --side-text: #c9d4e6;
  --side-muted: #8494ad;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e2e7ef;
  --text: #16202e;
  --muted: #5d6a7d;
  --accent: #2f6fdb;
  --accent-soft: #e6eefc;
  --prov: #9dbbee;
  --warn: #a15c00;
  --warn-bg: #fff5e5;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #1d7a4f;
  --ok-bg: #e8f5ee;
  --focus: #ffbf47;
  --radius: 12px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-width: 0; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

.btn {
  font: inherit; font-size: 0.9rem; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); width: 100%; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--side-text); border-color: var(--navy-line); width: 100%; }
.btn.ghost:hover { border-color: var(--side-text); }

.brand-mark {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #3d7bf0, #6a4fd8); color: #fff; font-weight: 700; font-size: 0.85rem;
}

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--navy-900); }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 28px;
  display: grid; gap: 10px; box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
}
.login-card h1 { font-size: 1.3rem; }
.login-card label { font-size: 0.85rem; font-weight: 600; margin-top: 6px; }
.login-card input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; width: 100%;
}
.login-card input:focus-visible { border-color: var(--accent); }
.notice { font-size: 0.8rem; color: var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; }
.alert { color: var(--danger); background: var(--danger-bg); padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--navy-800); color: var(--side-text); padding: 20px 16px; display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-size: 0.92rem; }
.nav a:hover { background: var(--navy-700); color: #fff; }
.session { margin-top: auto; display: grid; gap: 6px; border-top: 1px solid var(--navy-line); padding-top: 16px; }
.session-label { font-size: 0.75rem; color: var(--side-muted); }
.session-email { font-size: 0.85rem; color: #fff; overflow-wrap: anywhere; }
.session-warn { font-size: 0.75rem; color: #f3c27a; }

.main { padding: 24px 32px 64px; display: grid; gap: 28px; align-content: start; min-width: 0; }
.main:focus { outline: none; }
.main section { display: grid; gap: 12px; scroll-margin-top: 16px; min-width: 0; }
.main h1 { font-size: 1.4rem; }
.main h2 { font-size: 1.1rem; }

.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.field select {
  font: inherit; font-size: 0.9rem; color: var(--text); padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); min-height: 40px;
}
.segmented { border: 0; padding: 0; margin: 0; display: flex; gap: 0; }
.segmented legend { font-size: 0.8rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; padding: 0 12px; font-size: 0.88rem;
  border: 1px solid var(--line); background: var(--surface); margin-left: -1px;
}
.segmented label:first-of-type span { border-radius: 8px 0 0 8px; margin-left: 0; }
.segmented label:last-of-type span { border-radius: 0 8px 8px 0; }
.segmented input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; position: relative; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.status { font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.card.warn { border-color: #f0c98a; background: var(--warn-bg); }
.card-label { font-size: 0.8rem; color: var(--muted); }
.card-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-hint { font-size: 0.75rem; color: var(--muted); }
.note { font-size: 0.8rem; color: var(--warn); }
.note.wide { grid-column: 1 / -1; }

.freshness { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px; border-radius: 10px; font-size: 0.85rem; }
.freshness:empty { display: none; }
.freshness.ok { background: var(--ok-bg); color: var(--ok); }
.freshness.info { background: var(--accent-soft); color: var(--accent); }
.freshness.warn { background: var(--warn-bg); color: var(--warn); }

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-missing { border: 1px dashed #b5bfcd; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
caption { text-align: left; padding: 12px 14px 4px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
th, td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; background: #f9fafc; }
thead th.num { text-align: right; }
tbody th { font-weight: 500; }
tbody tr:last-child > * { border-bottom: 0; }
.row-missing { color: var(--muted); background: repeating-linear-gradient(135deg, transparent 0 6px, #f4f6f9 6px 12px); }
.empty { text-align: center; color: var(--muted); padding: 20px; white-space: normal; }
.badge { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; margin-right: 4px; font-weight: 600; }
.badge.complete { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.missing { background: #eceff4; color: var(--muted); }
.badge.prov { background: var(--accent-soft); color: var(--accent); }
.share { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.share-bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--w), #edf1f7 var(--w)); }

.links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.links a {
  display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.links a:hover { border-color: var(--accent); }
.links span { font-size: 0.82rem; color: var(--muted); }
.links em { font-style: normal; font-size: 0.75rem; color: var(--accent); }
.links em::after { content: " \2197"; }

.defs { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; }
.defs dt { font-weight: 600; margin-top: 10px; font-size: 0.9rem; }
.defs dd { margin: 2px 0 10px; color: var(--muted); font-size: 0.86rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 14px 16px; gap: 12px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; background: var(--navy-700); }
  .session { margin-top: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding-top: 12px; }
  .session-label, .session-warn { grid-column: 1 / -1; }
  .session .btn { width: auto; }
  .main { padding: 18px 16px 48px; }
  .controls { width: 100%; }
  .card-value { font-size: 1.3rem; }
}

@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
html { scroll-behavior: smooth; }

.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.link-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--surface); }
.detail { display: grid; gap: 12px; min-width: 0; }
.detail:empty { display: none; }
.detail h3 { font-size: 1rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--muted); }
.crumbs .sep::before { content: "/"; }

/* ECharts boxes (charts.js) and HTML legend for the daily line */
.sub { font-size: 0.95rem; margin: 4px 0 0; }
.ec { width: 100%; min-width: 0; overflow: hidden; } /* lets ResizeObserver shrink a chart drawn at a wider size */
.chart, .comp { min-width: 0; }
.comp { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.comp-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8rem; color: var(--muted); }
.comp-legend li { overflow-wrap: anywhere; }
.pick-note { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }
.sw-dot { background: var(--accent); border-radius: 50%; }
.sw-dot-prov { border: 1.5px solid var(--accent); border-radius: 50%; }
.sw-dot-partial { background: #e3a33b; border-radius: 50%; }
details summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); margin-bottom: 8px; }
