/* EAF AuditAssess — shared styles for the admin app and the respondent page */
:root {
  --navy: #1f3a5f;
  --navy-2: #2b4c78;
  --ink: #1d2433;
  --muted: #5d6677;
  --line: #e2e5eb;
  --line-2: #eef0f4;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #b8862b;          /* brass — used sparingly */
  --high: #b42318; --high-bg: #fdecea;
  --med: #a15c07;  --med-bg: #fef4e2;
  --low: #2e7d4f;  --low-bg: #e7f4ec;
  --info-bg: #e9eff7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .25em; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d6deea; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.brand-name { color: #fff; font-weight: 600; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 11.5px; color: #a9b6c9; }
.nav a { display: flex; align-items: center; gap: 10px; color: #d6deea; padding: 8px 10px; border-radius: 6px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.13); color: #fff; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8899b3; padding: 16px 10px 6px; }
.side-foot { margin-top: 24px; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; }
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot a { color: #a9b6c9; }
.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 4px; cursor: pointer; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- Cards, tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #fafbfc; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.bar { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--navy-2); width: 0; }
.stackbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line-2); min-width: 120px; }
.stackbar > span { display: block; height: 100%; width: 0; }
.stackbar .h { background: var(--high); } .stackbar .m { background: #d98a1c; } .stackbar .l { background: var(--low); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--muted); }
.b-high { background: var(--high-bg); color: var(--high); }
.b-medium { background: var(--med-bg); color: var(--med); }
.b-low { background: var(--low-bg); color: var(--low); }
.b-ok { background: var(--low-bg); color: var(--low); }
.b-warn { background: var(--med-bg); color: var(--med); }
.b-bad { background: var(--high-bg); color: var(--high); }
.b-info { background: var(--info-bg); color: var(--navy-2); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--navy); border-color: var(--navy); }

/* ---------- Forms and buttons ---------- */
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #cdd2db; border-radius: 6px; background: #fff;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #9db6d8; outline-offset: 1px; border-color: var(--navy-2); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 6px; border: 1px solid #cdd2db; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f6f9; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { color: var(--high); border-color: #f0c4bf; }
.btn-danger:hover { background: var(--high-bg); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--navy-2); padding: 0; cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 160px; }

/* ---------- Modal, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--high); }
.alert { padding: 10px 14px; border-radius: 6px; background: var(--info-bg); color: var(--navy); margin-bottom: 14px; }
.alert.warn { background: var(--med-bg); color: var(--med); }
.alert.err { background: var(--high-bg); color: var(--high); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--navy) 0%, #142842 100%); }
.login .card { width: min(400px, 100%); padding: 32px 28px; }
.login .brand { border: 0; padding: 0 0 18px; margin: 0; }
.login .brand-name { color: var(--ink); }
.login .brand-sub { color: var(--muted); }

/* ---------- Questionnaire builder ---------- */
.qb-section { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 16px; }
.qb-section-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.qb-section-head input { font-weight: 600; }
.qb-q { padding: 14px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.qb-q:last-child { border-bottom: 0; }
.qb-num { color: var(--muted); font-family: var(--mono); font-size: 12px; padding-top: 9px; }
.qb-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; margin-top: 8px; }
.qb-meta label { font-size: 12px; color: var(--muted); font-weight: 500; }
.qb-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.q-view { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; }
.q-view:last-child { border-bottom: 0; }

/* ---------- Response viewer ---------- */
.ans { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.ans:last-child { border-bottom: 0; }
.ans .a { font-weight: 600; }
.ans .flag { border-left: 3px solid var(--high); padding-left: 10px; }
.explain { background: #fafbfc; border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; }

/* ===================================================================== */
/* Respondent page (mobile first)                                         */
/* ===================================================================== */
.r-body { background: var(--bg); }
.r-head { background: var(--navy); color: #fff; padding: 14px 16px; }
.r-head .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.r-wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }
.r-intro { padding: 20px; margin-bottom: 16px; }
.r-section { margin-bottom: 16px; }
.r-section > h2 { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.r-q { padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.r-q:last-child { border-bottom: 0; }
.r-q.missing { background: #fff8f7; box-shadow: inset 3px 0 0 var(--high); }
.r-q .qt { font-weight: 500; margin-bottom: 10px; }
.r-q .req { color: var(--high); }
.r-q .err { color: var(--high); font-size: 12.5px; margin-top: 6px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span { display: block; padding: 10px 18px; border: 1px solid #cdd2db; border-radius: 6px; background: #fff; min-width: 64px; text-align: center; font-weight: 500; }
.choice input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.choice input:focus-visible + span { outline: 2px solid #9db6d8; outline-offset: 2px; }
.choices.col { flex-direction: column; }
.choices.col .choice span { text-align: left; }
.explain-box { margin-top: 10px; }
.files { margin-top: 10px; font-size: 13px; }
.files li { margin: 4px 0; }
.r-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 16px; z-index: 10; }
.r-bar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.progress { flex: 1; }
.progress .bar { height: 6px; }
.r-done { text-align: center; padding: 48px 24px; }
.r-done .ok { width: 56px; height: 56px; border-radius: 50%; background: var(--low-bg); color: var(--low); display: grid; place-items: center; font-size: 28px; margin: 0 auto 14px; }
.notice { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: #fafbfc; margin: 12px 0; font-size: 13.5px; }
.notice h3 { font-size: 13.5px; margin-top: 10px; }
@media (max-width: 480px) { .choice span { padding: 10px 14px; } }
.r-body .toasts { bottom: 76px; left: 16px; right: 16px; align-items: center; }
