:root {
    --bg: #eef4f8;
    --panel: #ffffff;
    --ink: #071b34;
    --muted: #64748b;
    --line: #dbe5ef;
    --primary: #0f766e;
    --primary-dark: #0b534d;
    --blue: #2563eb;
    --green: #059669;
    --red: #dc2626;
    --amber: #d97706;
    --shadow: 0 12px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
}
a { color: inherit; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(14px, 3vw, 34px);
    background: #102235;
    color: #fff;
    box-shadow: var(--shadow);
}
.topbar strong { display: block; font-size: 18px; }
.topbar span { display: block; color: #b8c8d9; font-size: 13px; margin-top: 2px; }
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar nav a {
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    padding: 9px 12px;
    font-weight: 800;
    background: rgba(255,255,255,.08);
}

.wrap {
    width: min(1480px, calc(100% - 28px));
    margin: 18px auto 36px;
}
.wrap.narrow { width: min(920px, calc(100% - 28px)); }
.hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.hero > div:first-child, .panel, .kpi, .sync-pill {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.hero > div:first-child { flex: 1; padding: 22px; }
.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 900;
}
h1, h2 { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.05; }
h2 { font-size: 20px; }
.hero p:last-child { color: var(--muted); margin-bottom: 0; }
.sync-pill {
    min-width: 280px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 5px solid var(--amber);
}
.sync-pill.ok { border-left-color: var(--green); }
.sync-pill span { font-weight: 900; }
.sync-pill small { color: var(--muted); margin-top: 5px; }

.panel { padding: 18px; margin-bottom: 14px; }
.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}
label { color: var(--muted); font-size: 13px; font-weight: 800; }
input {
    display: block;
    width: 100%;
    margin-top: 6px;
    min-height: 44px;
    border: 1px solid #cbd8e6;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}
.btn, .mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.ghost { background: #f8fafc; color: var(--ink); border-color: #cbd8e6; }
.export { background: #e7f0ff; color: #174ea6; border-color: #b9d0ff; }
.mini-btn { min-height: 34px; padding: 7px 10px; color: #fff; background: var(--blue); font-size: 13px; }

.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.kpi {
    padding: 18px;
    border-left: 5px solid var(--blue);
}
.kpi span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 900;
}
.kpi strong {
    display: block;
    margin-top: 7px;
    font-size: clamp(22px, 3vw, 31px);
    line-height: 1.1;
}
.kpi small { display: block; margin-top: 6px; color: var(--muted); font-weight: 700; }
.kpi.good { border-left-color: var(--green); }
.kpi.danger { border-left-color: var(--red); }
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.split-row:last-child { border-bottom: 0; }
.split-row small { color: var(--muted); margin-left: 4px; }
.muted { color: var(--muted); }
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.section-title span { color: var(--muted); font-weight: 800; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
    background: #eaf1f8;
    color: #0b2948;
    font-size: 12px;
    text-transform: uppercase;
}
td.num, th.num { text-align: right; white-space: nowrap; }
.bad-text { color: var(--red); font-weight: 900; }
.good-text { color: var(--green); font-weight: 900; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.alert {
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0;
    font-weight: 800;
}
.alert.error { background: #fee2e2; color: #991b1b; }
.ticket-text {
    white-space: pre-wrap;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 12px;
    padding: 18px;
    overflow-x: auto;
    font-size: 14px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
    background: radial-gradient(circle at top, #dff6ef 0, #eef4f8 44%, #dbeafe 100%);
}
.login-card {
    width: min(430px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .16);
    padding: 30px;
}
.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: #102235;
    color: #fff;
    font-size: 26px;
    font-weight: 900;
    margin-bottom: 18px;
}
.login-card h1 { font-size: 32px; }
.login-card p { color: var(--muted); margin: 8px 0 22px; }
.login-card label { display: block; margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 18px; }

@media (max-width: 900px) {
    .hero, .grid { grid-template-columns: 1fr; display: grid; }
    .sync-pill { min-width: 0; }
    .kpis, .grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    body { font-size: 15px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar nav { width: 100%; }
    .topbar nav a { flex: 1; text-align: center; }
    .wrap { width: min(100% - 18px, 100%); margin-top: 10px; }
    .hero > div:first-child, .panel, .kpi, .sync-pill { border-radius: 12px; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
    .filters .btn { width: 100%; }
    .kpis, .grid.compact { grid-template-columns: 1fr; }
    .table-wrap { border: 0; overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { display: none; }
    tr {
        border: 1px solid var(--line);
        border-radius: 12px;
        margin-bottom: 10px;
        overflow: hidden;
        background: #fff;
    }
    td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }
    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 900;
        text-align: left;
    }
    td.num { text-align: right; }
}

@media print {
    .topbar, .filters, .btn, .mini-btn { display: none !important; }
    body { background: #fff; }
    .wrap { width: 100%; margin: 0; }
    .panel, .kpi, .hero > div:first-child, .sync-pill { box-shadow: none; }
}
