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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #374151;
    --text-muted: #6b7280;
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --input-border: #d1d5db;
    --sidebar-bg: #020617;
    --sidebar-width: 180px;
    --topbar-height: 48px; /* Reduced from 50px */
    --white: #ffffff;
    --card-padding: 1rem; /* Reduced from 1.25rem */
    --container-padding: 1rem; /* Reduced from 24px */
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px; /* Reduced from 14px for density */
    color: var(--text-main);
    background: var(--bg-body);
    line-height: 1.4; /* Tighter line height */
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Layout Structure --- */

.layout-fixed {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.layout-auth {
    min-height: 100vh;
    background: radial-gradient(circle at top, #e0f2fe 0, #f9fafb 45%, #f1f5f9 100%);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #9ca3af;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header .logo {
    font-weight: 600;
    font-size: 16px;
    color: #f3f4f6;
    letter-spacing: -0.5px;
}

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

.nav-list {
    list-style: none;
}

.nav-header {
    padding: 8px 12px 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: #4b5563;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: rgba(255,255,255,0.05);
    color: #f3f4f6;
}

.nav-link.active {
    background: linear-gradient(90deg, var(--primary) 0%, #4338ca 100%);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-left-color: #818cf8;
}

.nav-icon {
    width: 20px;
    margin-right: 0.5rem;
    display: flex;
    justify-content: center;
    font-size: 14px;
}

.icon-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.nav-icon .icon-emoji {
    font-size: 16px;
}

.nav-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--topbar-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 900;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: left 0.3s ease;
}

.layout-auth .topbar {
    background-color: transparent;
    border-bottom-color: transparent;
    box-shadow: none;
}

@media (min-width: 1024px) {
    .topbar {
        left: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
        padding-top: var(--topbar-height);
        min-height: 100vh;
        transition: margin-left 0.3s ease;
    }

    .btn-icon-toggle {
        display: flex;
    }
}

@media (min-width: 1024px) {
    body.layout-auth .topbar {
        left: 0;
    }
    body.layout-auth .main-content {
        margin-left: 0;
    }
}

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

.topbar .logo {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.btn-icon-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-toggle .icon-emoji {
    font-size: 20px;
}

.btn-icon-toggle:hover {
    background-color: #f3f4f6;
    color: var(--text-main);
}

.logo-mobile {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-main);
}

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

.tenant-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background-color: #f0fdf4;
    border: 1px solid #dcfce7;
    border-radius: 9999px;
    color: #166534;
    font-size: 12px;
    font-weight: 500;
}

.tenant-icon {
    width: 16px;
    height: 16px;
    background-color: #16a34a;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout .icon-emoji {
    font-size: 18px;
}

.btn-logout:hover {
    background-color: #f3f4f6;
    color: var(--danger);
}

/* Main Content */
.main-content {
    padding-top: var(--topbar-height);
    transition: margin-left 0.3s ease;
    /* Ensure flexbox behavior to allow child to grow */
    display: flex;
    flex-direction: column;
}

.container-fluid {
    padding: var(--container-padding);
    width: 100%; /* Ensure 100% width */
    max-width: 100%; /* Full width for density */
    margin: 0 auto;
    flex: 1; /* Grow to fill available space */
}

/* Collapsed Sidebar */
body.sidebar-collapsed .sidebar {
    width: 48px;
}

body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-header,
body.sidebar-collapsed .sidebar-header .logo {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-header::after {
    content: 'M';
    font-weight: 700;
    font-size: 16px;
    color: #f3f4f6;
}

body.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 4px 0;
}

body.sidebar-collapsed .nav-icon {
    margin-right: 0;
    font-size: 1.2rem;
}

body.sidebar-collapsed .topbar {
    left: 48px;
}

body.sidebar-collapsed .main-content {
    margin-left: 48px;
}

/* Mobile Responsiveness */
@media (max-width: 1023.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .topbar {
        left: 0 !important;
    }

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

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 950;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        backdrop-filter: blur(2px);
    }

    body.sidebar-mobile-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

/* --- Buttons --- */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --text-main: #374151;
    --text-muted: #6b7280;
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --input-border: #d1d5db;
    --sidebar-bg: #020617;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.42rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.18s ease-in-out;
    line-height: 1.2;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(15,23,42,0.06);
    background: linear-gradient(135deg, #111827, #020617);
    color: #e5e7eb;
}

.btn span[aria-hidden="true"] {
    transform: translateY(0.5px);
}

.btn:hover {
    transform: translateY(-0.5px);
    box-shadow: 0 3px 6px rgba(15,23,42,0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(15,23,42,0.1);
}

.btn-primary, .btn-small-primary {
    background: linear-gradient(135deg, #4b5563, #111827);
    border-color: rgba(55,65,81,0.85);
    color: #f9fafb;
}

.btn-primary:hover, .btn-small-primary:hover {
    background: linear-gradient(135deg, #374151, #020617);
    filter: brightness(1.02);
}

.btn-secondary {
    background: radial-gradient(circle at top left, #4c1d95, #7c3aed);
    border-color: rgba(196,181,253,0.9);
    color: #ede9fe;
}

.btn-secondary:hover {
    background: radial-gradient(circle at top left, #3730a3, #6d28d9);
}

.btn-light {
    background: rgba(248,250,252,0.75);
    border-color: rgba(148,163,184,0.7);
    color: #0f172a;
    box-shadow: none;
}

.btn-light:hover {
    background: #e5e7eb;
    border-color: rgba(148,163,184,1);
}

.btn-success {
    background: radial-gradient(circle at top left, #059669, #22c55e);
    border-color: rgba(134,239,172,0.9);
    color: #ecfdf5;
}

.btn-success:hover {
    background: radial-gradient(circle at top left, #047857, #16a34a);
}

.btn-danger, .btn-small-danger {
    background: radial-gradient(circle at top left, #b91c1c, #ef4444);
    border-color: rgba(248,113,113,0.9);
    color: #fef2f2;
}

.btn-danger:hover, .btn-small-danger:hover {
    background: radial-gradient(circle at top left, #991b1b, #dc2626);
}

.btn-warning {
    background: radial-gradient(circle at top left, #d97706, #f59e0b);
    border-color: rgba(253,224,71,0.9);
    color: #fffbeb;
}

.btn-small, .btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.82rem;
    border-radius: 9999px;
    box-shadow: none;
}

.btn-icon-text {
    padding-left: 0.6rem;
    padding-right: 0.8rem;
}

.btn-icon-text span:not(.icon-emoji) {
    color: #ffffff;
    font-weight: 600;
}

.btn-light.btn-icon-text span:not(.icon-emoji) {
    color: var(--text-main);
}

.btn-primary.btn-icon-text .icon-emoji {
    color: #ffffff;
    text-shadow: 0 0 3px rgba(15, 23, 42, 0.7);
}

.btn-small-ghost, .btn-soft {
    background: rgba(15,23,42,0.02);
    border-color: rgba(148,163,184,0.55);
    color: #64748b;
    box-shadow: none;
}

.btn-small-ghost:hover, .btn-soft:hover {
    background: rgba(15,23,42,0.06);
    border-color: rgba(148,163,184,0.9);
    color: #0f172a;
}

.btn-icon {
    padding: 0;
    margin-right: 0.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
    color: inherit;
    transition: color 0.18s ease-in-out;
}

.btn-icon .icon-emoji {
    font-size: 1rem;
}

.btn-icon:hover {
    background: transparent;
}

.btn-icon:hover .icon-emoji {
    color: #1d4ed8;
    text-shadow: 0 0 3px rgba(37, 99, 235, 0.7);
}

/* Responsive Buttons */
@media (max-width: 768px) {
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn:not(.btn-sm):not(.btn-icon):not(.btn-small) {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Force full width for cards on mobile if needed, but allow full width on desktop too */
    .card {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* --- Forms --- */

.form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.form.form-tight label {
    margin-bottom: 8px;
}

.form span {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
}

.form.form-tight span {
    font-size: 0.8rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    background-color: #ffffff;
    border: 1px solid var(--input-border);
    border-radius: 0.375rem;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form.form-tight input[type="text"],
.form.form-tight input[type="email"],
.form.form-tight input[type="password"],
.form.form-tight input[type="number"],
.form.form-tight input[type="date"],
.form.form-tight select,
.form.form-tight textarea {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
}

.error {
    margin-top: 4px;
    font-size: 0.8rem;
    color: #b91c1c;
}

/* --- Cards --- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem; /* Reduced radius */
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.5rem; /* Reduced margin */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card h1, .card h2, .card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.card h1 { font-size: 1.15rem; }
.card h2 { font-size: 1rem; }
.card h3 { font-size: 0.9rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    align-items: stretch;
}

.grid.grid-campaign-edit,
.grid.grid-content-layout {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1024px) {
    .grid.grid-campaign-edit {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
        align-items: flex-start;
    }

    .grid.grid-content-layout {
        /* Force single column full width for content layout */
        grid-template-columns: 1fr;
        max-width: 100%;
    }
        align-items: flex-start;
    }

    .grid.grid-content-layout.grid-content-layout-single {
        grid-template-columns: minmax(0, 1fr);
        align-items: flex-start;
    }
}

.dashboard-charts {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.dashboard-summary-list {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.85rem;
    color: var(--text-main);
}

.dashboard-charts .card {
    display: flex;
    flex-direction: column;
    height: auto;
}

.dashboard-charts .card .table-header {
    margin-bottom: 0.75rem;
}

.dashboard-charts .card canvas {
    width: 100% !important;
    height: 180px !important;
    max-height: 180px;
    box-sizing: border-box;
}

.card.kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 72px;
    padding: 0.5rem 0.75rem;
    border-radius: 0.35rem;
    cursor: default;
}

.card.kpi .label {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #111827;
}

.card.kpi .value {
    font-size: 0.95rem;
    font-weight: 600;
}

.grid > .card.kpi:nth-child(1) {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-color: #bfdbfe;
}

.grid > .card.kpi:nth-child(2) {
    background: linear-gradient(135deg, #f5f3ff, #eef2ff);
    border-color: #ddd6fe;
}

.grid > .card.kpi:nth-child(3) {
    background: linear-gradient(135deg, #ecfdf5, #dcfce7);
    border-color: #bbf7d0;
}

.grid > .card.kpi:nth-child(4) {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: #fde68a;
}

.grid > .card.kpi:nth-child(5) {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fecaca;
}

.card.kpi:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

@media (max-width: 767px) {
    .grid {
        gap: 0.5rem;
    }

    .card.kpi {
        min-height: 64px;
        padding: 0.4rem 0.6rem;
    }

    .card h1 { font-size: 1.05rem; }
    .card h2 { font-size: 0.95rem; }

    .dashboard-charts {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .dashboard-charts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .dashboard-charts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* --- Tables --- */

.table-wrapper {
    overflow-x: auto;
    margin: 0 calc(var(--card-padding) * -1); /* Negative margin to span full card width */
    border-top: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem; /* Smaller font for tables */
    text-align: left;
}

.table th {
    background-color: #f9fafb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem; /* Smaller headers */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem; /* Tighter padding */
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 0.5rem 0.75rem; /* Tighter padding */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    white-space: nowrap;
    vertical-align: middle;
}

.table tr:hover td {
    background-color: #f9fafb;
}

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

/* --- Badges --- */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.12rem 0.45rem;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.badge-status-default {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #4b5563;
}

.badge-status-enabled {
    background-color: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.badge-status-paused {
    background-color: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.badge-status-removed {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.badge-mock {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
    background: #fef3c7;
    color: #92400e;
}

.badge-real {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
    background: #e5e7eb;
    color: #111827;
}

.cell-metrics, .cell-automations {
    white-space: normal;
}

.cell-metrics > div,
.cell-automations > div {
    line-height: 1.25;
}

/* Landing / Auth specific overrides */
.auth-wrapper {
    min-height: calc(100vh - var(--topbar-height));
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    padding: 1.5rem 0;
}

.auth-card {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    border-radius: 0.75rem;
}

.auth-card h1 { color: #f8fafc; text-align: center; }
.auth-card .form span { color: #cbd5e1; }
.auth-card input {
    background-color: #0f172a;
    border-color: #475569;
    color: #f8fafc;
}

.landing-auth-card {
    background: #ffffff;
    border-color: rgba(148,163,184,0.55);
    color: #0f172a;
    box-shadow: 0 16px 40px rgba(15,23,42,0.12);
}

.landing-auth-card .form span {
    color: #0f172a;
}

.landing-auth-card input {
    background-color: #f9fafb;
    border-color: #d1d5db;
    color: #0f172a;
}

.auth-card-login {
    max-width: 420px;
}

/* Landing Page Grid */
.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); /* Tighter grid */
    gap: 1rem; /* Reduced gap */
}

/* Helpers */
.landing-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.landing {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.landing-hero {
    align-items: stretch;
    background: radial-gradient(circle at top left, #eff6ff 0, #eef2ff 45%, #e5e7eb 100%);
    border-radius: 0.9rem;
    border: 1px solid rgba(148,163,184,0.4);
    padding: 1.5rem;
    box-shadow: 0 18px 40px rgba(15,23,42,0.08);
}

.landing-copy {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.landing-eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: #4b5563;
}

.landing-copy h1 {
    font-size: 1.7rem;
    line-height: 1.25;
}

.landing-copy p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.landing-logos {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: center;
    margin-top: 0.25rem;
}

.landing-logos-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6b7280;
    font-weight: 600;
}

.landing-logos-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.logo-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(15,23,42,0.03);
    border: 1px solid rgba(148,163,184,0.5);
    font-size: 0.78rem;
    color: #0f172a;
}

.logo-pill i {
    font-size: 0.8rem;
}

.landing-features {
    list-style: disc;
    padding-left: 1.1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.35rem 1rem;
    font-size: 0.85rem;
    color: var(--text-main);
}

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-hero-primary {
    padding-inline: 1.2rem;
    padding-block: 0.55rem;
    font-size: 0.9rem;
    box-shadow: 0 14px 30px rgba(15,23,42,0.25);
    background: linear-gradient(135deg, #4f46e5, #2563eb);
    border-color: #4f46e5;
    color: #f9fafb;
}

.btn-hero-secondary {
    padding-inline: 1rem;
    padding-block: 0.55rem;
    font-size: 0.88rem;
}

.btn-hero-primary span[aria-hidden="true"] {
    color: #f9fafb;
    font-weight: 600;
}

.landing-form {
    align-self: stretch;
}

.landing-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kpi-row .mini-kpi {
    flex: 1 1 0;
    min-width: 180px;
}

.mini-kpi .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mini-kpi .value {
    font-size: 1.1rem;
    font-weight: 600;
}

.mini-kpi .hint {
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.landing-benefits .card ul {
    padding-left: 1.1rem;
    font-size: 0.85rem;
}

.landing-benefits .card li + li {
    margin-top: 2px;
}

.step-card {
    position: relative;
    padding-left: 2rem;
}

.step-tag {
    position: absolute;
    left: 0.5rem;
    top: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #111827;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.plan-card {
    flex: 1 1 0;
    min-width: 200px;
}

.plan-card ul {
    padding-left: 1.1rem;
    font-size: 0.82rem;
}

.plan-card li + li {
    margin-top: 2px;
}

.plan-card-highlight {
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79,70,229,0.12), 0 8px 16px rgba(15,23,42,0.18);
}

.hero-visual {
    margin-top: 1rem;
}

.hero-screen {
    border-radius: 0.9rem;
    background: radial-gradient(circle at top left, #0f172a, #020617);
    padding: 0.8rem;
    color: #e5e7eb;
    box-shadow: 0 18px 32px rgba(15,23,42,0.8);
}

.hero-screen-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0.6rem;
}

.hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}

.dot-red { background: #f97373; }
.dot-amber { background: #facc15; }
.dot-green { background: #4ade80; }

.hero-title {
    margin-left: 8px;
    font-size: 0.78rem;
    color: #9ca3af;
}

.hero-screen-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hero-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.hero-metric-pill {
    flex: 1 1 0;
    min-width: 120px;
    padding: 0.45rem 0.6rem;
    border-radius: 0.75rem;
    background: rgba(15,23,42,0.85);
    border: 1px solid rgba(148,163,184,0.4);
}

.hero-metric-label {
    display: block;
    font-size: 0.7rem;
    color: #9ca3af;
}

.hero-metric-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e5e7eb;
}

.hero-chart-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.hero-chart-bar-group {
    flex: 1 1 0;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.hero-chart-bar {
    flex: 1;
    border-radius: 0.4rem 0.4rem 0 0;
    background: linear-gradient(to top, #22c55e, #a3e635);
    opacity: 0.9;
}

.hero-chart-bar.bar-1 { height: 26px; }
.hero-chart-bar.bar-2 { height: 40px; }
.hero-chart-bar.bar-3 { height: 32px; }
.hero-chart-bar.bar-4 { height: 20px; }

.hero-chart-list {
    flex: 1.3 1 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.78rem;
}

.hero-chart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.45rem;
    border-radius: 0.5rem;
    background: rgba(15,23,42,0.85);
}

.hero-chart-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.dot-google { background: #22c55e; }
.dot-meta { background: #3b82f6; }
.dot-neutral { background: #e5e7eb; }

.hero-chart-label {
    flex: 1;
    margin-left: 6px;
    color: #e5e7eb;
}

.hero-chart-number {
    font-weight: 600;
}

@media (max-width: 640px) {
    .container-fluid {
        padding: 16px;
    }
    .landing-row {
        flex-direction: column;
        align-items: stretch;
    }
    .landing-row > * {
        width: 100%;
    }
    .landing {
        max-width: 100%;
        gap: 1rem;
    }
    .landing-copy h1 {
        font-size: 1.3rem;
    }
    .landing-features {
        grid-template-columns: minmax(0, 1fr);
    }
    .hero-chart-row {
        flex-direction: column;
    }
}

/* --- Mobile High Density Overrides --- */
@media (max-width: 640px) {
    :root {
        --container-padding: 0.5rem; /* 8px padding */
        --card-padding: 0.75rem; /* 12px padding */
        --topbar-height: 44px;
    }
    
    body {
        font-size: 12px; /* Smaller base font */
    }

    .container-fluid {
        padding: var(--container-padding);
    }
    
    .card h1 { font-size: 1.1rem; margin-bottom: 0.5rem; }
    .card h2 { font-size: 0.95rem; margin-bottom: 0.5rem; }
    
    /* Tighter buttons on mobile */
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        width: 100%; /* Full width for touch targets */
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .btn-icon {
        width: 28px;
        height: 28px;
        display: inline-flex; /* Reset width for icon buttons */
        width: 28px;
    }
    
    /* Maximize table density */
    .table-wrapper {
        margin: 0 calc(var(--card-padding) * -1);
        width: calc(100% + var(--card-padding) * 2);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .table th, .table td {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Stack header actions */
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    /* Adjust topbar */
    .topbar {
        padding: 0 8px;
    }
    
    .logo-mobile {
        font-size: 14px;
    }

    .integrations-card > div {
        margin-top: 6px !important;
    }

    .integrations-card p {
        margin-top: 2px !important;
        margin-bottom: 4px !important;
    }

    .integrations-card .landing-row {
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .integrations-card h2,
    .integrations-card h3 {
        margin-bottom: 2px !important;
    }

    .integrations-card p {
        margin-top: 1px !important;
        margin-bottom: 3px !important;
    }

    .integrations-connect-col {
        margin-top: 4px !important;
    }

    .integrations-connect-col a.btn {
        margin-top: 2px;
        margin-bottom: 2px;
    }

    .integrations-connect-col p + p {
        margin-top: 2px !important;
    }

    .integrations-credentials-card {
        margin-top: 8px !important;
    }

    .integrations-credentials-card .landing-row {
        gap: 0.5rem !important;
    }

    .integrations-credentials-card label {
        margin-bottom: 6px;
    }
}
