/* ==========================================================================
   TRT Gestao - Transport Management System
   Light Theme - Production CSS
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ==========================================================================
   1. CSS Reset & Custom Properties
   ========================================================================== */

:root {
    /* Core palette — Windland brand light theme */
    --bg-primary: #cbd5e1;
    --bg-secondary: #edf0f4;
    --bg-tertiary: #e4e8ee;
    --bg-elevated: #ffffff;

    /* Accent — Windland orange */
    --accent: #F7941D;
    --accent-hover: #E8820A;
    --accent-light: rgba(247, 148, 29, 0.08);
    --accent-glow: rgba(247, 148, 29, 0.2);

    /* Borders */
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --border-focus: #F7941D;

    /* Text */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-tertiary: #a0aec0;
    --text-inverse: #ffffff;

    /* Status indicators */
    --success: #2e7d32;
    --danger: #ef4444;
    --warning: #FFAA44;
    --info: #1565c0;
    --success-bg: rgba(46, 125, 50, 0.08);
    --danger-bg: rgba(239, 68, 68, 0.08);
    --warning-bg: rgba(255, 170, 68, 0.08);
    --info-bg: rgba(21, 101, 192, 0.08);

    /* Typography */
    --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Sizing */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows — lighter for white theme */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);
    --shadow-accent: 0 4px 14px rgba(247, 148, 29, 0.2);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Z-index layers */
    --z-sidebar: 100;
    --z-header: 90;
    --z-dropdown: 200;
    --z-modal-backdrop: 300;
    --z-modal: 310;
    --z-flash: 400;
    --z-tooltip: 500;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

