:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --surface: rgba(255,255,255,.78);
  --surface-2: rgba(248,250,252,.92);
  --focus: rgba(29,78,216,.22);
  --ink:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --brand:#1d4ed8;
  --brand-2:#0ea5e9;
  --good:#16a34a;
  --warn:#f59e0b;
  --bad:#ef4444;
  --shadow-sm: 0 8px 18px rgba(2,6,23,.06);
  --shadow: 0 12px 34px rgba(2,6,23,.10);
  --shadow-lg: 0 22px 60px rgba(2,6,23,.18);
  --radius: 16px;
}
*{box-sizing:border-box}
html,body{height:100%; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans KR", Arial, sans-serif;
  color:var(--ink);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(29,78,216,.12), transparent 60%),
              radial-gradient(900px 500px at 90% 10%, rgba(14,165,233,.10), transparent 55%),
              var(--bg);
}


/* ----------------------------
   Monitor header: remaining time
-----------------------------*/
.monitor-remain{
  display:flex;
  align-items:baseline;
  gap:10px;
  flex-wrap:wrap;
}
.monitor-remain__label{
  font-size:12px;
  color:var(--muted);
  font-weight:800;
  letter-spacing:-.2px;
}
.monitor-remain__value{
  font-size:18px;
  font-weight:900;
  letter-spacing:-.4px;
}
@media (max-width:560px){
  .monitor-remain__value{ font-size:20px; }
}

/* ----------------------------
   Voter (mobile-first) tuning
   - Hide internal metadata labels
   - Slightly tighten spacing + typography
-----------------------------*/
body.voter{background:
  radial-gradient(1100px 520px at 12% -10%, rgba(29,78,216,.14), transparent 60%),
  radial-gradient(920px 540px at 96% 6%, rgba(14,165,233,.10), transparent 55%),
  #f6f8fc;
}
body.voter .container{max-width:720px; padding:14px 12px 84px}
body.voter .topbar .inner{padding:10px 12px}
body.voter .brand{font-size:14px}
body.voter .brand-logo-wrap{width:44px; height:44px; border-radius:14px; padding:6px; background:#fff; border:1px solid rgba(15,23,42,.10); box-shadow:0 6px 16px rgba(2,6,23,.10)}
body.voter .brand .brand-logo{border-radius:10px}
body.voter .card{box-shadow: 0 10px 26px rgba(2,6,23,.07)}
body.voter .card .hd{
  background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,1));padding:14px 14px 10px}
body.voter .card .bd{padding:14px}
body.voter .card .hd h2{font-size:16px}
body.voter .btn{padding:11px 12px; font-size:14px}
body.voter .note{font-size:12.5px}
body.voter .pill{font-size:12px; padding:7px 9px}
body.voter .tag{display:none !important}

