/* ============================================================
   Control Panel — Design System
   Tema claro/escuro via [data-theme] no <html>
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-contrast: #ffffff;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --success-text: #166534;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;
    --info-soft: #e0f2fe;
    --info-text: #075985;

    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-active-bg: #4f46e5;

    --code-bg: #0f172a;
    --code-text: #e2e8f0;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.25);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --sidebar-width: 256px;
    --topbar-height: 64px;
}

[data-theme="dark"] {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-soft: rgba(99, 102, 241, 0.15);

    --bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #16203a;
    --border: #23304d;
    --border: #243250;
    --border-strong: #334569;

    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --success: #4ade80;
    --success-soft: rgba(34, 197, 94, 0.15);
    --success-text: #86efac;
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --danger-text: #fca5a5;
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, 0.15);
    --warning-text: #fcd34d;
    --info-soft: rgba(14, 165, 233, 0.15);
    --info-text: #7dd3fc;

    --sidebar-bg: #0a0f1d;
    --code-bg: #060b16;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
}

/* ── Base ─────────────────────────────────────────────────── */

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

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s ease, color 0.25s ease;
}

body.menu-open { overflow: hidden; }

a { color: var(--primary); }

code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.45rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.85em;
    word-break: break-all;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Layout do app ────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
}

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

/* ── Sidebar ──────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-header h1 {
    color: #f1f5f9;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

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

.nav-group-label {
    display: block;
    padding: 1rem 0.75rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.sidebar-nav .nav-group-label:first-child { padding-top: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.nav-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: #ffffff;
    background: var(--sidebar-active-bg);
}

.nav-link.is-locked { opacity: 0.55; }

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.sidebar-user-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.sidebar-user-name {
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: var(--text-faint);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(2px);
    z-index: 55;
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* ── Sidebar recolhida (somente desktop) ──────────────────── */

@media (min-width: 1025px) {
    html.sidebar-collapsed .sidebar { width: 72px; }

    html.sidebar-collapsed .app-main { margin-left: 72px; }

    html.sidebar-collapsed .sidebar-header { justify-content: center; padding-left: 0; padding-right: 0; }

    html.sidebar-collapsed .sidebar-header h1,
    html.sidebar-collapsed .nav-group-label,
    html.sidebar-collapsed .nav-link span,
    html.sidebar-collapsed .sidebar-user-info { display: none; }

    html.sidebar-collapsed .sidebar-footer { padding-left: 0; padding-right: 0; }

    html.sidebar-collapsed .sidebar-user { justify-content: center; }

    html.sidebar-collapsed .nav-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    html.sidebar-collapsed .nav-link i { font-size: 1.05rem; }
}

@media (max-width: 1024px) {
    .sidebar-collapse-btn { display: none; }
}

/* ── Desfoque de dados sensíveis ──────────────────────────── */

html.blur-data #licenses .license-code,
html.blur-data #licenses .cell-truncate {
    filter: blur(5px);
    transition: filter 0.2s ease;
}

html.blur-data #licenses .license-code:hover,
html.blur-data #licenses .cell-truncate:hover {
    filter: none;
}

/* ── Topbar ───────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.menu-toggle { display: none; }

.user-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    padding: 0 0.25rem;
}

.user-chip .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

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

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
}

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

.lang-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.lang-switch a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
}

.lang-switch img {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    object-fit: cover;
    display: block;
}

.lang-switch a:hover { background: var(--surface-2); }

.lang-switch a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

/* ── Footer ───────────────────────────────────────────────── */

.app-footer {
    padding: 1.25rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-faint);
    border-top: 1px solid var(--border);
}

/* ── Seções (SPA) ─────────────────────────────────────────── */

.section { display: none; }

.section.active {
    display: block;
    animation: fadeUp 0.3s ease;
}

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

.section > h2,
.section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.25rem;
}

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

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 1.5rem; }

.card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}

.card-narrow { max-width: 600px; }

.card-accent-success { border-top: 3px solid var(--success); }
.card-accent-primary { border-top: 3px solid var(--primary); }

/* ── Dashboard ────────────────────────────────────────────── */

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary);
}

.stat-icon.is-success { background: var(--success-soft); color: var(--success); }
.stat-icon.is-warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.is-info { background: var(--info-soft); color: var(--info-text); }

.stat-body { min-width: 0; }

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.chart-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.chart-header h3 { margin-bottom: 0; }

.chart-summary {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chart-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary);
}

.chart-chip.is-green {
    background: var(--success-soft);
    color: var(--success-text);
}

.chart-canvas-wrap { position: relative; height: 300px; }

