/* ============================================================
   SEO Nexus — Premium Dark Theme v3
   Full redesign: mobile hamburger, avatar dropdown, toggle
   switches, package cards, premium admin, Lucide icons
   ============================================================ */

:root {
    --bg-primary: #0a0d14;
    --bg-secondary: #0e1219;
    --bg-card: #12161f;
    --bg-card-hover: #161b26;
    --bg-elevated: #181d28;
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.06);

    --accent: #e5a910;
    --accent-light: #f0c040;
    --accent-dark: #c48f00;
    --accent-soft: rgba(229, 169, 16, 0.12);
    --accent-border: rgba(229, 169, 16, 0.30);

    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.10);
    --success-border: rgba(34, 197, 94, 0.22);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.10);
    --danger-border: rgba(239, 68, 68, 0.22);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.10);
    --warning-border: rgba(245, 158, 11, 0.22);
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.10);
    --info-border: rgba(56, 189, 248, 0.22);

    --text-primary: #f0f2f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-faint: #4b5563;

    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.18);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.3);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.4);

    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
}

/* ============================================================
   Reset & Base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* ============================================================
   Layout
   ============================================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    position: relative;
    z-index: 1;
}

.ambient-glow {
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(180px);
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
}

.ambient-glow.top-right { top: -250px; right: -250px; background: var(--accent); }
.ambient-glow.bottom-left { bottom: -250px; left: -250px; background: var(--accent-dark); }

/* ============================================================
   Shared
   ============================================================ */

.accent, .value-accent { color: var(--accent); }
.muted { color: var(--text-muted); }

.spacer-sm { height: 10px; }
.spacer-md { height: 18px; }
.spacer-lg { height: 28px; }

.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions, .task-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ============================================================
   Cards — clean, no ::before overlays
   ============================================================ */

