:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --ink: #1b1c20;
  --muted: #6a6e77;
  --line: #e3e1db;
  --accent: #1a3a6e;
  --accent-ink: #ffffff;
  --accent-soft: #e4eaf4;
  --core: #c2410c;
  --core-soft: #fdeee4;
  --ok: #15803d;
  --ok-soft: #e4f3e9;
  --danger: #b91c1c;
  --radius: 10px;
  --sidebar-w: 240px;
  --attach-w: 280px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131417;
    --panel: #1b1c21;
    --ink: #ececee;
    --muted: #9a9ea8;
    --line: #2d2f36;
    --accent: #7aa2e0;
    --accent-ink: #0f1320;
    --accent-soft: #1d2945;
    --core: #fb923c;
    --core-soft: #3a2415;
    --ok: #4ade80;
    --ok-soft: #163322;
    --danger: #f87171;
  }
}
:root[data-theme="dark"] {
  --bg: #131417;
  --panel: #1b1c21;
  --ink: #ececee;
  --muted: #9a9ea8;
  --line: #2d2f36;
  --accent: #7aa2e0;
  --accent-ink: #0f1320;
  --accent-soft: #1d2945;
  --core: #fb923c;
  --core-soft: #3a2415;
  --ok: #4ade80;
  --ok-soft: #163322;
  --danger: #f87171;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0,0,0,0); }

/* ══════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════ */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  flex: none; width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 11px; letter-spacing: -.02em;
}
.brand b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.prog { display: flex; align-items: center; gap: 10px; flex: none; }
.pbar { width: 140px; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.pbar i {
  display: block; height: 100%; width: 0%;
  background: var(--accent); border-radius: 99px;
  transition: width .4s ease-out;
}
#ptxt {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px;
  min-width: 32px; text-align: right; color: var(--muted);
}

/* ══════════════════════════════════════════
   COMMON LAYOUT
   ══════════════════════════════════════════ */
.wrap {
  display: grid;
  max-width: 1120px; margin: 0 auto;
  padding: 0 0 80px;
}
main { min-width: 0; }

/* ── section header ───────────────────── */
.sech { margin-bottom: 20px; }
.eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; color: var(--accent); text-transform: uppercase;
}
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.3; font-weight: 700; }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ══════════════════════════════════════════
   CEO LAYOUT — mobile-first card style
   ══════════════════════════════════════════ */
body[data-role="ceo"] .wrap {
  grid-template-columns: minmax(0, 1fr);
  max-width: 640px;
  padding: 0 16px 80px;
}