.quota-card { margin-top: 1.5rem; }

.quota-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.quota-value {
    font-size: 1.4rem;
    font-weight: 700;
    white-space: nowrap;
}

.progress {
    background: var(--border);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* ── Alertas ──────────────────────────────────────────────── */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success-text);
    border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger-text);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}

.alert-warning {
    background: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
}

/* ── Formulários ──────────────────────────────────────────── */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}

.form-grid .span-2 { grid-column: span 2; }

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

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-group input[readonly] {
    background: var(--surface-2);
    color: var(--text-muted);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group small,
.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.checkbox-row input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }

.checkbox-row label { margin: 0; cursor: pointer; user-select: none; font-weight: 500; }

.checkbox-list {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.checkbox-list label:hover { background: var(--border); }

.checkbox-list input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.checkbox-list small { color: var(--text-muted); font-size: 0.8rem; }

/* ── Botões ───────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--primary-contrast);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

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

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: var(--text-faint);
}

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

.btn-danger:hover { filter: brightness(0.92); background: var(--danger); border-color: var(--danger); }

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

.btn-small { padding: 0.4rem 0.8rem; font-size: 0.78rem; }

.btn-block { width: 100%; }

.btn.is-disabled { opacity: 0.6; cursor: default; pointer-events: none; }

/* Botões de ícone (ações em tabelas) */

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.btn-icon:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-icon-edit:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.btn-icon-activate:hover { color: var(--success); border-color: var(--success); background: var(--success-soft); }
.btn-icon-deactivate:hover { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }
.btn-icon-reset:hover { color: var(--info-text); border-color: var(--info-text); background: var(--info-soft); }
.btn-icon-delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* ── Badges de status ─────────────────────────────────────── */

.status-active, .status.active,
.status-inactive, .status.inactive,
.status-expired {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-active, .status.active { background: var(--success-soft); color: var(--success-text); }
.status-inactive, .status.inactive { background: var(--warning-soft); color: var(--warning-text); }
.status-expired { background: var(--danger-soft); color: var(--danger-text); }

.status-active::before, .status.active::before,
.status-inactive::before, .status.inactive::before,
.status-expired::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Tabelas ──────────────────────────────────────────────── */

.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.7rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

thead th:first-child { padding-left: 1rem; }

tbody td {
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody td:first-child { padding-left: 1rem; }

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

tbody tr { transition: background 0.15s ease; }

tbody tr:hover { background: var(--surface-2); }

.cell-truncate {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.license-code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.72rem;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 0.25rem 0.45rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s ease;
}

.license-code:hover { filter: brightness(0.95); }

.product-thumb {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    display: block;
}

.product-thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--surface);
    font-size: 0.85rem;
}

.empty-cell {
    text-align: center;
    padding: 2.5rem 1rem !important;
    color: var(--text-muted);
}

/* ── Busca e paginação ────────────────────────────────────── */

.search-bar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.search-bar input[type="text"] {
    flex: 1;
    min-width: 160px;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.search-bar select {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 150px;
}

.search-bar input:focus, .search-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-bar input[type="date"] {
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

/* Ferramentas da listagem (desfoque, exportação, ações) */
.list-tools {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.action-menu { position: relative; }

.action-menu-list {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
}

.action-menu.open .action-menu-list { display: block; }

.action-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.action-item:hover { background: var(--surface-2); }

.action-item i { width: 16px; text-align: center; color: var(--text-muted); }

a.action-item { text-decoration: none; color: var(--text); }

.action-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.action-item img { border-radius: 2px; }

/* Dropdown de idioma na topbar (abre alinhado à direita) */
.lang-menu .action-menu-list {
    left: auto;
    right: 0;
    min-width: 170px;
}

/* Barra de seleção em massa */
.bulk-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
}

.bulk-bar.show { display: flex; }

.bulk-count { font-size: 0.875rem; color: var(--text); }

.bulk-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Coluna de seleção */
.th-check, .td-check { width: 36px; }

.th-check input, .td-check input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.search-info {
    margin-bottom: 1rem;
    padding: 0.7rem 1rem;
    background: var(--info-soft);
    border-radius: var(--radius-md);
    color: var(--info-text);
    font-size: 0.85rem;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

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

.pagination-pages {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
}

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

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

.page-ellipsis { color: var(--text-muted); padding: 0 0.2rem; }

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.page-jump span { color: var(--text-muted); font-size: 0.8rem; }

.page-jump input {
    width: 70px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.82rem;
}

.page-jump input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.page-jump .page-link { min-width: 34px; cursor: pointer; }

/* ── Modais ───────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal { transform: none; }

/* Form que envolve body+footer precisa participar do layout flex do modal */
.modal > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-sm { max-width: 420px; }

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.modal-close:hover { color: var(--text); background: var(--surface-2); }

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

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

.modal-message {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Toast ────────────────────────────────────────────────── */

.toast {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--text);
    color: var(--bg);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.3s ease;
}

.toast.show { transform: none; }

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ── Loading overlay ──────────────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.loading-overlay.active { opacity: 1; visibility: visible; }

.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2.5rem;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ── Blocos de código / docs da API ──────────────────────── */

.code-block {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

pre.code-block { white-space: pre-wrap; }

.code-block-success { color: #4ade80; }

.info-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    font-size: 0.9rem;
}

.info-box code { background: var(--surface); }

.doc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1rem 0;
}

.doc-table-wrap { overflow-x: auto; margin-top: 0.5rem; }

/* ── Login ────────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 60% 40% at 70% 0%, color-mix(in srgb, var(--primary) 18%, transparent), transparent),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
}

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

.login-brand .sidebar-logo { width: 52px; height: 52px; font-size: 1.5rem; }

.login-brand h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }

.login-brand p { font-size: 0.85rem; color: var(--text-muted); }

.login-footer {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-faint);
}

/* ── Downloads ────────────────────────────────────────────── */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.product-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.product-card-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.product-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
}

.product-icon.is-locked { opacity: 0.5; filter: grayscale(100%); }

.product-icon-placeholder {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.product-icon-placeholder.is-locked { background: var(--border-strong); }

.product-card-head h3 { margin: 0; font-size: 1rem; }

.product-availability { font-size: 0.75rem; font-weight: 600; }
.product-availability.is-available { color: var(--success); }
.product-availability.is-locked { color: var(--text-muted); font-weight: 500; }

.product-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.product-card-actions {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
}

.product-card-actions .btn { flex: 1; }

/* ── Suporte ──────────────────────────────────────────────── */

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.contact-item > i {
    font-size: 1.4rem;
    color: var(--primary);
    width: 28px;
    text-align: center;
}

.contact-item.is-whatsapp > i, .contact-item.is-whatsapp a { color: #25d366; }

/* ── Estado vazio / bloqueado ─────────────────────────────── */

.locked-state {
    max-width: 580px;
    margin: 3rem auto;
    text-align: center;
}

.locked-state .locked-icon {
    font-size: 3.5rem;
    opacity: 0.25;
    margin-bottom: 1rem;
}

.locked-state h2 { justify-content: center; margin-bottom: 1rem; }

.locked-state p {
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); font-size: 0.85rem; }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 1.5rem; }

/* ── Responsividade ───────────────────────────────────────── */

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }

    body.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }

    body.menu-open .sidebar-overlay { display: block; opacity: 1; }

    .sidebar-overlay { display: block; opacity: 0; pointer-events: none; }

    body.menu-open .sidebar-overlay { pointer-events: auto; }

    .app-main { margin-left: 0; }

    .menu-toggle { display: inline-flex; }

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

@media (max-width: 768px) {
    .content { padding: 1rem; }

    .topbar { padding: 0 1rem; gap: 0.6rem; }

    .user-chip { display: none; }

    .btn-logout span { display: none; }

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

    .form-grid .span-2 { grid-column: span 1; }

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

    .quota-row { flex-direction: column; align-items: stretch; gap: 0.75rem; }

    /* Tabelas viram cards */
    .table-cards thead { display: none; }

    .table-cards, .table-cards tbody { display: block; }

    .table-cards tr {
        display: block;
        padding: 0.5rem 1rem;
        border-bottom: 1px solid var(--border);
    }

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

    .table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px dashed var(--border);
        text-align: right;
        font-size: 0.85rem;
    }

    .table-cards td:last-child { border-bottom: none; }

    .table-cards td::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }

    .table-cards td.empty-cell { display: block; text-align: center; }
    .table-cards td.empty-cell::before { content: none; }

    .table-cards .cell-truncate { max-width: 180px; }

    .search-bar { flex-direction: column; align-items: stretch; }

    .search-bar input[type="text"], .search-bar select { width: 100%; min-width: 0; }

    .search-bar .btn { width: 100%; }

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

    .pagination-pages { justify-content: center; }

    .modal-overlay { padding: 0.75rem; align-items: flex-end; }

    .modal { max-height: 92vh; }

    .modal-footer { flex-direction: column-reverse; }

    .modal-footer .btn { width: 100%; }
}

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

    .login-card { padding: 1.5rem; }

    .topbar-title { font-size: 0.95rem; }
}
