/* Controle Operacional V7 - design system In-Haus */
:root {
    --brand-primary: #257a98;
    --brand-primary-hover: #1f6882;
    --brand-dark: #002034;
    --brand-slate: #516266;
    --brand-muted: #bbbdbd;
    --bg-page: #f5f7f8;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --border: #d8dee1;
    --border-soft: #e8edef;
    --text: #172329;
    --text-secondary: #66747b;
    --text-muted: #8a969c;
    --success: #15803d;
    --success-soft: #ecfdf3;
    --warning: #d97706;
    --warning-soft: #fff7ed;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --info: #2563eb;
    --info-soft: #eff6ff;
    --focus-ring: rgba(37, 122, 152, .18);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 10px;
    --sidebar-width: 248px;
    --header-height: 68px;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
}

html { background: var(--bg-page); }
body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
a { color: var(--brand-primary); }
a:hover { color: var(--brand-primary-hover); }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 16px; line-height: 1.35; font-weight: 650; }
.muted { color: var(--text-secondary) !important; }

/* Shell */
.app-body { min-height: 100vh; overflow-x: hidden; }
.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border-soft);
}
.app-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 10px 22px;
    border-bottom: 1px solid var(--border-soft);
}
.app-brand a { display: inline-flex; align-items: center; text-decoration: none; }
.app-brand img { display: block; width: 174px; max-width: 100%; height: auto; }
.app-nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px 22px;
    scrollbar-width: thin;
}
.app-nav-section + .app-nav-section { margin-top: 24px; }
.app-nav-label {
    display: block;
    padding: 0 10px 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .065em;
    text-transform: uppercase;
}
.app-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 9px 11px;
    border-radius: var(--radius);
    color: var(--brand-slate);
    text-decoration: none;
    font-size: 14px;
    font-weight: 550;
    transition: background-color .14s ease, color .14s ease;
}
.app-nav-link:hover { background: #f1f6f8; color: var(--brand-dark); }
.app-nav-link.is-active {
    background: rgba(37, 122, 152, .11);
    color: var(--brand-primary);
    font-weight: 700;
}
.app-nav-link .ui-icon { flex: 0 0 auto; }
.app-sidebar-footer {
    display: grid;
    gap: 2px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border-soft);
}
.app-product-name { color: var(--brand-dark); font-size: 12px; font-weight: 700; }
.app-version { color: var(--text-muted); font-size: 11px; }
.app-stage { min-height: 100vh; margin-left: var(--sidebar-width); }
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 28px;
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(8px);
}
.app-header-start, .app-header-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-page-heading { min-width: 0; }
.app-page-heading h1 { margin: 0; color: var(--brand-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-eyebrow { display: block; margin-bottom: 1px; color: var(--text-muted); font-size: 11px; font-weight: 650; letter-spacing: .045em; text-transform: uppercase; }
.app-user-block { display: grid; justify-items: end; line-height: 1.2; }
.app-user-block strong { max-width: 230px; color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user-block span { color: var(--text-muted); font-size: 11px; }
.app-icon-button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--brand-slate);
    text-decoration: none;
    cursor: pointer;
}
.app-icon-button:hover { background: var(--surface-soft); border-color: #becacf; color: var(--brand-dark); }
.app-menu-button { display: none; }
.ui-icon { display: block; }
.app-content {
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: 28px;
}
.app-sidebar-overlay { display: none; }

/* Environment */
.env {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid #b7cbd3;
    border-radius: 999px;
    background: #eff7fa;
    color: var(--brand-primary);
    font-size: 11px;
    line-height: 1;
    font-weight: 750;
    letter-spacing: .04em;
}

/* Cards, sections and alignment */
.page { max-width: 1600px; margin: 0 auto; padding: 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; align-items: stretch; }
.card,
.form-card,
.purchase-item-card,
.adm-detail-card,
.adm-lot-card,
.adm-approval-card,
.adm-lot-summary-card {
    border: 1px solid var(--border-soft) !important;
    border-radius: var(--radius-lg) !important;
    background: var(--surface) !important;
    box-shadow: 0 1px 2px rgba(0,32,52,.035);
}
.card { min-height: 108px; padding: 20px; color: inherit; text-decoration: none; }
.card:hover { border-color: #bfd0d6 !important; box-shadow: 0 4px 14px rgba(0,32,52,.055); }
.form-card { padding: 20px; }
.section-block { margin-top: 0; display: grid; gap: 18px; }
.section-heading { align-items: center; margin-bottom: 0; min-height: 42px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }

/* Forms */
.form { display: grid; gap: 16px; }
.form label,
.purchase-fields label,
.single-quantity-block label,
.buyer-assignment-form label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}
.form input,
.form select,
.form textarea,
.purchase-fields input,
.purchase-fields textarea,
.single-quantity-block input,
.cr-filter,
.smart-filter-input,
.size-quantity-row input,
.adm-quotation-table input,
.adm-approval-form textarea,
.adm-totvs-control-form input,
.adm-totvs-control-form select,
.buyer-assignment-form select,
.smart-filter {
    border-color: var(--border) !important;
    border-radius: var(--radius) !important;
    background: var(--surface);
    color: var(--text);
}
.form input,
.form select,
.purchase-fields input,
.single-quantity-block input,
.cr-filter,
.smart-filter-input,
.size-quantity-row input,
.adm-quotation-table input,
.adm-totvs-control-form input,
.adm-totvs-control-form select,
.buyer-assignment-form select {
    min-height: 40px;
    padding: 9px 11px;
}
.form textarea,
.purchase-fields textarea,
.adm-approval-form textarea { min-height: 96px; padding: 10px 11px; resize: vertical; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.smart-filter:focus-within,
.attachment-paste-zone:focus-visible {
    outline: none;
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 3px var(--focus-ring) !important;
}
::placeholder { color: #98a3a8; opacity: 1; }
.field-label { color: var(--text); font-size: 13px; font-weight: 650; }
.field-help { color: var(--text-secondary); font-size: 12px; font-weight: 400; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Buttons */
.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius);
    background: var(--brand-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease, transform .05s ease;
}
.button:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color: #fff; }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.button[disabled] { opacity: .52; cursor: not-allowed; transform: none; }
.button-secondary,
.button.secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--brand-dark);
}
.button-secondary:hover,
.button.secondary:hover { border-color: #b9c7cc; background: var(--surface-soft); color: var(--brand-dark); }
.button-danger,
.button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.button-danger:hover,
.button.danger:hover { border-color: #912018; background: #912018; color: #fff; }
.link-button { color: var(--brand-primary) !important; text-decoration: none !important; font-weight: 650; }
.link-button:hover { color: var(--brand-primary-hover) !important; text-decoration: underline !important; }

/* Alerts */
.alert {
    margin: 0 0 16px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
}
.alert-error { border-color: #fecaca; background: var(--danger-soft); color: #991b1b; }
.alert-success { border-color: #bbf7d0; background: var(--success-soft); color: #166534; }
.alert-warning, .notice { border-color: #fed7aa; background: var(--warning-soft); color: #9a3412; }

/* Tabs */
.purchase-tabs,
.adm-purchase-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 22px !important;
    padding: 0 2px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border) !important;
}
.purchase-tabs a,
.adm-purchase-tabs a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px !important;
    border-bottom: 2px solid transparent !important;
    color: var(--text-secondary) !important;
    font-size: 14px;
    font-weight: 600 !important;
    white-space: nowrap;
    text-decoration: none;
}
.purchase-tabs a:hover,
.adm-purchase-tabs a:hover { color: var(--brand-dark) !important; }
.purchase-tabs a.active,
.adm-purchase-tabs a.active {
    border-bottom-color: var(--brand-primary) !important;
    color: var(--brand-primary) !important;
    font-weight: 700 !important;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0,32,52,.025);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px; font-size: 13px; }
.table th,
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f5f6;
    color: var(--brand-slate);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .01em;
    text-align: left;
}
.table tbody tr:not([hidden]):hover > td { background: #fafcfc; }
.table tr:last-child td { border-bottom: 0; }
.table td strong { color: var(--brand-dark); }
.table td input, .table td select { font-size: 13px; }
.table .numeric, .table th.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Status */
.status-badge,
.adm-queue-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border: 0;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 750;
    line-height: 1;
    letter-spacing: .025em;
    text-transform: uppercase;
    white-space: nowrap;
}
.adm-queue-badge.is-new { background: var(--info-soft); color: var(--info); }
.adm-queue-badge.is-pending { background: var(--warning-soft); color: var(--warning); }
.adm-queue-badge.is-progress { background: #edf8fb; color: var(--brand-primary); }
.adm-queue-badge.is-done { background: var(--success-soft); color: var(--success); }
.adm-process-status { color: var(--text-secondary); font-size: 11px; }

/* Smart filters and queue controls */
.smart-filter {
    min-height: 40px !important;
    padding: 5px 9px !important;
    box-shadow: none;
}
.smart-filter input { min-height: 28px; color: var(--text); }
.smart-filter-tag { background: #edf4f6 !important; color: var(--brand-dark) !important; font-size: 12px; font-weight: 600; }
.adm-queue-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-queue-filter {
    min-height: 36px;
    border: 1px solid var(--border) !important;
    border-radius: 999px !important;
    background: var(--surface) !important;
    color: var(--brand-slate) !important;
    padding: 7px 11px !important;
    font-size: 12px !important;
    font-weight: 650 !important;
}
.adm-queue-filter.active { border-color: var(--brand-primary) !important; background: var(--brand-primary) !important; color: #fff !important; }
.adm-queue-filter span { background: #eef2f3 !important; color: var(--text-secondary) !important; }
.adm-queue-filter.active span { background: rgba(255,255,255,.18) !important; color: #fff !important; }
.adm-claim-button {
    width: 32px !important;
    height: 32px !important;
    border-color: #a9c2cb !important;
    border-radius: var(--radius) !important;
    color: var(--success) !important;
}
.adm-claim-button:hover { border-color: #85aaa0 !important; background: var(--success-soft) !important; }
.adm-mine-mark, .adm-claimed-icon { background: var(--success-soft) !important; color: var(--success) !important; }
.adm-request-summary-row[data-queue="new"] td:first-child { box-shadow: inset 3px 0 0 var(--info) !important; }
.adm-request-summary-row[data-queue="pending"] td:first-child { box-shadow: inset 3px 0 0 var(--warning) !important; }

/* Purchase cards */
.request-meta { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.request-meta > div { padding: 13px 14px; border-color: var(--border-soft); border-radius: var(--radius); }
.request-meta span { color: var(--text-muted); font-size: 11px; font-weight: 650; text-transform: none; letter-spacing: 0; }
.purchase-item-card { padding: 20px; }
.purchase-item-header { margin-bottom: 16px; }
.purchase-item-header strong { font-size: 16px; color: var(--brand-dark); }
.attachment-paste-zone { border-color: #b9c7cc !important; background: var(--surface-soft) !important; color: var(--text-secondary) !important; }
.attachment-paste-zone:focus,
.attachment-paste-zone.dragging { border-color: var(--brand-primary) !important; background: #f0f7f9 !important; box-shadow: 0 0 0 3px var(--focus-ring) !important; }

/* ADM cards */
.adm-toolbar { align-items: center; }
.adm-count { color: var(--text-secondary) !important; font-size: 12px; font-weight: 600; }
.adm-detail-card, .adm-lot-card, .adm-approval-card { padding: 20px !important; }
.adm-card-head h2, .adm-detail-head h2 { margin-bottom: 0; }
.adm-mini-grid span, .adm-card-head span, .adm-lot-summary-card span, .adm-approval-summary span { color: var(--text-secondary) !important; }
.adm-mini-grid b { color: var(--brand-dark) !important; }
.adm-readiness.ready { background: var(--success-soft) !important; color: var(--success) !important; }
.adm-readiness.pending { background: var(--warning-soft) !important; color: #9a3412 !important; }

/* Dashboard */
.dashboard-intro { margin-bottom: 20px; }
.dashboard-intro p { margin: 6px 0 0; color: var(--text-secondary); }
.dashboard-grid .card { display: flex; align-items: center; gap: 14px; }
.dashboard-card-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(37,122,152,.1);
    color: var(--brand-primary);
}
.dashboard-card-copy { display: grid; gap: 3px; }
.dashboard-card-copy strong { color: var(--brand-dark); font-size: 14px; }
.dashboard-card-copy span { color: var(--text-secondary); font-size: 12px; }

/* Auth */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(circle at 10% 10%, rgba(37,122,152,.08), transparent 30%),
        var(--bg-page);
}
.auth-card {
    width: min(100%, 440px);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 28px;
    background: var(--surface);
    box-shadow: 0 14px 36px rgba(0,32,52,.08);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 24px; }
.auth-brand img { width: 190px; height: auto; }
.auth-header { align-items: flex-start; margin-bottom: 22px; }
.auth-header h1 { margin-bottom: 5px; color: var(--brand-dark); font-size: 22px; }
.auth-header p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.auth-help { color: var(--text-secondary); font-size: 12px; }

/* Empty states */
.empty-state {
    min-height: 260px;
    display: grid;
    place-items: center;
    padding: 36px;
    border: 1px dashed #cbd6da;
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
}
.empty-state > div { max-width: 460px; }
.empty-state h2 { margin-bottom: 6px; color: var(--brand-dark); }
.empty-state p { margin: 0; color: var(--text-secondary); }

@media (max-width: 1100px) {
    :root { --sidebar-width: 226px; }
    .app-content { padding: 24px; }
}

@media (max-width: 860px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 18px 0 40px rgba(0,32,52,.12);
    }
    .app-body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 45;
        display: block;
        visibility: hidden;
        opacity: 0;
        background: rgba(0,32,52,.32);
        transition: opacity .2s ease, visibility .2s ease;
    }
    .app-body.sidebar-open .app-sidebar-overlay { visibility: visible; opacity: 1; }
    .app-stage { margin-left: 0; }
    .app-menu-button { display: inline-flex; }
    .app-header { padding: 0 18px; }
    .app-content { padding: 20px 18px 28px; }
    .app-user-block { display: none; }
    .purchase-fields { grid-template-columns: 1fr !important; }
}

@media (max-width: 640px) {
    .app-header { height: 62px; gap: 10px; }
    .app-page-heading h1 { font-size: 20px; }
    .app-header-actions { gap: 7px; }
    .app-icon-button { width: 34px; height: 34px; }
    .app-content { padding: 16px 12px 24px; }
    .form-card, .purchase-item-card, .adm-detail-card, .adm-lot-card, .adm-approval-card { padding: 16px !important; }
    .form-actions, .purchase-submit-row, .section-heading { align-items: stretch !important; flex-direction: column !important; }
    .form-actions .button, .purchase-submit-row .button { width: 100%; }
    .request-meta { grid-template-columns: 1fr; }
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.page-toolbar-compact { justify-content: flex-start; margin-bottom: 14px; }
.page-back-link { color: var(--brand-slate); font-size: 13px; font-weight: 600; text-decoration: none; }
.page-back-link:hover { color: var(--brand-primary); }
.users-page { max-width: 1500px; }
.form-page { max-width: 820px; }
.actions a { font-weight: 600; }

@media (max-width: 640px) {
    .page-toolbar { align-items: stretch; flex-direction: column; }
    .page-toolbar .actions { width: 100%; }
    .page-toolbar .actions .button { flex: 1; }
}

.context-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.context-strip > div {
    display: grid;
    gap: 3px;
    padding: 11px 13px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface);
}
.context-strip span { color: var(--text-muted); font-size: 11px; font-weight: 650; }
.context-strip strong { color: var(--brand-dark); font-size: 13px; overflow-wrap: anywhere; }
.status-badge { background: #edf4f6; color: var(--brand-slate); }
.table td.actions { justify-content: flex-end; align-items: center; }
.status-badge.is-success { background: var(--success-soft); color: var(--success); }
.status-badge.is-warning { background: var(--warning-soft); color: var(--warning); }
.status-badge.is-danger { background: var(--danger-soft); color: var(--danger); }
.status-badge.is-info { background: var(--info-soft); color: var(--info); }
.status-badge.is-neutral { background: #eef2f3; color: var(--brand-slate); }

/* V7 final shell: sidebar compacta por padrão e expansão por hover */
:root {
    --sidebar-collapsed-width: 72px;
}

@media (min-width: 861px) {
    .app-sidebar {
        width: var(--sidebar-collapsed-width);
        overflow: hidden;
        transition: width .18s ease, box-shadow .18s ease;
    }

    .app-sidebar:hover,
    .app-sidebar:focus-within {
        width: var(--sidebar-width);
        box-shadow: 12px 0 30px rgba(0, 32, 52, .08);
    }

    .app-stage {
        margin-left: var(--sidebar-collapsed-width);
    }

    .app-brand {
        justify-content: center;
        padding: 0;
        overflow: hidden;
    }

    .app-brand a {
        position: relative;
        width: 100%;
        height: 100%;
        justify-content: center;
        overflow: hidden;
    }

    .app-brand a::before {
        content: "IH";
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        color: var(--brand-primary);
        font-size: 17px;
        font-weight: 800;
        letter-spacing: -.04em;
        transition: opacity .12s ease;
    }

    .app-brand img {
        width: 174px;
        max-width: none;
        opacity: 0;
        transform: translateX(-4px);
        transition: opacity .12s ease .03s, transform .18s ease;
    }

    .app-sidebar:hover .app-brand a::before,
    .app-sidebar:focus-within .app-brand a::before {
        opacity: 0;
    }

    .app-sidebar:hover .app-brand img,
    .app-sidebar:focus-within .app-brand img {
        opacity: 1;
        transform: translateX(0);
    }

    .app-nav {
        padding: 14px 10px 20px;
        overflow-x: hidden;
    }

    .app-nav-section + .app-nav-section {
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-soft);
    }

    .app-nav-link {
        width: 52px;
        justify-content: center;
        gap: 0;
        padding: 9px 0;
        margin: 0 auto;
        white-space: nowrap;
        overflow: hidden;
        transition: width .18s ease, padding .18s ease, gap .18s ease, background-color .14s ease, color .14s ease;
    }

    .app-nav-link > span {
        width: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transition: opacity .10s ease, width .18s ease;
    }

    .app-sidebar:hover .app-nav-link,
    .app-sidebar:focus-within .app-nav-link {
        width: 100%;
        justify-content: flex-start;
        gap: 11px;
        padding: 9px 11px;
    }

    .app-sidebar:hover .app-nav-link > span,
    .app-sidebar:focus-within .app-nav-link > span {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    .app-sidebar-footer,
    .app-nav-label {
        display: none !important;
    }
}

/* Dashboard sem duplicação dos módulos da navegação */
.dashboard-page {
    max-width: 1600px;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr);
    gap: 16px;
    align-items: stretch;
}

.dashboard-panel {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 32, 52, .025);
    overflow: hidden;
}

.dashboard-panel-header {
    min-height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-soft);
}

.dashboard-panel-header h2 {
    margin: 0;
    color: var(--brand-dark);
    font-size: 16px;
    font-weight: 700;
}

.dashboard-empty {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 28px;
    color: var(--text-muted);
    font-size: 13px;
}

.dashboard-status-grid {
    display: grid;
    gap: 0;
}

.dashboard-status-item {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-soft);
}

.dashboard-status-item:last-child {
    border-bottom: 0;
}

.dashboard-status-item span {
    color: var(--text-secondary);
    font-size: 13px;
}

.dashboard-status-item strong {
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
}

.dashboard-status-item strong.is-success {
    color: var(--success);
}

@media (max-width: 860px) {
    .app-sidebar {
        width: var(--sidebar-width);
    }

    .app-brand a::before {
        content: none;
    }

    .app-brand img {
        width: 174px;
        opacity: 1;
        transform: none;
    }

    .app-nav-link {
        width: 100%;
        justify-content: flex-start;
        gap: 11px;
    }

    .app-nav-link > span {
        width: auto;
        opacity: 1;
    }

    .app-nav-section + .app-nav-section {
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-soft);
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

/* V7: seletor de tema no rodapé da barra lateral */
.app-sidebar-tools {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    padding: 10px 12px 14px;
    border-top: 1px solid var(--border-soft);
    background: var(--surface);
}

.app-theme-toggle {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 11px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--brand-slate);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .14s ease, color .14s ease, width .18s ease, padding .18s ease, gap .18s ease;
}

.app-theme-toggle:hover,
.app-theme-toggle:focus-visible {
    background: var(--surface-soft);
    color: var(--brand-primary);
    outline: none;
}

.app-theme-icon {
    display: grid;
    place-items: center;
    flex: 0 0 20px;
}

.app-theme-icon-sun { display: none; }
html[data-theme="dark"] .app-theme-icon-moon { display: none; }
html[data-theme="dark"] .app-theme-icon-sun { display: grid; }

@media (min-width: 861px) {
    .app-sidebar-tools { padding: 10px; }

    .app-theme-toggle {
        width: 52px;
        justify-content: center;
        gap: 0;
        padding: 9px 0;
        margin: 0 auto;
        overflow: hidden;
    }

    .app-theme-label {
        width: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transition: width .18s ease, opacity .10s ease;
    }

    .app-sidebar:hover .app-theme-toggle,
    .app-sidebar:focus-within .app-theme-toggle {
        width: 100%;
        justify-content: flex-start;
        gap: 11px;
        padding: 9px 11px;
    }

    .app-sidebar:hover .app-theme-label,
    .app-sidebar:focus-within .app-theme-label {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }
}

/* V7: tema escuro */
html[data-theme="dark"] {
    --brand-primary: #68b3cd;
    --brand-primary-hover: #85c4d9;
    --brand-dark: #e9f5f8;
    --brand-slate: #b7c7cd;
    --brand-muted: #73868e;
    --bg-page: #0f171b;
    --surface: #162126;
    --surface-soft: #1c2a30;
    --border: #3a4a51;
    --border-soft: #293940;
    --text: #e7eef1;
    --text-secondary: #a9b8be;
    --text-muted: #819299;
    --success: #6cc28a;
    --success-soft: #153424;
    --warning: #f0ab5b;
    --warning-soft: #382717;
    --danger: #f18b83;
    --danger-soft: #3b2020;
    --info: #7faef2;
    --info-soft: #182b46;
    --focus-ring: rgba(104, 179, 205, .24);
    color-scheme: dark;
}

html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] .app-body,
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .app-stage {
    background: var(--bg-page);
    color: var(--text);
}

html[data-theme="dark"] .app-header {
    background: rgba(22, 33, 38, .97);
    border-color: var(--border-soft);
}

html[data-theme="dark"] .app-sidebar,
html[data-theme="dark"] .app-sidebar-tools,
html[data-theme="dark"] .card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .dashboard-panel,
html[data-theme="dark"] .context-strip {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text);
}

html[data-theme="dark"] .app-nav-link:hover {
    background: #1b3039;
    color: var(--brand-primary);
}

html[data-theme="dark"] .app-nav-link.is-active {
    background: rgba(104, 179, 205, .14);
    color: var(--brand-primary);
}

html[data-theme="dark"] .app-icon-button,
html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .button.secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}

html[data-theme="dark"] .app-icon-button:hover,
html[data-theme="dark"] button.secondary:hover,
html[data-theme="dark"] .button.secondary:hover {
    background: var(--surface-soft);
    border-color: #52666f;
    color: var(--brand-primary);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #111b20 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #71838b !important;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 3px var(--focus-ring) !important;
}

html[data-theme="dark"] .table,
html[data-theme="dark"] table {
    color: var(--text);
}

html[data-theme="dark"] .table thead th {
    background: #1d2a30 !important;
    border-color: var(--border-soft) !important;
    color: #c4d0d5 !important;
}

html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .table tbody th {
    border-color: var(--border-soft) !important;
    color: var(--text);
}

html[data-theme="dark"] .table tbody tr:hover > td,
html[data-theme="dark"] .table tbody tr:hover > th {
    background: #19272d !important;
}

html[data-theme="dark"] .tabs,
html[data-theme="dark"] .module-tabs,
html[data-theme="dark"] .page-tabs {
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .tab-link,
html[data-theme="dark"] .module-tabs a,
html[data-theme="dark"] .page-tabs a {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .tab-link.is-active,
html[data-theme="dark"] .module-tabs a.is-active,
html[data-theme="dark"] .page-tabs a.is-active {
    color: var(--brand-primary) !important;
}

html[data-theme="dark"] .alert-error { border-color: #70413e; background: var(--danger-soft); color: #f2aaa4; }
html[data-theme="dark"] .alert-success { border-color: #2f6744; background: var(--success-soft); color: #8bd2a4; }
html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .notice { border-color: #6a4b27; background: var(--warning-soft); color: #efb777; }

html[data-theme="dark"] .status-badge { background: #223139; color: var(--text-secondary); }
html[data-theme="dark"] .status-badge.is-success { background: var(--success-soft); color: var(--success); }
html[data-theme="dark"] .status-badge.is-warning { background: var(--warning-soft); color: var(--warning); }
html[data-theme="dark"] .status-badge.is-danger { background: var(--danger-soft); color: var(--danger); }
html[data-theme="dark"] .status-badge.is-info { background: var(--info-soft); color: var(--info); }
html[data-theme="dark"] .status-badge.is-neutral { background: #223139; color: var(--text-secondary); }

html[data-theme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, .68) !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-track { background: #10191d; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4b53; }


/* V7 R07 - cobertura completa de tema */
.auth-theme-toggle {
    position: fixed;
    z-index: 100;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--brand-slate);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,32,52,.07);
}
.auth-theme-toggle:hover,
.auth-theme-toggle:focus-visible {
    background: var(--surface-soft);
    color: var(--brand-primary);
    outline: none;
}
.auth-theme-toggle svg { width: 19px; height: 19px; }

html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(circle at 8% 12%, rgba(104,179,205,.10), transparent 26%),
        var(--bg-page) !important;
}
html[data-theme="dark"] .auth-card {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
    box-shadow: 0 16px 42px rgba(0,0,0,.26) !important;
}
html[data-theme="dark"] .auth-card h1,
html[data-theme="dark"] .auth-card h2,
html[data-theme="dark"] .auth-card strong,
html[data-theme="dark"] .auth-card label,
html[data-theme="dark"] .auth-card label span {
    color: var(--text) !important;
}
html[data-theme="dark"] .auth-card p,
html[data-theme="dark"] .auth-card .auth-help {
    color: var(--text-secondary) !important;
}
html[data-theme="dark"] .password-toggle {
    color: var(--text-secondary) !important;
}
html[data-theme="dark"] .password-toggle:hover {
    color: var(--brand-primary) !important;
    background: var(--surface-soft) !important;
}
html[data-theme="dark"] .password-strength-track {
    background: #25343b !important;
}

html[data-theme="dark"] :where(
    .purchase-cart,
    .purchase-table-wrap,
    .purchase-request-table-wrap,
    .purchase-request-modal,
    .purchase-edit-modal,
    .adm-request-modal,
    .adm-lot-modal,
    .adm-quotation-modal,
    .adm-approval-modal,
    .adm-totvs-modal,
    .adm-selection-bar,
    .adm-toolbar,
    .adm-filter-bar,
    .smart-filter,
    .empty-state,
    .dropdown-menu,
    .popover,
    .context-menu
) {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] table thead th {
    background: #1d2a30 !important;
    border-color: var(--border-soft) !important;
    color: #c4d0d5 !important;
}
html[data-theme="dark"] table tbody td,
html[data-theme="dark"] table tbody th {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
}
html[data-theme="dark"] table tbody tr:hover > td,
html[data-theme="dark"] table tbody tr:hover > th {
    background: #19272d !important;
}

html[data-theme="dark"] :where(
    .tag,
    .chip,
    .pill,
    .filter-chip,
    .cr-chip,
    .size-chip,
    .size-tag
) {
    background: #1d2b31 !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] :where(
    .tag.is-active,
    .chip.is-active,
    .filter-chip.is-active,
    .cr-chip.is-selected,
    .size-chip.is-selected,
    .size-tag.is-selected
) {
    background: rgba(104,179,205,.17) !important;
    border-color: var(--brand-primary) !important;
    color: var(--brand-primary) !important;
}

html[data-theme="dark"] hr,
html[data-theme="dark"] .divider {
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] option {
    background: #111b20;
    color: var(--text);
}


/* ============================================================
   V7 R09 - Dark mode consolidado
   Organogramas ficam deliberadamente fora deste tema.
   ============================================================ */

html[data-theme="dark"] {
    --brand-primary: #58ABC8;
    --brand-primary-hover: #6DBAD4;
    --brand-dark: #EDF3F5;
    --brand-slate: #B1BEC3;
    --brand-muted: #83939A;

    --bg-page: #0E171B;
    --surface: #16252B;
    --surface-soft: #1B2C33;
    --surface-elevated: #1B2C33;
    --surface-deep: #111D22;

    --border: #304047;
    --border-soft: #26363D;

    --text: #EDF3F5;
    --text-secondary: #B1BEC3;
    --text-muted: #83939A;

    --success: #59B77A;
    --success-soft: rgba(89, 183, 122, .14);
    --warning: #D4A84F;
    --warning-soft: rgba(212, 168, 79, .14);
    --danger: #D66A6A;
    --danger-soft: rgba(214, 106, 106, .14);
    --info: #76A9E6;
    --info-soft: rgba(118, 169, 230, .14);

    --focus-ring: rgba(88, 171, 200, .24);
    color-scheme: dark;
}

/* Base e estrutura */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] .app-body,
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .app-stage,
html[data-theme="dark"] .app-content {
    background: var(--bg-page) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] .app-sidebar,
html[data-theme="dark"] .app-sidebar-tools {
    background: var(--surface-deep) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .app-header {
    background: rgba(17, 29, 34, .97) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .app-nav-link:hover {
    background: rgba(88, 171, 200, .09) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] .app-nav-link.is-active {
    background: rgba(88, 171, 200, .16) !important;
    color: var(--brand-primary) !important;
}

html[data-theme="dark"] .app-page-heading h1,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] strong {
    color: var(--text);
}

/* Superfícies e cards */
html[data-theme="dark"] :where(
    .card,
    .form-card,
    .purchase-item-card,
    .adm-detail-card,
    .adm-lot-card,
    .adm-approval-card,
    .adm-lot-summary-card,
    .dashboard-panel,
    .panel,
    .context-strip,
    .empty-state,
    .smart-filter,
    .adm-toolbar,
    .adm-filter-bar,
    .adm-selection-bar
) {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .request-meta > div {
    background: var(--surface-elevated) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .request-meta span {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .request-meta strong {
    color: var(--text) !important;
}

/* Inputs e campos */
html[data-theme="dark"] :where(
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .cr-filter,
    .smart-filter-input
) {
    background: #101C21 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] :where(input, textarea)::placeholder {
    color: #71838B !important;
    opacity: 1;
}

html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] {
    accent-color: var(--brand-primary);
}

html[data-theme="dark"] option {
    background: #101C21 !important;
    color: var(--text) !important;
}

/* Compras: CRs, tamanhos e anexos */
html[data-theme="dark"] .size-chip,
html[data-theme="dark"] .cr-chip span {
    background: #1A292F !important;
    border-color: #3A4C54 !important;
    color: #D9E3E6 !important;
}

html[data-theme="dark"] .size-chip:hover,
html[data-theme="dark"] .cr-chip span:hover {
    background: #20343C !important;
    border-color: #4D6974 !important;
}

html[data-theme="dark"] .size-chip.active,
html[data-theme="dark"] .cr-chip input:checked + span {
    background: rgba(88, 171, 200, .18) !important;
    border-color: var(--brand-primary) !important;
    color: #DDF4FB !important;
}

html[data-theme="dark"] .cr-chip[data-order]::after {
    border-color: var(--surface) !important;
    background: var(--brand-primary) !important;
    color: #081419 !important;
}

html[data-theme="dark"] .attachment-paste-zone {
    background: #111E23 !important;
    border-color: #40545D !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .attachment-list {
    color: var(--text-secondary) !important;
}

/* Carrinho / Itens da solicitação */
html[data-theme="dark"] .purchase-cart-section {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .cart-count,
html[data-theme="dark"] .attachment-count {
    background: #1A292F !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .purchase-cart-empty {
    background: #111E23 !important;
    border-color: #3A4C54 !important;
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .purchase-cart-item {
    background: var(--surface-elevated) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .purchase-cart-item-title p,
html[data-theme="dark"] .purchase-cart-item-meta {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .cart-item-number,
html[data-theme="dark"] .cart-row-number {
    background: #0B3444 !important;
    color: #EAF8FC !important;
}

/* Tabelas do portal */
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .purchase-cart-table-wrap,
html[data-theme="dark"] .request-modal-table-wrap,
html[data-theme="dark"] .purchase-cart-edit-table-wrap {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] :where(
    .table,
    .purchase-cart-table,
    .request-modal-table,
    .purchase-cart-edit-table,
    table
) {
    background: var(--surface) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] :where(
    .table thead th,
    .purchase-cart-table thead th,
    .request-modal-table thead th,
    .purchase-cart-edit-table thead th,
    table thead th
) {
    background: #1D2A30 !important;
    border-color: var(--border-soft) !important;
    color: #C4D0D5 !important;
}

html[data-theme="dark"] :where(
    .table tbody td,
    .table tbody th,
    .purchase-cart-table tbody td,
    .request-modal-table tbody td,
    .purchase-cart-edit-table tbody td,
    table tbody td,
    table tbody th
) {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] :where(
    .table tbody tr:hover > td,
    .purchase-cart-row:hover > td,
    .purchase-cart-table tbody tr:hover:not(.is-editing) > td,
    table tbody tr:hover > td
) {
    background: #19282E !important;
}

html[data-theme="dark"] .purchase-cart-row {
    background: var(--surface) !important;
}

html[data-theme="dark"] .purchase-cart-item-name strong {
    color: var(--text) !important;
}

html[data-theme="dark"] .purchase-cart-description,
html[data-theme="dark"] .purchase-cart-cr,
html[data-theme="dark"] .purchase-cart-size,
html[data-theme="dark"] .purchase-cart-table .purchase-cart-index {
    color: var(--text-secondary) !important;
}

/* Edição do carrinho */
html[data-theme="dark"] .purchase-cart-item.is-editing,
html[data-theme="dark"] .purchase-cart-edit-table td {
    background: var(--surface-elevated) !important;
}

html[data-theme="dark"] .cart-inline-cr-list label,
html[data-theme="dark"] .cart-edit-size-choice,
html[data-theme="dark"] .cart-edit-cr-list label {
    background: #1A292F !important;
    border-color: #3A4C54 !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .cart-inline-cr-list label[data-order],
html[data-theme="dark"] .cart-edit-size-choice.is-active,
html[data-theme="dark"] .cart-edit-cr-list label[data-order] {
    background: rgba(88, 171, 200, .15) !important;
    border-color: var(--brand-primary) !important;
    color: #DDF4FB !important;
}

html[data-theme="dark"] .cart-inline-cr-list.has-error,
html[data-theme="dark"] .cart-edit-cr-list.has-error {
    background: rgba(214, 106, 106, .08) !important;
}

/* Modal de solicitação */
html[data-theme="dark"] .request-modal {
    background: var(--surface) !important;
    color: var(--text) !important;
    box-shadow: 0 24px 70px rgba(0,0,0,.38) !important;
}

html[data-theme="dark"] .request-modal::backdrop {
    background: rgba(0, 8, 12, .72) !important;
}

html[data-theme="dark"] .request-modal-header,
html[data-theme="dark"] .request-modal-table-wrap,
html[data-theme="dark"] .request-modal-documents {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .request-modal-meta,
html[data-theme="dark"] .request-modal-footer {
    background: var(--surface-elevated) !important;
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .request-modal-meta > div + div {
    border-color: var(--border-soft) !important;
}

html[data-theme="dark"] .request-modal-title h3,
html[data-theme="dark"] .request-modal-meta strong:not(.status-badge) {
    color: var(--text) !important;
}

html[data-theme="dark"] .request-modal-title span,
html[data-theme="dark"] .request-modal-meta span {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .request-modal-header .request-modal-close {
    background: #152329 !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

/* Botões */
html[data-theme="dark"] .button {
    border-color: var(--brand-primary) !important;
    background: var(--brand-primary) !important;
    color: #081419 !important;
}

html[data-theme="dark"] .button:hover {
    border-color: var(--brand-primary-hover) !important;
    background: var(--brand-primary-hover) !important;
    color: #071216 !important;
}

html[data-theme="dark"] .button-secondary,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .icon-action-button {
    background: #18272D !important;
    border-color: var(--border) !important;
    color: var(--brand-primary) !important;
}

html[data-theme="dark"] .button-secondary:hover,
html[data-theme="dark"] .button.secondary:hover,
html[data-theme="dark"] .icon-action-button:hover {
    background: #20343C !important;
    border-color: #4B6671 !important;
}

html[data-theme="dark"] .button[disabled],
html[data-theme="dark"] button[disabled] {
    opacity: .46 !important;
    filter: saturate(.65);
    cursor: not-allowed !important;
}

/* Status e mensagens */
html[data-theme="dark"] .alert {
    background: var(--surface-elevated) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

html[data-theme="dark"] .alert-error {
    background: rgba(214, 106, 106, .12) !important;
    border-color: rgba(214, 106, 106, .42) !important;
    color: #F2B1B1 !important;
}

html[data-theme="dark"] .alert-success {
    background: rgba(89, 183, 122, .12) !important;
    border-color: rgba(89, 183, 122, .40) !important;
    color: #9DDFB4 !important;
}

html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .notice {
    background: rgba(212, 168, 79, .12) !important;
    border-color: rgba(212, 168, 79, .40) !important;
    color: #E7C981 !important;
}

/* Tabs e filtros */
html[data-theme="dark"] .purchase-tabs,
html[data-theme="dark"] .adm-purchase-tabs {
    border-color: var(--border) !important;
}

html[data-theme="dark"] .purchase-tabs a,
html[data-theme="dark"] .adm-purchase-tabs a {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .purchase-tabs a:hover,
html[data-theme="dark"] .adm-purchase-tabs a:hover {
    color: var(--text) !important;
}

html[data-theme="dark"] .purchase-tabs a.active,
html[data-theme="dark"] .adm-purchase-tabs a.active {
    color: var(--brand-primary) !important;
    border-bottom-color: var(--brand-primary) !important;
}

html[data-theme="dark"] .smart-filter-tag,
html[data-theme="dark"] .adm-queue-filter,
html[data-theme="dark"] :where(.tag,.chip,.pill,.filter-chip) {
    background: #1A292F !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

/* Auth */
html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(circle at 8% 12%, rgba(88, 171, 200, .09), transparent 28%),
        var(--bg-page) !important;
}

html[data-theme="dark"] .auth-card {
    background: var(--surface) !important;
    border-color: var(--border-soft) !important;
    color: var(--text) !important;
    box-shadow: 0 18px 48px rgba(0,0,0,.28) !important;
}

html[data-theme="dark"] .auth-brand {
    border-radius: 8px;
}

html[data-theme="dark"] .auth-theme-toggle {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .password-toggle {
    color: var(--text-secondary) !important;
}

/* Scrollbars */
html[data-theme="dark"] * {
    scrollbar-color: #3B515A #111D22;
}

html[data-theme="dark"] *::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html[data-theme="dark"] *::-webkit-scrollbar-track {
    background: #111D22;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background: #3B515A;
    border: 2px solid #111D22;
    border-radius: 999px;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
    background: #4C6671;
}

/* Usuários: mantém a célula de ações como célula de tabela.
   A classe global .actions usa flex para toolbars; aplicada diretamente no TD,
   ela quebra a continuidade das bordas horizontais da tabela. */
.users-page .table td.actions {
    display: table-cell;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}
.users-page .table td.actions > a {
    display: inline-block;
    margin-left: 10px;
}
.users-page .table td.actions > a:first-child {
    margin-left: 0;
}
.users-page .table th:last-child {
    text-align: right;
}

/* V7 consolidada - controle reutilizável para mostrar/ocultar senha */
.password-field {
    position: relative;
    display: block;
}
.password-field > input {
    width: 100%;
    padding-right: 48px !important;
}
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--brand-slate, #516266);
    cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
    color: var(--brand-primary, #257A98);
    background: var(--surface-soft, #EEF6F8);
    outline: none;
}
.password-toggle svg,
.password-toggle .password-icon {
    width: 20px;
    height: 20px;
}
.password-toggle .password-icon-visible { display: none !important; }
.password-toggle .password-icon-hidden { display: block !important; }
.password-toggle[aria-pressed="true"] .password-icon-visible { display: block !important; }
.password-toggle[aria-pressed="true"] .password-icon-hidden { display: none !important; }
