:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1d232d;
    --muted: #687385;
    --line: #dfe5eb;
    --primary: #176b5d;
    --primary-dark: #0f4d43;
    --danger: #b42318;
    --warning: #b7791f;
    --shadow: 0 14px 35px rgba(31, 41, 55, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.sidebar {
    background: #17202a;
    color: #f7fafc;
    padding: 22px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.brand.compact {
    margin-bottom: 22px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: #f0b429;
    color: #17202a;
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #aab4c0;
    margin-top: 3px;
}

nav {
    display: grid;
    gap: 4px;
}

nav a {
    border-radius: 8px;
    color: #d9e2ec;
    padding: 10px 12px;
}

nav a:hover,
nav a.active {
    background: rgba(255, 255, 255, .11);
    color: #ffffff;
}

.main {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar span {
    color: var(--muted);
    display: inline-block;
    margin-top: 4px;
}

.userbox,
.actions,
.toolbar,
.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

.panel.narrow {
    max-width: 980px;
}

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

.panel-head h2,
.report-grid h2 {
    margin: 0;
    font-size: 20px;
}

.panel-head p {
    color: var(--muted);
    margin: 0;
}

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

.metric {
    padding: 18px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 14px;
    margin-bottom: 9px;
}

.metric strong {
    font-size: 24px;
}

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

.report {
    max-width: 1180px;
}

.report-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.report-title {
    border-bottom: 2px solid var(--ink);
    margin-bottom: 16px;
    padding-bottom: 12px;
    text-align: center;
}

.report-title h2 {
    font-size: 22px;
    margin: 0 0 6px;
}

.report-title p {
    color: var(--muted);
    margin: 0;
}

.report-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 18px;
}

.signature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 48px;
    text-align: center;
}

.signature-grid div {
    border-top: 1px solid var(--ink);
    padding-top: 10px;
}

.module-tile {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.module-tile:hover {
    border-color: var(--primary);
}

.module-tile strong,
.module-tile span {
    display: block;
}

.module-tile span {
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.45;
}

.button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    font-size: 14px;
}

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

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

.button.ghost {
    background: transparent;
}

.button.small {
    min-height: 32px;
    padding: 5px 9px;
}

.button.danger {
    border-color: #f3b8b3;
    color: var(--danger);
}

.alert {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.alert.success {
    background: #e6f4ef;
    color: #115e4d;
}

.alert.error {
    background: #fff1f0;
    color: var(--danger);
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
}

.badge.ok {
    background: #e6f4ef;
    color: #115e4d;
}

.badge.warn {
    background: #fff8e1;
    color: var(--warning);
}

.badge.danger {
    background: #fff1f0;
    color: var(--danger);
}

.badge.neutral {
    background: #edf2f7;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

td.actions {
    min-width: 150px;
}

td.actions form {
    display: inline-flex;
}

td form {
    margin: 0;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.form {
    display: grid;
    gap: 14px;
}

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

.form label {
    display: grid;
    gap: 7px;
}

.form label.wide,
.form-actions.wide {
    grid-column: 1 / -1;
}

.form-actions {
    justify-content: flex-end;
}

.wide-card {
    max-width: 680px;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input[type="checkbox"] {
    height: 22px;
    min-height: 22px;
    width: 22px;
}

.toolbar {
    flex-wrap: wrap;
    margin-bottom: 14px;
    max-width: 980px;
}

.toolbar.wide-toolbar {
    max-width: 1180px;
}

.toolbar select {
    min-width: 150px;
    width: auto;
}

.file-preview {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 10px 12px;
}

.file-preview a {
    color: var(--primary);
    font-weight: 700;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-card {
    max-width: 430px;
    padding: 24px;
    width: 100%;
}

.wide-card {
    max-width: 680px;
}

.setup-note {
    color: var(--muted);
    line-height: 1.6;
}

code {
    background: #edf2f7;
    border-radius: 6px;
    padding: 2px 5px;
}

.payload {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    margin: 0;
    max-height: 180px;
    overflow: auto;
    padding: 8px;
    white-space: pre-wrap;
}

@media print {
    .sidebar,
    .topbar,
    .button,
    .toolbar,
    .report-actions {
        display: none !important;
    }

    .shell {
        display: block;
    }

    .main {
        padding: 0;
    }

    .panel {
        border: 0;
        box-shadow: none;
        margin: 0;
        padding: 0;
    }

    body {
        background: #fff;
    }

    th,
    td {
        border-color: #222;
        font-size: 11px;
        padding: 6px;
    }
}

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

    .sidebar {
        position: static;
    }

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

    .metric-grid,
    .module-grid,
    .report-grid,
    .report-meta,
    .signature-grid,
    .grid-form {
        grid-template-columns: 1fr;
    }

    .topbar,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
