:root {
    color-scheme: light;
    --blue: #0b3d91;
    --blue-hover: #082f70;
    --orange: #e67e22;
    --green: #1e8e3e;
    --red: #b42318;
    --text: #1a1a1a;
    --muted: #5f6875;
    --border: #c7d2e2;
    --surface: #ffffff;
    --surface-alt: #f5f7fa;
    --field: #f8fafc;
    --shadow: 0 12px 30px rgba(18, 34, 62, 0.09);
    --sidebar-width: 72px;
    --sidebar-open-width: 236px;
    --radius: 8px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --text: #f4f6f8;
    --muted: #b4bdc9;
    --border: #394454;
    --surface: #1c222b;
    --surface-alt: #11151b;
    --field: #252d38;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
        color-scheme: dark;
        --text: #f4f6f8;
        --muted: #b4bdc9;
        --border: #394454;
        --surface: #1c222b;
        --surface-alt: #11151b;
        --field: #252d38;
        --shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
    }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-alt); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--surface-alt); font-size: 15px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
.lucide { width: 18px; height: 18px; stroke-width: 2; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon-button {
    display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.icon-button:hover, .icon-button:focus-visible { border-color: var(--blue); color: var(--blue); }

.button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px;
    border: 1px solid transparent; border-radius: var(--radius); text-decoration: none; font-weight: 700;
}
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover, .button-primary:focus-visible { background: var(--blue-hover); }
.button-block { width: 100%; }

.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover, .button-secondary:focus-visible { border-color: var(--blue); color: var(--blue); }
.button-danger { background: var(--red); color: #fff; }
.button-danger-outline { border-color: var(--red); background: transparent; color: var(--red); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .45; }
.button .lucide, .module-button .lucide, .breadcrumb-row .lucide { margin-right: 8px; }
.danger-icon { color: var(--red); }

.content-section { margin-bottom: 28px; }
.section-toolbar, .detail-band, .action-row, .breadcrumb-row, .record-actions { display: flex; align-items: center; gap: 12px; }
.section-toolbar { justify-content: space-between; margin-bottom: 18px; }
.search-form { display: flex; align-items: center; gap: 10px; width: min(680px, 100%); }
.search-form > .lucide { flex: 0 0 auto; color: var(--muted); }
.search-form input { min-width: 0; flex: 1; }
.search-form > select { width: min(220px, 34vw); flex: 0 1 220px; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); color: var(--text); padding: 9px 11px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--blue) 18%, transparent); border-color: var(--blue); }

