:root {
  --navy-950: #04131f;
  --navy-900: #071b2d;
  --navy-800: #0b2a42;
  --teal-600: #078a91;
  --teal-500: #0aa6a6;
  --teal-100: #dff8f6;
  --orange-500: #f38b2a;
  --orange-100: #fff0df;
  --red-600: #c83d45;
  --red-100: #fde8e9;
  --blue-100: #e5f0ff;
  --ink: #152333;
  --muted: #64748b;
  --line: #dbe3ea;
  --surface: #ffffff;
  --bg: #f3f6f8;
  --shadow: 0 12px 34px rgba(4, 19, 31, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #0f4d64 0, transparent 33%), linear-gradient(145deg, var(--navy-950), var(--navy-800)); }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; color: white; background: rgba(6, 27, 45, .86); box-shadow: 0 24px 80px rgba(0,0,0,.32); backdrop-filter: blur(16px); text-align: center; }
.brand-mark { width: 68px; height: 68px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 20px; color: var(--navy-950); background: linear-gradient(135deg, #59e0d8, var(--teal-500)); font-weight: 900; font-size: 24px; box-shadow: 0 12px 30px rgba(10,166,166,.25); }
.brand-mark-small { width: 42px; height: 42px; margin: 0; border-radius: 12px; font-size: 15px; }
.eyebrow { margin: 0 0 8px; letter-spacing: .14em; font-size: 11px; font-weight: 800; color: var(--teal-600); }
.login-card .eyebrow { color: #66dcd6; }
.login-card h1, .login-card h2 { margin: 0; font-size: clamp(34px, 7vw, 48px); }
.login-card h2 { font-size: 30px; }
.login-subtitle { color: #bed0dd; line-height: 1.6; }
.standard-tags { margin: 24px 0 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.standard-tags span { padding: 7px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; font-size: 11px; color: #d6e8f3; background: rgba(255,255,255,.05); }
.fine-print { margin: 20px 0 0; color: #8fa8ba; font-size: 11px; line-height: 1.5; }
.google-g { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; color: #2867c7; background: white; font-weight: 800; }

.topbar { position: sticky; top: 0; z-index: 20; height: 70px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; color: white; background: var(--navy-900); box-shadow: 0 4px 16px rgba(4,19,31,.18); }
.topbar-brand, .topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-brand strong, .topbar-user strong { display: block; }
.topbar-brand small, .topbar-user small { display: block; margin-top: 2px; color: #9cb5c6; font-size: 11px; }
.icon-btn { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; color: white; background: rgba(255,255,255,.07); font-size: 20px; }

.main-content { width: min(1180px, 92vw); margin: 0 auto; padding: 34px 0 100px; }
.page-heading { margin-bottom: 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading h2 { margin: 0 0 5px; font-size: clamp(26px, 4vw, 38px); }
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted); }

.btn { min-height: 44px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 12px; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { color: white; background: var(--teal-600); box-shadow: 0 8px 20px rgba(7,138,145,.18); }
.btn-secondary { color: var(--navy-900); background: var(--orange-500); }
.btn-danger { color: white; background: var(--red-600); }
.btn-ghost { color: var(--ink); border: 1px solid var(--line); background: white; }
.login-card .btn-ghost { color: white; border-color: rgba(255,255,255,.2); background: transparent; }
.btn-wide { width: 100%; }
.text-btn { padding: 0; margin-bottom: 16px; border: 0; color: var(--teal-600); background: transparent; font-weight: 700; }

.metric-grid { margin-bottom: 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card { padding: 20px; display: flex; align-items: center; gap: 14px; border: 1px solid #e6ebef; border-radius: 16px; background: var(--surface); box-shadow: 0 6px 22px rgba(4,19,31,.04); }
.metric-card strong { display: block; font-size: 28px; }
.metric-card small { color: var(--muted); }
.metric-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-weight: 800; }
.metric-icon.blue { color: #2867c7; background: var(--blue-100); }
.metric-icon.orange { color: #b35d0d; background: var(--orange-100); }
.metric-icon.teal { color: var(--teal-600); background: var(--teal-100); }
.metric-icon.red { color: var(--red-600); background: var(--red-100); }

.panel { border: 1px solid #e2e8ed; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel h3 { margin: 0; }
.panel p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.empty-state { padding: 54px 24px; text-align: center; color: var(--muted); }
.audit-row { width: 100%; padding: 17px 22px; display: grid; grid-template-columns: 1.2fr 1.2fr .8fr .7fr 30px; align-items: center; gap: 14px; border: 0; border-bottom: 1px solid #edf1f4; color: inherit; background: white; text-align: left; }
.audit-row:hover { background: #f8fbfc; }
.audit-row:last-child { border-bottom: 0; }
.audit-row strong, .audit-row small { display: block; }
.audit-row small { margin-top: 4px; color: var(--muted); }
.row-arrow { color: var(--teal-600); font-size: 22px; }

.status-pill { display: inline-flex; width: fit-content; padding: 7px 10px; border-radius: 999px; background: var(--blue-100); color: #2867c7; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.status-pill.in_progress { color: #a75306; background: var(--orange-100); }
.status-pill.under_review { color: #6941c6; background: #efe8ff; }
.status-pill.finalised, .status-pill.closed { color: #087c70; background: var(--teal-100); }

.form-panel { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
label span { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: #34465a; }
input, textarea, select { width: 100%; padding: 12px 13px; border: 1px solid #cad5df; border-radius: 11px; color: var(--ink); background: white; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(10,166,166,.1); }
textarea { resize: vertical; line-height: 1.5; }
.full-span { grid-column: 1 / -1; }
.warning-box { margin-top: 20px; padding: 14px 16px; border-left: 4px solid var(--orange-500); border-radius: 10px; background: var(--orange-100); font-size: 13px; line-height: 1.55; }
.form-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }

.audit-title-row { display: flex; align-items: center; justify-content: space-between; }
.save-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.save-state span:first-child { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-500); }
.save-state.saving span:first-child { background: var(--orange-500); animation: pulse 1s infinite; }
.save-state.error span:first-child { background: var(--red-600); }
@keyframes pulse { 50% { opacity: .35; } }
.audit-hero { padding: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 18px; color: white; background: linear-gradient(135deg, var(--navy-900), #103f59); box-shadow: var(--shadow); }
.audit-hero h2 { margin: 0 0 6px; font-size: 28px; }
.audit-hero p:not(.eyebrow) { margin: 0; color: #b7cedd; }
.audit-hero .eyebrow { color: #60ddd6; }
.audit-hero-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }
.audit-progress-panel { margin: 18px 0; padding: 18px 20px; border: 1px solid #e2e8ed; border-radius: 16px; background: white; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.progress-copy span { color: var(--muted); }
.progress-track { height: 9px; margin: 12px 0; border-radius: 999px; background: #e9eff2; overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal-500), #27c58a); transition: width .3s ease; }
.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-chip { padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #edf2f5; }

.module-list { display: grid; gap: 14px; }
.module { border: 1px solid #dfe6eb; border-radius: 16px; background: white; overflow: hidden; box-shadow: 0 6px 20px rgba(4,19,31,.035); }
.module-head { width: 100%; padding: 17px 19px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 0; color: inherit; background: white; text-align: left; }
.module-head-left { display: flex; align-items: center; gap: 13px; }
.module-code { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: white; background: var(--navy-800); font-weight: 900; }
.module-head strong, .module-head small { display: block; }
.module-head small { margin-top: 4px; color: var(--muted); }
.module-content { border-top: 1px solid var(--line); }
.check-item { padding: 19px; border-bottom: 1px solid #edf1f4; }
.check-item:last-child { border-bottom: 0; }
.question-row { display: flex; gap: 12px; }
.item-number { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--teal-600); background: var(--teal-100); font-size: 12px; font-weight: 800; }
.question-copy { line-height: 1.5; font-weight: 650; }
.reference-copy { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }
.item-controls { margin: 15px 0 13px 40px; display: flex; flex-wrap: wrap; gap: 8px; }
.choice-btn { min-width: 72px; padding: 9px 12px; border: 1px solid #ccd7df; border-radius: 10px; color: #516477; background: white; font-size: 12px; font-weight: 800; }
.choice-btn.active.pass { color: #087c70; border-color: #63cdbd; background: var(--teal-100); }
.choice-btn.active.fail { color: var(--red-600); border-color: #ef9ba0; background: var(--red-100); }
.choice-btn.active.na { color: #465567; border-color: #aebac4; background: #edf2f5; }
.evidence-fields { margin-left: 40px; display: grid; grid-template-columns: 1fr 230px; gap: 10px; }
.observation-wrap { position: relative; }
.mic-btn { position: absolute; right: 8px; bottom: 8px; width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.mic-btn.listening { color: white; background: var(--red-600); animation: pulse 1s infinite; }
.classification-box { display: grid; gap: 8px; }
.classification-box select { font-size: 12px; }
.ai-placeholder { min-height: 38px; padding: 8px 10px; border: 1px dashed #b8c6d0; border-radius: 9px; color: var(--muted); background: #f8fafb; font-size: 11px; }
.na-field { margin: 10px 0 0 40px; }
.audit-footer-actions { margin-top: 20px; padding: 18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; border: 1px solid var(--line); border-radius: 16px; background: white; }

.access-row { padding: 18px 20px; display: grid; grid-template-columns: 1fr 190px auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.access-row:last-child { border-bottom: 0; }
.access-row small { display: block; margin-top: 4px; color: var(--muted); }

.bottom-nav { display: none; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 26px; max-width: min(92vw, 520px); padding: 12px 17px; border-radius: 12px; color: white; background: var(--navy-900); box-shadow: 0 14px 40px rgba(0,0,0,.24); transform: translate(-50%, 130px); opacity: 0; transition: .25s ease; text-align: center; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red-600); }

@media (max-width: 820px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .audit-row { grid-template-columns: 1fr .8fr 24px; }
  .audit-row .hide-mobile { display: none; }
  .evidence-fields { grid-template-columns: 1fr; }
  .audit-hero { align-items: flex-start; flex-direction: column; }
  .audit-hero-actions { justify-content: flex-start; }
}

@media (max-width: 600px) {
  .topbar { height: 62px; padding: 0 16px; }
  .topbar-brand small, .user-copy { display: none; }
  .main-content { width: 100%; padding: 24px 14px 104px; }
  .page-heading { align-items: flex-start; }
  .desktop-action { display: none; }
  .metric-grid { gap: 9px; }
  .metric-card { padding: 14px; }
  .metric-icon { width: 38px; height: 38px; }
  .metric-card strong { font-size: 22px; }
  .metric-card small { font-size: 10px; }
  .panel-head { padding: 17px; }
  .audit-row { padding: 15px 16px; grid-template-columns: 1fr auto 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .form-panel { padding: 17px; }
  .login-card { padding: 30px 22px; }
  .audit-hero { padding: 19px; border-radius: 15px; }
  .audit-hero h2 { font-size: 23px; }
  .audit-hero-actions .btn { font-size: 11px; padding: 9px 10px; }
  .progress-copy { align-items: flex-start; flex-direction: column; }
  .module-head { padding: 15px; }
  .check-item { padding: 16px 13px; }
  .item-controls, .evidence-fields, .na-field { margin-left: 0; }
  .choice-btn { flex: 1; }
  .bottom-nav { position: fixed; z-index: 30; left: 12px; right: 12px; bottom: 12px; height: 66px; padding: 7px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; color: white; background: rgba(7,27,45,.96); box-shadow: 0 12px 40px rgba(4,19,31,.32); backdrop-filter: blur(14px); }
  .nav-btn { border: 0; border-radius: 12px; color: #94aabb; background: transparent; font-size: 10px; font-weight: 700; }
  .nav-btn span { display: block; margin-bottom: 3px; font-size: 20px; }
  .nav-btn.active { color: white; background: rgba(10,166,166,.18); }
  .access-row { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .topbar, .bottom-nav, .audit-title-row, .audit-hero-actions, .audit-footer-actions, .mic-btn, .ai-placeholder { display: none !important; }
  .main-content { width: 100%; padding: 0; }
  #auditView { display: block !important; }
  .audit-hero { color: #111; border: 1px solid #bbb; background: white; box-shadow: none; }
  .audit-hero p:not(.eyebrow) { color: #444; }
  .module-content { display: block !important; }
  .module, .audit-progress-panel { box-shadow: none; break-inside: avoid; }
  .choice-btn:not(.active) { display: none; }
  textarea, select, input { border: 0; padding: 0; }
}
