﻿:root {
    --color-primary: #4A90B8;
    --color-secondary: #6B7280;
    --color-accent: #F97316;
    --color-white: #FFFFFF;
    --color-sidebar-bg: #1F2937;
    --color-sidebar-text: #D1D5DB;
    --color-sidebar-hover: #374151;
    --color-header-bg: #1F2937;
    --color-body-bg: #F3F4F6;
    --sidebar-width: 260px;
    --header-height: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-body-bg);
    color: #111827;
}

/* ── LAYOUT SHELL ──────────────────────────────────────── */
.layout-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── HEADER ────────────────────────────────────────────── */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    background-color: var(--color-header-bg);
    padding: 0 1.25rem;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.header-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--color-white);
    font-weight: 600;
}

.header-user svg { fill: var(--color-primary); }

.header-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    position: relative;
}

.header-nav .nav-btn {
    background: transparent;
    border: none;
    color: var(--color-sidebar-text);
    font-size: .9rem;
    cursor: pointer;
    padding: .4rem .75rem;
    border-radius: 6px;
    transition: background .2s, color .2s;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.header-nav .nav-btn:hover,
.header-nav .nav-btn.active {
    background: var(--color-accent);
    color: var(--color-white);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--color-white);
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
}

.dropdown-menu a,
.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .65rem 1rem;
    font-size: .875rem;
    color: #374151;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background .15s;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background: #F3F4F6;
    color: var(--color-accent);
}

.dropdown-logout-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .65rem 1rem;
    font-size: .875rem;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background .15s;
}

.dropdown-logout-btn:hover {
    background: #F3F4F6;
    color: var(--color-accent);
}