ul, ol {
    list-style: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

::selection {
    background: var(--accent);
    color: var(--text-inverse);
}

/* ==========================================================================
   2. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-ui);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 0.5em;
}

h1 { font-size: 1.875rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.text-mono {
    font-family: var(--font-mono);
}

.text-sm { font-size: 0.75rem; }
.text-base { font-size: 0.875rem; }
.text-lg { font-size: 1rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* ==========================================================================
   3. Login Page
   ========================================================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-tertiary);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(247, 148, 29, 0.04) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(21, 101, 192, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    position: relative;
    z-index: 1;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
    animation: fadeUp 0.5s ease forwards;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.login-card .login-logo h1 .accent {
    color: var(--accent);
}

.login-card .login-logo p {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.login-card .login-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-align: center;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.75rem;
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.login-card .btn-login {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.login-card .login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.login-card .login-footer a {
    color: var(--accent);
    font-weight: 500;
}

/* ==========================================================================
   4. Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-base);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #E8820A);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
}

.sidebar-logo-text .brand {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-logo-text .tagline {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-section {
    margin-bottom: 0.5rem;
}

.sidebar-section-title {
    padding: 0.5rem 1.5rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-link,
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-link:hover,
.nav-item:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

.sidebar-link.active,
.nav-item.active {
    color: var(--accent);
    background: var(--accent-light);
    border-left-color: var(--accent);
}

.sidebar-link .icon,
.nav-item .nav-icon,
.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active .icon,
.nav-item.active .nav-icon {
    opacity: 1;
}

.sidebar-link .badge-nav,
.nav-item .badge {
    margin-left: auto;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.badge-live {
    background: var(--danger);
    color: #fff;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #F7941D, #FFAA44);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.sidebar-user-logout {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-user-logout svg {
    width: 16px;
    height: 16px;
}

.sidebar-user-logout:hover {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: var(--danger);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: calc(var(--z-sidebar) + 1);
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: calc(var(--z-sidebar) - 1);
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   4b. Top Bar
   ========================================================================== */

.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 48px;
    background: linear-gradient(135deg, #F7941D, #E8820A);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: var(--z-header);
    box-shadow: 0 2px 8px rgba(247, 148, 29, 0.2);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.topbar-subtitle {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
    font-weight: 400;
    margin-left: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-datetime {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

.topbar-user-name {
    font-size: 0.78rem;
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   4c. Footer
   ========================================================================== */

.app-footer {
    margin-left: var(--sidebar-width);
    height: 40px;
    background: linear-gradient(135deg, #F7941D, #E8820A);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.8);
}

.app-footer a { color: rgba(255,255,255,0.9); }
.app-footer a:hover { color: #fff; }

/* ==========================================================================
   5. Main Content Area
   ========================================================================== */

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 48px;
    min-height: calc(100vh - 48px - 40px);
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1;
    padding: 1.5rem 2rem 2rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ==========================================================================
   6. Top Bar / Header
   ========================================================================== */

.top-bar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.top-bar-breadcrumb a {
    color: var(--text-secondary);
}

.top-bar-breadcrumb a:hover {
    color: var(--text-primary);
}

.top-bar-breadcrumb .separator {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

.top-bar-breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-bar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}

.top-bar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.top-bar-btn .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-elevated);
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.live-indicator .dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: var(--radius-full);
    animation: pulse 2s infinite;
}

/* ==========================================================================
   7. Cards & Stat Cards
   ========================================================================== */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0;
}

.card-header .card-action {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

.card-body {
    /* intentionally minimal */
}

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

/* Stat / KPI cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    animation: fadeUp 0.4s ease forwards;
    opacity: 0;
}

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }
.stat-card:nth-child(6) { animation-delay: 0.25s; }

.stat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card-info {
    flex: 1;
    min-width: 0;
}

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.stat-card-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.stat-card-change {
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-card-change.positive {
    color: var(--success);
}

.stat-card-change.negative {
    color: var(--danger);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card-icon.green {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card-icon.red {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-card-icon.orange {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card-icon.blue {
    background: var(--info-bg);
    color: var(--info);
}

/* ==========================================================================
   8. Tables
   ========================================================================== */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
}

.table {
    width: 100%;
    font-size: 0.85rem;
}

.table thead th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.table thead th:first-child {
    border-top-left-radius: var(--radius-lg);
}

.table thead th:last-child {
    border-top-right-radius: var(--radius-lg);
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

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

.table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.015);
}

.table tbody tr:hover {
    background: rgba(0, 0, 0, 0.04);
}

.table tbody td {
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    vertical-align: middle;
}

.table .td-mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.table .td-secondary {
    color: var(--text-secondary);
}

.table .td-bold {
    font-weight: 600;
}

.table .td-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.table-action-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.table-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.table-action-btn.danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-tertiary);
}

.table-empty .icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* Sortable column header */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.table thead th.sortable:hover {
    color: var(--text-secondary);
}

.table thead th.sortable .sort-icon {
    margin-left: 0.3rem;
    opacity: 0.3;
}

.table thead th.sortable.asc .sort-icon,
.table thead th.sortable.desc .sort-icon {
    opacity: 1;
    color: var(--accent);
}

/* ==========================================================================
   9. Forms
   ========================================================================== */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-control:hover {
    border-color: var(--border-light);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    outline: none;
}

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-control.is-valid {
    border-color: var(--success);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    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='%238b949e' d='M6 8.825a.5.5 0 01-.354-.146l-3.5-3.5a.5.5 0 01.708-.708L6 7.618l3.146-3.147a.5.5 0 01.708.708l-3.5 3.5A.5.5 0 016 8.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    padding-right: 2.25rem;
    cursor: pointer;
}

select.form-control option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.3rem;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Checkbox / Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: var(--shadow-accent);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: var(--text-inverse);
    border-color: var(--warning);
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.btn-info {
    background: var(--info);
    color: #fff;
    border-color: var(--info);
}

.btn-info:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
}

