:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --ink: #1c2b33;
    --muted: #5c7078;
    --accent: #0e7c66;
    --accent-dark: #0a5f4e;
    --line: #d8e0e3;
    --danger: #b3372f;
    --warn-bg: #fdf3e0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
}

.layout { min-height: 100vh; display: flex; flex-direction: column; }
.layout-plain { justify-content: center; align-items: center; }

.topbar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.7rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand a {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-dark);
    text-decoration: none;
}

.brand-sub { margin-left: 0.5rem; color: var(--muted); font-size: 0.85rem; }

.topnav { display: flex; gap: 1.25rem; flex: 1; }
.topnav a { color: var(--ink); text-decoration: none; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.topnav a.active { border-bottom-color: var(--accent); color: var(--accent-dark); font-weight: 600; }

.userbox { display: flex; align-items: center; gap: 0.75rem; }
.username { color: var(--muted); }
.inline-form { display: inline; margin: 0; }

.content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

h1 { font-size: 1.5rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.6rem; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--danger); }
.ok { color: var(--accent-dark); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.1rem 1.3rem;
    margin-bottom: 1.1rem;
}

.card-warn {
    background: var(--warn-bg);
    border-color: #e8c98d;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem 1.1rem; margin-bottom: 0.9rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.86rem; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

input, select, textarea {
    font: inherit;
    padding: 0.42rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    width: 100%;
}

input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }

.btn {
    font: inherit;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #e4b7b3; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

.actions { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }

table.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.1rem;
}

table.grid th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    background: #eef2f3;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--line);
}

table.grid td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid td input, table.grid td select { min-width: 9rem; }
.row-dim { opacity: 0.55; }
.row-actions { white-space: nowrap; }
.truncate { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    background: #e6eef0;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 600;
}

.pill-required { background: #f6dfd9; color: var(--danger); }
.pill-scope { background: var(--accent); color: #fff; }
.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }

.progress { background: #e6eef0; border-radius: 999px; height: 8px; width: 10rem; overflow: hidden; }
.progress.big { width: 100%; height: 12px; margin-bottom: 0.75rem; }
.progress > div { background: var(--accent); height: 100%; }

.summary { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1.25rem; margin: 0; }
.summary dt { color: var(--muted); font-size: 0.85rem; }
.summary dd { margin: 0; }

.client-header h1 { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }

.wizard-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.wizard-nav a {
    padding: 0.55rem 0.9rem;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

.wizard-nav a.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }

.question-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
}

.question-row:last-child { border-bottom: none; }
.question-text { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.q-code { font-weight: 700; color: var(--accent-dark); }
.q-prompt { flex: 1 1 100%; }
.question-input { display: flex; flex-direction: column; gap: 0.5rem; }
.question-input textarea { background: #f2f8fa; }

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 0.8rem 0;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.tab-row { display: flex; gap: 0.35rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.tab {
    font: inherit;
    padding: 0.45rem 1rem;
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: #e9eef0;
    color: var(--muted);
    cursor: pointer;
}
.tab.active { background: var(--panel); color: var(--accent-dark); font-weight: 600; border-bottom-color: var(--panel); }

.filter-row { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 0.9rem; flex-wrap: wrap; }
.filter-row label { flex-direction: row; align-items: center; gap: 0.5rem; }

.notes { margin: 0; padding-left: 1.1rem; }
.notes li { margin-bottom: 0.35rem; }

.flags { list-style: none; margin: 0; padding: 0; }
.flags li {
    padding: 0.45rem 0.7rem;
    border-left: 3px solid var(--line);
    margin-bottom: 0.4rem;
    color: var(--muted);
    border-radius: 0 6px 6px 0;
}
.flags li.on { border-left-color: var(--accent); color: var(--ink); background: #eef7f4; }

.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 2.25rem;
    width: min(420px, 90vw);
    box-shadow: 0 10px 30px rgba(28, 43, 51, 0.08);
}

.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.25rem; }
