:root {
    --primary: #b5273b;
    --primary-dark: #8f1e2f;
    --accent: #2e6fb5;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2733;
    --muted: #6b7688;
    --border: #dfe4ec;
    --ok: #2e9e5b;
    --warn: #e8833a;
    --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .05);
    --radius: 12px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Top bar ---------- */
.topbar { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 12px 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: inline-block; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: #fff; text-decoration: none; opacity: .92; font-size: .95rem; }
.topnav a:hover { opacity: 1; text-decoration: underline; }
.inline { display: inline; }
.link-btn { background: none; border: none; color: #fff; cursor: pointer; font: inherit; opacity: .92; }
.link-btn:hover { opacity: 1; text-decoration: underline; }

/* ---------- Layout ---------- */
.container { max-width: 820px; margin: 24px auto; padding: 0 16px; }
.container.wide { max-width: 1180px; }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 28px 16px 40px; }

/* ---------- Cards / sections ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.intro { border-left: 4px solid var(--primary); }
.section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.section-head { background: linear-gradient(180deg, #fbfcfe, #f2f5fa); padding: 14px 20px; border-bottom: 1px solid var(--border); }
.section-head h2 { margin: 0; font-size: 1.05rem; color: var(--primary-dark); }
.section-body { padding: 18px 20px; }

h1 { font-size: 1.5rem; margin: 0 0 6px; }
.subtitle { color: var(--muted); margin: 0 0 4px; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; margin-bottom: 7px; }
.field .req { color: var(--primary); }
input[type=text], input[type=number], input[type=password], select, textarea {
    width: 100%; padding: 11px 12px; border: 1px solid var(--border);
    border-radius: 9px; font-size: 1rem; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,111,181,.15); }

/* Radios & checkboxes rendered as chips */
ul { list-style: none; margin: 0; padding: 0; }
.field ul li { margin: 0 0 6px; }
.field ul li label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-weight: 400; transition: .12s; }
.field ul li label:hover { border-color: var(--accent); background: #f6faff; }
.field input[type=radio], .field input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }

.helptext { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.errorlist { color: var(--primary); font-size: .85rem; margin: 4px 0 0; padding-left: 0; }
.field.has-error input, .field.has-error select { border-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn { display: inline-block; background: var(--primary); color: #fff; border: none; padding: 13px 22px; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn.block { display: block; width: 100%; text-align: center; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.accent { background: var(--accent); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.alert-success { background: #e7f6ec; color: #1c6b3a; border: 1px solid #b8e2c6; }
.alert-error { background: #fdeaec; color: var(--primary-dark); border: 1px solid #f4c2c8; }

/* ---------- Confirmation ---------- */
.code-box { text-align: center; padding: 26px; }
.code-value { font-size: 2rem; font-weight: 800; letter-spacing: 2px; color: var(--primary); }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi .val { font-size: 1.9rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.kpi .val.accent { color: var(--accent); }
.kpi .val.ok { color: var(--ok); }
.kpi .lbl { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* ---------- Charts grid ---------- */
.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.chart-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.chart-card h3 { margin: 0 0 12px; font-size: .98rem; color: var(--text); }
.chart-card .full { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 260px; }
.span-2 { grid-column: 1 / -1; }

/* ---------- Table ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #f7f9fc; color: var(--muted); font-weight: 600; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge.ok { background: #e7f6ec; color: #1c6b3a; }
.badge.wait { background: #fff4e5; color: #a15c17; }

@media (max-width: 720px) {
    .charts { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}