/* CEO: chips nav at top */
body[data-role="ceo"] nav {
  position: sticky; top: 49px; z-index: 15;
  display: flex; flex-direction: row; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
body[data-role="ceo"] nav::-webkit-scrollbar { display: none; }
body[data-role="ceo"] .nv {
  display: flex; align-items: center; gap: 6px;
  flex: none; padding: 6px 12px; border: 0;
  background: var(--panel); box-shadow: 0 0 0 1px var(--line);
  border-radius: 99px; cursor: pointer; white-space: nowrap; font-size: 13px;
}
body[data-role="ceo"] .nv:hover { box-shadow: 0 0 0 1px var(--accent); }
body[data-role="ceo"] .nv.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
body[data-role="ceo"] .nv.done { background: var(--ok-soft); box-shadow: 0 0 0 1px var(--ok); }
body[data-role="ceo"] .nvn {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--line); color: var(--muted);
}
body[data-role="ceo"] .nv.on .nvn { background: rgba(255,255,255,.2); color: var(--accent-ink); }
body[data-role="ceo"] .nv.done .nvn { background: var(--ok); color: #fff; }
body[data-role="ceo"] .nvt { font-weight: 600; font-size: 13px; }
body[data-role="ceo"] .nvc { display: none; }
body[data-role="ceo"] .nv.submit { margin: 0; border-top: 0; padding-top: 6px; }

body[data-role="ceo"] main { padding: 20px 0; }

/* ══════════════════════════════════════════
   STAFF LAYOUT — PC-first with sidebar + attachment panel
   ══════════════════════════════════════════ */
body[data-role="staff"] .wrap {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  padding: 0 24px 80px;
}

/* Staff: sidebar nav */
body[data-role="staff"] nav {
  position: sticky; top: 49px; align-self: start;
  display: flex; flex-direction: column; gap: 1px;
  padding: 20px 16px 20px 0;
  max-height: calc(100vh - 49px); overflow-y: auto;
}
body[data-role="staff"] .nv {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px; border: 0; background: transparent;
  border-radius: 8px; cursor: pointer; text-align: left;
}
body[data-role="staff"] .nv:hover { background: var(--panel); }
body[data-role="staff"] .nv.on { background: var(--accent-soft); }
body[data-role="staff"] .nvn {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--line); color: var(--muted);
}
body[data-role="staff"] .nv.on .nvn { background: var(--accent); color: var(--accent-ink); }
body[data-role="staff"] .nv.done .nvn { background: var(--ok-soft); color: var(--ok); }
body[data-role="staff"] .nvt { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-role="staff"] .nvc { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
body[data-role="staff"] .nv.submit {
  margin-top: 8px; border-top: 1px dashed var(--line);
  border-radius: 0 0 8px 8px; padding-top: 12px;
}

body[data-role="staff"] main { padding: 20px 0 0 24px; }

/* Staff: main + attachment panel side-by-side */
.staff-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--attach-w);
  gap: 24px;
  align-items: start;
}
.staff-questions { min-width: 0; }
.staff-attach {
  position: sticky; top: 70px; align-self: start;
  max-height: calc(100vh - 90px); overflow-y: auto;
}
.staff-attach .attach-header {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

/* ══════════════════════════════════════════
   CARD / QUESTION
   ══════════════════════════════════════════ */
.card, .q {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.qh { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.qt { font-weight: 650; font-size: 14px; line-height: 1.45; }
.badge {
  flex: none; font-size: 10px; font-weight: 700;
  color: var(--core); background: var(--core-soft);
  padding: 2px 6px; border-radius: 4px; position: relative; top: -1px;
  letter-spacing: .02em;
}
.mx { font-size: 11px; color: var(--muted); }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.q > .opts, .q > .inp, .q > .numrow, .q > .gwrap, .q > textarea, .q > .drop { margin-top: 10px; }

/* ── options ───────────────────────────── */
.opts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px; border: 0; padding: 0; margin: 10px 0 0;
}
.opts > legend { grid-column: 1 / -1; }
.opt {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--accent); }
.opt.checked { border-color: var(--accent); background: var(--accent-soft); }
.opt input { accent-color: var(--accent); margin: 0; flex: none; }

/* ── inputs ────────────────────────────── */
.inp, textarea {
  display: block; width: 100%;
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: 14px;
}
.inp:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { min-height: 88px; resize: vertical; }
.other { margin-top: 6px; }
.numrow { display: flex; align-items: center; gap: 8px; max-width: 300px; }
.numrow .unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

/* ── grid ──────────────────────────────── */
.gwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; }
table.grid {
  border-collapse: separate; border-spacing: 4px; margin: -4px; min-width: 100%;
}
table.grid th {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-align: left; white-space: nowrap; padding: 0 4px;
}
table.grid td { min-width: 88px; }
table.grid .inp { padding: 7px 8px; font-size: 13px; }
.calc-row th { color: var(--accent); font-style: italic; }
.calc-auto { color: var(--muted); }
.share-warn { color: var(--danger); font-weight: 600; }

/* ── files (inline in question) ───────── */
.files { margin-top: 24px; }
.files > h2 { font-size: 15px; margin: 0 0 4px; font-weight: 700; }
.files > p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.q.qf .src { font-size: 11px; color: var(--muted); }
.q.qf.has { border-color: var(--ok); }
.drop {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px dashed var(--line);
  border-radius: 8px; cursor: pointer; color: var(--muted);
  font-size: 12px; transition: border-color .15s, background .15s;
  margin-top: 10px;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop b { color: var(--accent); }
.dropic {
  flex: none; width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
}
.flist { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.flist:empty { display: none; }
.flist li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--ok-soft); font-size: 12px;
}
.fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.rm {
  border: 0; background: transparent; cursor: pointer;
  font-size: 15px; line-height: 1; color: var(--muted); padding: 2px 4px;
}
.rm:hover { color: var(--danger); }

