:root {
    /* Premium Palette */
    --primary-color: #0F172A;
    /* Deep Navy */
    --secondary-color: #334155;
    /* Slate */
    --accent-color: #38BDF8;
    /* Sky Blue */
    --accent-hover: #0EA5E9;
    --success-color: #10B981;
    /* Emerald */
    --danger-color: #EF4444;
    /* Red */
    --warning-color: #F59E0B;
    /* Amber */

    --bg-color: #F8FAFC;
    /* Very Light Slate */
    --card-bg: #FFFFFF;

    --text-main: #1E293B;
    --text-muted: #64748B;
    --text-light: #F1F5F9;

    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

[data-theme="dark"] {
    --primary-color: #0F172A;
    --secondary-color: #1E293B;
    --accent-color: #38BDF8;
    --bg-color: #020617;
    /* Slate 950 */
    --card-bg: #1E293B;
    /* Slate 800 */

    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --text-light: #F8FAFC;

    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 64px;
    --sidebar-bg: #0A0F1E;
    --sidebar-border: rgba(56, 189, 248, 0.08);
    --sidebar-item-hover: rgba(56, 189, 248, 0.08);
    --sidebar-item-active: rgba(56, 189, 248, 0.12);
    --sidebar-text: #94A3B8;
    --sidebar-text-active: #F1F5F9;
    --sidebar-accent: #38BDF8;
    --sidebar-transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --content-transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--sidebar-transition);
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 64px;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand-logo {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.sidebar-brand-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--sidebar-text-active);
    letter-spacing: 0.05em;
    transition: opacity 0.2s ease;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(148, 163, 184, 0.5);
    padding: 0.25rem 0.75rem;
    margin: 0.5rem 0 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 0.5rem 0.75rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 2px;
}

.sidebar-item i {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.sidebar-item span {
    transition: opacity 0.15s ease;
    overflow: hidden;
}

.sidebar-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
    transform: translateX(2px);
}

.sidebar-item.active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-accent);
    font-weight: 600;
}

.sidebar-item.active i {
    color: var(--sidebar-accent);
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--sidebar-accent);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

/* Footer */
.sidebar-footer {
    padding: 0.75rem 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: var(--sidebar-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    flex: 1;
    transition: opacity 0.15s ease;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sidebar-text-active);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.65rem;
    color: rgba(148, 163, 184, 0.6);
    text-transform: capitalize;
    white-space: nowrap;
}

.sidebar-footer-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.sf-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sf-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--sidebar-accent);
}

/* Collapse button */
.sidebar-collapse-btn {
    position: absolute;
    right: -12px;
    top: 72px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    transition: all 0.15s ease;
    z-index: 10;
}

.sidebar-collapse-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* COLLAPSED STATE */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-item span,
.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 0.6rem;
    gap: 0;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer-actions {
    flex-direction: column;
}

/* Tooltip on collapsed items */
.sidebar.collapsed .sidebar-item {
    overflow: visible;
}

.sidebar.collapsed .sidebar-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed-w) - 4px);
    top: 50%;
    transform: translateY(-50%);
    background: #1E293B;
    color: #F1F5F9;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    white-space: nowrap;
    border: 1px solid #334155;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
}

.sidebar.collapsed .sidebar-item:hover::after {
    opacity: 1;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    padding: 2rem;
    transition: var(--content-transition);
    max-width: 1400px;
    width: calc(100% - var(--sidebar-w));
    box-sizing: border-box;
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed-w);
    width: calc(100% - var(--sidebar-collapsed-w));
}

/* NOTE: we use JS class toggling, so we handle collapsed via JS-applied class on sidebar */
/* This catches the case when sidebar has collapsed class */
body:has(.sidebar.collapsed) .main-content {
    margin-left: var(--sidebar-collapsed-w);
    width: calc(100% - var(--sidebar-collapsed-w));
}

/* Mobile */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 900;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-main);
    cursor: pointer;
    font-size: 1.1rem;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Auth layout (no sidebar) */