.btn-group {
    display: inline-flex;
    gap: 0;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group .btn + .btn {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   10. Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.6;
    letter-spacing: 0.02em;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Fatura / Invoice states */
.badge-pago {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(14, 168, 134, 0.2);
}
.badge-pago .badge-dot { background: var(--success); }

.badge-pendente {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge-pendente .badge-dot { background: var(--warning); }

.badge-vencida {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge-vencida .badge-dot { background: var(--danger); }

.badge-emitida {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.badge-emitida .badge-dot { background: var(--info); }

.badge-rascunho {
    background: rgba(110, 118, 129, 0.1);
    color: var(--text-tertiary);
    border: 1px solid rgba(110, 118, 129, 0.2);
}
.badge-rascunho .badge-dot { background: var(--text-tertiary); }

/* Vehicle / asset states */
.badge-activo {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(14, 168, 134, 0.2);
}
.badge-activo .badge-dot { background: var(--success); }

.badge-manutencao {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge-manutencao .badge-dot { background: var(--warning); }

.badge-inactivo {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge-inactivo .badge-dot { background: var(--danger); }

/* Generic colour badges */
.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: rgba(139, 148, 158, 0.1);
    color: var(--text-secondary);
}

/* ==========================================================================
   11. Chart Containers
   ========================================================================== */

.chart-container {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0;
}

.chart-header .chart-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.chart-body {
    position: relative;
    width: 100%;
    min-height: 250px;
}

.chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   12. Progress Bars (Zone Revenue, etc.)
   ========================================================================== */

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.progress-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-item-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-item-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent), #10d4a4);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.progress-bar-fill.danger {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

.progress-bar-fill.warning {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.progress-bar-fill.info {
    background: linear-gradient(90deg, var(--info), #60a5fa);
}

.progress-bar-sm {
    height: 4px;
}

.progress-bar-lg {
    height: 12px;
}

/* ==========================================================================
   13. Pagination
   ========================================================================== */

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pagination-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.pagination .page-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.pagination .page-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination .page-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination .page-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

/* ==========================================================================
   14. Flash Messages
   ========================================================================== */

.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-flash);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 420px;
    width: 100%;
    pointer-events: none;
}

.flash-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-lg);
    animation: flashIn 0.35s ease forwards;
    pointer-events: all;
}

.flash-message.removing {
    animation: flashOut 0.3s ease forwards;
}

.flash-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.flash-body {
    flex: 1;
    min-width: 0;
}

.flash-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.flash-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.flash-close {
    color: var(--text-tertiary);
    font-size: 1rem;
    flex-shrink: 0;
    padding: 0.15rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.flash-close:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.flash-success {
    border-color: rgba(46, 125, 50, 0.25);
    background: rgba(46, 125, 50, 0.06);
}
.flash-success .flash-icon { color: var(--success); }
.flash-success .flash-title { color: var(--success); }

.flash-error {
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.06);
}
.flash-error .flash-icon { color: var(--danger); }
.flash-error .flash-title { color: var(--danger); }

.flash-warning {
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.06);
}
.flash-warning .flash-icon { color: var(--warning); }
.flash-warning .flash-title { color: var(--warning); }

.flash-info {
    border-color: rgba(21, 101, 192, 0.25);
    background: rgba(21, 101, 192, 0.06);
}
.flash-info .flash-icon { color: var(--info); }
.flash-info .flash-title { color: var(--info); }

/* ==========================================================================
   15. Modals
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-base);
}

.modal-backdrop.active .modal {
    transform: scale(1) translateY(0);
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-sm { max-width: 400px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ==========================================================================
   16. Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
    .content-wrapper {
        padding: 1.25rem 1.5rem;
    }

    .top-bar {
        padding: 0 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-topbar {
        left: 0;
        padding: 0 12px;
    }

    .topbar-hamburger {
        display: flex;
    }

    .topbar-subtitle {
        display: none;
    }

    .topbar-user-name {
        display: none;
    }

    .app-footer {
        margin-left: 0;
        padding: 0 12px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        margin-top: 48px;
        padding-top: 0;
    }

    .top-bar {
        padding: 0 1rem 0 3.5rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

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

    .stat-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .page-header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-wrapper {
        border-radius: var(--radius-md);
    }

    .modal {
        max-width: 100%;
        max-height: 85vh;
        margin: auto 0.5rem;
    }

    .flash-container {
        left: 1rem;
        max-width: calc(100% - 2rem);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .pagination-wrapper {
        flex-direction: column;
        align-items: center;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    /* Fix mobile nav icons — force small size */
    .nav-icon,
    .nav-item svg,
    .sidebar-link svg,
    .sidebar svg:not(.sidebar-brand svg) {
        width: 16px !important;
        height: 16px !important;
        max-width: 16px;
        max-height: 16px;
        flex-shrink: 0;
    }

    .nav-item,
    .sidebar-link {
        padding: 0.5rem 1.25rem;
        font-size: 0.8rem;
        gap: 0.6rem;
    }

    .nav-section-title {
        font-size: 0.6rem;
        padding: 0.4rem 1.25rem 0.3rem;
    }

    .sidebar-brand {
        padding: 1rem 1.25rem;
    }

    .sidebar-brand-name {
        font-size: 1rem;
    }

    .sidebar-user {
        padding: 0.75rem 1.25rem;
    }

    .sidebar-user-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.7rem;
    }
}

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

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

    .login-card {
        padding: 1.75rem;
    }

    .pagination .page-link {
        min-width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   17. Animations
   ========================================================================== */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

@keyframes flashIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes flashOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-up {
    animation: fadeUp 0.4s ease forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-spin {
    animation: spin 0.8s linear infinite;
}

/* Skeleton loading shimmer */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   18. Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
    background-clip: content-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    border: none;
}

/* ==========================================================================
   19. Toggle Switches
   ========================================================================== */

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 0.6rem;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-secondary);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.toggle-input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-input:checked + .toggle-slider::after {
    transform: translateX(20px);
    background: #fff;
}

