/* ============================================
   MAX — Design System
   v2.0 — Modern SaaS Platform
   ============================================ */

/* ============================================
   1. RESET
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    font-size: 14.5px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }

/* ============================================
   2. DESIGN TOKENS — LIGHT MODE
   ============================================ */
:root {
    /* Colors — Surfaces */
    --bg:           #f2f2f2;
    --surface:      #ffffff;
    --surface-2:    #f2f2f2;
    --surface-3:    #efefef;
    --surface-hover:#e8e8eb;

    /* Colors — Borders */
    --border:       #e8e8ed;
    --border-2:     #d8d8df;
    --border-strong:#c8c8d0;

    /* Colors — Text */
    --text:         #333333;
    --text-2:       #52525b;
    --text-3:       #71717a;
    --text-muted:   #a1a1aa;

    /* Colors — Brand */
    --primary:      #007cba;
    --primary-hover:#0c58a4;
    --primary-fg:   #ffffff;
    --primary-soft: rgba(0, 124, 186, 0.1);
    --primary-glow: rgba(0, 124, 186, 0.16);
    --ring:         rgba(0, 124, 186, 0.32);

    /* Colors — Semantic */
    --success:      #00d084;
    --success-soft: rgba(0, 208, 132, 0.1);
    --warning:      #fcb900;
    --warning-soft: rgba(252, 185, 0, 0.1);
    --danger:       #cf2e2e;
    --danger-soft:  rgba(207, 46, 46, 0.1);
    --info:         #0693e3;
    --info-soft:    rgba(6, 147, 227, 0.1);

    /* Spacing — 4px base */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius:    8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl:20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow:    0 4px 8px -2px rgba(16, 24, 40, 0.06), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 20px 24px -4px rgba(16, 24, 40, 0.1), 0 8px 8px -4px rgba(16, 24, 40, 0.04);
    --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);

    /* Layout */
    --sidebar-w:      248px;
    --sidebar-w-min:  64px;
    --topbar-h:       56px;
    --content-max:    1200px;

    /* Motion */
    --t-fast: 150ms;
    --t:      200ms;
    --t-slow: 300ms;
    --ease:   cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   3. DESIGN TOKENS — DARK MODE
   ============================================ */
[data-theme="dark"] {
    --bg:           #0a0a0a;
    --surface:      #111111;
    --surface-2:    #161616;
    --surface-3:    #1c1c1c;
    --surface-hover:#1e1e1e;

    --border:       #1f1f1f;
    --border-2:     #2a2a2a;
    --border-strong:#3a3a3a;

    --text:         #fafafa;
    --text-2:       #a1a1aa;
    --text-3:       #71717a;
    --text-muted:   #52525b;

    --primary:      #4db8e8;
    --primary-hover:#7dcdf0;
    --primary-fg:   #0a0a0a;
    --primary-soft: rgba(77, 184, 232, 0.12);
    --primary-glow: rgba(77, 184, 232, 0.2);
    --ring:         rgba(77, 184, 232, 0.4);

    --success:      #33e0a0;
    --success-soft: rgba(51, 224, 160, 0.12);
    --warning:      #fdc933;
    --warning-soft: rgba(253, 201, 51, 0.12);
    --danger:       #e05858;
    --danger-soft:  rgba(224, 88, 88, 0.12);
    --info:         #3eabf0;
    --info-soft:    rgba(62, 171, 240, 0.12);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow:    0 4px 8px -2px rgba(0, 0, 0, 0.6), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 16px -4px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 24px -4px rgba(0, 0, 0, 0.5), 0 8px 8px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

/* Tema claro e o padrao. Tema escuro so quando o usuario alterna explicitamente
   via botao (data-theme="dark"). Nao segue mais prefers-color-scheme do SO. */

/* ============================================
   4. SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================
   5. APP SHELL
   ============================================ */
.app {
    display: flex;
    min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--t) var(--ease), transform var(--t) var(--ease);
}