/* ── pager ─────────────────────────────── */
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.btn, .pri, .ghost, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 600; font-size: 13px;
}
.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pri:hover { filter: brightness(1.1); }
.ghost:hover { border-color: var(--ink); }
.danger { color: var(--danger); background: transparent; }
.big { width: 100%; padding: 14px; font-size: 15px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ── submit KPIs ──────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.kpi b { display: block; font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi.warn b { color: var(--core); }
.kpi.ok b { color: var(--ok); }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lnk {
  border: 0; background: transparent; padding: 5px 0;
  text-align: left; cursor: pointer; color: var(--accent); font-size: 13px;
}
.lnk:hover { text-decoration: underline; }
table.docs { width: 100%; border-collapse: collapse; font-size: 12px; }
table.docs th { text-align: left; font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.docs td { padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.docs .sg td { font-weight: 700; color: var(--muted); font-size: 11px; padding-top: 12px; border-top: 0; }
.st { white-space: nowrap; font-weight: 700; font-size: 11px; }
.st.y { color: var(--ok); }
.st.n { color: var(--muted); }

/* ── toast ─────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 8px; font-size: 13px;
  z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; }

/* ══════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════ */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 60px); padding: 24px 16px;
}
.login-card { max-width: 400px; width: 100%; }
.login-card h1 { margin-bottom: 4px; font-size: 20px; }
.role-btns { display: flex; gap: 8px; }
.role-btn { flex: 1; padding: 14px; font-size: 15px; font-weight: 700; }
.role-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.err { color: var(--danger); font-weight: 600; }
.consent-box {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px;
}
.consent-text { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ══════════════════════════════════════════
   RESPONSIVE — CEO (already mobile-first, just widen on big screens)
   ══════════════════════════════════════════ */
@media (min-width: 641px) {
  body[data-role="ceo"] .wrap { padding: 0 24px 80px; }
  body[data-role="ceo"] nav { margin: 0 -24px; padding: 10px 24px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — STAFF mobile (collapse sidebar + attachment panel)
   ══════════════════════════════════════════ */
@media (max-width: 860px) {
  body[data-role="staff"] .wrap {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px 64px;
  }
  body[data-role="staff"] nav {
    position: sticky; top: 49px; z-index: 15;
    flex-direction: row; overflow-x: auto; gap: 6px;
    margin: 0 -16px; padding: 10px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    scrollbar-width: none; max-height: none;
  }
  body[data-role="staff"] nav::-webkit-scrollbar { display: none; }
  body[data-role="staff"] .nv {
    width: auto; flex: none; padding: 6px 10px;
    background: var(--panel); box-shadow: 0 0 0 1px var(--line);
    border-radius: 99px;
  }
  body[data-role="staff"] .nv.on { box-shadow: 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
  body[data-role="staff"] .nvc { display: none; }
  body[data-role="staff"] .nv.submit { margin: 0; border-top: 0; padding-top: 6px; border-radius: 99px; }
  body[data-role="staff"] main { padding: 16px 0 0; }

  .staff-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .staff-attach {
    position: static; max-height: none;
    border-top: 1px solid var(--line); padding-top: 16px;
  }
}

/* ══════════════════════════════════════════
   RESPONSIVE — generic small
   ══════════════════════════════════════════ */
@media (max-width: 860px) {
  .top { padding: 8px 16px; }
  .pbar { width: 80px; }
  .brand small { display: none; }
  h1 { font-size: 20px; }
  .card, .q { padding: 14px 16px; }
  .opts { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; }
  .kpi { padding: 10px; }
  .kpi b { font-size: 20px; }
}
@media (max-width: 420px) {
  .opts { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   NO ROLE SET (login screen / admin)
   ══════════════════════════════════════════ */
body:not([data-role]) .wrap {
  grid-template-columns: minmax(0, 1fr);
  max-width: 960px;
  padding: 0 24px 80px;
}
body:not([data-role]) nav { display: none; }