.toggle-input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px var(--accent-light);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-sm .toggle-slider {
    width: 36px;
    height: 20px;
}

.toggle-sm .toggle-slider::after {
    width: 14px;
    height: 14px;
}

.toggle-sm .toggle-input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

/* ==========================================================================
   20. Search Input
   ========================================================================== */

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 0.85rem;
    color: var(--text-tertiary);
    font-size: 0.95rem;
    pointer-events: none;
    transition: color var(--transition-fast);
}

.search-input {
    width: 100%;
    padding: 0.6rem 0.85rem 0.6rem 2.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-input:hover {
    border-color: var(--border-light);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    outline: none;
}

.search-input:focus + .search-icon,
.search-input-wrapper:focus-within .search-icon {
    color: var(--accent);
}

.search-input-wrapper .search-clear {
    position: absolute;
    right: 0.6rem;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-tertiary);
    font-size: 0.8rem;
    transition: all var(--transition-fast);
    opacity: 0;
    pointer-events: none;
}

.search-input:not(:placeholder-shown) ~ .search-clear {
    opacity: 1;
    pointer-events: all;
}

.search-input-wrapper .search-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.search-input-wrapper .search-shortcut {
    position: absolute;
    right: 0.75rem;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

/* ==========================================================================
   21. Avatar
   ========================================================================== */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #F7941D, #FFAA44);
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
    text-transform: uppercase;
}

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

.avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 0.6rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

.avatar-xl {
    width: 64px;
    height: 64px;
    font-size: 1.25rem;
}