.app[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-w-min);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-h);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-logo-mark {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    /* Gradiente serve de fallback quando o elemento e <span> com iniciais (admin) */
    background: linear-gradient(135deg, var(--primary), #7a00df);
}
/* Quando o elemento e uma <img> (logo da plataforma), garante preenchimento limpo */
img.sidebar-logo-mark {
    object-fit: cover;
    background: transparent;
}

.sidebar-logo-img {
    height: 28px;
    width: auto;
    display: block;
    transition: opacity var(--t) var(--ease), width var(--t) var(--ease);
}

/* Expanded: show image, hide mark */
.sidebar-logo-mark { display: none; }

/* Collapsed: show mark, hide image */
.app[data-sidebar="collapsed"] .sidebar-logo-mark {
    display: flex;
}
.app[data-sidebar="collapsed"] .sidebar-logo-img {
    display: none;
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    width: 100%;
    height: 34px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    flex-shrink: 0;
    margin-bottom: var(--space-2);
}
.sidebar-collapse-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar-collapse-btn svg {
    flex-shrink: 0;
}
.sidebar-collapse-label {
    transition: opacity var(--t) var(--ease);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.sidebar-section {
    padding: var(--space-3) 0;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: var(--space-2) var(--space-5);
    margin-bottom: var(--space-1);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 36px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.nav-item-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item-icon svg { width: 100%; height: 100%; }
.nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--t) var(--ease);
}

.app[data-sidebar="collapsed"] .sidebar-section-title,
.app[data-sidebar="collapsed"] .nav-item-label,
.app[data-sidebar="collapsed"] .sidebar-logo-text,
.app[data-sidebar="collapsed"] .sidebar-collapse-label,
.app[data-sidebar="collapsed"] .user-meta {
    display: none;
}
.app[data-sidebar="collapsed"] .sidebar-header {
    justify-content: center;
    padding: 0;
}
.app[data-sidebar="collapsed"] .sidebar-collapse-btn {
    justify-content: center;
    padding: 0;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    gap: 0;
}
.app[data-sidebar="collapsed"] .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}
.app[data-sidebar="collapsed"] .sidebar-nav {
    padding: 0;
    gap: 2px;
    align-items: stretch;
}
.app[data-sidebar="collapsed"] .nav-item {
    justify-content: center;
    padding: 0;
    height: 40px;
    width: 40px;
    margin: 0 auto;
    gap: 0;
    border-radius: var(--radius);
    overflow: visible;
}
.app[data-sidebar="collapsed"] .nav-item-icon {
    width: 20px;
    height: 20px;
    margin: 0 auto;
}
.app[data-sidebar="collapsed"] .sidebar-section {
    padding: var(--space-1) 0;
}
.app[data-sidebar="collapsed"] .sidebar-footer {
    padding: var(--space-2);
}
.app[data-sidebar="collapsed"] .user-card {
    justify-content: center;
    padding: var(--space-2);
    gap: 0;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-3);
    flex-shrink: 0;
}

/* Sino de notificações dentro da sidebar-footer */
.sidebar-notif { position: relative; margin-bottom: var(--space-2); }
.sidebar-notif-btn {
    display: flex;
    align-items: center;
    width: 100%;
    height: 34px;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.sidebar-notif-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar-notif-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-notif-label { transition: opacity var(--t) var(--ease); }

/* No modo colapsado, só o ícone do sino (alinhado ao centro, sem label) */
.app[data-sidebar="collapsed"] .sidebar-notif-btn {
    justify-content: center;
    padding: 0;
}
.app[data-sidebar="collapsed"] .sidebar-notif-label {
    display: none;
}

/* Badge de não-lidas (reaproveita .icon-btn-dot da topbar original) */
.sidebar-notif-btn.icon-btn-dot::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 20px;
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--danger);
    border: 2px solid var(--surface);
    box-sizing: content-box;
}
.app[data-sidebar="collapsed"] .sidebar-notif-btn.icon-btn-dot::after {
    top: 6px;
    left: auto;
    right: calc(50% - 14px);
}

/* Dropdown do sino — flutuante à direita da sidebar */
.sidebar-notif-dropdown {
    position: absolute;
    left: calc(100% + 12px);
    bottom: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}
.sidebar-notif-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.sidebar-notif-header button {
    font-size: 11px;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
}
.sidebar-notif-dropdown #notifList { padding: var(--space-2); }

.user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--t) var(--ease);
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
}
.user-card:hover { background: var(--surface-2); }

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #7a00df);
    color: #fff;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.user-meta {
    flex: 1;
    min-width: 0;
    transition: opacity var(--t) var(--ease);
}
.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--text-3);
    text-transform: capitalize;
}

