:root {
    color-scheme: light;
    --bg: #f5f7f4;
    --surface: #ffffff;
    --surface-strong: #eef4f1;
    --text: #17211f;
    --muted: #5c6965;
    --line: #d6dfdb;
    --primary: #176c62;
    --primary-strong: #0e4f48;
    --accent: #c76a2b;
    --danger: #b42318;
    --shadow: 0 14px 32px rgba(23, 33, 31, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

.app-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 24px clamp(16px, 4vw, 44px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
}

h2 {
    margin-bottom: 16px;
    font-size: 22px;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav a,
.button,
button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.nav a[aria-current="page"],
.button.primary,
button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button.secondary,
button.secondary {
    background: var(--surface-strong);
}

.button.danger,
button.danger {
    border-color: #f3b5ae;
    background: #fff4f2;
    color: var(--danger);
}

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

.panel {
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 0;
}

.panel-body {
    padding: 20px;
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

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

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

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(23, 108, 98, 0.16);
}

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

.lines-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

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

.lines-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.lines-table td.loaded-cell {
    text-align: center;
}

.check-field {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}

.check-field input {
    width: 22px;
    height: 22px;
    min-height: 0;
    accent-color: var(--primary);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.notice {
    margin-bottom: 18px;
    border: 1px solid #b7dfc7;
    border-radius: 8px;
    padding: 12px 14px;
    background: #eefaf2;
    color: #255a36;
    font-weight: 700;
}

.error-list {
    margin-bottom: 18px;
    border: 1px solid #f1b4ae;
    border-radius: 8px;
    padding: 12px 14px 12px 34px;
    background: #fff4f2;
    color: var(--danger);
}

.filters {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

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

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

.summary-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 28px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--primary-strong);
    font-weight: 700;
}

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

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

.detail-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-strong);
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-item strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

@media (max-width: 820px) {
    .app-header {
        align-items: stretch;
        flex-direction: column;
    }

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

    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .actions {
        justify-content: stretch;
    }

    .actions .button,
    .actions button,
    .filters button {
        width: 100%;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .app-header,
    .actions,
    .nav {
        display: none;
    }

    .page {
        width: 100%;
        margin: 0;
    }

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