:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #17212b;
    --muted: #687481;
    --line: #d9e2ec;
    --accent: #0f6b8f;
    --accent-dark: #0a4c66;
    --danger: #b42318;
    --danger-bg: #ffe8e6;
    --success-bg: #e7f7ed;
    --success: #126b37;
}

* {
    box-sizing: border-box;
}

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

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 8px 28px rgba(23, 33, 43, 0.08);
}

.title-row,
.table-title-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.table-actions {
    display: flex;
    align-items: end;
    gap: 12px;
}

.filter-form {
    min-width: 240px;
}

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

h1 {
    font-size: 30px;
}

h2 {
    font-size: 18px;
}

p {
    margin: 7px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 11px;
    border-radius: 6px;
    background: #e8f4f8;
    color: var(--accent-dark);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.alert {
    padding: 12px 14px;
    border-radius: 7px;
    margin-bottom: 16px;
    font-weight: 700;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.party-form {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    margin-bottom: 16px;
}

.inline-add {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
}

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

.top-grid {
    grid-template-columns: 2fr 1fr 1fr;
}

.range-grid {
    grid-template-columns: 1fr 1fr 1fr;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    font-size: 14px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #c9d5df;
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
    background: white;
    color: var(--ink);
}

input:focus,
select:focus {
    outline: 2px solid rgba(15, 107, 143, 0.18);
    border-color: var(--accent);
}

.conditional {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fbfdff;
}

.hidden {
    display: none;
}

.hint {
    font-size: 13px;
}

.actions {
    margin-top: 18px;
}

button {
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    min-height: 42px;
    padding: 9px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

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

button.secondary {
    background: #eef3f7;
    color: var(--accent-dark);
}

button.secondary:hover {
    background: #dfeaf1;
}

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

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

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

th {
    background: #12324a;
    color: white;
    font-size: 13px;
}

td {
    font-size: 14px;
}

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

.muted-detail {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    margin-top: 4px;
    max-width: 560px;
    white-space: normal;
}

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

.link-button:hover {
    background: transparent;
    text-decoration: underline;
}

@media (max-width: 760px) {
    .top-grid,
    .range-grid {
        grid-template-columns: 1fr;
    }

    .title-row,
    .table-title-row {
        display: block;
    }

    .table-actions {
        align-items: stretch;
        display: grid;
        gap: 10px;
        margin-top: 14px;
    }

    .inline-add {
        grid-template-columns: 1fr;
    }

    .badge {
        margin-top: 12px;
    }
}
