:root {
  --bg: #f1f3f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #171b23;
  --ink-dim: #5b6472;
  --ink-faint: #8992a1;
  --line: #dee2e8;
  --accent: #0c7e8c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f3;
  --critical: #c0392b;
  --critical-soft: #fbe9e7;
  --focus: #0c7e8c;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", -apple-system, sans-serif;

  --chip-blue-bg: #e8f1ff; --chip-blue-fg: #2f6fed;
  --chip-violet-bg: #f1eafb; --chip-violet-fg: #7c5cd1;
  --chip-coral-bg: #fdeee8; --chip-coral-fg: #e2603a;
  --chip-green-bg: #e6f6ee; --chip-green-fg: #1e9a57;

  --shadow-card: 0 1px 2px rgba(23,27,35,0.04), 0 10px 24px rgba(23,27,35,0.06);
  --shadow-card-hover: 0 1px 2px rgba(23,27,35,0.05), 0 16px 32px rgba(23,27,35,0.09);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2330;
    --ink: #e6e9ef;
    --ink-dim: #8b94a3;
    --ink-faint: #626b79;
    --line: #2b3341;
    --accent: #22c3b6;
    --accent-ink: #0a1414;
    --accent-soft: #14302e;
    --critical: #e5584a;
    --critical-soft: #34201d;
    --focus: #22c3b6;

    --chip-blue-bg: rgba(59,130,246,0.16); --chip-blue-fg: #8fbbff;
    --chip-violet-bg: rgba(124,92,209,0.20); --chip-violet-fg: #c3aef2;
    --chip-coral-bg: rgba(226,96,58,0.18); --chip-coral-fg: #f3a184;
    --chip-green-bg: rgba(30,154,87,0.20); --chip-green-fg: #5fe0a0;

    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 10px 24px rgba(0,0,0,0.35);
    --shadow-card-hover: 0 1px 2px rgba(0,0,0,0.35), 0 16px 32px rgba(0,0,0,0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2330;
  --ink: #e6e9ef;
  --ink-dim: #8b94a3;
  --ink-faint: #626b79;
  --line: #2b3341;
  --accent: #22c3b6;
  --accent-ink: #0a1414;
  --accent-soft: #14302e;
  --critical: #e5584a;
  --critical-soft: #34201d;
  --focus: #22c3b6;

  --chip-blue-bg: rgba(59,130,246,0.16); --chip-blue-fg: #8fbbff;
  --chip-violet-bg: rgba(124,92,209,0.20); --chip-violet-fg: #c3aef2;
  --chip-coral-bg: rgba(226,96,58,0.18); --chip-coral-fg: #f3a184;
  --chip-green-bg: rgba(30,154,87,0.20); --chip-green-fg: #5fe0a0;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 10px 24px rgba(0,0,0,0.35);
  --shadow-card-hover: 0 1px 2px rgba(0,0,0,0.35), 0 16px 32px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}
h1, h2, h3 { text-wrap: balance; margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input { font-family: inherit; }
.tabular { font-variant-numeric: tabular-nums; }

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: 0 10px 34px rgba(15, 20, 30, 0.06);
}
.brand-lockup { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
@media (prefers-reduced-motion: no-preference) {
  .brand-dot.live { animation: pulse 2.2s ease-in-out infinite; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50% { box-shadow: 0 0 0 8px var(--accent-soft); }
}
.brand-lockup span { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--ink-dim); font-size: 13px; margin: 0 0 24px; line-height: 1.6; }

.tabbar {
  display: flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 22px;
}
.tabbar .tab {
  flex: 1;
  text-align: center;
  text-decoration: none;
  padding: 8px 0;
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
  border-radius: 7px;
}
.tabbar .tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 20, 30, 0.1);
}

