:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --line: #d9e1e6;
    --text: #162026;
    --muted: #68747d;
    --primary: #0f6d5f;
    --primary-dark: #0a5147;
    --danger: #b42318;
    --warning: #9a6700;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
}

.topbar {
    align-items: center;
    background: #102027;
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
}

.topbar strong {
    display: block;
    font-size: 16px;
}

.topbar span {
    color: #b8c6cc;
    font-size: 12px;
}

.topbar nav {
    display: flex;
    gap: 8px;
}

.topbar nav a {
    border-radius: 6px;
    color: #eaf1f3;
    padding: 8px 10px;
    text-decoration: none;
}

.topbar nav a:hover {
    background: rgba(255, 255, 255, 0.09);
}

.page {
    margin: 0 auto;
    max-width: 1220px;
    padding: 24px;
}

.page-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
}

h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

.panel,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(18, 34, 43, 0.04);
}

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

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

.stat-card {
    padding: 18px;
}

.stat-card span,
.detail-grid span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}

.stat-card strong {
    font-size: 30px;
}

.button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    min-height: 36px;
    padding: 7px 12px;
    text-decoration: none;
}

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

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

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

.button.small {
    min-height: 30px;
    padding: 4px 9px;
}

.button.icon {
    justify-content: center;
    min-width: 34px;
    padding: 0;
}

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

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

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

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

.badge {
    background: #edf7f5;
    border: 1px solid #cfe8e2;
    border-radius: 999px;
    color: #0f6d5f;
    display: inline-block;
    padding: 3px 8px;
}

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

label,
.block-label {
    color: var(--muted);
    display: grid;
    font-size: 12px;
    gap: 5px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

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

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

.check {
    align-items: center;
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding-top: 22px;
}

.check input {
    min-height: auto;
    width: auto;
}

.collapsible,
.invoice-lines {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 14px;
}

.invoice-lines h2 {
    font-size: 18px;
    margin: 0 0 12px;
}

.collapsible summary {
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 12px;
}

.line-list {
    display: grid;
    gap: 10px;
}

.line-row {
    align-items: end;
    background: #f9fbfb;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    gap: 10px;
    grid-template-columns: 110px minmax(180px, 1fr) 90px 80px 110px 100px 80px minmax(160px, 1fr) 34px;
    padding: 12px;
}

.actions,
.actions-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.actions-row {
    justify-content: flex-start;
}

.detail-grid div {
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.detail-grid strong {
    font-size: 15px;
    overflow-wrap: anywhere;
}

.alert {
    border-radius: var(--radius);
    margin-bottom: 14px;
    padding: 12px 14px;
}

.alert-success {
    background: #eaf7ee;
    border: 1px solid #bedfc7;
}

.alert-error {
    background: #fff0ef;
    border: 1px solid #efc6c1;
    color: var(--danger);
}

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

.error-text strong {
    color: var(--danger);
}

@media (max-width: 900px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 14px 18px;
    }

    .topbar nav {
        flex-wrap: wrap;
    }

    .page {
        padding: 16px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

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

    .line-row {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