.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-flash {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 300px;
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 1rem 0;
    /* Remove horizontal padding from full bar, handle in inner container */
    display: flex;
    justify-content: center;
    /* Center the inner content */
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1000;
}

.navbar-container {
    width: 95%;
    max-width: 1400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Mobile Menu Toggle (Hidden by default) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.btn-logout {
    color: rgba(255, 255, 255, 0.7);
    /* Should be light in navbar */
    font-size: 1.1rem;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.btn-logout:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Desktop Menu Wrapper */
.nav-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-grow: 1;
    margin-left: 2rem;
}

/* Desktop Links */
.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s, transform 0.2s;
    font-size: 0.95rem;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-color);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

/* User Actions Section */
.nav-user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    /* ~24px spacing as requested */
    white-space: nowrap;
    margin-left: 2rem;
    /* Add separation from links */
}

.user-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    /* Pill shape */
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Container (legacy — kept for compatibility with page-level layouts) */
.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    flex: 1;
}

/* Auth Pages - Premium Redesign */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 85vh;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.05) 0%, transparent 70%);
}

.premium-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.5);
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .premium-card {
    background: rgba(30, 41, 59, 0.85);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.premium-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px -12px rgba(56, 189, 248, 0.15);
}

.brand-logo {
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    filter: drop-shadow(0 4px 6px rgba(56, 189, 248, 0.2));
}

.premium-card h2 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.025em;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

/* Bot\u00e3o de tema flutuante nas p\u00e1ginas de auth (login / forgot-password) */
.auth-theme-btn {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid rgba(56, 189, 248, 0.3);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--accent-color);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-theme-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
}

:root:not([data-theme="dark"]) .auth-theme-btn {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.auth-footer a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: all 0.25s ease;
    /* Cores fixas — anulam o visited purple do browser */
    color: var(--accent-color) !important;
    background: rgba(56, 189, 248, 0.08);
    border: 1.5px solid rgba(56, 189, 248, 0.25);
}

.auth-footer a:hover {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
    color: var(--accent-color) !important;
}

.auth-footer a:active {
    transform: translateY(0);
    box-shadow: none;
    color: var(--accent-color) !important;
}

.auth-footer a:visited {
    color: var(--accent-color) !important;
}

[data-theme="dark"] .auth-footer a {
    background: rgba(56, 189, 248, 0.06);
    border-color: rgba(56, 189, 248, 0.2);
}

[data-theme="dark"] .auth-footer a:hover {
    background: rgba(56, 189, 248, 0.15);
}


/* Premium Inputs */
.premium-input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.premium-input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    z-index: 2;
    transition: color 0.3s ease;
}

.premium-input-group .form-control {
    padding: 0.9rem 1rem 0.9rem 3rem;
    /* Space for icon */
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    transition: all 0.3s ease;
    font-size: 1rem;
    color: var(--text-main);
}

[data-theme="dark"] .premium-input-group .form-control {
    color: #ffffff;
    background: rgba(15, 23, 42, 0.6);
}

/* Cancela o autofill azul do browser nas caixas de login */
.premium-input-group .form-control:-webkit-autofill,
.premium-input-group .form-control:-webkit-autofill:hover,
.premium-input-group .form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: #ffffff;
    -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.8) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.premium-input-group .form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
    background: var(--card-bg);
}

.premium-input-group .form-control:focus+.input-icon,
.premium-input-group:focus-within .input-icon {
    color: var(--accent-color);
}

/* Password Toggle */
.password-toggle {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--accent-color);
}

/* Login Button */
.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.25);
    transition: all 0.3s ease;
}

.btn-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(56, 189, 248, 0.35);
    filter: brightness(1.1);
}

.btn-block:active {
    transform: translateY(0);
}

/* Forms */
.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
    /* To ensure padding doesn't affect width */
}

.form-control:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
}