.form-error {
  background: var(--critical-soft);
  color: var(--critical);
  border: 1px solid var(--critical);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin: 0 0 16px;
  line-height: 1.5;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
}
.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}
.btn-primary:hover { filter: brightness(1.06); }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--ink-dim); }
.auth-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* ===== APP SHELL ===== */
.app-shell { width: 100%; min-height: 100vh; display: flex; }
.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar .brand-lockup { padding: 0 6px; margin-bottom: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-dim);
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  text-decoration: none;
  width: 100%;
}
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main-col { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar form { margin: 0; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.topbar button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.content { padding: 30px 34px 60px; max-width: 1440px; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 21px; font-weight: 700; }
.page-head p { color: var(--ink-dim); font-size: 13px; margin-top: 6px; max-width: 58ch; line-height: 1.6; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-tile .label { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-tile .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat-tile .value.accent { color: var(--accent); }

.add-row { display: flex; gap: 8px; margin-bottom: 20px; }
.add-row input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
}
.add-row button {
  padding: 0 18px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.add-row button:hover { filter: brightness(1.06); }

.empty-hint { color: var(--ink-dim); font-size: 13.5px; padding: 20px 0; }

.kw-grid { display: flex; flex-direction: column; gap: 10px; }
.kw-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.kw-status { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kw-status .name { font-size: 14.5px; font-weight: 600; }
.pipeline { display: flex; gap: 6px; margin-left: auto; }
.stage {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-faint);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.stage.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.del-btn { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 15px; padding: 4px; }
.del-btn:hover { color: var(--critical); }

/* ===== 대시보드 ===== */
.greeting { font-size: 21px; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.greeting .wave { font-size: 20px; }
.greeting-sub { font-size: 13.5px; color: var(--ink-dim); margin-bottom: 24px; line-height: 1.6; max-width: 62ch; }
.greeting-sub b { color: var(--chip-coral-fg); font-weight: 700; }

.empty-banner {
  background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 12px 16px;
  font-size: 13px; margin-bottom: 20px;
}
.empty-banner a { font-weight: 700; text-decoration: underline; }

.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 30px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px;
  cursor: pointer; text-align: left; font-family: inherit; box-shadow: var(--shadow-card); position: relative;
}
@media (prefers-reduced-motion: no-preference) {
  .kpi-card { transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
  .kpi-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
  .bill-card { transition: box-shadow .15s ease, transform .15s ease; }
  .bill-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
}
.kpi-icon {
  position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.kpi-card[data-bucket="month"] .kpi-icon { background: var(--chip-blue-bg); color: var(--chip-blue-fg); }
.kpi-card[data-bucket="week"] .kpi-icon { background: var(--chip-violet-bg); color: var(--chip-violet-fg); }
.kpi-card[data-bucket="yesterday"] .kpi-icon { background: var(--chip-coral-bg); color: var(--chip-coral-fg); }
.kpi-card .label { font-size: 12.5px; color: var(--ink-dim); font-weight: 600; padding-right: 40px; }
.kpi-card .value { font-size: 30px; font-weight: 800; margin-top: 10px; }
.kpi-card .value .unit { font-size: 14px; color: var(--ink-dim); font-weight: 500; margin-left: 3px; }
.kpi-card .foot { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }
.kpi-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-card); }
.kpi-card.active .value { color: var(--accent); }

.list-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.list-head h3 { font-size: 15.5px; font-weight: 700; }
.list-head .count-badge {
  background: var(--surface-2); color: var(--ink-dim); font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 2px 9px; font-variant-numeric: tabular-nums;
}
.list-head .hint { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

.bill-list { display: flex; flex-direction: column; gap: 12px; }
.bill-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-card); cursor: pointer; }
.bc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.bc-source { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-faint); }
.bc-title { font-size: 15px; font-weight: 700; line-height: 1.4; margin-bottom: 6px; }
.bc-desc { font-size: 12.5px; color: var(--ink-dim); line-height: 1.6; margin-bottom: 12px; max-width: 68ch; }
.bc-bottom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.bc-tag { background: var(--surface-2); color: var(--ink-dim); font-size: 11.5px; padding: 4px 10px; border-radius: 999px; }
.bc-stage-link { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.bc-stage-link[data-cls="propose"] { color: var(--chip-blue-fg); }
.bc-stage-link[data-cls="committee"] { color: var(--chip-violet-fg); }
.bc-stage-link[data-cls="law"] { color: var(--chip-coral-fg); }
.bc-stage-link[data-cls="done"] { color: var(--chip-green-fg); }

.stage-badge { font-size: 11px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; font-weight: 700; }
.stage-badge.two-line { white-space: normal; text-align: center; line-height: 1.4; padding: 6px 10px; border-radius: 12px; }
.stage-badge[data-cls="propose"] { background: var(--chip-blue-bg); color: var(--chip-blue-fg); }
.stage-badge[data-cls="committee"] { background: var(--chip-violet-bg); color: var(--chip-violet-fg); }
.stage-badge[data-cls="law"] { background: var(--chip-coral-bg); color: var(--chip-coral-fg); }
.stage-badge[data-cls="done"] { background: var(--chip-green-bg); color: var(--chip-green-fg); }

.empty-note { color: var(--ink-faint); font-size: 13px; }

/* ===== 입안조회 ===== */
.lookup-title { font-size: 21px; font-weight: 700; margin-bottom: 4px; }
.lookup-sub { font-size: 13px; color: var(--ink-dim); margin-bottom: 22px; }

.filter-bar { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 14px; align-items: end; box-shadow: var(--shadow-card); }
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field label { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-field input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--ink); font-size: 13px; }
.filter-field input[type="date"] { font-variant-numeric: tabular-nums; }
.range-sep { align-self: center; color: var(--ink-faint); font-size: 13px; padding-bottom: 9px; }
.quick-range { display: flex; gap: 6px; }
.quick-range button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-dim); font-size: 12px; padding: 9px 13px; border-radius: 9px; cursor: pointer; }
.quick-range button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filter-field.grow { flex: 1; min-width: 200px; }
.filter-field.grow input { width: 100%; }
.search-btn { margin-left: auto; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 9px; padding: 11px 20px; font-size: 13px; font-weight: 700; cursor: pointer; }

.result-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0; }
.result-count { font-size: 13px; color: var(--ink-dim); }
.result-count b { color: var(--ink); }
.btn-excel { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-dim); font-size: 12.5px; padding: 9px 15px; border-radius: 9px; cursor: pointer; box-shadow: var(--shadow-card); }
.btn-excel:hover { border-color: var(--chip-green-fg); color: var(--chip-green-fg); }