/* --- MAIN --- */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--t) var(--ease);
}
.app[data-sidebar="collapsed"] .main {
    margin-left: var(--sidebar-w-min);
}

/* --- TOPBAR --- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.topbar-center {
    flex: 1;
    max-width: 480px;
    margin: 0 var(--space-4);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    position: relative;
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn-dot::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 9px;
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--danger);
    border: 2px solid var(--surface);
    box-sizing: content-box;
}

/* Search */
.search {
    position: relative;
    width: 100%;
}
.search-input {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3) 0 36px;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--t) var(--ease), background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--ring);
}
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-3);
    pointer-events: none;
}
.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    pointer-events: none;
    font-family: -apple-system, sans-serif;
}

/* ============================================
   FORM PICKER (searchable dropdown que substitui <select>)
   ============================================ */
.hd-picker { position: relative; }
.hd-picker-btn {
    width: 100%;
    display: flex; align-items: center; gap: var(--space-2);
    height: 40px;
    padding: 0 var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px; font-weight: 500; color: var(--text);
    font-family: inherit;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
    text-align: left;
}
.hd-picker-btn:hover, .hd-picker-btn:focus {
    border-color: var(--primary);
    outline: none;
}
.hd-picker-btn[aria-expanded="true"] {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.hd-picker-btn.hd-picker-btn--invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft, rgba(239,68,68,.15));
}
.hd-picker-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.hd-picker-avatar svg { width: 14px; height: 14px; }
.hd-picker-avatar--neutral { background: var(--surface-2); color: var(--text-3); }
.hd-picker-avatar--empty {
    background: transparent;
    border: 1px dashed var(--border-2);
}
.hd-picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-picker-label--placeholder { color: var(--text-3); font-weight: 400; }
.hd-picker-chevron { width: 14px; height: 14px; flex-shrink: 0; opacity: .5; }

.hd-picker-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}
.hd-picker-dropdown[hidden] { display: none; }

.hd-picker-search-wrap {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border);
}
.hd-picker-search-wrap > div {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-2);
    border-radius: var(--radius);
}
.hd-picker-search-wrap svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.hd-picker-search-input {
    border: none; background: transparent; outline: none;
    font-size: 13px; color: var(--text); width: 100%;
    font-family: inherit;
}

.hd-picker-list {
    max-height: 280px; overflow-y: auto;
    padding: var(--space-1);
}
.hd-picker-item {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    transition: background var(--t) var(--ease);
    cursor: pointer;
}
.hd-picker-item:hover { background: var(--surface-2); }
.hd-picker-item--active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.hd-picker-item--active:hover { background: var(--primary-soft); }
.hd-picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-picker-check { width: 14px; height: 14px; color: var(--primary); flex-shrink: 0; }
.hd-picker-empty {
    padding: var(--space-4);
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
}

/* Client selection grid (step 0 in modules) */
.client-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
}
.client-select-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--t) var(--ease);
    font-family: inherit;
    text-align: left;
}
.client-select-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.client-select-card.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.client-select-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.client-select-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

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

/* User menu (in topbar) */
.user-menu { position: relative; }
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: var(--space-1);
    animation: dropdown-in 180ms var(--ease);
}
.user-menu-dropdown[hidden] { display: none; }

.user-menu-header {
    padding: var(--space-3) var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-1);
}
.user-menu-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.user-menu-email {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.menu-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.menu-item-icon {
    width: 16px;
    height: 16px;
    color: var(--text-3);
    flex-shrink: 0;
}
.menu-item-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-1) 0;
}
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu-item-danger .menu-item-icon { color: var(--danger); }

/* Theme toggle (icon swap) */
.theme-toggle [data-theme-icon-light] { display: none; }
.theme-toggle [data-theme-icon-dark]  { display: block; }
[data-theme="dark"] .theme-toggle [data-theme-icon-light] { display: block; }
[data-theme="dark"] .theme-toggle [data-theme-icon-dark]  { display: none; }

/* --- CONTENT --- */
.content {
    flex: 1;
    padding: var(--space-8) var(--space-6);
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
}

/* Módulo helpdesk: área mais larga pra acomodar layout 2-col (main + activity) */
.content--helpdesk {
    max-width: 1400px;
}