.btn-primary:hover {
    filter: brightness(110%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #DC2626);
    color: white;
}

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

/* Tables */
.table-container {
    background: var(--card-bg);
    padding: 0;
    /* Remove padding for edge-to-edge look */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    /* rounded corners for table */
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    white-space: nowrap;
    /* Prevent wrapping in cells */
}

th,
td {
    padding: 1rem 1.5rem;
    text-align: left;
    /* Better readability */
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-main);
    font-size: 0.95rem;
}

th {
    background-color: var(--bg-color);
    /* Light gray header */
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: rgba(241, 245, 249, 0.5);
    /* Subtle hover */
}

[data-theme="dark"] tr:hover {
    background-color: rgba(30, 41, 59, 0.5);
}

/* Status Badges */
.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-pending {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.status-confirmed,
.status-inprogress {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
}

.status-completed,
.status-shipped {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-cancelled {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    /* Space between buttons */
    align-items: center;
    max-width: 140px;
    /* Constrain width to keep buttons closer */
    margin: 0 auto;
    /* Center the container */
}

.action-buttons .btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    /* Remove padding to rely on dimensions */
    width: 38px;
    /* Fixed width */
    height: 38px;
    /* Fixed height for consistency */
    border-radius: 4px;
    font-size: 1rem;
    /* Same font size */
    line-height: 1;
    /* Reset line height */
}

/* .action-buttons .btn-primary and .btn-danger removed as they were empty */

/* Form Layout */
.form-row {
    display: flex;
    gap: 15px;
    /* Space between columns */
    margin-bottom: 1.2rem;
}

.form-row .form-group {
    flex: 1;
    /* Equal width columns */
    margin-bottom: 0;
    /* Remove bottom margin inside row */
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}

/* Utilities */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

[data-theme="dark"] .card:hover {
    background-color: var(--secondary-color);
}

.card i {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    background: rgba(56, 189, 248, 0.1);
    padding: 1rem;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card h3 {
    margin: 0.5rem 0;
    color: var(--text-main);
    font-weight: 600;
}

.card p {
    color: var(--text-muted);
}

.card a {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--accent-color);
    font-weight: 600;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(56, 189, 248, 0.1);
    transition: background 0.2s;
}

.card a:hover {
    background: rgba(56, 189, 248, 0.2);
}

/* Modal Styles */
/* Premium Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
    background: #ffffff;
    margin: auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.8);
    width: 90%;
    max-width: 500px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: visible;
    /* Changed to allow close button overflow if needed, but visible might be bad for large content. set to hidden usually. */
}

/* Specific content adjustments */
.modal-content {
    overflow: hidden;
    /* Keep hidden for border radius */
}

[data-theme="dark"] .modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header {
    background: #ffffff;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-theme="dark"] .modal-header {
    background: var(--card-bg);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.close-btn {
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    line-height: 1;
    position: static;
    /* Reset absolute positioning */
}

.close-btn:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

.modal-body p {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.item-details {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    margin-top: 1rem;
}

.item-details p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.item-details strong {
    color: var(--text-main);
    font-weight: 600;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

[data-theme="dark"] .modal-footer {
    background: rgba(0, 0, 0, 0.2);
}

/* Premium Form Styles in Modal */
.modal .form-group {
    margin-bottom: 1.5rem;
}

.modal label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.95rem;
}

.modal .form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: var(--bg-color);
    color: var(--text-main);
}

.modal .form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.modal button[type="submit"] {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.modal button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile Sidebar
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-w));
        transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--sidebar-w) !important;
        /* Always full width on mobile */
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem;
        padding-top: 4rem;
        /* space for hamburger */
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .form-group {
        width: 100%;
        min-width: 100%;
    }

    /* Tabs */
    .tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 10px 15px;
    }

    .btn-save {
        margin-left: 0;
        width: 100%;
        margin-top: 10px;
    }

    .table-container {
        padding: 1rem;
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    .header-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .nav-links {
        gap: 0.75rem;
    }

    .nav-links a {
        font-size: 0.9rem;
    }

    .nav-menu {
        margin-left: 1rem;
    }
}

