:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #eef4f6;
    --text: #14232b;
    --muted: #647681;
    --line: #dbe4e8;
    --primary: #0f6f70;
    --primary-dark: #0a5557;
    --accent: #d8972d;
    --danger: #b94b4b;
    --success: #2f7d5a;
    --radius: 20px;
    --shadow: 0 12px 30px rgba(20, 35, 43, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 12px; }
.container { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }

/* Topbar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar .inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 12px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    display: grid; place-items: center; color: #fff; font-weight: 900; box-shadow: var(--shadow);
}
.brand small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .03em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.user-chip b { color: var(--text); }

/* Shell: sidebar + content */
.app-shell { display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: calc(100vh - 64px); }
.sidebar {
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 18px 12px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
    color: var(--muted); font-weight: 700; font-size: 14px; margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--primary); }
.sidebar nav a.active { background: var(--surface-2); color: var(--primary); }
.sidebar .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; margin: 16px 12px 6px; }
.content { padding: 24px; min-width: 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.soft { box-shadow: none; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stat cards */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat .num { font-size: 28px; font-weight: 900; letter-spacing: -.03em; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 4px; }
.stat .trend { font-size: 12px; margin-top: 6px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--primary); font-size: 12px; font-weight: 800; }
.badge.warn { background: #fff6df; color: #8c651d; }
.badge.ok { background: #e8f7ef; color: var(--success); }
.badge.danger { background: #fff1f1; color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* Buttons */
.btn { border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost { background: var(--surface-2); color: var(--primary); }
.btn.danger { background: #fff1f1; color: var(--danger); border-color: #f1cccc; }
.btn.small { padding: 7px 11px; font-size: 12px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(15,111,112,.35); outline-offset: 2px;
}

/* Forms */
label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.req { color: var(--danger); }
input:not([type=checkbox],[type=radio],[type=hidden],[type=submit],[type=button]),
select, textarea {
    width: 100%; border: 1px solid #ccd8dd; background: #fff; padding: 11px 12px; border-radius: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,111,112,.12); }
textarea { min-height: 100px; resize: vertical; }
.field { margin-bottom: 18px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 700; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.options { display: flex; flex-wrap: wrap; gap: 10px; }
.option { display: flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover { border-color: var(--primary); }
.option:has(input:checked) { border-color: var(--primary); background: rgba(15,111,112,.06); font-weight: 700; }
.option input { accent-color: var(--primary); }

/* Kuisioner responden (form bertahap) -- jarak & pemisah antar pertanyaan dalam satu langkah */
.question { padding: 16px 0; border-bottom: 1px solid var(--line); }
.question:first-child { padding-top: 0; }
.question:last-child { border-bottom: none; padding-bottom: 0; }
.question.unanswered { background: linear-gradient(90deg, rgba(216,151,45,.06), transparent 40px); }
.question .label { font-size: 15px; line-height: 1.4; }

/* Notices / alerts */
.notice { padding: 12px 16px; border-radius: 14px; border: 1px solid #d7e7e8; background: #f3fafa; color: #2d565b; font-size: 14px; margin-bottom: 16px; }
.notice.warn { background: #fff9e9; border-color: #f3dfae; color: #72581c; }
.notice.danger { background: #fff1f1; border-color: #f1cccc; color: #853d3d; }
.notice.success { background: #eaf7f0; border-color: #bfe4cf; color: #205c3f; }

/* Tables */
.table-toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.table-toolbar .group { display: flex; gap: 8px; flex-wrap: wrap; }
.table-toolbar input, .table-toolbar select { width: auto; min-width: 160px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data th, table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { position: sticky; top: 0; background: #f8fafb; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr:hover { background: #fafcfc; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* Kuisioner responden -- lebar dibatasi supaya nyaman dibaca (beda dari .container umum yang lebih
   lebar untuk tabel/dashboard admin) */
.form-shell { max-width: 720px; margin: 0 auto; }

/* Progress / stepper (form bertahap) */
.stepper { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step-dot { flex: 1; min-width: 60px; text-align: center; padding: 8px 6px; border-radius: 10px; font-size: 11px; font-weight: 800; color: var(--muted); background: var(--surface-2); }
.step-dot.active { background: var(--primary); color: #fff; }
.step-dot.done { background: #e8f7ef; color: var(--success); }
.progress-track { height: 8px; border-radius: 99px; background: #e5ecef; overflow: hidden; margin: 10px 0 18px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #29a695); transition: .25s; }
.autosave-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.autosave-status.saving { color: var(--accent); }
.autosave-status.saved { color: var(--success); }
.autosave-status.error { color: var(--danger); }

/* Likert table */
.likert-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.likert-table th, .likert-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.likert-table th:first-child, .likert-table td:first-child { text-align: left; }
.likert-table th { font-size: 11px; color: var(--muted); }

/* Auth pages */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, rgba(15,111,112,.08), transparent 30%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }

.footer { padding: 24px 0; color: var(--muted); font-size: 13px; text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .content { padding: 16px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    table.data { min-width: 560px; }
}
