:root {
    --hc-sidebar-bg: #0f0f1a;
    --hc-sidebar-width: 240px;
    --hc-accent: #6366f1;
    --hc-body-bg: #f4f6fb;
}

body.hc-body {
    min-height: 100vh;
    background: var(--hc-body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Sidebar ---------- */

.hc-sidebar {
    width: var(--hc-sidebar-width);
    min-height: 100vh;
    background: var(--hc-sidebar-bg);
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    overflow-y: auto;
}

.hc-brand {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
}

.hc-brand:hover { color: #a5b4fc; }

.hc-nav-link {
    color: #94a3b8;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
}

.hc-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}

.hc-nav-link.active {
    color: #fff;
    background: var(--hc-accent);
}

.hc-nav-section {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 0 12px;
    margin-top: 8px;
}

.hc-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Main ---------- */

.hc-main {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

/* ---------- Cards ---------- */

.hc-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.hc-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* ---------- Table ---------- */

.hc-table {
    width: 100%;
    border-collapse: collapse;
}

.hc-table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    font-weight: 600;
    padding: 10px 16px;
    border-bottom: 1px solid #e8edf3;
    white-space: nowrap;
    background: #fff;
}

.hc-table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    color: #1e293b;
}

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

.hc-table tbody tr:hover td { background: #f8faff; }

/* ---------- Badges ---------- */

.hc-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hc-badge-newsletter { background: #dcfce7; color: #15803d; }
.hc-badge-quote      { background: #fef9c3; color: #854d0e; }
.hc-badge-lead       { background: #ede9fe; color: #6d28d9; }
.hc-badge-default    { background: #f1f5f9; color: #475569; }

/* ---------- Monospace ID ---------- */

.hc-id {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.72rem;
    color: #94a3b8;
}

/* ---------- Page header ---------- */

.hc-page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.hc-subtitle {
    font-size: 0.875rem;
    color: #64748b;
}

/* ---------- Filter bar ---------- */

.hc-filter-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
}

/* ---------- Code / JSON ---------- */

.hc-json {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    max-height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: #1e293b;
    line-height: 1.6;
}

/* ---------- Login ---------- */

.hc-login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a16 0%, #1a1040 60%, #0f1a30 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hc-login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.hc-login-logo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--hc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ---------- Detail metadata table ---------- */

.hc-meta td:first-child {
    width: 160px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: top;
    padding-top: 6px;
}

.hc-meta td {
    padding: 6px 0;
    font-size: 0.875rem;
    border: none;
}

/* ---------- DB status pill ---------- */

.hc-db-ok   { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.hc-db-err  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ==================== RESPONSIVE ==================== */

/* Mobile topbar — hidden on desktop */
.hc-topbar {
    display: none;
    background: var(--hc-sidebar-bg);
    padding: 10px 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}

/* Hamburger button */
.hc-hamburger {
    background: transparent;
    border: 1px solid rgba(255,255,255,.12);
    color: #94a3b8;
    font-size: 1.3rem;
    padding: 5px 9px;
    border-radius: 7px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: color .15s, border-color .15s;
}
.hc-hamburger:hover  { color: #fff; border-color: rgba(255,255,255,.25); }
.hc-hamburger:focus-visible { outline: 2px solid var(--hc-accent); outline-offset: 2px; }

/* Backdrop overlay for off-canvas sidebar */
.hc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 300;
    animation: hcFadeIn .18s ease;
}
.hc-overlay.active { display: block; }

@keyframes hcFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Tablet (≤ 991px) ── */
@media (max-width: 991.98px) {
    .hc-main { padding: 1.25rem !important; }
}

/* ── Mobile (≤ 767px) ── */
@media (max-width: 767.98px) {

    /* Show mobile topbar */
    .hc-topbar { display: flex; }

    /* Off-canvas sidebar */
    .hc-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 400;
        transform: translateX(-110%);
        transition: transform 0.26s cubic-bezier(.4, 0, .2, 1);
    }
    .hc-sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 40px rgba(0, 0, 0, .5);
    }

    /* Main takes full width — sidebar is out of flex flow when fixed */
    .hc-main { padding: 0.875rem !important; }

    .hc-page-title { font-size: 1.2rem; }

    /* Filter bars: stack inputs vertically */
    .hc-filter-bar .d-flex.flex-wrap.gap-2.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
    }
    .hc-filter-bar select,
    .hc-filter-bar input[type="text"],
    .hc-filter-bar input[type="date"] {
        width: 100% !important;
        min-width: unset !important;
    }
    .hc-filter-bar .btn { align-self: flex-start; }

    /* Date range container */
    .hc-date-range {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    .hc-date-range input[type="date"] { flex: 1 1 130px; }

    /* Template editor: label + variable buttons wrap on mobile */
    .hc-var-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }
    .hc-var-row .d-flex.gap-1 { flex-wrap: wrap; }

    /* Login: side padding so card doesn't touch screen edge */
    .hc-login-wrap { padding: 1rem; }
}

/* ── Small Mobile (≤ 575px) ── */
@media (max-width: 575.98px) {
    .hc-main { padding: 0.75rem !important; }
    .hc-page-title { font-size: 1.1rem; }

    /* Hero headers in Detail and LeadDetail: reduce padding */
    .hc-hero { padding: 14px 16px !important; }

    /* Table cells: tighter padding */
    .hc-table thead th,
    .hc-table tbody td { padding: 9px 10px; }
}