/* ============================================
   6. PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}
.page-header-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-3);
    margin-top: var(--space-1);
    line-height: 1.5;
}

/* ============================================
   7. BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-4);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t-fast) var(--ease);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-2);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}
.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

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

.btn-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: transparent;
}
.btn-success:hover {
    background: var(--success);
    color: #fff;
}

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: 12px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: 14px; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

/* ============================================
   8. CARDS
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-padded { padding: var(--space-6); }
.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.card-subtitle {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}
.card-body { padding: var(--space-6); }
.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    background: var(--surface-2);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ============================================
   9. FORMS
   ============================================ */
.form-group { margin-bottom: var(--space-5); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: var(--space-2);
}
.form-help {
    font-size: 12px;
    color: var(--text-3);
    margin-top: var(--space-1);
}

.form-control {
    width: 100%;
    height: 38px;
    padding: 0 var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.form-control:disabled {
    background: var(--surface-2);
    color: var(--text-3);
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 96px;
    padding: var(--space-3);
    resize: vertical;
    line-height: 1.6;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* Radio cards */
.radio-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.radio-card {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: border-color var(--t) var(--ease), background var(--t) var(--ease), color var(--t) var(--ease);
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card input { display: none; }
.radio-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.radio-card-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================
   10. TABLES
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t) var(--ease); }
tbody tr:hover { background: var(--surface-2); }

/* ============================================
   11. BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 22px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
}

/* ============================================
   12. ALERTS
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 13px;
    margin-bottom: var(--space-5);
}
.alert + .page-header {
    margin-top: calc(-1 * var(--space-3));
}
.alert-success {
    background: var(--success-soft);
    border-color: var(--success);
    color: var(--success);
}
.alert-danger {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}
.alert-info {
    background: var(--info-soft);
    border-color: var(--info);
    color: var(--info);
}
.alert-icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; }
.alert-body { flex: 1; line-height: 1.5; }
.alert-body strong { font-weight: 600; }

/* ============================================
   13. EMPTY STATE
   ============================================ */
.empty {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    color: var(--text-3);
}
.empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-4);
    background: var(--surface-2);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-2);
}
.empty-description {
    font-size: 14px;
    color: var(--text-3);
    max-width: 360px;
    margin: 0 auto var(--space-5);
    line-height: 1.6;
}

/* ============================================
   14. SPINNER & LOADING
   ============================================ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   15. TOAST
   ============================================ */
#toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    font-size: 13px;
    color: var(--text);
    min-width: 280px;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    animation: toast-in 220ms var(--ease);
}
.toast-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-error .toast-icon   { color: var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-info .toast-icon    { color: var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-out { animation: toast-out 200ms var(--ease) forwards; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ============================================
   16. MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t) var(--ease);
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-12px) scale(0.98);
    transition: transform var(--t) var(--ease);
    box-shadow: var(--shadow-xl);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.modal-close {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: var(--space-6); }
.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    background: var(--surface-2);
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* ============================================
   17. TOGGLE SWITCH
   ============================================ */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.switch input { display: none; }
.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    transition: background var(--t) var(--ease);
    cursor: pointer;
}
.switch-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--t) var(--ease);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

/* ============================================
   18. MODULE: PUBLISHER (WordPress Post)
   ============================================ */

/* Steps indicator */
.steps {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-8);
    padding: var(--space-4) var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
    flex-shrink: 0;
}
.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text-3);
    border: 1px solid var(--border-2);
    transition: all var(--t) var(--ease);
}
.step.active { color: var(--primary); }
.step.active .step-num {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.step.done .step-num {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.step-divider {
    flex: 1;
    height: 1px;
    background: var(--border);
    min-width: 24px;
}

/* Drop zone */
.dropzone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius-lg);
    padding: var(--space-12) var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
    position: relative;
    background: var(--surface);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.dropzone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.dropzone-icon svg { width: 24px; height: 24px; }
.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-1);
}
.dropzone-sub {
    font-size: 13px;
    color: var(--text-3);
}
.dropzone-types {
    margin-top: var(--space-3);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Selected file pill */
.file-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--primary-soft);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    margin-top: var(--space-4);
}
.file-pill svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Editor */
.editor {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    padding: var(--space-5);
    min-height: 320px;
    max-height: 520px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    outline: none;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.editor h2, .editor h3 {
    margin: var(--space-4) 0 var(--space-2);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.editor h2 { font-size: 18px; }
.editor h3 { font-size: 16px; }
.editor p { margin-bottom: var(--space-3); }
.editor strong { font-weight: 600; color: var(--text); }
.editor a { color: var(--primary); text-decoration: underline; }

/* Image preview */
.image-preview {
    position: relative;
    display: inline-block;
    margin-top: var(--space-3);
}
.image-preview img {
    width: 100%;
    max-width: 320px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.image-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger);
    color: #fff;
    border: 2px solid var(--surface);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}
.image-preview-remove svg { width: 12px; height: 12px; }

/* Success card */
.success-card {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-5);
    background: var(--success-soft);
    color: var(--success);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}