.avatar-gradient-1 { background: linear-gradient(135deg, #F7941D, #FFAA44); }
.avatar-gradient-2 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-gradient-3 { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.avatar-gradient-4 { background: linear-gradient(135deg, #ef4444, #ec4899); }
.avatar-gradient-5 { background: linear-gradient(135deg, #10b981, #0ea5e9); }

.avatar-group {
    display: flex;
    align-items: center;
}

.avatar-group .avatar {
    border: 2px solid var(--bg-elevated);
    margin-left: -0.5rem;
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

.avatar-group .avatar-more {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
}

/* ==========================================================================
   22. Utility Classes
   ========================================================================== */

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow-0 { flex-grow: 0; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-stretch { align-items: stretch; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.justify-content-start { justify-content: flex-start; }

/* Gap */
.gap-0 { gap: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Margin */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 0.75rem !important; }
.m-4 { margin: 1rem !important; }
.m-5 { margin: 1.25rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 0.75rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-5 { margin-top: 1.25rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.mt-8 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-5 { margin-bottom: 1.25rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }
.mb-8 { margin-bottom: 2rem !important; }

.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.ml-3 { margin-left: 0.75rem !important; }
.ml-4 { margin-left: 1rem !important; }
.ml-auto { margin-left: auto !important; }

.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 0.75rem !important; }
.mr-4 { margin-right: 1rem !important; }
.mr-auto { margin-right: auto !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 0.75rem !important; }
.p-4 { padding: 1rem !important; }
.p-5 { padding: 1.25rem !important; }
.p-6 { padding: 1.5rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 0.75rem !important; }
.pt-4 { padding-top: 1rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 0.75rem !important; }
.pb-4 { padding-bottom: 1rem !important; }

.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 0.25rem !important; }
.pl-2 { padding-left: 0.5rem !important; }
.pl-3 { padding-left: 0.75rem !important; }
.pl-4 { padding-left: 1rem !important; }

.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 0.25rem !important; }
.pr-2 { padding-right: 0.5rem !important; }
.pr-3 { padding-right: 0.75rem !important; }
.pr-4 { padding-right: 1rem !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

/* Text alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

/* Text colours */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-white { color: #fff !important; }
.text-muted { color: var(--text-tertiary) !important; }

/* Background colours */
.bg-primary { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-tertiary { background-color: var(--bg-tertiary) !important; }
.bg-accent { background-color: var(--accent) !important; }
.bg-success { background-color: var(--success-bg) !important; }
.bg-danger { background-color: var(--danger-bg) !important; }
.bg-warning { background-color: var(--warning-bg) !important; }
.bg-info { background-color: var(--info-bg) !important; }

/* Border */
.border { border: 1px solid var(--border) !important; }
.border-top { border-top: 1px solid var(--border) !important; }
.border-bottom { border-bottom: 1px solid var(--border) !important; }
.border-0 { border: none !important; }
.rounded { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* Width & Height */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.h-full { height: 100% !important; }
.min-h-screen { min-height: 100vh !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* Position */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.sticky { position: sticky !important; }

/* Visibility */
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }
.opacity-0 { opacity: 0 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-100 { opacity: 1 !important; }

/* Cursor */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }
.cursor-not-allowed { cursor: not-allowed !important; }

/* Text utilities */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-nowrap { white-space: nowrap !important; }
.text-break { word-break: break-word !important; }
.text-uppercase { text-transform: uppercase !important; }
.text-lowercase { text-transform: lowercase !important; }
.text-capitalize { text-transform: capitalize !important; }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-none { box-shadow: none !important; }

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

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

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* Tooltip (CSS-only, position: relative parent needed) */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 0.35rem 0.65rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    z-index: var(--z-tooltip);
    box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.35rem;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu,
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    width: 100%;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger-bg);
}

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0;
}

/* Tabs */
.tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    max-width: 360px;
}

/* ==========================================================================
   Alert Bar
   ========================================================================== */

.alert-bar {
    background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
    border: 1px solid #fbbf24;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.alert-bar-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.alert-bar-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-bar-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: #92400e;
}

.alert-bar-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: #d97706;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.alert-bar-link:hover {
    color: #b45309;
    text-decoration: underline;
}

.alert-bar-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #92400e;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.alert-bar-close:hover {
    opacity: 1;
}

/* Print styles */
@media print {
    .sidebar,
    .top-bar,
    .sidebar-toggle,
    .flash-container,
    .btn,
    .pagination-wrapper {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card,
    .table-wrapper {
        border-color: #ccc;
        box-shadow: none;
    }

    .table thead th {
        background: #f0f0f0;
    }
}

/* ==========================================================================
   17. Top Nav layout (May 2026) — overrides sidebar layout when body has
       `.app-body-topnav`. Sidebar becomes a mobile-only drawer.
   ========================================================================== */

.app-body-topnav .app-topbar {
    left: 0;
    height: 56px;
    padding: 0 16px;
    gap: 12px;
}
.app-body-topnav .main-content {
    margin-left: 0;
    margin-top: 56px;
}
.app-body-topnav .app-footer {
    margin-left: 0;
}
.app-body-topnav .sidebar.sidebar-mobile-only {
    display: none;
}

.topbar-with-nav {
    display: flex;
    align-items: stretch;
}

.topbar-with-nav .topbar-left,
.topbar-with-nav .topbar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.topbar-with-nav .topbar-title {
    white-space: nowrap;
}

.topbar-with-nav .topbar-hamburger {
    display: none;
}

/* Top horizontal nav */
.topnav {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    margin: 0 8px;
    flex-wrap: wrap;
}
.topnav::-webkit-scrollbar { height: 4px; }
.topnav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }

.topnav-section {
    position: relative;
    display: flex;
    align-items: stretch;
}

.topnav-button {
    background: transparent;
    border: 0;
    color: rgba(255,255,255,0.92);
    font: inherit;
    font-weight: 500;
    font-size: 0.82rem;
    padding: 0 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.topnav-section:hover .topnav-button,
.topnav-section:focus-within .topnav-button {
    background: rgba(0,0,0,0.10);
    color: #fff;
}
.topnav-button.active {
    border-bottom-color: #fff;
    color: #fff;
    font-weight: 600;
}

.topnav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 240px;
    padding: 6px;
    display: none;
    z-index: 200;
    margin-top: 2px;
}
.topnav-section:hover .topnav-dropdown,
.topnav-section:focus-within .topnav-dropdown {
    display: block;
    animation: topnav-fadein 0.12s ease-out;
}
@keyframes topnav-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: background 0.12s;
}
.topnav-link:hover {
    background: var(--bg-secondary);
}
.topnav-link.active {
    background: var(--accent-light);
    color: var(--accent-hover);
    font-weight: 600;
}
.topnav-link .nav-icon {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.topnav-link.active .nav-icon {
    color: var(--accent);
}

/* User menu in topbar */
.topbar-user-menu {
    position: relative;
}
.topbar-user-button {
    background: transparent;
    border: 0;
    color: #fff;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.15s;
    white-space: nowrap;
}
.topbar-user-menu:hover .topbar-user-button,
.topbar-user-menu:focus-within .topbar-user-button {
    background: rgba(0,0,0,0.10);
}
.topbar-user-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
}
.topbar-user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 200px;
    padding: 6px;
    display: none;
    z-index: 200;
    margin-top: 2px;
}
.topbar-user-menu:hover .topbar-user-dropdown,
.topbar-user-menu:focus-within .topbar-user-dropdown {
    display: block;
    animation: topnav-fadein 0.12s ease-out;
}
.topbar-user-info-row {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.topbar-user-info-row strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.topbar-user-info-row small {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}
.topbar-user-logout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--danger, #d32f2f);
    font-size: 0.82rem;
    transition: background 0.12s;
}
.topbar-user-logout-link:hover {
    background: rgba(211,47,47,0.08);
}

/* Mobile breakpoint: hide topnav, show hamburger drawer */
@media (max-width: 1024px) {
    .app-body-topnav .topnav { display: none; }
    .app-body-topnav .topbar-hamburger { display: flex !important; align-items:center; }
    .app-body-topnav .sidebar.sidebar-mobile-only {
        display: flex;
        transform: translateX(-100%);
    }
    .app-body-topnav .sidebar.sidebar-mobile-only.open {
        transform: translateX(0);
    }
    .topbar-user-name { display: none; }
}

/* Tighter spacing on smaller screens */
@media (max-width: 1280px) {
    .topbar-with-nav .topbar-title { display: none; }
    .topnav-button { padding: 0 8px; font-size: 0.78rem; }
}

/* Hover bridge: prevents dropdown from closing when mouse moves between button and dropdown */
.topnav-section .topnav-dropdown,
.topbar-user-menu .topbar-user-dropdown {
    margin-top: 0;
    padding-top: 6px;
    background-clip: padding-box;
}
.topnav-section .topnav-dropdown::before,
.topbar-user-menu .topbar-user-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

/* ==========================================================================
   18. Mac console look — compact monospace UI (May 2026)
   Smaller base font + system monospace stack for that terminal feel.
   Keep --font-mono for code/numbers (JetBrains Mono).
   ========================================================================== */

html { font-size: 13px; }

body {
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    letter-spacing: -0.01em;
}

/* Headings: same monospace family but heavier and tighter */
h1, h2, h3, h4, h5, h6,
.page-title, .card-title, .stat-value, .topbar-title {
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, monospace;
    letter-spacing: -0.02em;
}

/* Tighten paddings to increase information density */
.card { padding: 14px 16px; }
.card-header { padding: 0 0 10px; }
.form-group { margin-bottom: 0.85rem; }
.form-control,
input[type='text'], input[type='number'], input[type='date'],
input[type='email'], input[type='password'], input[type='url'],
input[type='search'], textarea, select {
    font-size: 0.92rem;
    padding: 6px 10px;
}
.btn { padding: 6px 12px; font-size: 0.85rem; }
.btn-sm { padding: 4px 9px; font-size: 0.78rem; }
.page-title { font-size: 1.25rem; }
.page-subtitle { font-size: 0.78rem; }
.stat-value { font-size: 1.15rem; }
.stat-label { font-size: 0.65rem; }

/* Tables */
table { font-size: 0.85rem; }
th { font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }

/* Topbar tighter */
.app-body-topnav .app-topbar { height: 48px; padding: 0 14px; }
.app-body-topnav .main-content { margin-top: 48px; }
.topnav-button { font-size: 0.78rem; padding: 0 10px; }
.topnav-link { font-size: 0.82rem; padding: 6px 10px; }
.topbar-title { font-size: 0.95rem; }
.topbar-datetime { font-size: 0.72rem; }
.topbar-user-name { font-size: 0.78rem; }

/* Badges and small bits */
.badge { font-size: 0.65rem; padding: 1px 8px; }
.flash { font-size: 0.85rem; padding: 8px 12px; }

/* Form labels: smaller, uppercased — terminal-style */
.form-group label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }

/* Page wrapper a touch tighter */
.content-wrapper { padding: 1rem 1.5rem 1.5rem; }

/* ==========================================================================
   19. Page padding + fixed footer (May 2026)
   ========================================================================== */

.app-body-topnav .main-content {
    padding: 1.5rem 2.5rem 80px;
    box-sizing: border-box;
}

.app-body-topnav .app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin-left: 0;
    z-index: 99;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 1024px) {
    .app-body-topnav .main-content { padding: 1.25rem 1.5rem 80px; }
}
@media (max-width: 600px) {
    .app-body-topnav .main-content { padding: 1rem 1rem 80px; }
}

/* ==========================================================================
   20. App background — solid for readability (May 2026)
   ========================================================================== */

.app-body-topnav {
    position: relative;
    background: var(--bg-primary);
}

.app-body-topnav .main-content { position: relative; z-index: 1; }

.app-body-topnav .card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

/* ==========================================================================
   21. Help icon + hover popup (May 2026)
   ========================================================================== */

.help-icon {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    margin-left: 8px;
    cursor: help;
    outline: none;
}

.help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-hover);
    font-size: 0.7rem;
    font-weight: 800;
    border: 1px solid var(--accent);
    transition: all 0.15s;
    user-select: none;
}

.help-icon:hover .help-trigger,
.help-icon:focus-within .help-trigger {
    background: var(--accent);
    color: #fff;
    transform: scale(1.1);
}

.help-popup {
    position: absolute;
    display: none;
    z-index: 250;
    top: calc(100% + 6px);
    left: 0;
    min-width: 320px;
    max-width: 420px;
    width: max-content;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
    padding: 14px 18px;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-primary);
    text-align: left;
    font-weight: 400;
    cursor: default;
    text-transform: none;
    letter-spacing: normal;
}

