:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #687385;
    --line: #dce2e8;
    --brand: #116466;
    --brand-dark: #0b484a;
    --accent: #c84b31;
    --good: #0f7a43;
    --danger: #a83232;
    --shadow: 0 16px 40px rgba(23, 32, 42, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--brand);
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: #162126;
    color: #fff;
}

.brand,
.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    color: #fff;
    font-weight: 800;
    margin-bottom: 26px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 900;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a {
    color: rgba(255, 255, 255, .78);
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 650;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.content {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    font-weight: 800;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.08rem;
}

.batch-switch select,
input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 9px 11px;
}

.batch-switch {
    min-width: 220px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat,
.panel,
.setup-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat {
    padding: 18px;
}

.stat span,
label span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 7px;
}

.stat strong {
    display: block;
    font-size: 1.45rem;
    line-height: 1.2;
}

.stat small {
    display: block;
    color: var(--muted);
    margin-top: 6px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 18px;
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-title span {
    color: var(--muted);
    font-size: .9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.form-grid.compact {
    grid-template-columns: 1fr;
}

.span-2 {
    grid-column: span 2;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 9px 13px;
    cursor: pointer;
    font-weight: 750;
}

.button.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.button.primary:hover {
    background: var(--brand-dark);
}

.button.wide {
    width: 100%;
}

.inline-form {
    margin-top: 12px;
}

.notice {
    margin-bottom: 18px;
    padding: 13px 14px;
    border-radius: 8px;
    background: #fff8e8;
    border: 1px solid #ead39d;
    color: #6e5014;
}

.notice.success {
    background: #eaf7ef;
    border-color: #b8dfc7;
    color: var(--good);
}

.notice.danger {
    background: #fff0f0;
    border-color: #e3b9b9;
    color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafb;
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    background: #e8f2f2;
    color: var(--brand-dark);
    padding: 3px 9px;
    font-size: .82rem;
    font-weight: 800;
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
}

.actions form {
    display: inline;
}

.actions button {
    min-height: auto;
    padding: 0;
    border: 0;
    color: var(--danger);
    background: transparent;
}

.table-search {
    max-width: 360px;
    margin-bottom: 12px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.report-link {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
}

.report-link span,
.muted {
    color: var(--muted);
}

.small {
    font-size: .88rem;
}

.setup-page {
    display: grid;
    place-items: center;
    padding: 18px;
    background: linear-gradient(135deg, #162126 0%, #24363d 58%, #314449 100%);
}

.setup-shell {
    width: min(720px, 100%);
}

.setup-panel {
    padding: 24px;
}

.setup-panel .brand-block {
    align-items: flex-start;
    margin-bottom: 22px;
}

.setup-panel p {
    margin: 6px 0 0;
    color: var(--muted);
}

@media (max-width: 1000px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

    .brand {
        margin-bottom: 12px;
    }

    .sidebar nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .sidebar nav a {
        flex: 0 0 auto;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .split,
    .report-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 16px;
    }

    .topbar,
    .panel-title {
        display: grid;
        justify-content: stretch;
    }

    .batch-switch {
        min-width: 0;
    }

    .stat-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    h1 {
        font-size: 1.45rem;
    }

    .stat strong {
        font-size: 1.25rem;
    }

    .panel,
    .setup-panel {
        padding: 14px;
    }
}
