/**
 * UI v2 — Tema profissional e responsivo (Indústria ERP)
 */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,400;0,6..12,500;0,6..12,600;0,6..12,700;1,6..12,400&display=swap');

:root {
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --primary-rgb: 13, 148, 136;
    --secondary: #0f172a;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0284c7;
    --dark: #0f172a;
    --light: #f8fafc;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --sidebar-width: 272px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.bg-pattern {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.03) 0%, transparent 50%),
                radial-gradient(ellipse at 100% 0%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
                var(--bg);
    opacity: 1;
    background-size: auto;
    background-image: none;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    box-shadow: var(--shadow-lg);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header::after {
    display: none;
}

.sidebar-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-section {
    padding: 1.25rem 1.25rem 0.35rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.35);
}

.nav-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-group:last-child {
    border-bottom: none;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: calc(100% - 1rem);
    margin: 0.35rem 0.5rem 0;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}

.nav-group-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
}

.nav-group.is-open > .nav-group-toggle {
    color: rgba(255, 255, 255, 0.9);
}

.nav-group-chevron {
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform var(--transition);
    opacity: 0.75;
}

.nav-group.is-open > .nav-group-toggle .nav-group-chevron {
    transform: rotate(45deg);
}

.nav-submenu {
    display: none;
    padding: 0.15rem 0 0.5rem;
}

.nav-group.is-open > .nav-submenu {
    display: block;
}

.nav-submenu .nav-item {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    padding-left: 0.85rem;
    font-size: 0.8125rem;
}

.nav-item {
    padding: 0.65rem 1rem;
    margin: 0.125rem 0.75rem;
    border-radius: var(--radius-sm);
    border-left: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.72);
    transition: background var(--transition), color var(--transition);
}

.nav-item::before {
    display: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding-left: 1rem;
}

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.2);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary-light);
}

.nav-item .icon {
    font-size: 1.05rem;
    width: 1.35rem;
    opacity: 0.9;
}

.topbar {
    min-height: var(--header-height);
    padding: 0 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
}

.topbar-left {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.topbar-left h1,
.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.topbar-left h1::after,
.topbar h1::after {
    display: none;
}

.btn-sidebar-toggle {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--gray);
}