/* When the icon is near the right edge, flip the popup */
.help-icon.help-right .help-popup { left: auto; right: 0; }

.help-icon:hover .help-popup,
.help-icon:focus-within .help-popup {
    display: block;
    animation: helpFadeIn 0.15s ease-out;
}

@keyframes helpFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.help-popup h4 {
    margin: 0 0 8px;
    color: var(--accent-hover);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.help-popup ol,
.help-popup ul {
    margin: 6px 0;
    padding-left: 20px;
}
.help-popup li { margin-bottom: 5px; }

.help-popup code {
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent-hover);
}

.help-popup strong { color: var(--text-primary); }

.help-popup p { margin: 6px 0; }
.help-popup p:first-child { margin-top: 0; }
.help-popup p:last-child  { margin-bottom: 0; }

/* Hide help icons in print */
@media print { .help-icon { display: none !important; } }

/* ==========================================================================
   22. Black text overrides — menu, footer, and stat-labels (May 2026)
   ========================================================================== */

/* Topbar / topnav — letras a preto */
.topbar-with-nav .topbar-title,
.topbar-with-nav .topbar-subtitle,
.topbar-with-nav .topbar-datetime,
.topbar-with-nav .topbar-user-name,
.topbar-with-nav .topbar-brand,
.topbar-with-nav .topbar-user-avatar-sm,
.topnav-button,
.topbar-user-button {
    color: #111 !important;
}
.topnav-section:hover .topnav-button,
.topnav-section:focus-within .topnav-button,
.topbar-user-menu:hover .topbar-user-button,
.topbar-user-menu:focus-within .topbar-user-button {
    color: #111 !important;
    background: rgba(0, 0, 0, 0.08) !important;
}
.topnav-button.active {
    border-bottom-color: #111 !important;
    color: #111 !important;
}
.topnav-button svg,
.topbar-user-button svg {
    stroke: #111;
    opacity: 0.6;
}
.topbar-hamburger {
    color: #111 !important;
}
.topbar-user-avatar-sm {
    background: rgba(0, 0, 0, 0.15) !important;
}

