:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --border: #e2e6ef;
    --text: #1a2233;
    --muted: #6b7488;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #101827;
    color: #cbd5e1;
    padding: 20px 14px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 24px;
    padding: 0 8px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #cbd5e1;
    margin-bottom: 4px;
    font-weight: 500;
}

.nav-badge {
    background: #dc2626;
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: #1e293b;
    color: #fff;
    text-decoration: none;
}

.main {
    flex: 1;
    padding: 28px 32px;
    max-width: 1200px;
}

.main h1 {
    margin: 0 0 20px;
    font-size: 22px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
    /* Широкие таблицы скроллятся внутри карточки, а не всей страницей —
       иначе горизонтальная прокрутка утаскивает закреплённый сайдбар. */
    overflow-x: auto;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.stat-card .value {
    font-size: 26px;
    font-weight: 700;
}

.stat-card .label {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 4px;
}

.stage-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:hover td { background: #fafbff; }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover { background: var(--accent-dark); text-decoration: none; }

.btn.secondary {
    background: #eef1f8;
    color: var(--text);
}

.btn.secondary:hover { background: #e2e6f2; }

input[type="text"], input[type="password"], input[type="tel"], input[type="email"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

label {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 5px;
    font-weight: 600;
}

.field { margin-bottom: 14px; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #101827, #1e3a8a);
}

.login-box {
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    width: 340px;
}

.login-box h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.login-box .sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 22px;
}

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input[type="text"] { max-width: 260px; }

.muted { color: var(--muted); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef1f8;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}

.timeline-item {
    border-left: 2px solid var(--border);
    padding: 4px 0 14px 16px;
    margin-left: 4px;
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-item .meta {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 2px;
}