@media (max-width: 1024px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    /* Keep previous adjustments or refine if needed, but 992px will handle the big switch */
}

@media (max-width: 992px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    .menu-toggle {
        display: block;
        color: var(--text-light);
    }

    /* Hide the entire menu wrapper on mobile */
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        flex-direction: column;
        background-color: var(--primary-color);
        padding: 1rem 0;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 999;
        margin-left: 0;
        /* Reset desktop margin */
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .nav-links li {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-links li:last-child {
        border-bottom: none;
        margin-top: 0;
    }

    .nav-links a {
        display: block;
        padding: 0.75rem 2rem;
        color: var(--text-muted);
        text-align: center;
    }

    .nav-links a:hover,
    .nav-links a.active {
        background: rgba(255, 255, 255, 0.05);
        color: var(--accent-color);
    }

    /* Mobile User Actions */
    .nav-user-actions {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(0, 0, 0, 0.2);
    }

    .user-badge {
        display: inline-block;
        margin: 0;
    }

    .btn-logout {
        display: inline-flex;
        margin-bottom: 0.5rem;
        background: transparent;
        color: white;
        font-size: 1.25rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .btn-logout:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: scale(1.1);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }

    /* Forms */
    .form-row {
        flex-direction: column;
        /* Stack columns */
        gap: 10px;
    }

    .form-group {
        width: 100%;
        min-width: 100%;
    }

    /* Tabs */
    .tabs-nav {
        flex-wrap: nowrap;
        /* Prevent wrapping if we want horizontal scroll */
        overflow-x: auto;
        padding-bottom: 5px;
        /* Space for scrollbar */
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    .tabs-nav::-webkit-scrollbar {
        height: 6px;
    }

    .tabs-nav::-webkit-scrollbar-thumb {
        background-color: var(--accent-color);
        border-radius: 3px;
    }

    .tab-btn {
        flex: 0 0 auto;
        /* Don't shrink */
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 10px 15px;
        /* Larger touch target */
    }

    .btn-save {
        margin-left: 0;
        /* Align with others */
        width: 100%;
        /* Full width save button */
        margin-top: 10px;
    }

    /* Tables */
    .table-container {
        padding: 1rem;
        overflow-x: auto;
        /* Ensure horizontal scroll */
    }

    table {
        min-width: 600px;
        /* Force scroll for small screens */
    }

    /* Header Actions */
    .header-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions .view-toggles {
        width: 100%;
        display: flex;
    }

    .btn-toggle {
        flex: 1;
        /* Equal width toggles */
        text-align: center;
    }

    }

    /* Cards */
    .dashboard-grid {
        grid-template-columns: 1fr;
        /* Single column */
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT MODE OVERRIDES — Contraste e Legibilidade
   ═══════════════════════════════════════════════════════════════════════════ */

:root:not([data-theme="dark"]) {
    --text-main: #0F172A;      /* Slate 900 — máximo contraste */
    --text-muted: #475569;     /* Slate 600 — subtítulos legíveis */
    --border-color: #CBD5E1;   /* Slate 300 — bordas visíveis */
    --bg-color: #F1F5F9;       /* Slate 100 — fundo levemente cinza */
    --card-bg: #FFFFFF;
}

/* ── Fundo geral e body ───────────────────────────────────────── */
:root:not([data-theme="dark"]) body {
    background-color: #F1F5F9;
    color: #0F172A;
}

/* ── Table container ─────────────────────────────────────────── */
:root:not([data-theme="dark"]) .table-container {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* ── Cabeçalho da tabela ─────────────────────────────────────── */
:root:not([data-theme="dark"]) th {
    background-color: #F8FAFC;
    color: #334155;
    border-bottom: 2px solid #CBD5E1;
}

/* ── Células ─────────────────────────────────────────────────── */
:root:not([data-theme="dark"]) td {
    color: #1E293B;
    border-bottom-color: #E2E8F0;
}

/* ── Links de pedido (ORDER NO) ──────────────────────────────── */
:root:not([data-theme="dark"]) table a {
    color: #0369A1;
    font-weight: 600;
    text-decoration: none;
}
:root:not([data-theme="dark"]) table a:hover {
    color: #0284C7;
    text-decoration: underline;
}

/* ── Texto de buyer / seller / produto na tabela ─────────────── */
:root:not([data-theme="dark"]) td,
:root:not([data-theme="dark"]) td span {
    color: #1E293B;
}

/* ── Hover de linha ──────────────────────────────────────────── */
:root:not([data-theme="dark"]) tr:hover {
    background-color: #EFF6FF;
}

/* ── Status badges na tabela ─────────────────────────────────── */
:root:not([data-theme="dark"]) .status-badge {
    font-weight: 700;
}

/* NEW / Pending */
:root:not([data-theme="dark"]) .status-badge[style*="background"] {
    border: 1px solid currentColor;
    opacity: 1;
}

/* ── Filtros de status (pills acima da tabela) ───────────────── */
:root:not([data-theme="dark"]) .filter-pill,
:root:not([data-theme="dark"]) .status-filter,
:root:not([data-theme="dark"]) .tab-filter {
    font-weight: 600;
    opacity: 1;
}

/* Garantir legibilidade de qualquer badge inline que use rgba apagado */
:root:not([data-theme="dark"]) .status-badge {
    filter: saturate(1.3) brightness(0.85);
}

/* ── Barra de busca e input ──────────────────────────────────── */
:root:not([data-theme="dark"]) input[type="text"],
:root:not([data-theme="dark"]) input[type="search"],
:root:not([data-theme="dark"]) select,
:root:not([data-theme="dark"]) textarea {
    background: #FFFFFF;
    color: #0F172A;
    border-color: #94A3B8;
}
:root:not([data-theme="dark"]) input::placeholder,
:root:not([data-theme="dark"]) textarea::placeholder {
    color: #94A3B8;
}

/* ── Page title / subtítulo ──────────────────────────────────── */
:root:not([data-theme="dark"]) h1,
:root:not([data-theme="dark"]) h2,
:root:not([data-theme="dark"]) h3,
:root:not([data-theme="dark"]) h4 {
    color: #0F172A;
}

/* ── Contagem (189 PEDIDO(S)) ────────────────────────────────── */
:root:not([data-theme="dark"]) .records-count,
:root:not([data-theme="dark"]) .total-count,
:root:not([data-theme="dark"]) [class*="count"] {
    color: #475569;
    font-weight: 600;
}

/* ── Paginação ───────────────────────────────────────────────── */
:root:not([data-theme="dark"]) .pagination a,
:root:not([data-theme="dark"]) .pagination span,
:root:not([data-theme="dark"]) .page-link {
    color: #1E293B;
    border-color: #CBD5E1;
    background: #FFFFFF;
}
:root:not([data-theme="dark"]) .pagination .active,
:root:not([data-theme="dark"]) .page-link.active {
    background: #0EA5E9;
    color: #FFFFFF;
    border-color: #0EA5E9;
}

/* ── Botões secundários ──────────────────────────────────────── */
:root:not([data-theme="dark"]) .btn-secondary {
    background: #F8FAFC;
    color: #1E293B;
    border: 1px solid #CBD5E1;
}
:root:not([data-theme="dark"]) .btn-secondary:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

/* ── Header da página (título + botões) ──────────────────────── */
:root:not([data-theme="dark"]) .main-content {
    background-color: #F1F5F9;
}

/* ── Card do Dashboard ───────────────────────────────────────── */
:root:not([data-theme="dark"]) .card {
    background: #FFFFFF;
    border-color: #CBD5E1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07);
}
:root:not([data-theme="dark"]) .card h3 {
    color: #0F172A;
}
:root:not([data-theme="dark"]) .card p {
    color: #475569;
}