/* Voter layout helpers */
body.voter .voter-shell{display:flex; flex-direction:column; gap:12px}
body.voter .voter-hero{
  border:1px solid rgba(226,232,240,.9);
  border-radius: 18px;
  overflow:hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,1));
}
body.voter .voter-hero .vh{
  padding:14px 14px 12px;
  border-bottom:1px solid rgba(226,232,240,.9);
  display:flex; align-items:flex-start; justify-content:space-between; gap:10px;
}
/* Fix rights badge wrapping on mobile */
body.voter .voter-hero .vh .pill{flex-shrink:0; white-space:nowrap}
@media (max-width: 420px){
  body.voter .voter-hero .vh{flex-direction:column}
  body.voter .voter-hero .vh .pill{align-self:flex-start}
}
body.voter .voter-hero .vh .k{font-size:12px; color:var(--muted); font-weight:800}
body.voter .voter-hero .vh .t{font-size:17px; font-weight:1000; letter-spacing:-.3px; margin-top:4px}
body.voter .voter-hero .vb{padding:12px 14px}
body.voter .voter-hero .meta{display:flex; gap:8px; flex-wrap:wrap; align-items:center}
body.voter .voter-hero .meta .chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:7px 10px;
  border-radius:999px;
  background: rgba(29,78,216,.08);
  border:1px solid rgba(29,78,216,.16);
  color:#1e3a8a;
  font-size:12px;
  font-weight:900;
}
body.voter .voter-hero .meta .chip.ok{background: rgba(22,163,74,.10); border-color: rgba(22,163,74,.18); color:#065f46}
body.voter .voter-hero .meta .chip.warn{background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.22); color:#7c2d12}
body.voter .voter-hero .meta .chip.bad{background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.20); color:#7f1d1d}

body.voter .progress{
  height:10px;
  border-radius:999px;
  background: rgba(148,163,184,.25);
  overflow:hidden;
}
body.voter .progress .bar{
  height:100%; width:0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius:999px;
}
body.voter .progressrow{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:10px}
body.voter .progressrow .txt{font-size:12px; color:var(--muted); font-weight:900}

/* Question cards */
body.voter .qcard{
  border:1px solid rgba(226,232,240,.9);
  border-radius: 18px;
  background:#fff;
  box-shadow: 0 10px 26px rgba(2,6,23,.06);
  overflow:hidden;
}
body.voter .qcard .qh{padding:14px 14px 10px; border-bottom:1px solid rgba(226,232,240,.9)}
body.voter .qno{font-size:12px; font-weight:1000; color:rgba(29,78,216,.92)}
body.voter .qtitle{margin-top:6px; font-size:15px; font-weight:1000; letter-spacing:-.2px; line-height:1.35}
body.voter .qbd{padding:12px 14px 14px}
body.voter .qhelp{color:var(--muted); font-size:12.5px; line-height:1.55}
body.voter .qdetails{margin-top:10px}
body.voter .qdetails summary{cursor:pointer; font-weight:1000; font-size:12.5px}
body.voter .qdetails .inner{margin-top:10px}

/* Mobile-friendly options */
body.voter .optgrid{display:flex; flex-direction:column; gap:10px; margin-top:10px}
body.voter .opt{
  display:flex; align-items:center; gap:10px;
  padding:12px 12px;
  border-radius: 16px;
  border:1px solid rgba(148,163,184,.35);
  background: linear-gradient(180deg, rgba(248,250,252,.9), rgba(255,255,255,1));
  cursor:pointer;
  user-select:none;
}
body.voter .opt input{width:18px; height:18px}
body.voter .opt .txt{font-weight:900; font-size:14px; line-height:1.25}
body.voter .opt.checked,
body.voter .opt:has(input:checked){
  border-color: rgba(29,78,216,.45);
  background: linear-gradient(180deg, rgba(29,78,216,.10), rgba(255,255,255,1));
}

/* Sticky submit bar */
body.voter .voter-submitbar{
  position:fixed; left:0; right:0; bottom:0; z-index:50;
  padding:10px 12px 12px;
  background: linear-gradient(180deg, rgba(246,248,252,0), rgba(246,248,252,.88) 30%, rgba(246,248,252,1));
}
body.voter .voter-submitbar .inner{max-width:720px; margin:0 auto}
body.voter .voter-submitbar .hint{font-size:12px; color:var(--muted); margin-top:8px; text-align:center}

/* Print: keep existing behavior, but hide sticky bar */
@media print{
  body.voter .voter-submitbar{display:none !important}
}
a{color:inherit; text-decoration:none}
.container{max-width:1180px; margin:0 auto; padding:24px 18px 44px}
.topbar{
  position:sticky; top:0; z-index:10;
  background: linear-gradient(90deg, #0b1f4a, #0c2b6b);
  color:white;
  box-shadow: 0 6px 20px rgba(2,6,23,.25);
}
.topbar .inner{
  max-width:1180px; margin:0 auto; padding:14px 18px;
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:800; letter-spacing:-.2px}
.brand .logo{
  width:30px; height:30px; border-radius:10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(29,78,216,.35);
}
/* Real logo image */
.brand-logo-wrap{width:46px; height:46px; border-radius:14px; padding:6px; background:#fff; border:1px solid rgba(15,23,42,.12); box-shadow:0 6px 16px rgba(2,6,23,.10)}
.brand .brand-logo{width:100%; height:100%; display:block; object-fit:contain; border-radius:10px}
.brand-title{font-weight:800}

body.voter .brand .brand-logo{border-radius:10px}
.badge{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:999px;
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.18);
}
.badge .avatar{
  width:28px; height:28px; border-radius:999px;
  background: rgba(255,255,255,.2);
}
.stepper{
  display:flex; gap:10px; flex-wrap:wrap;
  padding:12px 0 0;
}
.step{
  display:flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.65);
  color:var(--muted);
  backdrop-filter: blur(10px);
}
.step.active{
  color:#fff;
  border-color: rgba(29,78,216,.55);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 18px 38px rgba(29,78,216,.28);
}

/* top navigator (topbar) active state */
.topbar .btn.nav-active{
  background: rgba(255,255,255,.26);
  border-color: rgba(255,255,255,.55);
  box-shadow: 0 10px 22px rgba(2,6,23,.25), inset 0 -2px 0 rgba(255,255,255,.85);
}
.grid{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:16px;
}
@media (max-width: 960px){
  .grid{grid-template-columns:1fr}
}
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.card{transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease}
.card:hover{transform:none; box-shadow: var(--shadow-md); border-color: rgba(148,163,184,.35)}

.card .hd{
  background: linear-gradient(180deg, var(--surface-2), rgba(255,255,255,1));
  padding:16px 16px 12px;
  border-bottom:1px solid var(--line);
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
}
.card .hd h2{margin:0; font-size:18px; letter-spacing:-.2px}
.card .hd p{margin:6px 0 0; color:var(--muted); font-size:13px; line-height:1.35}
.card .bd{padding:16px}
.row{display:grid; grid-template-columns: 140px 1fr; gap:12px; align-items:flex-start; margin:10px 0}
@media (max-width: 560px){ .row{grid-template-columns:1fr} }
.label{color:var(--muted); font-size:13px; padding-top:10px}
.input, textarea, select{
  width:100%;
  border:1px solid var(--line);
  border-radius: 12px;
  padding:10px 12px;
  font-size:14px;
  outline:none;
  background:#fff;
}
textarea{min-height:96px; resize:vertical}
.input:focus, textarea:focus, select:focus{
  border-color: rgba(29,78,216,.55);
  box-shadow: 0 0 0 4px var(--focus);
}

.pills{display:flex; gap:10px; flex-wrap:wrap}
.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius:999px;
  background:#f1f5ff;
  border:1px solid rgba(29,78,216,.18);
  color:#1e3a8a;
  font-size:13px;
}
.pill strong{font-size:14px}
.btnbar{
  display:flex; justify-content:flex-end; gap:10px;
  padding:14px 16px;
  border-top:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,1));
  flex-wrap:wrap;
}
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 14px;
  border-radius: 12px;
  border:1px solid var(--line);
  background:#fff;
  font-weight:800;
  font-size:14px;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{transform: translateY(-1px); box-shadow: var(--shadow-sm)}