/* Footer — letras a preto */
.app-footer,
.app-footer a,
.app-footer span {
    color: #111 !important;
}
.app-footer a:hover { color: #000 !important; }

/* Legendas (stat-label) das fichas de funcionário e frota — a preto */
.app-body-topnav [class*='funcionarios'] .stat-label,
.app-body-topnav [class*='frota'] .stat-label,
.app-body-topnav [class*='veiculos'] .stat-label {
    color: #111 !important;
    font-weight: 600;
}

/* Aplicar a TODOS os stat-label da página actual quando o page-title contém
   funcionário/funcionários/veículo/veículos/frota — selector mais simples:
   basta marcar com classe explícita o body. Mas como não temos isso,
   aplicamos a stat-label em geral nas fichas (view.php). Robustez: target
   específico por URL não é trivial em CSS — então damos prioridade às páginas
   ficha onde os labels devem ser legíveis. */
.app-body-topnav main.main-content .stat-label {
    color: #1a1a1a;
    font-weight: 600;
}

/* ==========================================================================
   23. Help popup z-index fix (May 2026)
   Fix stacking context conflict with .card backdrop-filter / animate-fade-up.
   ========================================================================== */

.app-body-topnav .page-header {
    position: relative;
    z-index: 50;
}

.app-body-topnav .help-icon {
    position: relative;
    z-index: 100;
}

.app-body-topnav .help-popup {
    z-index: 9999;
}

/* ==========================================================================
   24. Topnav fit-all-buttons fix (May 2026)
   The 7 sections were wrapping into a 2nd row clipped by the fixed-height
   topbar. Force single line and shrink buttons to fit.
   ========================================================================== */

.app-body-topnav .topnav {
    flex-wrap: nowrap !important;
    overflow: visible;
}

.app-body-topnav .topnav-section {
    flex-shrink: 1;
    min-width: 0;
}

.app-body-topnav .topnav-button {
    white-space: nowrap;
    padding: 0 9px;
    font-size: 0.78rem;
}

@media (max-width: 1400px) {
    .app-body-topnav .topnav-button { padding: 0 7px; font-size: 0.74rem; }
    .app-body-topnav .topnav-button svg { display: none; }
}

@media (max-width: 1200px) {
    .app-body-topnav .topbar-title,
    .app-body-topnav .topbar-datetime { display: none; }
    .app-body-topnav .topnav { margin: 0 4px; }
    .app-body-topnav .topnav-button { padding: 0 6px; font-size: 0.72rem; }
}