.card, .glass-card, .admin-section-card, .task-header-card,
.task-form-card, .task-report-card, .pipeline-card,
.admin-kpi-card, .kpi-box, .saved-report-item, .project-item {
    position: relative;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.glass-card, .glass {
    background: rgba(18, 22, 31, 0.80);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Remove all decorative ::before */
.card::before, .glass-card::before, .admin-section-card::before,
.task-header-card::before, .task-form-card::before, .task-report-card::before,
.pipeline-card::before, .admin-kpi-card::before, .kpi-box::before,
.saved-report-item::before, .project-item::before {
    display: none;
}

.card-body {
    position: relative;
    z-index: 1;
    padding: 20px;
}

/* Card text hierarchy */
.card-title, .panel-title, .modal-title, .report-title, .pipeline-title {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-weight: 700;
}

.card-title, .panel-title, .report-title, .pipeline-title {
    font-size: 1.15rem;
}

.card-text, .panel-subtitle {
    color: var(--text-secondary);
    font-size: 1.02rem;
    line-height: 1.5;
}

.panel-subtitle { margin: 6px 0 0; }

/* KPI */
.kpi-label, .admin-kpi-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kpi-value, .admin-kpi-value {
    display: block;
    margin-top: 8px;
    color: var(--text-primary);
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.admin-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.admin-kpi-card { padding: 20px; }
.admin-kpi-sub { margin-top: 8px; color: var(--text-muted); font-size: 0.82rem; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.15s var(--ease);
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { color: #0a0d14; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary { color: var(--text-primary); background: rgba(255,255,255,0.05); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.08); }

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

.btn-ghost { min-height: auto; padding: 0; background: transparent; border: 0; color: var(--text-primary); font-weight: 600; }
.btn-ghost:hover { color: var(--accent); transform: none; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 10px;
    border-radius: var(--radius-xs);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-accent, .badge-primary {
    color: #0a0d14;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 700;
}

.badge-success { color: #bbf7d0; background: var(--success-soft); border-color: var(--success-border); }
.badge-danger { color: #fecaca; background: var(--danger-soft); border-color: var(--danger-border); }
.badge-warning { color: #fef3c7; background: var(--warning-soft); border-color: var(--warning-border); }

/* ============================================================
   Icon Buttons
   ============================================================ */

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0;
    transition: all 0.15s var(--ease);
}

.icon-btn:hover {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--text-primary);
}

/* Lucide icon sizing inside buttons */
.icon-btn svg, .btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* ============================================================
   Forms
   ============================================================ */

.task-field { display: grid; gap: 6px; }

.task-field label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-field .field-hint {
    color: var(--text-faint);
    font-size: 0.88rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 2px;
}

input, textarea, select {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 10px 14px;
    outline: none;
    font-size: 0.92rem;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { min-height: 80px; resize: vertical; }

input:focus, textarea:focus, select:focus {
    border-color: var(--accent-border);
    background: var(--bg-input-focus);
}

/* Fix select dropdown colors — prevents white-on-white */
select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ============================================================
   Toggle Switch (replaces select for active/visible)
   ============================================================ */

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255,255,255,0.10);
    border: 1px solid var(--border-strong);
    transition: all 0.2s var(--ease);
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.2s var(--ease);
}

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

.toggle-switch input:checked + .toggle-track::after {
    left: 20px;
    background: var(--accent);
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 14px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.88rem;
}

.alert-success { color: #bbf7d0; background: var(--success-soft); border-color: var(--success-border); }
.alert-error { color: #fecaca; background: var(--danger-soft); border-color: var(--danger-border); }
.alert-warning { color: #fef3c7; background: var(--warning-soft); border-color: var(--warning-border); }
.alert-info { color: #e0f2fe; background: var(--info-soft); border-color: var(--info-border); }
.alert-action-link { color: var(--accent); text-decoration: underline; cursor: pointer; margin-left: 6px; font-weight: 700; }

/* ============================================================
   Site Header + Auth + Footer (public pages)
   ============================================================ */

.auth-body { display: flex; flex-direction: column; min-height: 100vh; }

.site-header { position: relative; z-index: 2; padding: 18px 0 10px; }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; }
.site-nav { display: flex; align-items: center; gap: 22px; color: var(--text-secondary); font-size: 0.92rem; font-weight: 500; }
.site-nav a:hover, .footer-links a:hover { color: var(--accent); }
.site-header-actions { display: flex; align-items: center; gap: 10px; }

.auth-shell { position: relative; z-index: 1; flex: 1; display: grid; place-items: center; padding: 24px 16px 38px; }
.auth-card { width: min(100%, 560px); display: grid; gap: 16px; }
.auth-brand { text-align: center; display: grid; gap: 6px; }
.auth-logo { font-size: 1rem; font-weight: 800; color: var(--accent); }
.auth-brand h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -0.04em; line-height: 1.05; }
.auth-form { display: grid; gap: 14px; padding: 24px; border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--bg-card); }
.auth-form label { color: var(--text-secondary); font-size: 0.88rem; font-weight: 600; margin-bottom: -2px; }
.auth-links { display: grid; gap: 6px; text-align: center; color: var(--text-secondary); font-size: 0.88rem; }

.footer { position: relative; z-index: 1; padding: 22px 0 28px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; align-items: center; font-size: 0.88rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; color: var(--text-secondary); }

/* ============================================================
   Public page sections
   ============================================================ */

.section { padding: 52px 0; }
.section-lg { padding: 72px 0 52px; text-align: center; }

.eyebrow {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-xs);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.page-title { margin: 0; font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.section-title { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; }
.section-text { color: var(--text-secondary); font-size: 1.02rem; max-width: 680px; margin: 10px auto 0; }
.lead { color: var(--text-secondary); font-size: 1.05rem; max-width: 700px; margin: 10px auto 0; }

.hero-title { margin: 0; font-weight: 800; letter-spacing: -0.04em; line-height: 1.02; }
.hero-text { max-width: 680px; color: var(--text-secondary); font-size: 1.02rem; }
.hero-actions { margin-top: 22px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   Workspace Shell
   ============================================================ */

.workspace-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* Sidebar */
.workspace-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    overflow-y: auto;
    z-index: 50;
}

.workspace-sidebar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: 0;
    border: none;
    background: none;
    box-shadow: none;
}

.workspace-brand { padding: 20px 18px 16px; }

.workspace-brand-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.workspace-brand-subtitle {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.workspace-nav-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 12px;
}

.workspace-nav-group { margin-bottom: 20px; }

.workspace-nav-label {
    margin-bottom: 6px;
    padding: 0 8px;
    color: var(--accent);
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    font-weight: 700;
}

.workspace-nav-list { display: grid; gap: 2px; }

.workspace-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    border: 1px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.3;
    transition: all 0.12s var(--ease);
}

.workspace-nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.workspace-nav-item.is-active {
    color: var(--text-primary);
    background: var(--accent-soft);
    border-color: var(--accent-border);
    font-weight: 600;
}

.workspace-sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

/* Hamburger button (hidden on desktop) */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 0;
    cursor: pointer;
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
}

.sidebar-overlay.is-open { display: block; }

/* ============================================================
   Workspace Main + Topbar
   ============================================================ */

.workspace-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.workspace-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 10px 28px;
    background: rgba(10, 13, 20, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.workspace-breadcrumb {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.workspace-status {
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    background: var(--info-soft);
    border: 1px solid var(--info-border);
    color: #bae6fd;
    font-size: 0.78rem;
    font-weight: 600;
}

.workspace-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.workspace-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================================
   User Avatar Dropdown
   ============================================================ */

.user-avatar-wrap { position: relative; }

.user-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #0a0d14;
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: -0.02em;
    border: 2px solid rgba(229,169,16,0.4);
    cursor: pointer;
    transition: border-color 0.15s var(--ease);
}

.user-avatar-btn:hover { border-color: var(--accent-light); }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 230px;
    padding: 8px 0;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-xl);
    z-index: 100;
}

.user-dropdown.is-open { display: block; }

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.98rem;
    font-weight: 500;
    transition: all 0.1s var(--ease);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.user-dropdown-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.user-dropdown-item.is-accent { color: var(--accent); font-weight: 700; }
.user-dropdown-item.is-accent:hover { background: var(--accent-soft); }

.user-dropdown-sep { height: 1px; margin: 6px 0; background: var(--border); }

.user-dropdown-icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* ============================================================
   Workspace Canvas
   ============================================================ */

.workspace-canvas {
    padding: 20px 28px;
    flex: 1;
}

.workspace-canvas-inner {
    width: min(100%, 960px);
    margin: 0 auto;
    display: grid;
    gap: 16px;
}

/* ============================================================
   Task Header — impactful
   ============================================================ */

.task-header-card, .task-form-card, .task-report-card,
.pipeline-card, .admin-section-card {
    overflow: hidden;
    padding: 22px;
}

.task-header-card {
    padding: 28px;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(18,22,31,0.95) 100%);
    border-color: var(--border-strong);
}

.task-header-top {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
}

.task-header-title {
    margin: 0;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.task-header-description {
    margin: 10px 0 0;
    max-width: 700px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.55;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.task-form-grid { position: relative; z-index: 1; display: grid; gap: 14px; }

.task-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.task-form-actions-left, .task-form-actions-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.task-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    user-select: none;
    font-size: 0.88rem;
}

.task-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    padding: 0;
    box-shadow: none;
}

.task-top {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

/* ============================================================
   Report Display — NO fixed max-height
   ============================================================ */

.report-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.report-toolbar-left, .report-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.report-content {
    position: relative;
    z-index: 1;
    padding: 28px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Report headings — h1/h2 in accent yellow */
.report-content h1, .report-content h2 {
    color: var(--accent);
    line-height: 1.2;
    margin: 1.5em 0 0.5em;
}

.report-content h3, .report-content h4 {
    color: var(--text-primary);
    line-height: 1.2;
    margin: 1.5em 0 0.5em;
}

.report-content h1 { font-size: 1.6rem; font-weight: 800; }
.report-content h2 { font-size: 1.3rem; font-weight: 700; }
.report-content h3 { font-size: 1.1rem; font-weight: 700; }
.report-content h4 { font-size: 1rem; font-weight: 600; }

.report-content h1:first-child, .report-content h2:first-child { margin-top: 0; }
.report-content p { margin: 0 0 1em; }
.report-content ul, .report-content ol { margin: 0 0 1em; padding-left: 1.5em; }
.report-content li { margin-bottom: 0.4em; }
.report-content strong { color: var(--text-primary); font-weight: 700; }

.report-content table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.88rem; }
.report-content th, .report-content td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.report-content th { color: var(--text-muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }

.report-content blockquote {
    margin: 1em 0;
    padding: 12px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.report-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.report-content code { padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.06); font-size: 0.85em; }

/* ============================================================
   Pipeline
   ============================================================ */

.pipeline-list { display: grid; gap: 6px; margin-top: 14px; }

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    font-size: 0.88rem;
}

.pipeline-marker { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.pipeline-step.is-done .pipeline-marker { background: var(--success); }
.pipeline-step.is-running .pipeline-marker { background: var(--accent); animation: pulse-marker 1.2s ease infinite; }

@keyframes pulse-marker { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.pipeline-label { flex: 1; color: var(--text-secondary); }
.pipeline-step.is-done .pipeline-label { color: var(--text-primary); }
.pipeline-status { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; }
.pipeline-step.is-done .pipeline-status { color: var(--success); }

/* ============================================================
   Data Tables
   ============================================================ */

.data-table-wrap { overflow-x: auto; margin-top: 14px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

.data-table th {
    padding: 10px 14px;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-strong);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table td strong { color: var(--text-primary); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================================================
   Admin — Users, Costs, Tasks
   ============================================================ */

.admin-users-list { display: grid; gap: 6px; margin-top: 14px; }

.admin-user-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.7fr 0.6fr 0.5fr;
    gap: 10px;
    align-items: center;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    font-size: 0.88rem;
    transition: border-color 0.12s var(--ease);
}

.admin-user-row:hover { border-color: var(--border-strong); }
.admin-user-row .actions { display: flex; justify-content: flex-end; }

/* Admin user modal — credit actions */
.admin-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.admin-action-card {
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    display: grid;
    gap: 12px;
}

.admin-action-card h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Admin user modal — danger actions */
.admin-danger-actions {
    display: flex;
    gap: 12px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
    align-items: center;
}

.admin-danger-actions .danger-label {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Costs grid */
.costs-grid { display: grid; gap: 10px; margin-top: 14px; }

.cost-row {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 0.8fr 0.5fr;
    gap: 14px;
    align-items: end;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kpi-box { padding: 16px; }
.kpi-box .kpi-value { font-size: 1.3rem; }

/* Admin task config — collapsible with aligned badges */
.admin-task-details {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    overflow: hidden;
}

.admin-task-summary {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-task-summary::-webkit-details-marker { display: none; }

.admin-task-summary .task-status-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.admin-task-summary .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.admin-task-summary .status-dot.is-on { background: var(--success); }
.admin-task-summary .status-dot.is-off { background: var(--danger); }

.admin-task-summary .task-chevron {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s var(--ease);
}

.admin-task-details[open] .admin-task-summary .task-chevron {
    transform: rotate(180deg);
}

.admin-task-body {
    padding: 0 18px 18px;
}

/* ============================================================
   Consumo API — filter row aligned
   ============================================================ */

.usage-filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.usage-filter-row .task-field {
    min-width: 160px;
}

/* ============================================================
   Package Selection Cards (purchase modal)
   ============================================================ */

.package-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.package-card {
    position: relative;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s var(--ease);
}

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

.package-card.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.package-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
}

.package-card .package-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.package-card .package-credits {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.03em;
}

.package-card .package-price {
    margin-top: 4px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Customer type radio */
.customer-type-group {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.customer-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s var(--ease);
}

.customer-type-option:hover {
    border-color: var(--border-hover);
}

.customer-type-option.is-selected {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.customer-type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
}

/* Conditional form sections */
.billing-fields-privato,
.billing-fields-azienda {
    display: none;
}

.billing-fields-privato.is-visible,
.billing-fields-azienda.is-visible {
    display: grid;
    gap: 14px;
}

/* ============================================================
   Projects Modal
   ============================================================ */

.projects-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
}

.projects-sidebar {
    padding: 18px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 72vh;
}

.projects-main {
    padding: 18px;
    overflow-y: auto;
    max-height: 72vh;
}

.project-list { display: grid; gap: 6px; }

.project-item {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    transition: border-color 0.12s var(--ease);
}

.project-item.is-active {
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

.project-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Saved reports */
.saved-report-list { display: grid; gap: 4px; }

.saved-report-item {
    padding: 12px 14px;
    transition: border-color 0.12s var(--ease);
}

.saved-report-item:hover { border-color: var(--border-strong); }

.saved-report-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.saved-report-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.saved-report-query {
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 500;
    font-style: italic;
}

.saved-report-meta {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 2px;
}

/* Collapsible edit panels */
.report-edit-panel, .project-edit-panel {
    border: none;
    padding: 0;
    margin: 0;
}

.report-edit-panel[open], .project-edit-panel[open] {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
}

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(4, 6, 10, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
}

.modal-overlay.is-open { display: flex; }

.modal-dialog {
    width: min(100%, 700px);
    max-height: min(88vh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-xl);
}

.modal-lg { width: min(100%, 960px); }

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

.modal-title { font-size: 1.15rem; }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   Scrollbars
   ============================================================ */

.workspace-nav-scroll::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.report-content::-webkit-scrollbar,
.data-table-wrap::-webkit-scrollbar,
.projects-sidebar::-webkit-scrollbar,
.projects-main::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.workspace-nav-scroll::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.report-content::-webkit-scrollbar-thumb,
.data-table-wrap::-webkit-scrollbar-thumb,
.projects-sidebar::-webkit-scrollbar-thumb,
.projects-main::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.10);
    border-radius: 999px;
}

.workspace-nav-scroll::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.report-content::-webkit-scrollbar-track,
.data-table-wrap::-webkit-scrollbar-track,
.projects-sidebar::-webkit-scrollbar-track,
.projects-main::-webkit-scrollbar-track {
    background: transparent;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1360px) {
    .workspace-shell { grid-template-columns: 240px minmax(0, 1fr); }
    .admin-user-row { grid-template-columns: 1.3fr 1fr 1fr 0.8fr 0.6fr 0.5fr; }
}

@media (max-width: 1200px) {
    .grid-4, .admin-kpis, .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .projects-layout { grid-template-columns: 1fr; }
    .projects-sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 200px; }
    .admin-user-row { grid-template-columns: 1fr 1fr; align-items: start; }
    .admin-user-row .actions { justify-content: flex-start; }
    .cost-row { grid-template-columns: 1fr; }
    .admin-actions-grid { grid-template-columns: 1fr; }
    .package-grid { grid-template-columns: 1fr; }
    .customer-type-group { flex-direction: column; }
}

@media (max-width: 1024px) {
    .hamburger-btn { display: flex; }

    .workspace-shell { grid-template-columns: 1fr; }

    .workspace-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s var(--ease);
        box-shadow: var(--shadow-xl);
        z-index: 60;
    }

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

    .workspace-main { min-width: 0; }
    .workspace-topbar { position: sticky; top: 0; padding: 10px 16px; }
    .workspace-canvas { padding: 16px; }

    .task-header-top, .report-toolbar { flex-direction: column; align-items: flex-start; }
    .task-meta, .report-toolbar-right { justify-content: flex-start; }
    .site-header-inner, .footer-inner { flex-direction: column; align-items: flex-start; }
    .site-nav, .footer-links { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .admin-kpis, .kpi-row, .form-row {
        grid-template-columns: 1fr;
    }

    .workspace-topbar-actions { justify-content: flex-start; }
    .workspace-canvas { padding: 14px; }
    .workspace-brand-title { font-size: 1rem; }
    .task-header-title { font-size: 1.3rem; }
    .task-header-card { padding: 18px; }
    .report-content { padding: 16px; }

    .modal-dialog, .modal-lg { width: 100%; max-height: 92vh; border-radius: var(--radius-lg); }
    .modal-header, .modal-body, .modal-footer { padding-left: 14px; padding-right: 14px; }
    .projects-sidebar, .projects-main { padding: 14px; }
    .admin-section-card { padding: 14px; }

    .form-actions .btn, .task-actions .btn, .hero-actions .btn, .task-form-actions .btn { width: 100%; }
    .hero-actions { width: 100%; }
    .workspace-topbar-actions .icon-btn { width: 36px; height: 36px; }
    .workspace-user-pill { display: none; }

    .saved-report-top { flex-direction: column; align-items: flex-start; gap: 8px; }
    .project-item-top { flex-direction: column; align-items: flex-start; gap: 6px; }
    .admin-danger-actions { flex-direction: column; align-items: flex-start; }

    .usage-filter-row { flex-direction: column; align-items: stretch; }
    .usage-filter-row .task-field { min-width: auto; }

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

@media (max-width: 520px) {
    .workspace-canvas, .workspace-topbar { padding-left: 12px; padding-right: 12px; }
    .report-content h1 { font-size: 1.4rem; }
    .report-content h2 { font-size: 1.15rem; }
    .task-header-title { font-size: 1.2rem; }
    .auth-shell { padding-left: 10px; padding-right: 10px; }
    .auth-form { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    /* Hide everything except report content */
    .workspace-sidebar,
    .workspace-topbar,
    .task-header-card,
    .task-form-card,
    .pipeline-card,
    .report-toolbar,
    .modal-overlay,
    .hamburger-btn,
    .user-dropdown,
    .workspace-status,
    .workspace-sidebar-footer,
    .kpi-row,
    .task-grid,
    .alert,
    [data-inline-alert],
    #server-export-form {
        display: none !important;
    }

    /* Reset layout to single column */
    .workspace-shell {
        display: block !important;
    }

    /* White background everywhere */
    body,
    html,
    .workspace-shell,
    .workspace-main,
    .workspace-canvas,
    .workspace-canvas-inner,
    .task-report-card,
    .report-content {
        background: #ffffff !important;
        color: #111111 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

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

    .report-content {
        padding: 20pt !important;
        font-size: 11pt !important;
        line-height: 1.6 !important;
    }

    /* Headings */
    .report-content h1,
    .report-content h2,
    .report-content h3,
    .report-content h4 {
        color: #111111 !important;
        page-break-after: avoid;
    }

    .report-content h1 { font-size: 18pt !important; margin-top: 0 !important; }
    .report-content h2 { font-size: 14pt !important; margin-top: 20pt !important; border-bottom: 1px solid #cccccc; padding-bottom: 4pt; }
    .report-content h3 { font-size: 12pt !important; margin-top: 14pt !important; }
    .report-content h4 { font-size: 11pt !important; margin-top: 10pt !important; }

    /* Paragraphs and text */
    .report-content p,
    .report-content li,
    .report-content span {
        color: #222222 !important;
    }

    .report-content strong {
        color: #111111 !important;
    }

    .report-content a {
        color: #222222 !important;
        text-decoration: underline !important;
    }

    /* Tables */
    .report-content table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
        page-break-inside: auto;
    }

    .report-content th,
    .report-content td {
        border: 1px solid #aaaaaa !important;
        padding: 5pt 8pt !important;
        color: #111111 !important;
        background: #ffffff !important;
    }

    .report-content th {
        background: #eeeeee !important;
        font-weight: 700 !important;
    }

    .report-content tr {
        page-break-inside: avoid;
    }

    /* Code blocks */
    .report-content code,
    .report-content pre {
        background: #f5f5f5 !important;
        color: #111111 !important;
        border: 1px solid #dddddd !important;
        font-size: 9pt !important;
    }

    /* Lists */
    .report-content ul,
    .report-content ol {
        color: #222222 !important;
        padding-left: 20pt !important;
    }

    /* Page break control */
    h2, h3 { page-break-after: avoid; }
    table, figure, img { page-break-inside: avoid; }
}

/* Modal storico più larga + date senza a capo */
#credits-modal .modal-dialog,
#orders-modal .modal-dialog {
    max-width: 960px;
}

#credits-modal td:first-child,
#orders-modal td:first-child {
    white-space: nowrap;
}