.btn:active{transform: translateY(0); box-shadow:none}

.btn.primary{
  background: linear-gradient(135deg, var(--brand), #2563eb);
  border-color: rgba(29,78,216,.35);
  color:white;
}
.btn.danger{
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: rgba(239,68,68,.35);
  color:white;
}
.btn.small{padding:8px 10px; font-size:12px}
.btn.ghost{background:transparent}
.tablewrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius: 14px;
}
table{width:100%; border-collapse:separate; border-spacing:0; min-width:760px}
th,td{padding:10px 10px; border-bottom:1px solid var(--line); font-size:13px; text-align:left; white-space:nowrap}
th{
  position:sticky; top:0;
  background:#f8fafc;
  z-index:2;
  color:#334155;
}
tbody tr:nth-child(even) td{background: rgba(248,250,252,.6)}
tbody tr:hover td{background: rgba(29,78,216,.06)}

td .muted{color:var(--muted)}
td.center{text-align:center}
td.right{text-align:right}

/* ----------------------------
   Results (Step 5) dense layout
   - smaller charts
   - centered tables for readability
-----------------------------*/
.results-item-grid{
  display:grid;
  grid-template-columns: .85fr 1.15fr;
  gap:12px;
  align-items:start;
}
.results-chart{
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  padding:10px 10px 6px;
}

