/* =====================================================
   GLOBAL BASE
===================================================== */

body {
    background-color: #f8fafc;
}

/* =====================================================
   CRM / ADMIN PANEL (SCOPED)
===================================================== */

body.crm {
    background-color: #f8fafc;
}

.crm-layout {
    min-height: 100vh;
}

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

.crm-content {
    padding: 1.5rem;
}

.crm-sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    min-height: 100vh;
}

.crm-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #e5e7eb;
    text-decoration: none !important;
    border-radius: 10px;
    margin: 2px 6px;
    transition: background .2s ease, color .2s ease;
}

.crm-link:hover {
    background: #111827;
    color: #fff;
}

.crm-link.active {
    background: linear-gradient(90deg, #2563eb, #4f46e5);
    color: #fff;
    font-weight: 600;
}

.crm-menu-icon {
    width: 18px;
    text-align: center;
    opacity: .9;
}

.crm-brand-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #8b5cf6);
    font-weight: 700;
}

.crm-dashboard-card {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
    border: 1px solid #eef2ff;
}

.crm-kpi-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-size: 20px;
}

.crm-service-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    background: #f8fafc;
}

.crm-service-card h6 {
    margin: 2px 0 0;
    font-weight: 700;
    color: #111827;
}

.crm-service-key {
    display: inline-flex;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.crm-status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 700;
}

.crm-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.crm-chip-row span {
    border-radius: 999px;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #475569;
    font-size: 12px;
}

.crm-mini-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eef2f7;
}

.crm-mini-row:last-child {
    border-bottom: 0;
}

.crm-mini-row strong,
.crm-mini-row small {
    display: block;
}

.crm-mini-row small,
.crm-mini-row span {
    color: #64748b;
    font-size: 12px;
}

@media (max-width: 991.98px) {
    .crm-layout {
        flex-direction: column;
    }

    .crm-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        min-height: auto;
    }

    .crm-content {
        padding: 1rem;
    }
}

/* ---------- Buttons ---------- */

.crm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none !important;
}