.table-wrap { position: relative; width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { background: var(--surface-alt); color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 800; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td small, .info-grid small, .weighing-summary span { display: block; margin-top: 4px; color: var(--muted); }
.primary-link { color: var(--blue); font-weight: 800; text-decoration: none; }
.primary-link:hover { text-decoration: underline; }
.actions-cell { width: 58px; text-align: right !important; }

.status-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-verified, .status-validated, .status-stored, .status-open { background: #e7f6ec; color: #166534; }
.status-to_verify, .status-draft { background: #edf2f9; color: #36536f; }
.status-submitted, .status-pending { background: #fff3dc; color: #8a4b08; }
.status-completed, .status-planned { background: #fff3dc; color: #8a4b08; }
.status-rejected, .status-blocked { background: #feeceb; color: #9b1c17; }
.status-active { background: #e7f6ec; color: #166534; }
.status-inactive { background: #edf2f9; color: #36536f; }

.breadcrumb-row { margin: -4px 0 18px; color: var(--muted); font-size: 13px; }
.breadcrumb-row a { display: inline-flex; align-items: center; color: var(--blue); text-decoration: none; }
.breadcrumb-row span + span::before, .breadcrumb-row a + span::before, .breadcrumb-row a + a::before { content: '/'; margin-right: 12px; color: var(--border); }
.detail-band { justify-content: space-between; padding: 4px 0 22px; border-bottom: 1px solid var(--border); }
.identity-block { display: flex; align-items: center; gap: 14px; min-width: 0; }
.identity-block h2 { margin: 2px 0 4px; }
.identity-block p { margin: 0; color: var(--muted); }
.identity-mark { display: grid; place-items: center; width: 52px; height: 52px; flex: 0 0 52px; border-radius: var(--radius); background: var(--blue); color: #fff; font-size: 22px; font-weight: 800; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0 0 28px; border-bottom: 1px solid var(--border); }
.info-grid > div { min-width: 0; padding: 18px 18px 18px 0; }
.info-grid span:first-child { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.info-grid strong { overflow-wrap: anywhere; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 18, 30, .62); }
.modal-dialog { position: relative; width: min(600px, 100%); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .28); }
.modal-wide { width: min(880px, 100%); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.modal-header { position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-header h2 { margin: 2px 0 0; font-size: 19px; }
.modal-body { display: grid; gap: 16px; padding: 20px; }
.modal-footer { position: sticky; bottom: 0; z-index: 2; border-top: 1px solid var(--border); background: var(--surface); justify-content: flex-end; }
.modal-footer-split { justify-content: space-between; }
.modal-open { overflow: hidden; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; font-weight: 700; }
.field > span { font-size: 13px; }
.field > small:not(.field-error) { color: var(--muted); font-weight: 400; }
.field-span-2 { grid-column: span 2; }
.field-error { color: var(--red); font-size: 12px; font-weight: 700; }
.block-error { margin-bottom: 10px; }
.check-field { display: flex; align-items: flex-start; gap: 10px; }
.check-field input { width: 18px; min-height: 18px; margin-top: 2px; }

.metric-grid-compact { margin-top: 22px; }
.weighing-record { padding: 17px 0; border-top: 1px solid var(--border); }
.weighing-summary { display: grid; grid-template-columns: 1.3fr 1fr .8fr auto; align-items: center; gap: 18px; }
.weighing-summary strong { display: block; }
.inline-warning { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0; padding: 11px; border-left: 3px solid var(--orange); background: color-mix(in srgb, var(--orange) 10%, var(--surface)); }
.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.weighing-record details { margin-top: 14px; }
.weighing-record summary { cursor: pointer; color: var(--blue); font-weight: 700; }
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.bag-grid > div { display: flex; justify-content: space-between; gap: 8px; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); }
.record-actions { justify-content: flex-end; margin-top: 14px; }
.weighing-toolbar { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.weighing-toolbar span { display: block; color: var(--muted); font-size: 12px; }
.weighing-toolbar strong { font-size: 18px; }
.bag-input-list { display: grid; gap: 8px; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.bag-input-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 40px; align-items: center; gap: 10px; }

.segmented-tabs { display: inline-flex; max-width: 100%; gap: 3px; margin-bottom: 28px; padding: 4px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.segmented-tabs a { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 13px; border-radius: 5px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 700; }
.segmented-tabs a.is-active { background: var(--blue); color: #fff; }
.segmented-tabs .lucide { width: 16px; height: 16px; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.inline-note { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 16px; padding: 11px 13px; border-left: 3px solid var(--blue); background: color-mix(in srgb, var(--blue) 8%, var(--surface)); color: var(--muted); }
.offline-status-button { position: relative; }
.offline-count {
    position: absolute; top: -5px; right: -5px; display: grid; place-items: center;
    min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid var(--surface);
    border-radius: 999px; background: var(--orange); color: #fff; font-size: 10px; font-weight: 800;
}
.offline-indicator {
    position: absolute; right: 5px; bottom: 5px; width: 8px; height: 8px;
    border: 2px solid var(--surface); border-radius: 50%; background: var(--green);
}
.offline-indicator.is-offline { background: var(--orange); }
.offline-indicator.has-conflict { background: var(--red); }
.offline-connection {
    display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: start; gap: 10px;
    padding: 13px 15px; border-left: 3px solid var(--green); background: color-mix(in srgb, var(--green) 8%, var(--surface));
}
.offline-connection.is-offline { border-left-color: var(--orange); background: color-mix(in srgb, var(--orange) 9%, var(--surface)); }
.offline-connection strong, .offline-connection span { display: block; }
.offline-connection span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.offline-operation-list { display: grid; gap: 1px; border: 1px solid var(--border); background: var(--border); }
.offline-operation-list > .empty-state { background: var(--surface); }
.offline-operation-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
    min-height: 76px; padding: 13px 15px; background: var(--surface);
}
.offline-operation-main { min-width: 0; }
.offline-operation-main strong, .offline-operation-main span, .offline-operation-main small { display: block; }
.offline-operation-main span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.offline-operation-main small { margin-top: 5px; color: var(--red); overflow-wrap: anywhere; }
.offline-operation-actions { display: flex; align-items: center; gap: 6px; }
.offline-confirm-modal { z-index: 120; }
.offline-toast {
    position: fixed; z-index: 160; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px));
    padding: 13px 15px; border-left: 3px solid var(--blue); border-radius: var(--radius);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 700;
}
.offline-toast.is-warning { border-left-color: var(--orange); }
.offline-toast.is-error { border-left-color: var(--red); }
.operation-result { margin-top: 13px; color: var(--muted); }
.operation-result strong { color: var(--text); }
.withdrawal-details { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 13px; color: var(--muted); font-size: 13px; }
.inventory-strip { display: grid; gap: 1px; border: 1px solid var(--border); background: var(--border); }
.inventory-item { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(110px, 1fr)) 44px; align-items: center; gap: 16px; padding: 14px 16px; background: var(--surface); }
.inventory-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.calculation-preview { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 15px; border-left: 3px solid var(--green); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.icon-button.success { color: var(--green); }
.icon-button.danger { color: var(--red); }

@media (max-width: 620px) {
    .offline-operation-row { grid-template-columns: minmax(0, 1fr) auto; }
    .offline-operation-row > .status-badge { grid-column: 1; justify-self: start; }
    .offline-operation-actions { grid-column: 2; grid-row: 1 / span 2; }
}
.report-filter-band { margin-bottom: 22px; padding: 16px; border: 1px solid var(--border); background: var(--surface); }
.report-filters { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto; align-items: end; gap: 12px; }
.report-metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.movement-badge { display: inline-flex; min-height: 24px; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: 12px; font-weight: 800; }
.movement-deposit { background: #e7f6ec; color: #166534; }
.movement-withdrawal { background: #fff3dc; color: #8a4b08; }
.system-backup-band { display: flex; align-items: center; justify-content: space-between; gap: 24px; border-left: 4px solid var(--blue); }
.system-backup-band h2 { margin: 3px 0 6px; }
.system-backup-band p { max-width: 720px; margin: 0; color: var(--muted); }
.data-table code { font-size: 12px; }
.hash-value { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.schema-preview { max-width: 760px; max-height: 280px; overflow: auto; padding: 12px; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); font-size: 12px; white-space: pre-wrap; }
.role-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.role-badges span { padding: 3px 7px; border: 1px solid var(--border); background: var(--surface-alt); color: var(--muted); font-size: 11px; font-weight: 700; }
.role-fieldset { margin: 0; padding: 14px; border: 1px solid var(--border); }
.role-fieldset legend { padding: 0 6px; font-size: 13px; font-weight: 800; }
.role-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.client-link-fields { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.client-link-fields[hidden] { display: none; }
.text-muted { color: var(--muted); }
.organization-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.organization-preview { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.organization-preview h2 { margin: 16px 0 6px; font-size: 20px; }
.organization-preview p { margin: 0; color: var(--muted); }
.organization-logo-preview { display: grid; place-items: center; width: 112px; height: 112px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-strong); color: var(--primary); font-size: 30px; font-weight: 800; overflow: hidden; }
.organization-logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.organization-contacts { display: grid; gap: 8px; margin-top: 18px; text-align: left; }
.organization-contacts span { display: flex; gap: 8px; align-items: center; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.organization-contacts svg { width: 16px; height: 16px; flex: 0 0 auto; }
.organization-form-section { margin-top: 0; }

@media (max-width: 760px) {
    .section-toolbar, .detail-band, .modal-footer-split { align-items: stretch; flex-direction: column; }
    .section-toolbar .button, .detail-band > .action-row { width: 100%; }
    .detail-band > .action-row { flex-wrap: wrap; }
    .search-form { display: grid; grid-template-columns: 24px minmax(0, 1fr); }
    .search-form > select { grid-column: 2; width: 100%; }
    .search-form .button { grid-column: 1 / -1; }
    .info-grid, .form-grid { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: auto; }
    .weighing-summary { grid-template-columns: 1fr 1fr; }
    .weighing-toolbar { grid-template-columns: 1fr 1fr; }
    .weighing-toolbar .button { grid-column: 1 / -1; }
    .modal { padding: 8px; }
    .modal-dialog { max-height: calc(100vh - 16px); }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .action-row { width: 100%; flex-direction: column; }
    .modal-footer .button { width: 100%; }
    .segmented-tabs { display: flex; width: 100%; }
    .inventory-item { grid-template-columns: 1fr 1fr 44px; }
    .inventory-item > div:first-child { grid-column: 1 / -1; }
    .report-filters { grid-template-columns: 1fr; }
    .report-filters .button { grid-column: auto; }
    .report-metric-grid { grid-template-columns: 1fr 1fr; }
    .system-backup-band { align-items: stretch; flex-direction: column; }
    .system-backup-band .button { width: 100%; }
    .role-check-grid, .client-link-fields, .organization-layout { grid-template-columns: 1fr; }
}

@media print {
    @page { size: A4 landscape; margin: 12mm; }
    .sidebar, .topbar, .page-header .header-controls, .report-filter-band, .button, .icon-button { display: none !important; }
    .app-frame { margin-left: 0 !important; }
    .page-header, .page-content { padding-left: 0 !important; padding-right: 0 !important; }
    .page-content { background: #fff !important; }
    .content-section, .metric-card, .data-table, .table-wrap { break-inside: avoid; box-shadow: none !important; }
    .table-wrap { overflow: visible !important; }
    .data-table { min-width: 0 !important; font-size: 9pt; }
    .report-metric-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

.field { display: grid; gap: 8px; }
.field label, .role-form label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
    width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--field); color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.14); }
.stack-form { display: grid; gap: 20px; }
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.password-toggle {
    position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted);
}
.otp-input { font-size: 24px; font-weight: 700; letter-spacing: 0.22em; text-align: center; }
.text-link { color: var(--blue); text-align: center; font-weight: 700; text-decoration: none; }

.alert { margin-bottom: 18px; padding: 12px 14px; border: 1px solid; border-radius: var(--radius); }
.alert-error { color: #8a1710; border-color: #e9a9a4; background: #fde7e7; }
.alert-warning { color: #7a3f08; border-color: #f0b77f; background: #fcead9; }
.alert-success { color: #176c31; border-color: #9bc9a7; background: #e8f4ea; }
:root[data-theme="dark"] .alert-error { color: #ffb9b4; background: #3a1c1c; border-color: #7f3732; }
:root[data-theme="dark"] .alert-warning { color: #ffd0a4; background: #3c2a18; border-color: #80532d; }
:root[data-theme="dark"] .alert-success { color: #a9e1b6; background: #173121; border-color: #356f44; }

.auth-page { background: var(--surface-alt); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 42%) 1fr; }
.auth-brand {
    display: flex; flex-direction: column; justify-content: center; padding: clamp(46px, 8vw, 112px);
    background: var(--blue); color: #fff;
}
.auth-brand-logo {
    display: grid; place-items: center; width: min(100%, 520px); padding: 22px;
    border-radius: var(--radius); background: #fff;
}
.auth-brand-logo img { display: block; width: 100%; height: auto; max-height: 190px; object-fit: contain; }
.auth-brand-copy {
    width: min(100%, 520px); margin: 28px auto 0; color: #d9e8f5;
    font-size: 36px; line-height: 1.3; text-align: center;
}
.auth-panel { position: relative; display: grid; place-items: center; padding: 72px 28px 40px; }
.auth-toolbar { position: absolute; top: 22px; right: 28px; display: flex; align-items: center; gap: 18px; }
.auth-toolbar form { display: flex; align-items: center; gap: 8px; }
.language-button { border: 0; background: transparent; color: var(--muted); font-weight: 800; }
.language-button:hover, .language-button:focus-visible { color: var(--blue); }
.auth-content { width: min(100%, 480px); }
.auth-card { padding: 38px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.auth-card-header { margin-bottom: 28px; }
.auth-card-header h2 { margin-bottom: 0; font-size: 28px; }
.section-label { display: block; margin-bottom: 8px; color: var(--orange); font-size: 11px; font-weight: 800; }
.error-card { text-align: center; }
.error-code { display: block; color: var(--orange); font-size: 54px; font-weight: 800; }

.app-page { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar-width); overflow: hidden;
    background: var(--blue); color: #fff; transition: width 160ms ease; box-shadow: 4px 0 14px rgba(0, 0, 0, 0.08);
}
.sidebar:hover, .sidebar:focus-within { width: var(--sidebar-open-width); }
.sidebar-nav { display: grid; gap: 6px; padding: 74px 10px 16px; }
.nav-item {
    display: grid; grid-template-columns: 44px 1fr; align-items: center; min-height: 46px; border-radius: var(--radius);
    color: #fff; text-decoration: none; white-space: nowrap;
}
.nav-item > span:first-child { display: grid; place-items: center; width: 44px; font-weight: 800; }
.nav-item > span:last-child { opacity: 0; transition: opacity 100ms ease; }
.sidebar:hover .nav-item > span:last-child, .sidebar:focus-within .nav-item > span:last-child { opacity: 1; }
.nav-item:hover, .nav-item:focus-visible, .nav-item.is-active { background: rgba(255, 255, 255, 0.16); }
.app-frame { min-height: 100vh; padding-left: var(--sidebar-width); }
.topbar {
    position: relative; z-index: 40; display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 28px;
    border-bottom: 1px solid var(--border); background: var(--surface);
}
.product-logo { display: inline-flex; align-items: center; width: min(180px, 28vw); height: 48px; text-decoration: none; }
.product-logo img { display: block; width: auto; max-width: 100%; height: 40px; object-fit: contain; object-position: left center; }
.topbar-actions, .header-controls { display: flex; align-items: center; gap: 12px; }
.compact-form select { min-height: 36px; width: 70px; padding: 5px 8px; border: 0; }
.user-avatar {
    display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; overflow: hidden;
    border-radius: 50%; background: var(--orange); color: #fff; font-size: 13px; font-weight: 800;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-menu { position: relative; }
.account-menu > summary { list-style: none; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu-trigger {
    display: flex; align-items: center; gap: 5px; min-width: 50px; height: 44px; padding: 2px 5px;
    border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
}
.account-menu-trigger:hover, .account-menu-trigger:focus-visible, .account-menu[open] .account-menu-trigger {
    border-color: var(--border); background: var(--surface-alt); outline: none;
}
.account-menu-chevron { width: 15px; height: 15px; color: var(--muted); transition: transform 140ms ease; }
.account-menu[open] .account-menu-chevron { transform: rotate(180deg); }
.account-menu-panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 80; width: min(280px, calc(100vw - 32px));
    padding: 7px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    box-shadow: var(--shadow);
}
.account-menu-identity { display: grid; gap: 3px; padding: 10px 11px 12px; border-bottom: 1px solid var(--border); }
.account-menu-identity strong, .account-menu-identity span { overflow-wrap: anywhere; }
.account-menu-identity span, .account-menu-identity small { color: var(--muted); }
.account-menu-identity span { font-size: 13px; }
.account-menu-identity small { font-size: 12px; font-weight: 700; }
.account-menu-panel form { margin: 0; }
.account-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; margin-top: 4px; padding: 8px 10px;
    border: 0; border-radius: 5px; background: transparent; color: var(--text); text-align: left; text-decoration: none;
}
.account-menu-item:hover, .account-menu-item:focus-visible { background: var(--surface-alt); color: var(--blue); outline: none; }
.account-menu-item .lucide { width: 17px; height: 17px; }
.account-menu-logout { color: var(--red); }
.page-header {
    display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 16px 28px;
    border-bottom: 1px solid var(--border); background: var(--surface);
}
.page-header h1 { margin-bottom: 3px; font-size: 22px; }
.page-header p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.role-form { display: flex; align-items: center; gap: 10px; }
.role-form select { min-height: 40px; width: min(260px, 40vw); }
.page-content { padding: 28px; }

.profile-overview { gap: 24px; padding: 8px 0 24px; }
.profile-identity { align-items: center; }
.profile-avatar {
    display: grid; place-items: center; width: 82px; height: 82px; flex: 0 0 82px; overflow: hidden;
    border: 1px solid var(--border); border-radius: 50%; background: var(--blue); color: #fff; font-size: 26px; font-weight: 800;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-role-badges { margin-top: 10px; }
.profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.profile-info-grid { margin-top: 0; }
.profile-security-note { max-width: 780px; }
.profile-photo-field { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 18px; }
.profile-avatar-large { width: 88px; height: 88px; flex-basis: 88px; font-size: 28px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric-card { position: relative; min-height: 118px; padding: 22px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; }
.metric-blue::before { background: var(--blue); }
.metric-green::before { background: var(--green); }
.metric-orange::before { background: var(--orange); }
.metric-danger::before { background: var(--red); }
.metric-neutral::before { background: #8795a8; }
.metric-card span { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { font-size: 27px; }
.deadline-summary { margin-bottom: 18px; }
.deadline-heading { gap: 20px; }
.deadline-heading .segmented-tabs { margin-bottom: 0; }
.status-overdue { background: #feeceb; color: #9b1c17; }
.status-today { background: #fff3dc; color: #8a4b08; }
.status-soon { background: #e7f6ec; color: #166534; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.7fr); gap: 18px; margin-top: 18px; }
.workspace-main, .workspace-side { min-height: 390px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-heading h2 { margin-bottom: 0; }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 270px; padding: 30px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }
.empty-state strong { margin-bottom: 8px; }
.empty-state span { max-width: 430px; color: var(--muted); }
.module-list { display: grid; gap: 10px; }
.module-button {
    display: grid; grid-template-columns: 38px 1fr; align-items: center; min-height: 52px; padding: 6px 14px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); color: var(--text); text-align: left; font-weight: 700;
}
.module-button > span:first-child { color: var(--orange); font-weight: 800; text-align: center; }
.module-button:hover, .module-button:focus-visible { border-color: var(--blue); color: var(--blue); }

@media (max-width: 980px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { min-height: 260px; padding: 48px 32px; }
    .auth-brand-logo { width: min(100%, 430px); padding: 16px; }
    .auth-brand-logo img { max-height: 120px; }
    .auth-brand-copy { margin-top: 18px; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workspace-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    :root { --sidebar-width: 56px; }
    .app-frame { width: 100%; max-width: 100%; overflow-x: hidden; }
    .page-content, .content-section { min-width: 0; max-width: 100%; }
    .segmented-tabs, .table-wrap { max-width: 100%; }
    .sidebar:hover, .sidebar:focus-within { width: var(--sidebar-width); }
    .sidebar-nav { padding: 74px 6px 12px; }
    .nav-item { grid-template-columns: 44px; }
    .nav-item > span:last-child { display: none; }
    .topbar { gap: 8px; padding-left: 8px; padding-right: 8px; }
    .page-header, .page-content { padding-left: 16px; padding-right: 16px; }
    .product-logo { width: 82px; flex: 0 0 82px; }
    .product-logo img { width: auto; max-width: 82px; height: 36px; }
    .topbar-actions { gap: 6px; }
    .compact-form select { width: 52px; padding-left: 4px; padding-right: 4px; }
    .account-menu-trigger { min-width: 40px; width: 40px; padding: 1px; }
    .account-menu-chevron { display: none; }
    .page-header { align-items: flex-start; gap: 14px; }
    .header-controls { align-items: flex-end; }
    .role-form { display: grid; gap: 4px; }
    .role-form select { width: min(180px, 46vw); }
    .auth-panel { padding: 72px 16px 26px; }
    .auth-card { padding: 26px 20px; }
}

@media (max-width: 500px) {
    .auth-brand { min-height: 225px; padding: 34px 24px; }
    .auth-brand-logo { padding: 12px; }
    .auth-brand-logo img { max-height: 90px; }
    .auth-brand-copy { font-size: 30px; }
    .auth-toolbar { right: 16px; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 104px; }
    .deadline-heading { align-items: stretch; flex-direction: column; }
    .page-header { flex-direction: column; }
    .header-controls { width: 100%; justify-content: space-between; }
    .role-form { flex: 1; }
    .role-form select { width: 100%; }
    .profile-actions { width: 100%; align-items: stretch; flex-direction: column; }
    .profile-actions .button { width: 100%; }
    .profile-photo-field { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
    .product-logo { width: 48px; flex-basis: 48px; }
    .product-logo img { max-width: 48px; height: 32px; }
    .topbar-actions { gap: 4px; }
    .topbar-actions .icon-button { width: 36px; height: 36px; }
    .compact-form select { width: 46px; min-height: 34px; }
    .account-menu-trigger { width: 36px; min-width: 36px; height: 38px; }
    .user-avatar { width: 34px; height: 34px; flex-basis: 34px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.print-document-page {
    min-height: 100vh;
    margin: 0;
    padding: 32px;
    background: #e9edf3;
    color: #1a1a1a;
}
.document-toolbar {
    display: flex;
    justify-content: space-between;
    width: min(210mm, 100%);
    margin: 0 auto 16px;
}
.document-paper {
    display: grid;
    gap: 22px;
    width: min(210mm, 100%);
    min-height: 297mm;
    margin: 0 auto;
    padding: 18mm 16mm;
    background: #fff;
    border: 1px solid #d8dee8;
    box-shadow: 0 20px 60px rgba(25, 36, 55, 0.16);
}
.document-header, .document-brand, .document-reference, .document-summary, .document-signatures {
    display: flex;
    align-items: center;
}
.document-header {
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 14px;
    border-bottom: 3px solid #0b3d91;
}
.document-brand { gap: 12px; }
.document-brand img, .document-brand > span {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    object-fit: contain;
    border: 1px solid #c7d2e2;
    border-radius: 6px;
    color: #0b3d91;
    font-weight: 800;
}
.document-brand div, .document-reference { display: grid; gap: 4px; }
.document-brand strong { color: #0b3d91; font-size: 18px; }
.document-brand small, .document-reference span, .document-title span, .document-grid span, .document-summary span, .document-signatures span {
    color: #5b6472;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.document-reference { justify-items: end; text-align: right; }
.document-reference strong { font-size: 18px; }
.document-title { text-align: center; }
.document-title h1 { margin: 5px 0 6px; color: #0b3d91; font-size: 28px; letter-spacing: 0; }
.document-title p { margin: 0; color: #555; }
.document-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.document-grid > div, .document-summary > div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid #d9e1ec;
    background: #f8fafc;
}
.document-grid strong { font-size: 15px; }
.document-grid small { color: #596273; }
.document-grid-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.document-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.document-table th {
    padding: 10px;
    background: #0b3d91;
    color: #fff;
    text-align: left;
}
.document-table td { padding: 11px 10px; border: 1px solid #cad4e2; }
.document-block { display: grid; gap: 10px; }
.document-block h2 { margin: 0; color: #e67e22; font-size: 16px; letter-spacing: 0; }
.document-block ul { margin: 0; padding-left: 20px; }
.document-summary { align-items: stretch; gap: 12px; }
.document-summary > div { flex: 1; }
.document-summary strong { color: #0b3d91; font-size: 18px; }
.document-warning, .document-note {
    display: grid;
    gap: 5px;
    padding: 12px 14px;
    border-left: 4px solid #e67e22;
    background: #fff7ef;
}
.document-signatures {
    align-items: stretch;
    gap: 14px;
    margin-top: 12px;
}
.document-signatures > div {
    display: grid;
    flex: 1;
    min-height: 100px;
    align-content: space-between;
    padding: 12px;
    border: 1px solid #c7d2e2;
}
.document-signatures strong { border-top: 1px solid #8a94a4; padding-top: 8px; }
.document-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #c7d2e2;
    color: #697386;
    font-size: 10px;
}

@media (max-width: 720px) {
    .print-document-page { padding: 12px; }
    .document-paper { min-height: auto; padding: 22px 16px; }
    .document-header, .document-summary, .document-signatures, .document-footer { align-items: stretch; flex-direction: column; }
    .document-reference { justify-items: start; text-align: left; }
    .document-grid, .document-grid-compact { grid-template-columns: 1fr; }
    .document-table { min-width: 640px; }
    .document-paper { overflow-x: auto; }
}

@media print {
    @page { size: A4 portrait; margin: 10mm; }
    .print-document-page { padding: 0; background: #fff; }
    .document-toolbar { display: none !important; }
    .document-paper {
        width: 100%;
        min-height: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
    .document-table, .document-block, .document-signatures, .document-summary { break-inside: avoid; }
}
