:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6d778b;
    --line: #dfe5ef;
    --brand: #6366f1;
    --brand-dark: #4f46e5;
    --accent: #d16f3f;
    --success: #16825d;
    --warning: #a96805;
    --danger: #b83b46;
    --shadow: 0 4px 24px rgba(23, 32, 51, 0.07);
    --shadow-md: 0 8px 32px rgba(23, 32, 51, 0.12);
    --radius: 14px;
    --transition: 0.15s ease;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', Inter, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

/* ─── Template: Glass card ──────────────────────────────── */

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: box-shadow var(--transition), transform var(--transition);
}

.glass-card:hover {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08), 0 1px 4px rgba(0,0,0,0.04);
}

/* ─── Template: Sidebar nav item ────────────────────────── */

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    color: #94a3b8;
    border-radius: 0.5rem;
    transition: all 0.15s;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-item:hover,
.nav-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* ─── Template: Custom scrollbar ────────────────────────── */

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* ─── Template: Status badges ───────────────────────────── */

.status-badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active  { background: #dcfce7; color: #15803d; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-paused  { background: #fee2e2; color: #991b1b; }

/* ─── Template: Misc ─────────────────────────────────────── */

.brand-large {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    color: var(--brand-dark);
    margin-bottom: 24px;
}

.muted {
    color: var(--muted);
}

.page-header,
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

h1,
h2,
p {
    margin-top: 0;
    overflow-wrap: anywhere;
}

h1 {
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.08;
    margin-bottom: 0;
}

h2 {
    font-size: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card,
.panel,
.auth-card,
.ref-link,
.ref-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 22px;
    display: grid;
    gap: 12px;
}

.stat-card span,
td span,
.small {
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    font-size: 28px;
}

.panel {
    padding: 22px;
}

.two-column {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    font: inherit;
    color: var(--text);
    background: #ffffff;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ─── Table polish ───────────────────────────────────────── */

tr:hover td {
    background: #f8fafc;
}

tbody tr {
    transition: background var(--transition);
}

.button {
    border: 0;
    border-radius: 8px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.button:active {
    transform: translateY(1px);
}

.button.primary {
    background: var(--brand);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--brand-dark);
}

.button.ghost {
    color: var(--brand);
    background: #eaf4f8;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

td strong,
td span {
    display: block;
}

.badge,
.code-pill {
    display: inline-flex;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge.active,
.badge.approved,
.badge.paid {
    color: var(--success);
    background: #e8f6f0;
}

.badge.pending,
.badge.lead,
.badge.paused {
    color: var(--warning);
    background: #fff4df;
}

.badge.cancelled,
.alert.error {
    color: var(--danger);
    background: #fdecef;
}

.code-pill {
    color: var(--brand-dark);
    background: #eaf4f8;
}

.empty-state {
    color: var(--muted);
    text-align: center;
}

.alert {
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert.success {
    color: #15803d;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.alert.error {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
}

.alert.warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.auth-layout,
.public-lead {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.75fr);
    gap: 38px;
    align-items: center;
    padding: 48px;
    background: linear-gradient(135deg, #f8fbfd 0%, #e8f1f5 52%, #fff7ee 100%);
}

.auth-background {
    position: relative;
    isolation: isolate;
    background-image: linear-gradient(90deg, rgba(248, 251, 253, 0.96) 0%, rgba(232, 241, 245, 0.9) 42%, rgba(16, 24, 40, 0.5) 100%), url('https://images.unsplash.com/photo-1551836022-d5d88e9218df?auto=format&fit=crop&w=1800&q=80');
    background-size: cover;
    background-position: center right;
}

.auth-background::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(255, 255, 255, 0.08);
}

.auth-hero,
.lead-copy {
    max-width: 720px;
}

.auth-hero p,
.lead-copy p {
    color: #4f5b6f;
    font-size: 18px;
    line-height: 1.7;
}

.brand-large {
    margin-bottom: 24px;
    color: var(--brand-dark);
}

.auth-card {
    padding: 28px;
    display: grid;
    gap: 18px;
}

.ref-link,
.ref-box {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ref-link span {
    font-weight: 800;
}

@media (max-width: 980px) {
    .auth-layout,
    .public-lead,
    .two-column {
        display: block;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth-layout,
    .public-lead {
        min-height: 100dvh;
        padding: 28px 18px;
    }

    .auth-background {
        background-image: linear-gradient(180deg, rgba(248, 251, 253, 0.98) 0%, rgba(232, 241, 245, 0.94) 56%, rgba(16, 24, 40, 0.36) 100%), url('https://images.unsplash.com/photo-1551836022-d5d88e9218df?auto=format&fit=crop&w=1200&q=80');
        background-position: center top;
    }

    .auth-card,
    .public-lead .panel {
        margin-top: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }
}

@media (max-width: 620px) {
    .brand span:last-child {
        font-size: 15px;
    }

    h1 {
        font-size: 30px;
        line-height: 1.12;
    }

    h2 {
        font-size: 18px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header,
    .panel-header,
    .ref-link {
        align-items: stretch;
        flex-direction: column;
    }

    .panel,
    .auth-card,
    .stat-card {
        padding: 18px;
    }

    .button {
        width: 100%;
    }

    table {
        min-width: 640px;
    }

    th,
    td {
        padding: 12px 10px;
    }

    .auth-hero p,
    .lead-copy p {
        font-size: 16px;
        line-height: 1.6;
    }
}

@media (max-width: 420px) {
    .auth-layout,
    .public-lead {
        padding-left: 14px;
        padding-right: 14px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* ─── Modern enhancements ────────────────────────────────── */

/* Kpi / stat card hover lift */
.glass-card.kpi-card {
    cursor: default;
}

/* Action buttons (used inline in tables / modals) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.btn-icon:active { transform: scale(0.93); }
.btn-icon.edit   { background: #eef2ff; color: #6366f1; }
.btn-icon.edit:hover   { background: #e0e7ff; }
.btn-icon.delete { background: #fff1f2; color: #ef4444; }
.btn-icon.delete:hover { background: #ffe4e6; }
.btn-icon.view   { background: #f0fdf4; color: #16a34a; }
.btn-icon.view:hover   { background: #dcfce7; }

/* Section eyebrow label */
.section-eyebrow {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6366f1;
    margin: 0 0 6px;
}

/* ID pill — CLT / INF badges */
.id-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: #eef2ff;
    color: #4338ca;
    white-space: nowrap;
}

/* Badge additions for more statuses */
.badge.inactive,
.badge.cancelled { background: #fee2e2; color: #991b1b; }
.badge.approved  { background: #dcfce7; color: #15803d; }
.badge.paid      { background: #dcfce7; color: #15803d; }
.badge.active    { background: #dcfce7; color: #15803d; }
.badge.lead      { background: #fef9c3; color: #854d0e; }
.badge.pending   { background: #fef9c3; color: #854d0e; }
.badge.paused    { background: #f1f5f9; color: #64748b; }

/* Smooth page transitions */
.p-8 > * {
    animation: fadeUp 0.2s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Copy button */
.copy-button {
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
}
.copy-button:hover { background: #4f46e5; }

/* Sidebar nav hover (CSS fallback for JS-free hover) */
.nav-item:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* ── Mobile sidebar toggle button ────────────────────────── */
#sidebarToggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s;
}
#sidebarToggle:hover { background: #f1f5f9; }

/* ── Sidebar overlay backdrop ─────────────────────────────── */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.42);
    z-index: 9996;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
#sidebarOverlay.open { display: block; }

/* ── Tablet (≤ 900px) ────────────────────────────────────── */
@media (max-width: 900px) {
    .two-column { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ── Mobile (≤ 768px) ────────────────────────────────────── */
@media (max-width: 768px) {
    /* Show hamburger */
    #sidebarToggle { display: flex; }

    /* Sidebar: slide-in overlay drawer */
    #sidebarWrap {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100dvh !important;
        z-index: 9997 !important;
        padding: 0 !important;
        transform: translateX(-310px);
        transition: transform .28s cubic-bezier(.25,.8,.25,1);
        will-change: transform;
    }
    #sidebarWrap.open { transform: translateX(0); }
    #sidebarPanel {
        height: 100dvh !important;
        border-radius: 0 2rem 2rem 0 !important;
    }

    /* Header padding */
    #mainHeader { padding-left: 1rem !important; padding-right: 1rem !important; }

    /* Shrink search bar */
    #headerSearch { width: 160px !important; }

    /* Hide user name on mobile */
    .header-user-name { display: none !important; }

    /* Notification dropdown: cap width */
    #notifDropdown { width: min(360px, calc(100vw - 24px)) !important; }

    /* Content area padding */
    .p-8 { padding: 1rem !important; }

    /* Flash alert margins */
    .alert[style*="margin: 16px 32px"] { margin: 10px 16px 0 !important; }

    /* Marquee */
    .inf-marquee { margin: 8px 12px 0 !important; }

    /* Page header stack */
    .page-header { flex-wrap: wrap; gap: 8px; }

    /* Form grid single column */
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }

    /* Tables always scroll horizontally */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }
}

/* ── Small phones (≤ 480px) ──────────────────────────────── */
@media (max-width: 480px) {
    /* Single column stats */
    .stats-grid { grid-template-columns: 1fr !important; }

    /* Hide search completely */
    #headerSearch { display: none !important; }

    /* Notification anchored to near-viewport edge */
    #notifDropdown { right: -10px !important; width: calc(100vw - 20px) !important; }

    /* Content: tighter */
    .p-8 { padding: 0.75rem !important; }

    .panel, .stat-card { padding: 16px !important; }
}