.success-icon svg { width: 32px; height: 32px; }
.success-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-2);
    letter-spacing: -0.01em;
}
.success-card p {
    color: var(--text-3);
    font-size: 14px;
    margin-bottom: var(--space-6);
}
.success-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   19. ADMIN — Client cards
   ============================================ */
.client-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-3);
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.client-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
.client-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}
.client-card-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.client-card-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #7a00df);
    color: #fff;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.client-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.client-card-slug {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
    font-family: ui-monospace, monospace;
}
.client-card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.creds-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}
.cred-item {
    font-size: 12px;
}
.cred-label {
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 2px;
}
.cred-value {
    font-size: 12px;
    color: var(--text-2);
    word-break: break-all;
}
.cred-value.has-value { color: var(--success); }
.cred-value.no-value  { color: var(--text-muted); }

/* Input tabs (texto/arquivo) */
.input-tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-5);
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: var(--space-1);
}
.input-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.input-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.input-tab:hover {
    color: var(--text);
}
.input-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   20. LOGIN PAGE
   ============================================ */
@keyframes auth-float {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(0, -30px); }
}
@keyframes auth-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background:
        linear-gradient(rgba(0, 124, 186, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 124, 186, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 0% 0%, rgba(0, 124, 186, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(122, 0, 223, 0.12) 0%, transparent 50%),
        var(--bg);
    background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%, 100% 100%;
}
.auth-page::before,
.auth-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    animation: auth-float 30s ease-in-out infinite;
}
.auth-page::before {
    width: 500px;
    height: 500px;
    top: -10%;
    right: -5%;
    background: rgba(0, 124, 186, 0.08);
}
.auth-page::after {
    width: 400px;
    height: 400px;
    bottom: -10%;
    left: -5%;
    background: rgba(122, 0, 223, 0.06);
    animation-delay: -15s;
}

.auth-wrapper {
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
    animation: auth-fade-in 0.6s var(--ease) both;
}
.auth-brand {
    text-align: center;
    margin-bottom: var(--space-10);
}
.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}
.auth-logo-img {
    height: 48px;
    width: auto;
    display: block;
    transition: transform var(--t) var(--ease);
}
.auth-logo:hover .auth-logo-img {
    transform: scale(1.05);
}
.auth-logo .sidebar-logo-mark {
    width: 48px;
    height: 48px;
    font-size: 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35), 0 0 0 4px var(--primary-soft);
    transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.auth-logo:hover .sidebar-logo-mark {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), 0 0 0 4px var(--primary-glow);
}
.auth-tagline {
    font-size: 13px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-top: var(--space-2);
}
.auth-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-10);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.auth-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-1);
    letter-spacing: -0.01em;
}
.auth-card-subtitle {
    font-size: 13px;
    color: var(--text-3);
    font-weight: 400;
    margin-bottom: var(--space-6);
}

/* Auth — Input with icon */
.auth-input-wrap {
    position: relative;
}
.auth-input-wrap .form-control {
    padding-left: 40px;
    height: 44px;
    font-size: 14px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border-color: transparent;
    transition: background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.auth-input-wrap .form-control:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.auth-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--t) var(--ease);
}
.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--primary);
}

/* Auth — Submit button */
.auth-card .btn-primary.btn-lg {
    height: 48px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #7a00df);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    margin-top: var(--space-4);
    transition: box-shadow var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.auth-card .btn-primary.btn-lg:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}
.auth-card .btn-primary.btn-lg:active {
    transform: translateY(0) scale(0.98);
}

/* Auth — Link (esqueci senha, voltar) */
.auth-link {
    text-align: center;
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}
.auth-link a {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    transition: color var(--t) var(--ease);
}
.auth-link a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    color: var(--text-muted);
    font-size: 12px;
}

