:root{
    --bg:#f4f6fb;
    --surface:#fff;
    --surface-soft:#f8faff;
    --ink:#172033;
    --muted:#5b6883;
    --line:#e3e8f5;
    --brand:#3558d4;
    --brand-dark:#20346b;
    --sidebar:#10192f;
    --sidebar-soft:#233150;
    --success-bg:#e5f8ee;
    --success:#0f7045;
    --warning-bg:#fff7dd;
    --warning:#866500;
    --danger-bg:#ffe9e9;
    --danger:#9d1b1b;
    --shadow:0 16px 40px rgba(31,46,88,.06);
    --radius:22px;
}
*{box-sizing:border-box}
html{min-width:320px;-webkit-text-size-adjust:100%}
body{margin:0;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--ink);line-height:1.5}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
img,svg,video{max-width:100%;height:auto}
button,.button{display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:12px;background:#edf1ff;color:var(--brand-dark);padding:.65rem .95rem;font-weight:700;cursor:pointer;gap:.35rem;text-align:center;min-height:42px;line-height:1.2;text-decoration:none;touch-action:manipulation}
button:hover,.button:hover{text-decoration:none;filter:brightness(.98)}
button:disabled,.button[disabled]{cursor:not-allowed;opacity:.58}
.button.ghost,button.ghost{background:#f4f6fb;color:#26395e}
.button.primary,button.primary{background:var(--brand);color:white}
.danger,button.danger{background:#ffe7e7;color:var(--danger)}
.skip-link{position:fixed;left:1rem;top:.5rem;z-index:1000;background:#fff;color:#000;padding:.55rem .8rem;border-radius:10px;box-shadow:var(--shadow);transform:translateY(-150%)}
.skip-link:focus{transform:translateY(0)}
.app-shell{display:grid;grid-template-columns:280px minmax(0,1fr);min-height:100vh}
.sidebar{background:var(--sidebar);color:#f7f8ff;padding:1.25rem;position:sticky;top:0;height:100vh;overflow:auto;overscroll-behavior:contain}
.brand-mark,.mobile-brand{display:flex;align-items:center;gap:.8rem}
.brand-mark{margin-bottom:1.3rem}
.brand-icon{width:46px;height:46px;border-radius:14px;background:#6dd7b9;color:#0d2630;display:grid;place-items:center;font-weight:900;flex:0 0 auto}
.brand-icon.small{width:34px;height:34px;border-radius:11px;font-size:.85rem}
.brand-mark span,.user-card span,.user-card small{display:block;color:#aab6d3;font-size:.85rem}
.user-card{background:rgba(255,255,255,.07);padding:1rem;border-radius:16px;margin-bottom:1rem;overflow-wrap:anywhere}
.sidebar nav{display:grid;gap:.35rem}
.sidebar a{color:#cdd7f2;border-radius:12px;padding:.72rem .85rem;text-decoration:none;display:block}
.sidebar a.active,.sidebar a:hover{background:rgba(255,255,255,.12);color:#fff;text-decoration:none}
.logout-form{margin-top:1rem}
.logout-form button{width:100%;background:var(--sidebar-soft);color:#fff}
.main-content{padding:clamp(1rem,2.5vw,2rem);max-width:1500px;width:100%;margin:0 auto;min-width:0}
.mobile-topbar{display:none}
.sidebar-backdrop{display:none}
.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1rem}
.page-head h1{margin:.1rem 0;font-size:clamp(1.55rem,3vw,2rem);line-height:1.12}
.page-head p{margin:.3rem 0;color:var(--muted)}
.page-head > .button,.page-head > a.button,.page-head > .pill{flex:0 0 auto}
.card,.auth-card,.mini-card,.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:1.25rem;margin-bottom:1rem;min-width:0}
.auth-card{max-width:480px;margin:6vh auto}
.auth-card.wide{max-width:820px}
.card > :first-child,.mini-card > :first-child,.stat > :first-child{margin-top:0}
.card > :last-child,.mini-card > :last-child,.stat > :last-child{margin-bottom:0}
.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1rem;margin-bottom:1rem}
.stat span{display:block;color:#63708a}
.stat strong{font-size:clamp(1.55rem,3.4vw,2rem);line-height:1.1;overflow-wrap:anywhere}
.grid{display:grid;gap:1rem}
.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}
.cards-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(250px,100%),1fr));gap:1rem}
.stack{display:grid;gap:1rem}
.compact{gap:.45rem}
.grid-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;align-items:start}
.grid-form .full,.full{grid-column:1/-1}
label{display:grid;gap:.35rem;font-weight:700;color:#26364f;min-width:0}
.inline{display:inline-flex!important;align-items:center;gap:.4rem;font-weight:600}
input,select,textarea{width:100%;max-width:100%;border:1px solid #d6deef;border-radius:12px;background:#fff;padding:.7rem;font:inherit;color:var(--ink)}
select{min-height:42px}
textarea{min-height:92px;resize:vertical}
input[type="checkbox"],input[type="radio"]{width:auto;flex:0 0 auto}
.check-row{display:flex!important;align-items:flex-start;gap:.55rem;font-weight:700;color:#26364f;line-height:1.35}
.check-row input{margin-top:.2rem}
input[type="range"]{padding:.35rem 0;accent-color:var(--brand)}
output{display:inline-flex;min-width:2.2rem;justify-content:center;border-radius:999px;background:#edf1ff;color:var(--brand-dark);font-weight:800;padding:.2rem .55rem;margin-left:.45rem}
.filters{display:flex;gap:.65rem;align-items:center;flex-wrap:wrap;margin-bottom:1rem}
.filters input,.filters select{width:auto;min-width:180px}
.alert{border-radius:14px;padding:.8rem 1rem;margin-bottom:1rem;font-weight:700;overflow-wrap:anywhere}
.alert.success{background:#e6faf2;color:#0f6d45}
.alert.error{background:#ffecec;color:#a52424}
.table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse;min-width:720px}
th,td{padding:.8rem;border-bottom:1px solid #e8edf7;text-align:left;vertical-align:top;overflow-wrap:anywhere}
th{font-size:.82rem;text-transform:uppercase;color:#60708f;background:var(--surface-soft);letter-spacing:.02em}
td form{margin:.2rem 0}
.actions{display:flex;gap:.4rem;flex-wrap:wrap;align-items:center}
.actions form{display:inline-flex;gap:.35rem;align-items:center;flex-wrap:wrap}
.actions input,.actions select{min-width:130px}
.status,.pill{display:inline-flex;align-items:center;border-radius:999px;padding:.25rem .6rem;font-size:.78rem;font-weight:800;background:#eef2ff;color:#2f4fc0;white-space:nowrap}
.status-live,.status-approved,.status-fulfilled{background:var(--success-bg);color:var(--success)}
.status-submitted,.status-requested{background:var(--warning-bg);color:var(--warning)}
.status-ended,.status-rejected{background:var(--danger-bg);color:var(--danger)}
.plain-list{list-style:none;padding:0;margin:0;display:grid;gap:.7rem}
.plain-list li{padding:.75rem;border:1px solid #e8edf7;border-radius:14px;overflow-wrap:anywhere}
.plain-list small{display:block;color:#7b879d;margin-top:.25rem}
.question-editor{border:1px dashed #cbd5ea;border-radius:16px;padding:1rem;min-width:0}
.section-title{display:flex;justify-content:space-between;align-items:center;gap:1rem}
.question-row{display:grid;grid-template-columns:minmax(120px,150px) minmax(180px,1fr) minmax(180px,1fr) minmax(80px,100px) minmax(100px,120px);gap:.75rem;align-items:end;border-top:1px solid #edf1f8;padding-top:1rem;margin-top:1rem}
fieldset{border:1px solid #dce3f2;border-radius:16px;padding:1rem;min-width:0}
legend{font-weight:800;padding:0 .25rem}
.choice{display:flex;align-items:flex-start;gap:.6rem;font-weight:500;margin:.4rem 0;line-height:1.4}
.choice input{margin-top:.2rem}
pre{white-space:pre-wrap;max-width:100%;overflow:auto;background:#f8faff;border:1px solid #e8edf7;border-radius:12px;padding:.75rem}
details{margin:.8rem 0}
summary{cursor:pointer;font-weight:800;color:#26364f}
.faq h2{margin-top:1.3rem}
.survey-answer button.primary,.mini-card form button{width:max-content;max-width:100%}
.result-block{border-top:1px solid #edf1f8;padding-top:1rem;margin-top:1rem}

@media (max-width:1200px){
    .app-shell{grid-template-columns:248px minmax(0,1fr)}
    .sidebar{padding:1rem}
    .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media (max-width:900px){
    body.nav-open{overflow:hidden}
    .mobile-topbar{display:flex;position:sticky;top:0;z-index:40;justify-content:space-between;align-items:center;padding:.7rem max(1rem,env(safe-area-inset-left)) .7rem max(1rem,env(safe-area-inset-right));background:var(--sidebar);color:#fff;box-shadow:0 8px 24px rgba(16,25,47,.14)}
    .menu-button{background:#26395e;color:#fff;border:1px solid rgba(255,255,255,.12);padding:.55rem .8rem;min-height:38px}
    .app-shell{display:block;min-height:calc(100vh - 56px)}
    .sidebar{display:block;position:fixed;z-index:50;top:0;bottom:0;left:0;width:min(86vw,340px);height:100dvh;padding:calc(.95rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));transform:translateX(-105%);transition:transform .18s ease;box-shadow:24px 0 50px rgba(8,15,35,.28)}
    .sidebar.open{transform:translateX(0)}
    .sidebar-backdrop{position:fixed;inset:0;z-index:45;display:block;background:rgba(9,16,35,.5);backdrop-filter:blur(2px)}
    .sidebar-backdrop[hidden]{display:none}
    .main-content{padding:1rem;max-width:none}
    .grid.two,.grid.three,.grid-form{grid-template-columns:1fr}
    .page-head{display:grid;align-items:start}
    .page-head > .button,.page-head > a.button,.page-head > .pill{justify-self:start}
    .question-row{grid-template-columns:1fr}
    .filters{display:grid;grid-template-columns:1fr;align-items:stretch}
    .filters input,.filters select,.filters button{width:100%;min-width:0}
}

@media (max-width:720px){
    :root{--radius:18px}
    .main-content{padding:.85rem}
    .card,.auth-card,.mini-card,.stat{padding:1rem;border-radius:18px}
    .auth-card{margin:1rem auto}
    .stats-grid{grid-template-columns:1fr;gap:.75rem}
    .stat{display:flex;align-items:center;justify-content:space-between;gap:1rem}
    .stat span{font-weight:700}
    .section-title{display:grid;align-items:start}
    .section-title .button,.section-title button{justify-self:start}
    .table-wrap{overflow:visible}
    table{min-width:0;border-collapse:separate;border-spacing:0 1rem}
    thead{display:none}
    tbody,tr,td{display:block;width:100%}
    tr{background:#fff;border:1px solid #e3e8f5;border-radius:16px;box-shadow:0 8px 24px rgba(31,46,88,.05);overflow:hidden}
    td{border-bottom:1px solid #edf1f8;padding:.8rem 1rem .8rem 8.2rem;position:relative;min-height:45px}
    td:last-child{border-bottom:0}
    td::before{content:attr(data-label);position:absolute;left:1rem;top:.8rem;width:6.4rem;color:#60708f;font-size:.74rem;text-transform:uppercase;font-weight:900;letter-spacing:.02em;line-height:1.25}
    td[colspan] {padding-left:1rem}
    td[colspan]::before{display:none}
    .actions,.actions form,td form.stack{display:grid;grid-template-columns:1fr;align-items:stretch;width:100%}
    .actions .button,.actions button,.actions input,.actions select,.actions textarea,td form.stack button,td form.stack select,td form.stack textarea{width:100%;min-width:0}
    pre{max-height:260px}
}

@media (max-width:520px){
    .mobile-brand strong{max-width:58vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .page-head h1{font-size:1.45rem}
    .card,.auth-card,.mini-card,.stat{padding:.9rem}
    button,.button{width:100%;padding:.72rem .9rem}
    .page-head > .pill{width:auto}
    .inline{align-items:flex-start}
    .choice{padding:.2rem 0}
    td{padding:2.25rem .85rem .85rem}
    td::before{left:.85rem;top:.7rem;width:auto}
    .stat{display:block}
    .survey-answer button.primary,.mini-card form button{width:100%}
}