.dropdown-divider { height: 1px; background: #E5E7EB; }

/* ── BODY AREA ─────────────────────────────────────────── */
.body-area {
    display: flex;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #374151 transparent;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4rem 1rem;
    border-bottom: 1px solid #374151;
}

.sidebar-logo .logo-placeholder {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 1px;
}

.nav-sections {
    padding: .75rem .5rem .25rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.nav-section-tab {
    background: linear-gradient(135deg, #2D3748, #374151);
    border: 1px solid #4B5563;
    border-radius: 7px;
    overflow: hidden;
}

.nav-section-tab .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem .9rem;
    cursor: pointer;
    color: var(--color-white);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    transition: background .2s;
    user-select: none;
}

.nav-section-tab .section-header:hover        { background: var(--color-primary); }
.nav-section-tab .section-header.expanded     { background: var(--color-primary); border-bottom: 1px solid #3B82F6; }

.section-chevron       { transition: transform .25s; font-size: .7rem; color: var(--color-sidebar-text); }
.section-chevron.open  { transform: rotate(180deg); }

.section-sub-menu { display: flex; flex-direction: column; background: #111827; }

.section-sub-menu a {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .9rem .5rem 1.2rem;
    font-size: .825rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s, color .15s;
}

.section-sub-menu a:hover,
.section-sub-menu a.active {
    background: #1F2937;
    border-left-color: var(--color-accent);
    color: var(--color-white);
}

.nav-standalone {
    padding: .5rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    border-top: 1px solid #374151;
    margin-top: .25rem;
}

.nav-standalone a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .9rem;
    font-size: .875rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-radius: 7px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.nav-standalone a:hover,
.nav-standalone a.active {
    background: var(--color-sidebar-hover);
    color: var(--color-white);
    border-left-color: var(--color-accent);
}

.nav-item-icon { font-size: 1rem; width: 20px, text-align: center; color: var(--color-secondary); }
.nav-standalone a:hover .nav-item-icon,
.nav-standalone a.active .nav-item-icon { color: var(--color-accent); }

.nav-standalone-section {
    border-radius: 7px;
    overflow: hidden;
}

.nav-standalone-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .9rem;
    cursor: pointer;
    color: var(--color-sidebar-text);
    font-size: .875rem;
    font-weight: 400;
    border-radius: 7px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    user-select: none;
}

.nav-standalone-section .section-header:hover,
.nav-standalone-section .section-header.expanded {
    background: var(--color-sidebar-hover);
    color: var(--color-white);
    border-left-color: var(--color-accent);
}

.nav-standalone-section .section-header.expanded {
    border-radius: 7px 7px 0 0;
}

.nav-standalone-section .section-sub-menu {
    display: flex;
    flex-direction: column;
    background: transparent;
}

.nav-standalone-section .section-sub-menu a {
    padding-left: 2rem;
    border-radius: 0 0 7px 7px;
}

/* ── MAIN CONTENT ──────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; background: var(--color-body-bg); }

/* ── PAGE CARD ─────────────────────────────────────────── */
.page-card {
    background: var(--color-white);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    padding: 1.5rem;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 1rem;
    padding-bottom: .6rem;
    border-bottom: 2px solid var(--color-primary);
}

/* ── PAGE HEADER ROW ───────────────────────────────────── */
.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.toolbar-label { font-size: .875rem; font-weight: 600; color: #374151; }
.status-text   { color: #9CA3AF; font-size: .875rem; }
.record-count  { margin-top: .75rem; font-size: .8rem; color: #6B7280; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 600;
    transition: opacity .2s, transform .1s;
}

.btn:hover  { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--color-primary);   color: var(--color-white); }
.btn-accent  { background: var(--color-accent);    color: var(--color-white); }
.btn-grey    { background: var(--color-secondary); color: var(--color-white); }
.btn-outline { background: transparent; border: 1px solid var(--color-primary); color: var(--color-primary); }
.btn-sm      { padding: .3rem .65rem; font-size: .78rem; }

/* ── BUTTON SPINNER ──────────────────────────────────────── */
.btn-spinner {
    display: inline-block;
    width: .85rem;
    height: .85rem;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-right: .3rem;
    vertical-align: middle;
}

/* ── TABLE ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }

.data-table th {
    background: var(--color-primary);
    color: var(--color-white);
    padding: .65rem 1rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.data-table th:first-child { border-radius: 7px 0 0 0; }
.data.table th:last-child  { border-radius: 0 7px 0 0; }

.data-table td { padding: .6rem 1rem; border-bottom: 1px solid #E5E7EB; color: #374151; }
.data-table tr:hover td { background: #F9FAFB; }
.data-table tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-phone { background: #DBEAFE; color: #1D4ED8; }
.badge-email { background: #D1FAE5; color: #065F46; }
.badge-ip    { background: #FEE2E2; color: #991B1B; }

/* ── OMNISUBSYSTEM BADGES ───────────────────────────────── */
.badge-db    { background: #EFF6FF; color: #1D4ED8; }
.badge-queue { background: #F0FDF4; color: #15803D; }

/* ── ALERTS ────────────────────────────────────────────── */
.alert-success {
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    border-radius: 8px;
    padding: .65rem 1rem;
    font-size: .85rem;
    font-weight: 600;
    color: #15803D;
}

.alert-error {
    background: #FFF1F2;
    border: 1px solid #FECDD3;
    border-radius: 8px;
    padding: .65rem 1rem;
    font-size: .85rem;
    font-weight: 600;
    color: #BE123C;
}

/* ── MODAL ─────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 300;
    animation: fadeIn .15s ease;
}

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 301;
    background: var(--color-white);
    border-radius: 12px;
    width: min(540px, 94vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: slideUp .2s ease;
}

.modal-dialog-wide { width: min(780px, 96vw); }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { transform: translate(-50%, -46%); opacity: 0; }
    to   { transform: translate(-50%, -50%); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #E5E7EB;
    font-size: 1rem;
    font-weight: 700;
    color: #1F2937;
    background: linear-gradient(135deg, #F8FAFC, #EFF6FF);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #9CA3AF;
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 4px;
    transition: background .15s, color .15s;
}

.modal-close:hover { background: #FEE2E2; color: #DC2626; }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    padding: .9rem 1.25rem;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

/* ── FORM FIELDS ───────────────────────────────────────── */
.field-group {
    display: flex;
    flex-direction: column;   /* ← this is what was missing */
    gap: .4rem;
    width: 100%;
}

.field-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.4;
}

.field-hint {
    font-weight: 400;
    color: #9CA3AF;
    font-size: .75rem;
    margin-left: .3rem;
}

.required { color: #EF4444; }

.form-select,
.form-input {
    width: 100%;
    padding: .45rem .75rem;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: .875rem;
    color: #374151;
    background: var(--color-white);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.form-select:focus,
.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74,144,184,0.15);
}

.form-textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: .825rem;
    font-family: 'Consolas', monospace;
    color: #374151;
    background: var(--color-white);
    resize: vertical;
    min-height: 130px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    line-height: 1.6;
    display: block;      /* ← ensures it sits below the label */
}

.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74,144,184,0.15);
}

/* ── PARSE SUMMARY BAR ──────────────────────────────────── */
.parse-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F8FAFC;
    border: 1px solid #E5E7EB;
    border-radius: 7px;
    padding: .55rem .9rem;
    font-size: .82rem;
    color: #374151;
}

.summary-type { display: flex; align-items: center; gap: .4rem; }

/* ── PARSE RESULTS GRID ─────────────────────────────────── */
.parse-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.parse-col {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.parse-col-valid   { border-color: #BBF7D0; }
.parse-col-invalid { border-color: #FECDD3; }

.parse-col-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .75rem;
    font-size: .78rem;
    font-weight: 700;
    color: #374151;
    border-bottom: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.parse-col-valid   .parse-col-header { background: #F0FDF4; border-color: #BBF7D0; }
.parse-col-invalid .parse-col-header { background: #FFF1F2; border-color: #FECDD3; }

.parse-dot       { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.parse-dot-green { background: #22C55E; }
.parse-dot-red   { background: #EF4444; }

.parse-count     { margin-left: auto; font-weight: 700; color: #15803D; }
.parse-count-red { color: #DC2626; }

.parse-col-scroll {
    overflow-y: auto;
    max-height: 220px;
    padding: .4rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    background: var(--color-white);
}

.parse-empty { font-size: .8rem; color: #9CA3AF; padding: .4rem; text-align: center; }

.parse-item {
    font-size: .78rem;
    font-family: 'Consolas', monospace;
    padding: .25rem .45rem;
    border-radius: 4px;
    word-break: break-all;
}

.parse-item-valid   { background: #DCFCE7; color: #166534; }
.parse-item-invalid { background: #FEF2F2; color: #991B1B; display: flex; flex-direction: column; gap: .1rem; }
.parse-item-value   { font-weight: 600; }
.parse-item-reason  { font-size: .72rem; color: #B91C1C; font-style: italic; }

.parse-warn {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 7px;
    padding: .55rem .9rem;
    font-size: .8rem;
    color: #92400E;
} 

/* ── SEARCH BOX ────────────────────────────────────────── */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    left: .6rem;
    font-size: .85rem;
    pointer-events: none;
    line-height: 1;
}

.search-input {
    width: 100%;
    padding: .45rem .75rem .45rem 2rem;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: .875rem;
    color: #374151;
    background: var(--color-white);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74,144,184,0.15);
}

.search-clear {
    position: absolute;
    right: .4rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #9CA3AF;
    font-size: .8rem;
    padding: .2rem .35rem;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
}

.search-clear:hover { color: #DC2626; background: #FEE2E2; }

/* ── SEARCH RESULTS ────────────────────────────────────── */
.search-highlight {
    background: #FEF08A;
    color: #713F12;
    border-radius: 2px;
    padding: 0 1px;
    font-weight: 600;
}

.search-hint { color: #9CA3AF; font-style: italic; }

.search-no-results {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: #F9FAFB;
    border: 1px dashed #D1D5DB;
    border-radius: 8px;
    font-size: .875rem;
    color: #6B7280;
}

/* ── CONTENT KEYWORD BADGES ────────────────────────────── */
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-critical { background: #FEE2E2; color: #991B1B; }
.badge-active   { background: #D1FAE5; color: #065F46; }
.badge-yellow   { background: #FEF9C3; color: #854D0E; }
.badge-inactive { background: #F3F4F6; color: #6B7280; }  /* kept for any static use */

/* Light-red variant used on the inactive toggle pill */
.badge-inactive-red { background: #FEE2E2; color: #991B1B; }

/* ── ACTIVE/INACTIVE TOGGLE BUTTON ─────────────────────── */
.badge-toggle {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: filter .15s, transform .1s, opacity .15s;
    white-space: nowrap;
    font-family: inherit;
}

.badge-toggle:hover  { filter: brightness(.92); transform: translateY(-1px); }
.badge-toggle:active { transform: translateY(0); }

.badge-toggle:disabled {
    opacity: .6;
    cursor: wait;
    transform: none;
}

/* ── SORTABLE TABLE HEADERS ─────────────────────────────── */
.sort-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sort-th:hover { background: #3a7fa8; }

.sort-th .sort-icons {
    display: inline-flex;
    flex-direction: column;
    margin-left: .35rem;
    gap: 1px;
    vertical-align: middle;
    line-height: 1;
    opacity: .45;
    font-size: .6rem;
}

.sort-th.sorted .sort-icons { opacity: 1; }

.sort-th .sort-asc  { line-height: 1; }
.sort-th .sort-desc { line-height: 1; }

.sort-th.asc  .sort-desc,
.sort-th.desc .sort-asc  { opacity: .25; }
/* ── MARKETING SOURCE BADGES ────────────────────────────── */
.badge-spark  { background: #EDE9FE; color: #5B21B6; }
.badge-market { background: #FEF3C7; color: #92400E; }

/* ── LOGIN PAGE ────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-sidebar-bg);
}

.login-card {
    background: var(--color-white);
    border-radius: 14px;
    padding: 2.5rem 2rem;
    width: min(420px, 96vw);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.login-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
    letter-spacing: 1px;
}

.login-logo img {
    max-width: 120px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.login-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1F2937;
    text-align: center;
    margin: 0;
}

.login-subtitle {
    font-size: .875rem;
    color: #6B7280;
    text-align: center;
    margin-bottom: .5rem;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: #374151;
    margin-top: .75rem;
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: .65rem;
    font-size: .95rem;
    margin-top: 1rem;
}

/* ── APPROVAL PAGE ──────────────────────────────────────── */
.approval-th {
    text-align: center;
    padding: .5rem .6rem;
    white-space: nowrap;
}

.approval-cell {
    text-align: center;
    padding: .5rem .6rem;
    white-space: nowrap;
}

.approval-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .65rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.approval-yes {
    background: #D1FAE5;
    color: #065F46;
}

.approval-no {
    background: #FEE2E2;
    color: #991B1B;
}

.approval-missing {
    background: #F3F4F6;
    color: #9CA3AF;
}

/* ── APPROVAL EDIT CHECKLIST ────────────────────────────── */
.approval-check-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.approval-check-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .85rem;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    font-size: .875rem;
}

.approval-check-item.check-approved {
    background: #F0FDF4;
    border-color: #86EFAC;
}

.approval-check-item.check-unapproved {
    background: #FFF1F2;
    border-color: #FECDD3;
}

.approval-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}

.check-label {
    flex: 1;
}

.check-saving {
    font-size: .75rem;
    color: #9CA3AF;
    font-style: italic;
}

/* ── LEADS PAGE ─────────────────────────────────────────── */
.leads-date-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    background: #F8FAFC;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
}

.leads-quick-dates {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.leads-date-range {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ── FILTER CHIPS ────────────────────────────────────────── */
.leads-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .75rem;
}

.leads-chip {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.leads-chip-clear {
    background: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
    cursor: pointer;
    border: 1px solid #FECACA;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    padding: .2rem .6rem;
}

.leads-chip-clear:hover { background: #FCA5A5; }

/* ── LEADS TABLE ─────────────────────────────────────────── */
.leads-table tbody tr.lead-row {
    cursor: pointer;
    transition: background .12s;
}

.leads-table tbody tr.lead-row:hover td { background: #EFF6FF; }

/* ── HOVER POPUP ─────────────────────────────────────────── */
.lead-popup {
    background: #1E293B;
    color: #F1F5F9;
    border-radius: 8px;
    padding: .9rem 1.1rem;
    font-size: .78rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    animation: fadeIn .1s ease;
}

.lead-popup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .3rem .75rem;
}

.lead-popup-grid div {
    display: flex;
    flex-direction: column;
    gap: .05rem;
}

.lp-label {
    font-size: .68rem;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.lp-val  { color: #F1F5F9; }
.lp-mono { font-family: 'Consolas', monospace; font-size: .73rem; }

.lead-popup-hint {
    margin-top: .6rem;
    font-size: .7rem;
    color: #64748B;
    text-align: right;
}

/* ── PAGINATION ──────────────────────────────────────────── */
.leads-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .9rem;
    gap: .5rem;
}

/* ── SEARCH MODAL GRID ───────────────────────────────────── */
.leads-search-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
}

/* ── BUTTON SPINNER ──────────────────────────────────────── */
.btn-spinner {
    display: inline-block;
    width: .85rem;
    height: .85rem;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-right: .3rem;
    vertical-align: middle;
}

/* ── Lead Detail ─────────────────────────────────────────── */
.lead-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.lead-detail-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.lead-detail-heading {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid #e2e8f0;
}

.lead-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    padding: .3rem 0;
    font-size: .85rem;
    border-bottom: 1px solid #f1f5f9;
}

.lead-detail-row:last-child {
    border-bottom: none;
}

.lead-detail-row span:first-child {
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

.lead-detail-row span:last-child {
    text-align: right;
    word-break: break-all;
}

/* ── HOME — STAT REPORT PANEL ───────────────────────────── */
.stat-report-date {
    font-size: .875rem;
    color: #6B7280;
    font-weight: 500;
}

.stat-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.stat-tile {
    border-radius: 8px;
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    border: 1px solid transparent;
}

.stat-tile-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .75;
}

.stat-tile-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-tile-primary { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }
.stat-tile-success { background: #F0FDF4; border-color: #BBF7D0; color: #15803D; }
.stat-tile-info    { background: #F0F9FF; border-color: #BAE6FD; color: #0369A1; }
.stat-tile-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.stat-tile-danger  { background: #FFF1F2; border-color: #FECDD3; color: #BE123C; }

.stat-subsystem-section { margin-top: .5rem; }

/* ── LINK BUTTON (inline text styled as hyperlink) ───────── */
.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:hover { color: var(--color-accent); }

/* ── MSG EDITOR ──────────────────────────────────────────── */
.msg-editor-row {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}

.msg-editor-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.msg-tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid #D1D5DB;
}

.msg-tab {
    padding: .35rem .85rem;
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: #9CA3AF;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.msg-tab:hover:not(.active) {
    background: #F3F4F6;
    color: #374151;
}

.msg-tab.active {
    background: var(--color-white);
    color: #1F2937;
    border-color: #D1D5DB;
    border-bottom-color: var(--color-white);
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

.msg-textarea {
    border-radius: 0 6px 6px 6px;
    min-height: 145px;
    resize: vertical;
}

.char-counter {
    display: flex;
    justify-content: flex-end;
    font-size: .75rem;
    font-weight: 600;
    color: #6B7280;
    padding-top: .3rem;
}

.char-warn { color: #DC2626; }

/* ── TOKEN PANEL ─────────────────────────────────────────── */
.token-panel {
    width: 175px;
    flex-shrink: 0;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 220px;
}

.token-panel-header {
    padding: .45rem .7rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9CA3AF;
    background: #F8FAFC;
    border-bottom: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.token-list {
    overflow-y: auto;
    flex: 1;
}

.token-btn {
    width: 100%;
    padding: .35rem .6rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid #F3F4F6;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: .1rem;
    transition: background .12s;
}

.token-btn:last-child      { border-bottom: none; }
.token-btn:hover:not(:disabled) { background: #EFF6FF; }
.token-btn:disabled        { opacity: .45; cursor: not-allowed; }

.token-label {
    font-size: .78rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.3;
}

.token-code {
    font-size: .67rem;
    font-family: 'Consolas', monospace;
    color: #2563EB;
    background: #EFF6FF;
    padding: .05rem .25rem;
    border-radius: 3px;
    display: inline-block;
}

/* ── JSON VIEWER ────────────────────────────────────────── */
.json-viewer {
    background: #0F172A;
    color: #E2E8F0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-family: 'Consolas', 'Cascadia Code', monospace;
    font-size: .78rem;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre;
    margin-top: .5rem;
    max-height: 420px;
}

/* ── CLICKABLE BADGE BUTTON ─────────────────────────────── */
.badge-btn {
    border: none;
    cursor: pointer;
    font: inherit;
    transition: filter .15s, transform .1s;
}
.badge-btn:hover  { filter: brightness(.88); transform: translateY(-1px); }
.badge-btn:active { transform: translateY(0); }