.btn-sidebar-toggle:hover {
    background: rgba(var(--primary-rgb), 0.08);
    border-color: rgba(var(--primary-rgb), 0.35);
    color: var(--primary-dark);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.875rem 0.35rem 0.35rem;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    flex-shrink: 0;
    max-width: min(280px, 42vw);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar--photo {
    background: var(--surface-muted, #e2e8f0);
}

.user-avatar--photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.usuario-avatar-section {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.usuario-avatar-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    border: 3px solid var(--border, #e2e8f0);
}

.usuario-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.usuario-avatar-inicial {
    line-height: 1;
}

.usuario-avatar-fields {
    flex: 1;
    min-width: 0;
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    color: var(--gray, #64748b);
    font-size: 0.8125rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.user-details strong {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-details small {
    font-size: 0.6875rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 0.75rem;
    margin-left: auto;
}

.topbar-right .btn-danger {
    flex-shrink: 0;
    white-space: nowrap;
}

.content {
    padding: 1.5rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.stat-card {
    background: var(--surface);
    padding: 1.25rem 1.35rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card::before {
    display: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--dark);
}

.stats-grid {
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.card::before {
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.card-header {
    padding: 1rem 1.25rem;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    background: var(--light);
    border-top: 1px solid var(--border);
}

.dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 1.25rem;
}

.home-empresa-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem 1.75rem;
}

.home-empresa-info h2 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.form-control {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 0.35rem;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.btn:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.4);
}

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }

.btn-outline {
    background: var(--surface);
    color: var(--secondary);
    border-color: var(--border-strong);
}

.btn-outline:hover {
    background: var(--light);
    border-color: var(--gray-light);
}

.table-container {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll table {
    min-width: 640px;
}

.table-toolbar {
    padding: 1rem 1.25rem;
    background: var(--light);
    border-bottom: 1px solid var(--border);
}

.table-container table thead,
table thead {
    background: var(--secondary);
}

.table-container table th,
table th {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 0.875rem 1rem;
    border-bottom: none;
    white-space: nowrap;
}

.table-container table td,
table td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table-container table tbody tr:last-child td,
table tbody tr:last-child td {
    border-bottom: none;
}

.table-container table tbody tr:hover,
table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.04);
}

.search-box input[type="text"] {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    min-width: 180px;
}

.badge {
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
}

.content > .alert-flash-success,
.content > .alert-flash-error {
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.log-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.log-filtros select,
.log-filtros input[type="date"],
.log-filtros input[type="text"] {
    min-width: 140px;
}

.log-table .log-data {
    white-space: nowrap;
}

.log-detalhe-row td {
    background: #f8fafc;
    padding-top: 0;
}

.log-detalhe-vazio {
    padding: 0.75rem 0 1rem;
    margin: 0;
}

.log-alteracoes {
    width: 100%;
    margin: 0.75rem 0 1rem;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.log-alteracoes th,
.log-alteracoes td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.log-alteracoes th {
    background: #fff;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
}

.log-valor-antigo {
    color: #b91c1c;
}

.log-valor-novo {
    color: #047857;
}

.log-paginacao {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 1rem;
    justify-content: center;
}

.bom-custos-card {
    margin-bottom: 1.25rem;
}

.bom-custos-resumo {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
}

.bom-custo-linha {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.bom-custo-valor {
    font-size: 1.125rem;
    white-space: nowrap;
}

.bom-custos-intro {
    font-size: 0.875rem;
    color: #475569;
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.bom-custos-guia {
    margin-bottom: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    background: #f8fafc;
}

.bom-custos-guia summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: #334155;
    list-style: none;
}

.bom-custos-guia summary::-webkit-details-marker {
    display: none;
}

.bom-custos-guia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
    padding: 0 1rem 1rem;
}

.bom-custos-guia-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.bom-custos-guia-item h4 {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bom-custos-guia-item p {
    margin: 0 0 0.35rem;
    color: #64748b;
}

.bom-custos-guia-calculo {
    color: #0f766e !important;
}

.bom-custo-sigla {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: #e0f2fe;
    color: #0369a1;
}

.bom-custo-sigla--inline {
    margin-left: 0.35rem;
    vertical-align: middle;
}

.bom-custos-campos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.bom-custo-campo label {
    display: block;
    margin-bottom: 0.35rem;
}

.bom-custo-hint {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
    margin-top: 0.35rem;
}

.bom-custo-exemplo {
    display: block;
    font-size: 0.7rem;
    color: #0f766e;
    margin-top: 0.25rem;
    line-height: 1.35;
}

.bom-custos-total h4 {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    color: #334155;
}

.bom-custos-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #e2e8f0;
}

.bom-custos-tabela {
    width: 100%;
    max-width: 420px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.bom-custos-tabela td {
    padding: 0.35rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.bom-custos-tabela .text-right {
    text-align: right;
}

.bom-custos-total-linha td {
    border-bottom: none;
    padding-top: 0.75rem;
    font-size: 1rem;
}

.alert-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-left: 4px solid #10b981;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #3b82f6;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
}

.modal-card,
.app-dialog-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.sidebar-overlay {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}

.login-page {
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #0f766e 100%);
    padding: 1.25rem;
}

.login-page::before {
    opacity: 0.4;
}

.login-box {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    border-top: none;
    padding: 2.5rem 2rem;
    max-width: 440px;
}

.login-box h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.login-box h1:not(.login-brand-name) {
    color: var(--primary);
    text-align: center;
    margin-bottom: 10px;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-box h2 {
    font-size: 0.875rem;
    color: var(--gray);
    margin-bottom: 1.75rem;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.login-logo .logo-mark,
.login-logo .logo-mark.has-img {
    width: 72px;
    height: 72px;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.login-logo .logo-mark.has-img img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.login-brand-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.25;
    text-align: center;
}

.login-brand-tagline {
    font-size: 0.875rem;
    color: var(--gray);
    margin: 0;
    line-height: 1.4;
    text-align: center;
}

.login-box h1.login-brand-name {
    display: block;
    flex-direction: unset;
    gap: unset;
    color: var(--dark);
    font-size: 1.35rem;
    margin-bottom: 0;
}

.login-box .login-brand h2,
.login-box .login-brand-tagline {
    margin-bottom: 0;
}

.login-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.35rem;
    text-align: center;
}

.login-panel-desc {
    font-size: 0.875rem;
    color: var(--gray);
    text-align: center;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.login-footer-link {
    text-align: center;
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary-dark);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:hover {
    color: var(--primary);
}

.login-panel[hidden] {
    display: none !important;
}

/* Campo senha com botão olho */
.input-password-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-password-wrap .form-control {
    padding-right: 2.75rem;
    width: 100%;
}

.btn-toggle-password {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: color var(--transition), background var(--transition);
}

.btn-toggle-password:hover {
    color: var(--primary-dark);
    background: rgba(var(--primary-rgb), 0.06);
}

.btn-toggle-password:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.btn-toggle-password.is-visible {
    color: var(--primary);
}

.btn-toggle-password svg {
    display: block;
    flex-shrink: 0;
}

.form-tab.active {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}

.toggle-field {
    border-radius: var(--radius-md);
    border-color: var(--border);
    background: var(--light);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.hide-mobile { display: initial; }
.show-mobile { display: none; }

@media (max-width: 1200px) {
    .content { padding: 1.25rem; }
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 1024px) {
    :root { --sidebar-width: 260px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 1.25rem; }
    .user-chip { max-width: min(240px, 50vw); }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .search-box { width: 100%; }
    .search-box input[type="text"] { flex: 1; min-width: 0; }
    .table-toolbar > .btn,
    .table-toolbar > a.btn { width: 100%; justify-content: center; }
}

@media (max-width: 768px) {
    .sidebar {
        width: min(var(--sidebar-width), 88vw);
        z-index: 200;
    }

    body:not(.sidebar-collapsed) .sidebar-overlay {
        display: block;
    }

    .topbar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .topbar-left {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .topbar-left h1,
    .topbar h1 {
        font-size: 1.05rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .topbar-right {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: nowrap;
        max-width: 100%;
    }

    .user-chip {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
    }
    .content { padding: 1rem; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.25rem; }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header > div,
    .card-header > a { width: 100%; }

    .card-header .btn { width: 100%; justify-content: center; }
    .card-footer { flex-direction: column; }
    .card-footer .btn { width: 100%; justify-content: center; }
    .form-row { grid-template-columns: 1fr; }

    .home-empresa-banner {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem;
    }

    .quick-actions { flex-direction: column; }
    .quick-actions .btn { width: 100%; justify-content: center; }
    .actions { white-space: normal; }
    .actions .btn { margin: 0.125rem; }
    .modal-card { max-height: 90vh; overflow-y: auto; }
    .app-dialog-card { margin: 0.5rem; }
    .vendas-vendedor-frete-row { grid-template-columns: 1fr; }
    .login-box { padding: 1.75rem 1.25rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }

    .user-chip {
        padding: 0.35rem 0.65rem 0.35rem 0.35rem;
    }

    .topbar-right .btn-danger {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }
}

@media (hover: none) and (pointer: coarse) {
    .btn, .nav-item, .form-control, .btn-sidebar-toggle { min-height: 44px; }
    .btn-sm { min-height: 38px; padding: 0.5rem 0.75rem; }
    .nav-item { padding: 0.75rem 1rem; }
}

.table-scroll::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-scroll::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.card-body .table-scroll,
.table-container .table-scroll {
    margin: 0;
}

/* RH */
.form-section-title {
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text, #1e293b);
}

.form-section-title:first-child {
    margin-top: 0;
}

.table-empty {
    text-align: center;
    padding: 2rem;
    color: var(--gray, #64748b);
}

.rh-dashboard .stats-grid {
    margin-bottom: 1.5rem;
}

.stat-card--warning {
    border-left: 3px solid var(--warning, #f59e0b);
}

.rh-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.rh-link-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.rh-link-card:hover {
    border-color: var(--primary, #0d9488);
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
}

.rh-link-icon {
    font-size: 1.5rem;
}

.rh-link-card small {
    color: var(--gray, #64748b);
    font-size: 0.8125rem;
}