.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-card); }
.grid-scroll { overflow-x: auto; }
table.results { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; min-width: 720px; }
table.results th { text-align: center; font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; padding: 13px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.results td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: center; overflow-wrap: break-word; }
table.results tr:last-child td { border-bottom: none; }
table.results td.name { font-weight: 600; text-align: left; word-break: keep-all; }
table.results td.date { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-dim); }
table.results td.datekind { color: var(--ink-faint); font-size: 12px; white-space: nowrap; }
table.results tr { cursor: pointer; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); font-size: 13px; padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 메일 관리 ===== */
.page-head-top { display: flex; align-items: center; gap: 10px; }
.page-head-checkbox { width: 15px; height: 15px; margin-top: 3px; cursor: pointer; }

.mail-accordion {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.mail-accordion.open { max-height: 3000px; }
@media (prefers-reduced-motion: reduce) {
  .mail-accordion { transition: none; }
}

.mail-grid { display: flex; flex-direction: column; gap: 16px; }
.mail-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 26px; display: flex; flex-direction: column; gap: 18px;
}

.mail-row { display: flex; flex-direction: row; align-items: center; gap: 36px; flex-wrap: wrap; }

.mail-bullet { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); flex-shrink: 0; }
.mail-label {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-size: 14px; font-weight: 700; color: var(--ink);
}
.mail-hint { font-weight: 400; color: var(--ink-faint); font-size: 12.5px; margin-left: 2px; }

.mail-subject-value { font-size: 14px; color: var(--ink); }

.mail-field-row { flex-wrap: wrap; margin-left: 0; gap: 10px; }
.mail-field-row .stage { font-size: 13px; padding: 8px 18px; }
.stage.locked, .stage:disabled { cursor: default; opacity: 1; }

.mail-content-preview {
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink); font-size: 13px; line-height: 1.8;
  font-family: inherit; resize: vertical; white-space: pre-wrap; width: 100%;
}

@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .nav-group { flex-direction: row; }
  .stat-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .content { padding: 20px; }
  .bc-stage-link { margin-left: 0; }
}