/* Auth — Dark mode */
[data-theme="dark"] .auth-card {
    background: rgba(17, 17, 17, 0.85);
    border-color: var(--border-2);
    border-top-color: var(--primary);
}
[data-theme="dark"] .auth-page::before {
    background: rgba(77, 184, 232, 0.06);
}
[data-theme="dark"] .auth-page::after {
    background: rgba(122, 0, 223, 0.05);
}
[data-theme="dark"] .auth-page {
    background:
        linear-gradient(rgba(77, 184, 232, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(77, 184, 232, 0.02) 1px, transparent 1px),
        radial-gradient(circle at 0% 0%, rgba(77, 184, 232, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(122, 0, 223, 0.08) 0%, transparent 50%),
        var(--bg);
    background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%, 100% 100%;
}

/* ============================================
   21. RESPONSIVE
   ============================================ */

/* Botão flutuante do hamburger — substitui a topbar em mobile */
.sidebar-mobile-float-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 110;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--t) var(--ease), transform var(--t) var(--ease);
}
.sidebar-mobile-float-btn svg { width: 22px; height: 22px; }
.sidebar-mobile-float-btn:hover { background: var(--surface-2); }
.sidebar-mobile-float-btn:active { transform: scale(0.95); }

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
    }
    .app[data-sidebar-mobile="open"] .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }
    /* Backdrop escuro atrás da sidebar quando aberta — reforço visual e alvo de clique pra fechar */
    .app[data-sidebar-mobile="open"]::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 99;
        animation: sidebarBackdropFade var(--t) var(--ease);
    }
    @keyframes sidebarBackdropFade {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    .app[data-sidebar-mobile="open"] .sidebar-section-title,
    .app[data-sidebar-mobile="open"] .nav-item-label,
    .app[data-sidebar-mobile="open"] .user-meta {
        opacity: 1 !important;
        pointer-events: all !important;
        width: auto !important;
    }
    .app[data-sidebar-mobile="open"] .sidebar-header {
        justify-content: space-between !important;
        padding: 0 var(--space-5) !important;
    }
    .app[data-sidebar-mobile="open"] .nav-item {
        justify-content: flex-start !important;
        padding: 0 var(--space-3) !important;
    }
    .main { margin-left: 0 !important; }
    .sidebar-collapse-btn { display: none; }

    /* Botão flutuante aparece apenas em mobile */
    .sidebar-mobile-float-btn { display: flex; }
    /* Esconde o botão quando a sidebar mobile está aberta (evita sobreposição) */
    .app[data-sidebar-mobile="open"] .sidebar-mobile-float-btn { display: none; }

    /* Espaço superior pra não colar no hamburger flutuante (42px + 12px topo + 8px respiro) */
    .content { padding: 64px var(--space-4) var(--space-6); }
    .form-row { grid-template-columns: 1fr; }
    .creds-grid { grid-template-columns: 1fr; gap: var(--space-2); }
}

@media (max-width: 540px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .step-label { display: none; }

    .auth-card { padding: var(--space-6); border-radius: var(--radius-xl); }
    .auth-logo { font-size: 24px; }
    .auth-logo .sidebar-logo-mark { width: 40px; height: 40px; font-size: 16px; }
    .auth-logo-img { height: 40px; }
}

/* ============================================
   22. SOCIAL PUBLISHER
   ============================================ */

/* Format selection cards */
.format-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}
.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-5);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
    text-align: center;
}
.format-card:hover {
    border-color: var(--border-2);
    background: var(--surface-2);
}
.format-card.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px var(--ring);
}
.format-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.format-card-desc {
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.4;
}

/* Briefing output */
.briefing-output {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    max-height: 500px;
    overflow-y: auto;
}

/* Social loading spinner */
.social-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-10) 0;
    color: var(--text-3);
    font-size: 14px;
}
.social-loading[hidden] { display: none !important; }

@media (max-width: 540px) {
    .format-cards { grid-template-columns: 1fr; }
    .format-card { padding: var(--space-6) var(--space-4); }
}

/* ============================================
   23. UTILITIES
   ============================================ */
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-3  { margin-top: var(--space-3); }
.mt-4  { margin-top: var(--space-4); }
.mb-4  { margin-bottom: var(--space-4); }
.text-sm    { font-size: 12px; }
.text-muted { color: var(--text-3); }
.hidden { display: none !important; }