.crm-btn-primary { background:#4f46e5; color:#fff }
.crm-btn-primary:hover { background:#4338ca }

.crm-btn-success { background:#16a34a; color:#fff }
.crm-btn-success:hover { background:#15803d }

.crm-btn-warning { background:#f59e0b; color:#fff }
.crm-btn-warning:hover { background:#d97706 }

.crm-btn-danger { background:#dc2626; color:#fff }
.crm-btn-danger:hover { background:#b91c1c }

.crm-btn-outline {
    background:#fff;
    border:1px solid #d1d5db;
    color:#374151;
}

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

.crm-badge {
    padding:4px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:600;
}

.crm-badge-new        { background:#e5e7eb; color:#374151 }
.crm-badge-contacted { background:#dbeafe; color:#1e3a8a }
.crm-badge-followup  { background:#fef3c7; color:#92400e }
.crm-badge-converted { background:#ede9fe; color:#5b21b6 }
.crm-badge-won       { background:#dcfce7; color:#166534 }
.crm-badge-lost      { background:#fee2e2; color:#991b1b }

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

.crm-card {
    background:#fff;
    border-radius:16px;
    padding:20px;
    box-shadow:0 10px 25px rgba(0,0,0,.06);
}

.crm-page-header {
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:1rem;
    margin-bottom:1.25rem;
}

.crm-page-title {
    font-size:1.35rem;
    font-weight:700;
    color:#111827;
    margin:0;
}

.crm-page-subtitle {
    color:#64748b;
    margin-top:.25rem;
    font-size:.925rem;
}

.crm-panel {
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:10px;
    box-shadow:0 8px 22px rgba(15,23,42,.05);
}

.crm-panel-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:.75rem;
    padding:1rem 1.25rem;
    border-bottom:1px solid #eef2f7;
    font-weight:700;
    color:#111827;
}

.crm-table {
    width:100%;
    margin-bottom:0;
}

.crm-table th {
    background:#f8fafc;
    color:#475569;
    font-size:.78rem;
    letter-spacing:.02em;
    text-transform:uppercase;
    white-space:nowrap;
}

.crm-table td {
    vertical-align:middle;
}

.crm-table-title {
    color:#0f172a;
    font-weight:800;
    text-decoration:none;
}

a.crm-table-title:hover {
    color:#1d4ed8;
}

.crm-count-pill,
.crm-soft-badge {
    display:inline-flex;
    align-items:center;
    border-radius:999px;
    font-size:12px;
    font-weight:800;
    line-height:1;
    white-space:nowrap;
}

.crm-count-pill {
    background:#eef2ff;
    color:#3730a3;
    padding:7px 10px;
}

.crm-soft-badge {
    background:#f1f5f9;
    border:1px solid #e2e8f0;
    color:#475569;
    padding:6px 9px;
}

.crm-empty-state {
    display:grid;
    gap:4px;
    padding:2.5rem 1rem;
    text-align:center;
    color:#64748b;
}

.crm-empty-state strong {
    color:#0f172a;
    font-size:16px;
}

.crm-empty-state span {
    font-size:13px;
}

.crm-action-bar {
    display:flex;
    flex-wrap:wrap;
    gap:.5rem;
    align-items:center;
    justify-content:flex-end;
}

.crm-inline-form {
    display:inline-flex;
    flex-wrap:wrap;
    gap:8px;
    align-items:center;
}

.crm-inline-form .form-select,
.crm-inline-form .form-control {
    min-width:160px;
}

.crm-alert {
    border:0;
    border-radius:8px;
    box-shadow:0 8px 22px rgba(15,23,42,.06);
}

.crm-panel .form-control,
.crm-panel .form-select,
.crm-card .form-control,
.crm-card .form-select {
    border-color:#dbe3ef;
    border-radius:8px;
    min-height:40px;
}

.crm-panel .form-control:focus,
.crm-panel .form-select:focus,
.crm-card .form-control:focus,
.crm-card .form-select:focus {
    border-color:#93c5fd;
    box-shadow:0 0 0 .2rem rgba(37,99,235,.12);
}

.crm-kanban-board {
    display:grid;
    grid-auto-columns:minmax(280px, 320px);
    grid-auto-flow:column;
    gap:16px;
    overflow-x:auto;
    padding-bottom:12px;
    scroll-snap-type:x proximity;
}

.crm-kanban-column {
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:8px;
    box-shadow:0 8px 22px rgba(15,23,42,.05);
    min-height:320px;
    scroll-snap-align:start;
}

.crm-kanban-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:14px;
    border-bottom:1px solid #eef2f7;
}

.crm-kanban-body {
    display:grid;
    gap:10px;
    min-height:250px;
    padding:12px;
}

.crm-kanban-card {
    display:block;
    background:#f8fafc;
    border:1px solid #e2e8f0;
    border-radius:8px;
    color:#0f172a;
    padding:12px;
    text-decoration:none;
    transition:border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.crm-kanban-card:hover {
    border-color:#93c5fd;
    box-shadow:0 10px 24px rgba(37,99,235,.10);
    color:#0f172a;
    transform:translateY(-1px);
}

.crm-kanban-empty {
    align-self:start;
    background:#f8fafc;
    border:1px dashed #cbd5e1;
    border-radius:8px;
    color:#64748b;
    font-size:13px;
    padding:14px;
    text-align:center;
}

@media (max-width: 767.98px) {
    .crm-page-header {
        flex-direction:column;
    }

    .crm-action-bar {
        justify-content:flex-start;
        width:100%;
    }

    .crm-inline-form {
        width:100%;
    }

    .crm-inline-form .form-select,
    .crm-inline-form .form-control,
    .crm-inline-form .btn {
        width:100%;
    }

    .crm-kanban-board {
        grid-auto-columns:minmax(260px, 86vw);
    }
}

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

.sidebar-section {
    margin:16px 12px 6px;
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.06em;
    color:#9ca3af;
}

.crm-sidebar-link {
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px 12px;
    margin:2px 6px;
    border-radius:8px;
    color:#374151;
    text-decoration:none !important;
    transition:background .2s ease, color .2s ease;
}

.crm-sidebar-link:hover {
    background:#f1f5f9;
    color:#111827;
}

.crm-sidebar-link.active {
    background:#eef2ff;
    color:#4338ca;
    font-weight:600;
}

/* =====================================================
   SUPER ADMIN PANEL (SCOPED)
===================================================== */

body.super-admin {
    background:#f8fafc;
}

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

.super-admin .sa-card {
    background:#fff;
    border-radius:14px;
    padding:20px;
    box-shadow:0 8px 25px rgba(0,0,0,.05);
    border:1px solid #f1f5f9;
}

.super-admin .sa-card h2 {
    font-size:28px;
    font-weight:700;
    margin-bottom:4px;
}

.super-admin .sa-card p {
    font-size:13px;
    color:#6b7280;
    margin-bottom:0;
}

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

.super-admin .sa-badge-ok {
    background:#e6f7ec;
    color:#0a8a3a;
    font-weight:600;
    padding:4px 10px;
    border-radius:999px;
    font-size:12px;
}

.super-admin .sa-badge-warn {
    background:#fdeaea;
    color:#b30000;
    font-weight:600;
    padding:4px 10px;
    border-radius:999px;
    font-size:12px;
}

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

.super-admin .sa-link {
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px 14px;
    margin:2px 6px;
    border-radius:8px;
    color:#cbd5f5;
    text-decoration:none !important;
    transition:background .2s ease, color .2s ease;
}

.super-admin .sa-link:hover {
    background:#1e293b;
    color:#fff;
}

.super-admin .sa-link.active {
    background:#4f46e5;
    color:#fff;
    font-weight:600;
}

/* =====================================================
   CRMEXPERT UI REFRESH
===================================================== */

body.crm {
    background-color: #f5f7fb;
    color: #111827;
}

.crm-main {
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, .08), transparent 28rem),
        #f5f7fb;
}

.crm-sidebar {
    width: 272px;
    min-width: 272px;
    max-width: 272px;
    background: #0f172a !important;
    border-right: 1px solid rgba(255,255,255,.08);
}

.crm-sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.crm-link {
    border-radius: 8px;
}

.crm-link:hover {
    background: rgba(255,255,255,.08);
}

.crm-link.active {
    background: #2563eb;
}

.crm-menu-icon {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: rgba(255,255,255,.08);
    font-size: 11px;
    font-weight: 700;
    opacity: .95;
}

.crm-brand-icon,
.crm-dashboard-card,
.crm-card {
    border-radius: 8px;
}

.crm-dashboard-card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.crm-topbar {
    min-height: 70px;
    background: rgba(255,255,255,.88);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(12px);
}

.crm-topbar-kicker,
.crm-eyebrow {
    color: #64748b;
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.crm-topbar-actions,
.crm-page-actions,
.crm-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-icon-btn,
.crm-user-menu {
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #111827;
    min-height: 38px;
    border-radius: 8px;
}

.crm-icon-btn {
    width: 38px;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.crm-dot {
    width: 8px;
    height: 8px;
    background: #dc2626;
    border: 2px solid #fff;
    border-radius: 999px;
    position: absolute;
    top: 7px;
    right: 7px;
}

.crm-user-menu {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 5px;
}

.crm-avatar {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
}

.crm-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.crm-page-header h3 {
    margin: 2px 0 4px;
    font-size: 26px;
    font-weight: 800;
}

.crm-page-header p {
    color: #64748b;
    margin-bottom: 0;
}

.crm-section-title {
    justify-content: space-between;
    margin-bottom: 14px;
}

.crm-section-title h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.crm-stat-card span {
    color: #64748b;
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.crm-stat-card b {
    color: #0f172a;
    display: block;
    font-size: 34px;
    line-height: 1;
}

.crm-stat-card.danger b {
    color: #dc2626;
}

.crm-status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 12px;
}

.crm-status-pill.ok {
    background: #dcfce7;
    color: #166534;
}

.crm-status-pill.warn {
    background: #fef3c7;
    color: #92400e;
}

.crm-form-grid,
.crm-copy-list {
    display: grid;
    gap: 14px;
}

.crm-copy-list label {
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: -7px;
}

.ivr-builder-shell {
    display: grid;
    grid-template-columns: 260px minmax(420px, 1fr) 320px;
    min-height: calc(100vh - 112px);
    gap: 16px;
}

.ivr-block-panel,
.ivr-settings-panel,
.ivr-canvas {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.ivr-block {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 11px 12px;
    margin-bottom: 10px;
    color: #0f172a;
    font-weight: 700;
    background: #f8fafc;
}

.ivr-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.ivr-flow-node {
    width: 220px;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

.ivr-flow-node.start {
    border-left-color: #16a34a;
}

.ivr-flow-node span {
    color: #64748b;
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.ivr-flow-node strong {
    display: block;
    margin-top: 3px;
}

.ivr-flow-line {
    width: 2px;
    height: 34px;
    background: #cbd5e1;
}

.ivr-flow-line.split {
    height: 24px;
}

.ivr-flow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 14px;
}

.crm-timeline {
    display: grid;
    gap: 18px;
}

.crm-timeline-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 12px;
    position: relative;
}

.crm-timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 18px;
    bottom: -18px;
    width: 2px;
    background: #e5e7eb;
}

.crm-timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #2563eb;
    margin-top: 6px;
    position: relative;
    z-index: 1;
}

@media (max-width: 991.98px) {
    .crm-topbar,
    .crm-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .crm-user-name {
        display: none;
    }

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

    .ivr-flow-grid {
        grid-template-columns: 1fr;
    }
}