.results-chart canvas{display:block; width:100% !important; height:110px !important;}
.results-table th,
.results-table td{
  text-align:center !important;
  vertical-align:middle;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 860px){
  .results-item-grid{ grid-template-columns: 1fr; }
}
.sticky-first{position:sticky; left:0; background:#fff; z-index:1}
th.sticky-first{background:#f8fafc; z-index:3}
.kpi{display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:12px}
@media (max-width: 560px){ .kpi{grid-template-columns:1fr} }
.kpi .box{
  padding:14px;
  border-radius: 14px;
  border:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.7), #fff);
}
.kpi .box .t{font-size:12px; color:var(--muted)}
.kpi .box .v{font-size:22px; font-weight:900; margin-top:4px}
.note{font-size:12px; color:var(--muted); margin-top:8px; line-height:1.45}
.phoneframe{
  width: 360px; height: 680px;
  border-radius: 34px;
  border: 6px solid #0b1220;
  background:#0b1220;
  padding: 6px;
  margin: 0 auto;
  box-shadow: 0 22px 60px rgba(2,6,23,.25);
}
.phoneframe .screen{
  background:#fff;
  border-radius: 22px;
  height:100%;
  overflow:hidden;
  display:flex; flex-direction:column;
}
.phoneframe .screen .head{
  padding:12px 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color:white;
  font-weight:900;
}
.phoneframe .screen .body{padding:14px; overflow:auto}
.voteopt{
  border:1px solid var(--line);
  border-radius: 14px;
  padding:12px;
  margin:10px 0;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
}
.voteopt .tag{font-size:12px; color:var(--muted)}
.toast{
  position:fixed; right:16px; bottom:16px; z-index:100;
  padding:12px 14px; border-radius:14px;
  background:#0b1220; color:#fff;
  box-shadow: 0 18px 50px rgba(2,6,23,.35);
  opacity:0; transform: translateY(10px);
  transition: all .18s ease;
}
.toast.show{opacity:1; transform: translateY(0)}
.modal-backdrop{
  position:fixed; inset:0; background:rgba(2,6,23,.55);
  display:none; align-items:center; justify-content:center;
  z-index:200;
  padding:18px;
}
.modal-backdrop.show{display:flex}
.modal{
  width:min(920px, 100%);
  max-height: min(86vh, 920px);
  overflow:auto;
  background:#fff;
  border-radius: 18px;
  border:1px solid rgba(226,232,240,.9);
  box-shadow: 0 30px 90px rgba(2,6,23,.35);
}
.modal .mh{
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  display:flex; align-items:flex-start; justify-content:space-between; gap:10px;
}
.modal .mh h3{margin:0; font-size:16px}
.modal .mb{padding:16px}
.modal .mf{
  padding:14px 16px;
  border-top:1px solid var(--line);
  display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap;
}
.editor{
  border:1px solid var(--line);
  border-radius: 12px;
  overflow:hidden;
}
.editor .ql-toolbar{border:none; border-bottom:1px solid var(--line)}
.editor .ql-container{border:none; min-height:150px}
.filelist{display:flex; flex-direction:column; gap:8px}
.fileitem{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.fileitem a{color: var(--brand); font-weight:800}


/* topbar buttons should be readable on dark background */
.topbar .btn{
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
  color: #fff;
}
.topbar .btn:hover{ background: rgba(255,255,255,.18); }

/* Print / PDF */
@media print {
  body { background: #fff !important; }
  .topbar { display: none !important; }
  .stepper { display: none !important; }
  .btnbar, .hd > div:last-child { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .container { padding: 0 !important; }
  a { color: inherit !important; text-decoration: none !important; }
}

@media print{
  /* 결과 리포트: 인쇄/PDF에서 문항이 누락되지 않도록 */
  .topbar, .stepper { display:none !important; }
  .btn, .btnbar, button, a.btn { display:none !important; }
  .container{ max-width: 100% !important; padding: 0 !important; }
  .card{ box-shadow:none !important; border: none !important; }
  #resultsList{ display:block !important; }
  .qcard, .qwrap, .qrow, .qcol { break-inside: avoid; page-break-inside: avoid; }
  canvas{ max-width:100% !important; }
}

@media print{
  .item-title-line{display:block !important;}
}


@media (min-width: 1024px){
  .container{max-width:1200px;}
}


/* === PRINT FIX (baseline-proven): keep question titles visible in results PDF/print === */
@media print{
  /* prevent global rules (.hd > div:last-child) from hiding question titles inside results list */
  #resultsList .hd > div:last-child{ display:block !important; }
  /* keep top report header controls hidden in print */
  .report-head .hd > div:last-child{ display:none !important; }
}

