:root {
    --ink: #172033;
    --muted: #687386;
    --line: #dce2ea;
    --panel: #ffffff;
    --canvas: #f2f5f9;
    --navy: #153a75;
    --blue: #245fb3;
    --blue-soft: #e8f0fb;
    --green: #1f7a55;
    --red: #b63838;
    --shadow: 0 18px 45px rgba(35, 52, 78, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header {
    height: 74px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    letter-spacing: -.5px;
    background: linear-gradient(145deg, #153a75, #2e72c7);
    box-shadow: 0 8px 18px rgba(21, 58, 117, .24);
}
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.auth-user-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
    color: var(--ink);
    font-size: 12px;
    line-height: 1.15;
    white-space: nowrap;
}
.auth-user-badge strong { font-size: 13px; }
.auth-user-badge span { color: var(--blue); font-weight: 800; }
.save-state { color: var(--muted); font-size: 12px; margin-right: 8px; }

main { width: min(1480px, calc(100% - 44px)); margin: 0 auto; padding: 30px 0 50px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.hero h1 { font-size: clamp(30px, 4vw, 45px); margin: 2px 0 4px; letter-spacing: -1.7px; }
.eyebrow { color: var(--blue); letter-spacing: 1.5px; font-size: 11px; font-weight: 800; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; }
.stats article { min-width: 155px; padding: 15px 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.stats span { display: block; color: var(--muted); font-size: 11px; }
.stats strong { display: block; font-size: 21px; margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.toolbar { padding: 16px; display: flex; gap: 10px; border-bottom: 1px solid var(--line); }
.toolbar select { min-width: 150px; }
.search-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    background: #fff;
}
.search-field span { font-size: 22px; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; height: 40px; }
input, select {
    border: 1px solid #cbd4e0;
    border-radius: 9px;
    padding: 9px 10px;
    color: var(--ink);
    background: #fff;
}
input:focus, select:focus { outline: 3px solid rgba(36, 95, 179, .14); border-color: var(--blue); }

.button {
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 9px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    font-weight: 650;
}
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 6px 15px rgba(36, 95, 179, .22); }
.button.primary:hover { background: #1d519b; }
.button.ghost { color: var(--navy); background: #fff; border-color: var(--line); }
.button.ghost:hover { background: #f7f9fc; border-color: #bdc9d8; }
.button.ghost.active-view { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.button.danger { color: var(--red); background: #fff; border-color: #e6bcbc; }
.button.danger:hover { background: #fff4f4; }

.global-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    place-items: center;
    padding: 20px;
    background: rgba(17, 30, 50, .42);
    cursor: wait;
}
.global-loading-overlay[open] { display: grid; }
.global-loading-overlay:not([open]) { display: none; }
.global-loading-overlay::backdrop { background: transparent; }
.global-loading-card {
    display: grid;
    justify-items: center;
    gap: 10px;
    min-width: min(300px, calc(100vw - 40px));
    padding: 26px 30px;
    border-radius: 16px;
    background: #fff;
    color: var(--navy);
    box-shadow: 0 24px 64px rgba(17, 30, 50, .3);
}
.global-loading-card strong { font-size: 18px; }
.global-loading-card span:last-child { color: var(--muted); }
.global-loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #dce8f7;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: global-loading-spin .75s linear infinite;
}
@keyframes global-loading-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .global-loading-spinner { animation-duration: 1.5s; }
}

.auth-overlay {
    min-height: calc(100vh - 74px);
    display: grid;
    place-items: center;
    padding: 34px 18px;
}
.auth-overlay[hidden] { display: none !important; }
.auth-card {
    width: min(440px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.auth-card h1 { margin: 2px 0 6px; font-size: 34px; letter-spacing: -1px; }
.auth-card label {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: #536074;
    font-weight: 750;
}
.auth-card input { height: 46px; font-size: 17px; }
.auth-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.auth-actions { display: flex; gap: 10px; margin-top: 18px; }
.auth-actions .button { flex: 1; }
.auth-wide-button { width: 100%; margin-top: 10px; }
.auth-error {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px solid #f0b9b9;
    border-radius: 10px;
    color: var(--red);
    background: #fff1f1;
    font-weight: 700;
}
body.auth-required .header-actions > :not(#logoutButton) {
    display: none !important;
}

.password-dialog {
    border: 0;
    border-radius: 20px;
    padding: 0;
    width: min(440px, calc(100vw - 28px));
    box-shadow: var(--shadow);
}
.password-dialog::backdrop { background: rgba(17, 30, 50, .32); }
.password-card { padding: 24px; }
.password-card h3 { margin: 0 0 8px; font-size: 25px; }
.password-card label {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    color: #536074;
    font-weight: 750;
}
.password-card input { height: 44px; font-size: 16px; }
.user-admin-dialog { width: min(980px, calc(100vw - 28px)); }
.user-admin-card { max-height: min(78vh, 720px); overflow: auto; }
.user-admin-rows {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}
.user-admin-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.user-admin-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.45fr 145px 1fr 150px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfe;
}
.user-admin-row label {
    display: grid;
    gap: 4px;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}
.user-admin-row input,
.user-admin-row select { width: 100%; min-width: 0; }
.user-admin-row .button { align-self: end; height: 42px; }
.user-admin-actions {
    display: grid;
    gap: 8px;
    align-self: end;
}
.user-admin-actions .button { width: 100%; }
.user-admin-meta {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    padding-left: 2px;
}

.table-wrap { overflow: auto; max-height: calc(100vh - 310px); min-height: 420px; }
table { width: 100%; border-collapse: collapse; }
.data-table thead { position: sticky; top: 0; background: #f8fafc; z-index: 1; }
th { color: #536074; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; text-align: left; }
th, td { padding: 11px 13px; border-bottom: 1px solid #e8edf3; }
.data-table tbody tr { cursor: pointer; transition: background .12s; }
.data-table tbody tr:hover { background: #f1f6fd; }
.data-table td:first-child { font-weight: 800; color: var(--navy); }
.data-table td:nth-child(4) { min-width: 250px; }
.row-action { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 18px; }
.badge { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.badge.locked { color: #176b4d; background: #e5f6ef; }
.badge.open { color: #785d1d; background: #fff4d6; }
.empty { text-align: center; color: var(--muted); padding: 70px 20px !important; }
.result-count { padding: 10px 16px; color: var(--muted); font-size: 12px; background: #fbfcfe; }

.evaluation-toolbar {
    align-items: end;
    flex-wrap: wrap;
}
.evaluation-context {
    display: inline-flex;
    margin: 5px 0 0;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 850;
}
.evaluation-report-type {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 6px;
    padding: 7px 11px;
    border: 1px solid #bfd3ea;
    border-radius: 8px;
    background: #f5f9ff;
    color: var(--navy);
    font-weight: 800;
}
.evaluation-report-type span {
    color: var(--muted);
    font-weight: 700;
}
.evaluation-driver-hint {
    display: grid;
    gap: 8px;
    margin: 0 16px 8px;
    padding: 8px 12px;
    border: 1px solid #bfd3ea;
    border-radius: 8px;
    background: #f5f9ff;
    color: var(--ink);
    font-size: 13px;
}
.evaluation-driver-hint[hidden] { display: none; }
.driver-hint-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.evaluation-driver-hint strong { color: var(--navy); }
.evaluation-driver-hint span { color: var(--muted); }
.driver-hint-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.driver-hint-choices button {
    padding: 5px 9px;
    border: 1px solid #bfd3ea;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    font-weight: 750;
    cursor: pointer;
}
.driver-hint-choices button:hover,
.driver-hint-choices button.active {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}
.driver-hint-choices button mark {
    background: #ffe45c;
    color: #111;
}
.driver-hint-choices button small {
    margin-left: 6px;
    color: inherit;
    opacity: .75;
    font-weight: 650;
}
.evaluation-toolbar > label:not(.search-field):not(.checkbox) {
    display: grid;
    gap: 5px;
    min-width: 135px;
    color: #536074;
    font-size: 11px;
    font-weight: 800;
}
.evaluation-toolbar input,
.evaluation-toolbar select { min-height: 40px; }
.evaluation-search {
    min-width: 320px;
    flex: 1 1 320px;
}
.evaluation-checkbox {
    padding-top: 0;
    min-height: 40px;
    align-items: center;
}
.evaluation-bus-options {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}
.evaluation-bus-options .evaluation-checkbox {
    min-height: 40px;
    white-space: nowrap;
}
.evaluation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 16px;
}
.evaluation-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    background: #fff;
}
.evaluation-card.wide { grid-column: 1 / -1; }
.evaluation-card h3 {
    margin: 0;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
    font-size: 15px;
}
.evaluation-table-wrap {
    overflow: auto;
    max-height: 360px;
}
.data-table.compact th,
.data-table.compact td {
    padding: 8px 10px;
    vertical-align: top;
}
.data-table.compact td:first-child { color: var(--ink); }
.data-table.compact tbody tr[data-id] { cursor: pointer; }
.evaluation-transports-table {
    min-width: 1120px;
}
.evaluation-transports-table th,
.evaluation-transports-table td {
    white-space: nowrap;
}
.evaluation-transports-table th:nth-child(3),
.evaluation-transports-table td:nth-child(3) {
    min-width: 260px;
    white-space: normal;
}
.evaluation-transports-table th:nth-child(4),
.evaluation-transports-table td:nth-child(4) {
    min-width: 120px;
}
.evaluation-transports-table th:nth-child(5),
.evaluation-transports-table td:nth-child(5) {
    min-width: 190px;
    white-space: normal;
}
.evaluation-transports-table th:nth-child(7),
.evaluation-transports-table td:nth-child(7),
.evaluation-transports-table th:nth-child(8),
.evaluation-transports-table td:nth-child(8),
.evaluation-transports-table .number-cell {
    min-width: 135px;
    text-align: right;
    white-space: nowrap;
}
.data-table mark {
    padding: 0 2px;
    border-radius: 3px;
    background: #ffe45c;
    color: #111;
    font-weight: 850;
}

dialog {
    width: min(1180px, calc(100vw - 30px));
    max-height: calc(100vh - 28px);
    padding: 0;
    border: 0;
    border-radius: 18px;
    color: var(--ink);
    box-shadow: 0 28px 85px rgba(17, 30, 49, .32);
}
dialog::backdrop { background: rgba(19, 31, 49, .58); backdrop-filter: blur(3px); }
#editorForm, #addressForm { max-height: calc(100vh - 28px); overflow: auto; }
.dialog-header, .dialog-footer {
    position: sticky;
    background: #fff;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}
.dialog-header { top: 0; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 2px 0 0; font-size: 25px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0f3f7; cursor: pointer; font-size: 25px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 21px 24px; }
.form-grid label { position: relative; color: #536074; font-size: 11px; font-weight: 700; }
.form-grid input, .form-grid select { display: block; width: 100%; margin-top: 5px; color: var(--ink); font-weight: 400; }
.unit-field { position: relative; display: block; }
.unit-field input { padding-right: 34px; }
.unit-field span { position: absolute; right: 10px; top: calc(50% + 2px); transform: translateY(-50%); color: var(--muted); font-size: 12px; font-weight: 800; pointer-events: none; }
.form-grid select[size]:not([size="1"]),
.cargo-table select[size]:not([size="1"]) { height: auto; max-height: 230px; background: #fff; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .row-span-2 { grid-row: span 2; }
.protected-editor input:disabled,
.protected-editor select:disabled,
.protected-editor textarea:disabled,
.protected-editor button:disabled {
    opacity: .68;
    cursor: not-allowed;
    background: #eef2f7;
}
.protected-editor #fieldProtected {
    opacity: 1;
    cursor: pointer;
}
.checkbox { display: flex !important; align-items: center; gap: 8px; padding-top: 25px; }
.checkbox input { width: 17px; height: 17px; margin: 0; }
.seal-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding-top: 25px; min-width: 0; }
.seal-controls .checkbox { padding-top: 0; white-space: nowrap; }
.seal-controls .seal-number-label { color: #536074; font-size: 11px; font-weight: 700; }
.inline-seal-number { display: flex !important; align-items: center; gap: 8px; margin-top: -5px; white-space: nowrap; }
.inline-seal-number input { width: 120px !important; margin-top: 0 !important; }
.cargo-condition-controls { display: flex; align-items: center; gap: 10px; padding-top: 25px; min-width: 0; }
.cargo-condition-controls > span { color: var(--muted); font-weight: 800; white-space: nowrap; }
.cargo-condition-controls .checkbox { padding-top: 0; white-space: nowrap; }
.section-actions .cargo-condition-controls { padding-top: 0; margin-right: 8px; }

.cargo-section { margin: 0 24px 20px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.section-title { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.section-title h3 { margin: 2px 0 0; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.cargo-table-wrap { overflow: auto; }
.cargo-table { width: 100%; min-width: 1120px; table-layout: fixed; }
.cargo-table input, .cargo-table select { width: 100%; min-width: 0; padding: 7px; }
.cargo-table th:first-child,
.cargo-table td.cargo-position {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    text-align: center;
    font-weight: 800;
    color: var(--blue);
}
.cargo-table th:nth-child(2) { width: 32%; }
.cargo-table th:nth-child(3) { width: 102px; }
.cargo-table th:nth-child(4) { width: 86px; }
.cargo-table th:nth-child(5) { width: 92px; }
.cargo-table th:nth-child(6),
.cargo-table th:nth-child(7),
.cargo-table th:nth-child(8) { width: 112px; }
.cargo-table th:nth-child(9),
.cargo-table td:nth-child(9) { width: 104px; min-width: 104px; max-width: 104px; }
.cargo-table th:nth-child(9),
.cargo-table td:nth-child(9) {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -8px 0 12px rgba(15, 23, 42, .08);
}
.cargo-table tr.pending-cargo-row td:nth-child(9) { background: #ffe6e6; }
.cargo-table .cargo-condition { min-width: 0; }
.cargo-table .cargo-unit { min-width: 0; white-space: nowrap; color: var(--muted); font-weight: 700; }
.cargo-table tr.pending-cargo-row td { background: #ffe6e6; }
.cargo-table tr.pending-cargo-row input,
.cargo-table tr.pending-cargo-row select { border-color: #d92d20; background: #fff5f5; }
.address-form-grid .checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d6e0ec;
    border-radius: 12px;
    background: #f8fbff;
    color: var(--ink);
    font-size: 14px;
}
.address-form-grid .checkbox input { width: 22px; height: 22px; margin: 0; }
.address-form-grid .checkbox.pending-approval {
    border-color: #d92d20;
    background: #fff1f1;
    color: #9f1d17;
}
.employee-signature-editor {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 220px auto;
    gap: 12px;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: #f8fafc;
}
.employee-signature-preview {
    height: 58px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    color: var(--muted);
    font-weight: 700;
}
.employee-signature-preview img {
    max-width: 100%;
    max-height: 46px;
    object-fit: contain;
}
.cargo-goods-picker { display: grid; gap: 5px; min-width: 300px; }
.cargo-goods-picker { position: relative; }
.cargo-goods-search { border-color: #9db7d7 !important; background: #f7fbff; }
.cargo-recalc-prompt {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    z-index: 10020;
    width: min(360px, 90vw);
    padding: 10px;
    border: 1px solid #f2b84b;
    border-radius: 11px;
    background: #fff8e6;
    box-shadow: 0 12px 28px #1b2b441f;
    color: #25364d;
    font-size: 13px;
    font-weight: 800;
}
.cargo-recalc-prompt div {
    display: flex;
    gap: 7px;
    margin-top: 8px;
}
.cargo-recalc-prompt button {
    border: 1px solid #d7a33c;
    border-radius: 8px;
    background: #fff;
    color: #173d70;
    cursor: pointer;
    font-weight: 800;
    padding: 6px 9px;
}
.cargo-recalc-prompt .cargo-recalc-yes {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.search-matches {
    position: fixed;
    z-index: 10000;
    max-height: 430px;
    overflow: auto;
    border: 1px solid #91a9c7;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 9px 24px rgba(19, 41, 70, .22);
}
.search-matches button {
    display: block;
    width: 100%;
    min-height: 36px;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    background: #fff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.search-matches button:hover { background: #eef5ff; }
.search-matches button strong,
.search-matches button small { display: block; }
.search-matches button small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.search-matches mark {
    padding: 0 1px;
    border-radius: 2px;
    background: #ffe45c;
    color: #111;
    font-weight: 800;
}
.cargo-actions { display: flex; align-items: center; justify-content: center; gap: 5px; width: 96px; }
.review-cargo { border: 1px solid #d92d20; color: #b42318; background: #fff7f7; border-radius: 7px; height: 31px; width: 58px; padding: 0 4px; cursor: pointer; font-weight: 700; font-size: 12px; }
.remove-cargo { border: 0; color: var(--red); background: #fff0f0; border-radius: 7px; width: 29px; height: 31px; cursor: pointer; }
.functions-section { margin: 0 24px 20px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.function-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 9px; padding: 12px; background: #fff; }
.function-button {
    min-height: 74px;
    padding: 9px 7px;
    border: 1px solid #d5dfeb;
    border-radius: 10px;
    background: linear-gradient(#fff, #f5f8fb);
    color: var(--ink);
    cursor: pointer;
    transition: transform .12s, border-color .12s, box-shadow .12s;
}
.function-button:hover { transform: translateY(-1px); border-color: var(--blue); box-shadow: 0 5px 14px rgba(25, 64, 112, .12); }
.function-button b { display: block; color: var(--blue); font-size: 16px; margin-bottom: 5px; }
.function-button span { display: block; font-size: 10px; font-weight: 700; line-height: 1.2; }
.seal-checkbox { color: #1f5fb8; }
.seal-number-label input { max-width: 140px; }
.dialog-footer { bottom: 0; gap: 15px; padding: 15px 24px; border-top: 1px solid var(--line); }
.dialog-footer > div { display: flex; gap: 8px; }

.master-data-dialog { width: min(1280px, calc(100vw - 30px)); }
.master-data-tabs {
    position: sticky;
    top: 78px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}
.master-data-tabs button {
    padding: 7px 11px;
    border: 1px solid #d5dfeb;
    border-radius: 8px;
    background: #f6f8fb;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
}
.master-data-tabs button.active { border-color: var(--blue); background: #eaf3ff; color: var(--blue); }
.master-data-layout { display: grid; grid-template-columns: minmax(270px, 30%) 1fr; min-height: 620px; }
.address-browser { padding: 18px; border-right: 1px solid var(--line); background: #f7f9fc; }
.address-browser > input { width: 100%; margin-bottom: 12px; }
.address-registry-list { display: grid; gap: 6px; max-height: calc(100vh - 220px); overflow: auto; }
.address-registry-list button {
    padding: 10px 11px;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.address-registry-list button:hover,
.address-registry-list button.active { border-color: var(--blue); background: #edf5ff; }
.address-registry-list button strong,
.address-registry-list button span { display: block; }
.address-registry-list button span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.address-editor { padding: 20px 22px; }
.address-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.address-form-grid--two-columns { grid-auto-flow: row; }
.address-form-grid--two-columns .address-col-de { grid-column: 1; }
.address-form-grid--two-columns .address-col-ru { grid-column: 2; }
.address-form-grid--two-columns .address-row-1 { grid-row: 1; }
.address-form-grid--two-columns .address-row-2 { grid-row: 2; }
.address-form-grid--two-columns .address-row-3 { grid-row: 3; }
.address-form-grid--two-columns .address-row-4 { grid-row: 4; }
.address-form-grid--two-columns .address-row-5 { grid-row: 5; }
.address-form-grid--two-columns .address-row-6 { grid-row: 6; }
.address-form-grid--two-columns .address-row-7 { grid-row: 7; }
.address-form-grid--two-columns .address-row-8 { grid-row: 8; }
.address-form-grid label { color: #536074; font-size: 11px; font-weight: 700; }
.address-form-grid input,
.address-form-grid select,
.address-form-grid textarea { display: block; width: 100%; margin-top: 5px; color: var(--ink); font-weight: 400; }
.address-form-grid textarea { resize: vertical; }
.address-form-grid .span-2 { grid-column: span 2; }
.driver-editor-note { margin: 0; color: var(--muted); font-size: 12px; }
.goods-live-matches {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid #bfd3ea;
    border-radius: 8px;
    background: #f5f9ff;
}
.goods-live-matches[hidden] { display: none; }
.goods-live-matches > strong {
    color: var(--navy);
    font-size: 12px;
}
.goods-live-matches p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}
.goods-live-matches button {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid #d8e4f1;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.goods-live-matches button:hover { border-color: var(--blue); background: #edf5ff; }
.goods-live-matches button span { font-weight: 800; }
.goods-live-matches button small { color: var(--muted); }

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483647;
    max-width: 390px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #fff;
    background: #20344f;
    box-shadow: var(--shadow);
    transform: translateY(30px);
    opacity: 0;
    pointer-events: none;
    transition: .2s;
}
.toast[popover] {
    inset: auto 24px 24px auto;
    width: auto;
    height: auto;
    margin: 0;
    border: 0;
    overflow: visible;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #963636; }

.document-report-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 34vh;
    background: rgba(17, 30, 50, .22);
}
.document-report-overlay[hidden] { display: none; }
.document-report-card {
    width: min(560px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 18px 20px;
    border: 1px solid #cfe2d7;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(20, 34, 58, .28);
}
.document-report-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: #1f8a4c;
    font-size: 24px;
    font-weight: 900;
}
.document-report-body h3 {
    margin: 0 0 6px;
    color: var(--ink);
    font-size: 19px;
}
.document-report-body p {
    margin: 0;
    padding: 7px 9px;
    border-radius: 8px;
    color: #29405f;
    background: #f4f8fc;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.document-report-overlay--error .document-report-card {
    border-color: #f0b7b7;
}
.document-report-overlay--error .document-report-icon {
    background: #b32626;
}
.document-report-overlay--error .document-report-body p {
    color: #842020;
    background: #fff1f1;
}

.share-dialog {
    border: 0;
    border-radius: 18px;
    padding: 0;
    width: min(620px, calc(100vw - 28px));
    box-shadow: var(--shadow);
}
.share-dialog::backdrop { background: rgba(17, 30, 50, .32); }
.share-dialog-card { padding: 22px; }
.share-dialog-card h3 { margin: 0 0 12px; font-size: 22px; }
.share-dialog-card textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    font: 16px/1.45 "Segoe UI", Arial, sans-serif;
}
.share-error-text {
    color: #b42318 !important;
    font-weight: 800;
    background: #fff1f0;
    border: 1px solid #ffb4ab;
    border-radius: 10px;
    padding: 10px 12px;
}
.share-ok-text {
    color: #185c37 !important;
    font-weight: 700;
    background: #edfdf3;
    border: 1px solid #9bd8b4;
    border-radius: 10px;
    padding: 10px 12px;
}
.share-file-links {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
}
.share-file-link-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.share-file-link-grid .button {
    font-size: 14px;
    padding: 9px 12px;
}
.share-file-link {
    align-items: flex-start;
    flex-direction: column;
    max-width: 100%;
    text-align: left;
}
.share-file-link small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-network-path {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.share-network-path code {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    font-size: 13px;
}
.share-dialog-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 14px;
}

.archive-dialog {
    width: min(1000px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    border: 0;
    border-radius: 18px;
    padding: 0;
    box-shadow: 0 28px 70px rgba(20, 34, 58, .32);
}
.archive-dialog::backdrop { background: rgba(17, 30, 50, .35); }
.archive-card { padding: 22px; }
.archive-header, .archive-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.archive-header h2 { margin: 2px 0; }
.archive-toolbar {
    justify-content: flex-start;
    margin: 18px 0 12px;
}
.archive-entries {
    display: grid;
    gap: 8px;
    max-height: 65vh;
    overflow: auto;
}
.archive-entry {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    color: var(--ink);
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-align: left;
}
.archive-folder {
    grid-template-columns: auto minmax(0, 1fr);
}
.archive-folder:hover { border-color: var(--primary); background: #eef6ff; }
.archive-folder-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.archive-select-entry {
    width: 18px;
    height: 18px;
    margin: 0;
}
.archive-icon { font-size: 24px; }
.archive-file small { display: block; margin-top: 3px; color: var(--muted); }
.archive-file .button {
    width: max-content;
    justify-self: start;
}
.archive-drop-zone {
    margin: 0 0 12px;
    padding: 18px;
    border: 2px dashed var(--line);
    border-radius: 12px;
    background: #f8fbff;
    color: var(--muted);
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
}
.archive-drop-zone.drag-over {
    border-color: var(--primary);
    background: #eaf4ff;
    color: var(--primary);
}

@media (max-width: 640px) {
    .archive-file { grid-template-columns: auto auto minmax(0, 1fr); }
    .archive-file .button { grid-column: 3; justify-self: start; }
}

.pdf-package-dialog {
    width: min(860px, calc(100vw - 32px));
    overflow: visible;
}
.pdf-package-print-dialog {
    width: min(820px, calc(100vw - 32px));
}
.pdf-package-choice-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 18px;
}
.pdf-package-choice-actions .button {
    min-height: 52px;
    white-space: normal;
}
.pdf-package-check {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
}
.pdf-package-warnings {
    margin: 12px 0 4px;
    padding: 12px 14px;
    border: 1px solid #f0c36a;
    border-radius: 12px;
    background: #fff8e6;
    color: #7a4b00;
    font-size: 14px;
    line-height: 1.45;
}
.pdf-package-warnings strong {
    display: block;
    margin-bottom: 6px;
    color: #5f3a00;
}
.pdf-package-print-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    max-height: 55vh;
    overflow: auto;
}
.pdf-package-print-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto 150px;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
}
.pdf-package-print-row a {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}
.pdf-package-copy-count {
    display: grid;
    grid-template-columns: 1fr 64px;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}
.pdf-package-copy-count input {
    width: 64px;
    padding: 7px 8px;
    text-align: center;
}

.versandpapiere-dialog {
    width: min(520px, calc(100vw - 32px));
}
.versandpapiere-dialog .share-dialog-card {
    padding: 16px;
}
.versandpapiere-dialog .share-dialog-card h3 {
    margin-bottom: 6px;
    font-size: 20px;
}
.versandpapiere-dialog .muted {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.35;
}
.versandpapiere-dialog .pdf-package-print-list {
    gap: 6px;
    margin-top: 8px;
    max-height: none;
}
.versandpapiere-dialog .pdf-package-check {
    min-height: 38px;
    margin: 0;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 14px;
}
.versandpapiere-dialog .pdf-package-check input {
    width: 18px;
    height: 18px;
}
.versandpapiere-dialog .share-dialog-actions {
    gap: 7px;
    margin-top: 12px;
}
.versandpapiere-dialog .share-dialog-actions .button {
    min-height: 38px;
    padding: 8px 13px;
    font-size: 14px;
}

.mautbefreiung-dialog {
    width: min(500px, calc(100vw - 32px));
}
.mautbefreiung-dialog .share-dialog-card {
    padding: 16px;
}
.mautbefreiung-dialog .share-dialog-card h3 {
    margin-bottom: 5px;
    font-size: 20px;
}
.mautbefreiung-dialog .muted {
    margin: 0 0 9px;
    font-size: 13px;
    line-height: 1.25;
}
.mautbefreiung-dialog .pdf-package-print-list {
    gap: 5px;
    margin-top: 8px;
    max-height: none;
}
.mautbefreiung-dialog .pdf-package-check {
    min-height: 34px;
    margin: 0;
    padding: 6px 9px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.15;
}
.mautbefreiung-dialog .pdf-package-check input {
    width: 17px;
    height: 17px;
}
.mautbefreiung-dialog .share-dialog-actions {
    gap: 7px;
    margin-top: 10px;
}
.mautbefreiung-dialog .share-dialog-actions .button {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 14px;
}

.backup-dialog {
    width: min(420px, calc(100vw - 32px));
    border: 0;
    border-radius: 18px;
    padding: 0;
    box-shadow: 0 24px 60px rgba(20, 34, 58, .25);
}
.backup-dialog::backdrop { background: rgba(17, 30, 50, .28); }
.backup-dialog-card { padding: 22px; }
.backup-dialog-card h3 {
    margin: 0 0 18px;
    font-size: 22px;
    color: var(--ink);
}
.backup-dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.app-confirm-dialog {
    width: min(440px, calc(100vw - 32px));
    border: 0;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 28px 70px rgba(20, 34, 58, .32);
    z-index: 99999;
}
.app-confirm-dialog::backdrop { background: rgba(17, 30, 50, .35); }
.app-confirm-dialog form { padding: 24px; }
.app-confirm-dialog h3 {
    margin: 0 0 12px;
    font-size: 24px;
    color: var(--ink);
}
.app-confirm-dialog p {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.45;
    white-space: pre-line;
}
.app-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 22px;
}

@media (max-width: 980px) {
    .hero { align-items: stretch; flex-direction: column; }
    .stats { grid-template-columns: repeat(3, 1fr); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .function-grid { grid-template-columns: repeat(4, 1fr); }
    .toolbar { flex-wrap: wrap; }
    .search-field { flex-basis: 100%; }
    .master-data-layout { grid-template-columns: 1fr; }
    .evaluation-grid { grid-template-columns: 1fr; }
    .address-browser { border-right: 0; border-bottom: 1px solid var(--line); }
    .address-registry-list { max-height: 220px; }
}
@media (max-width: 640px) {
    .app-header { height: auto; padding: 12px 15px; align-items: flex-start; }
    .brand span, .save-state, .header-actions .ghost { display: none; }
    .header-actions #archiveButton { display: inline-flex; }
    main { width: calc(100% - 20px); padding-top: 20px; }
    .stats { grid-template-columns: 1fr; }
    .stats article { min-width: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .form-grid .span-3 { grid-column: auto; }
    .seal-controls { flex-wrap: wrap; }
    .function-grid { grid-template-columns: repeat(2, 1fr); }
    .dialog-footer { align-items: stretch; flex-direction: column; }
    .dialog-footer > div { justify-content: flex-end; flex-wrap: wrap; }
    .address-form-grid { grid-template-columns: 1fr; }
    .address-form-grid .span-2 { grid-column: auto; }
    .address-form-grid--two-columns .address-col-de,
    .address-form-grid--two-columns .address-col-ru { grid-column: auto; }
    .address-form-grid--two-columns .address-row-1,
    .address-form-grid--two-columns .address-row-2,
    .address-form-grid--two-columns .address-row-3,
    .address-form-grid--two-columns .address-row-4,
    .address-form-grid--two-columns .address-row-5,
    .address-form-grid--two-columns .address-row-6,
    .address-form-grid--two-columns .address-row-7,
    .address-form-grid--two-columns .address-row-8 { grid-row: auto; }
}

@media print {
    .app-header,
    #listView,
    .evaluation-toolbar,
    .evaluation-driver-hint,
    .result-count,
    .toast { display: none !important; }
    body { background: #fff; }
    main { width: 100%; padding: 0; }
    .panel,
    .evaluation-card {
        box-shadow: none;
        border-color: #777;
        break-inside: avoid;
    }
    .evaluation-grid { grid-template-columns: 1fr; padding: 0; gap: 10px; }
    .evaluation-table-wrap { max-height: none; overflow: visible; }
}
