:root {
    --cyan-950: #073843;
    --cyan-900: #084653;
    --cyan-800: #075b69;
    --cyan-700: #087486;
    --cyan-600: #0893a5;
    --cyan-500: #19adbc;
    --cyan-300: #77d8e1;
    --cyan-100: #dff7f8;
    --page-gutter: clamp(18px, 2.4vw, 38px);
    --card-pad: clamp(18px, 1.7vw, 26px);
    --soft-ring: 0 0 0 1px color-mix(in srgb, var(--accent) 7%, transparent);
}

/* --------------------------------------------------------------------------
   1. PAGE FOUNDATION / READABILITY
   -------------------------------------------------------------------------- */
html { background: var(--bg); }
body {
    font-size: 16px;
    line-height: 1.62;
    letter-spacing: -0.005em;
    background:
        radial-gradient(circle at 86% 0%, color-mix(in srgb, var(--accent) 8%, transparent) 0, transparent 31rem),
        radial-gradient(circle at 12% 100%, rgba(13, 115, 134, .055) 0, transparent 29rem),
        linear-gradient(180deg, color-mix(in srgb, var(--bg) 94%, white 6%) 0%, var(--bg) 38%, var(--bg) 100%);
}

h1, h2, h3, h4 { font-weight: 720; }
h1 { font-size: clamp(2rem, 2.7vw, 2.8rem); letter-spacing: -.045em; }
h2 { font-size: clamp(1.45rem, 2vw, 1.9rem); letter-spacing: -.035em; }
h3 { font-size: 1.15rem; letter-spacing: -.025em; }
p { line-height: 1.7; }

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent-strong);
    font-size: 12px !important;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: .11em;
}

/* Visible keyboard focus on every interactive control. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. APP SHELL / TOP BAR
   -------------------------------------------------------------------------- */
.main-column { min-width: 0; }
.main-content {
    width: min(1560px, 100%);
    padding: 32px var(--page-gutter) 64px;
}

.topbar {
    height: 78px;
    padding: 0 var(--page-gutter);
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    border-bottom-color: color-mix(in srgb, var(--border) 82%, transparent);
    box-shadow: 0 1px 0 rgba(255,255,255,.3);
}
html[data-theme="dark"] .topbar { box-shadow: none; }

.topbar-page-title {
    display: grid;
    gap: 1px;
    line-height: 1.2;
}
.topbar-page-title span {
    color: var(--muted);
    font-size: 11.5px !important;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .095em;
}
.topbar-page-title strong {
    color: var(--text-strong);
    font-size: 17px !important;
    font-weight: 760;
    letter-spacing: -.02em;
}

.global-search {
    min-height: 42px;
    width: min(340px, 30vw);
    padding: 0 11px 0 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.global-search:focus-within {
    border-color: color-mix(in srgb, var(--accent) 44%, var(--border));
    box-shadow: 0 0 0 4px var(--accent-faint);
}
.global-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 14.5px !important;
}
.global-search kbd {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font: 600 10.5px/1.4 var(--font);
}

.profile-chip {
    min-height: 44px;
    padding: 5px 8px 5px 6px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    cursor: pointer;
    transition: .2s var(--ease);
}
.profile-chip:hover { background: var(--surface-hover); border-color: var(--border); }
.profile-copy { display: grid; text-align: left; line-height: 1.22; }
.profile-copy strong { color: var(--text-strong); font-size: 13.5px !important; }
.profile-copy small { margin-top: 2px; color: var(--muted); font-size: 11.5px !important; }

.icon-btn {
    min-width: 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    transition: transform .18s var(--ease), border-color .18s ease, background .18s ease, color .18s ease;
}
.icon-btn:hover { transform: translateY(-1px); }

/* --------------------------------------------------------------------------
   3. SIDEBAR — COMPACT, READABLE, CALM
   -------------------------------------------------------------------------- */
:root { --sidebar-width: 272px; }
.sidebar {
    width: var(--sidebar-width);
    padding: 18px 12px 14px;
    background:
        radial-gradient(circle at 0 0, rgba(83, 222, 236, .10), transparent 20rem),
        linear-gradient(180deg, #073f4d 0%, #063946 56%, #053540 100%);
    border-right: 1px solid rgba(255,255,255,.09);
    box-shadow: 10px 0 35px rgba(1, 33, 40, .05);
}
.sidebar .brand-row {
    min-height: 54px;
    padding: 0 8px 14px;
    margin-bottom: 2px;
}
.sidebar .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.07));
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.10);
}
.sidebar .brand-copy strong { font-size: 16.5px !important; letter-spacing: -.02em; }
.sidebar .brand-copy small { font-size: 11.5px !important; }
.sidebar-section-label {
    margin: 8px 10px 7px !important;
    padding: 0 !important;
    color: #79ddeb;
    font-size: 11.5px !important;
    letter-spacing: .14em;
}
.sidebar-nav { gap: 2px !important; }
.sidebar .nav-item {
    position: relative;
    min-height: 43px !important;
    padding: 8px 11px !important;
    gap: 11px;
    border-radius: 11px !important;
    font-size: 14.75px !important;
    font-weight: 580;
}
.sidebar .nav-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 6px 6px 0;
    background: transparent;
    transform: scaleY(.35);
    transition: .2s var(--ease);
}
.sidebar .nav-item:hover { background: rgba(255,255,255,.065); }
.sidebar .nav-item.active {
    background: linear-gradient(90deg, rgba(28, 159, 181, .36), rgba(21, 128, 149, .44));
    border-color: rgba(108, 229, 247, .14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.sidebar .nav-item.active::before { background: #84e8f3; transform: scaleY(1); }
.sidebar .nav-icon { width: 23px; color: #b6f5fc; }
.sidebar .nav-badge {
    min-width: 28px;
    height: 23px;
    padding: 0 8px;
    background: rgba(22, 154, 179, .94);
    border-color: rgba(151, 239, 252, .18);
    font-size: 11.5px;
}
.nav-group { gap: 0; }
.nav-submenu {
    margin: 3px 0 4px 23px !important;
    padding: 3px 0 3px 13px !important;
    gap: 1px !important;
    border-left-color: rgba(152, 228, 240, .22);
}
.nav-subitem {
    min-height: 37px !important;
    padding: 7px 10px !important;
    border-radius: 9px;
    color: rgba(245, 253, 254, .86);
    font-size: 14px !important;
}
.nav-subitem:hover { transform: translateX(2px); background: rgba(255,255,255,.055); }
.nav-subitem.active { background: rgba(44, 183, 205, .15); color: #fff; }
.sidebar-status {
    margin-top: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 9px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 13px;
    background: rgba(255,255,255,.045);
}
.sidebar-status > div { display: grid; min-width: 0; }
.sidebar-status strong { color: #fff; font-size: 12.5px; }
.sidebar-status small { margin-top: 1px; color: rgba(255,255,255,.58); font-size: 11px; }

/* --------------------------------------------------------------------------
   4. PAGE INTRO / SHARED SURFACES
   -------------------------------------------------------------------------- */
.page-intro {
    position: relative;
    margin-bottom: 24px;
    padding: 4px 0 3px 16px;
}
.page-intro::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 7px;
    width: 3px;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 20%, transparent));
}
.page-intro h1 { margin-bottom: 8px; }
.page-intro p { max-width: 760px; font-size: 15.5px !important; color: color-mix(in srgb, var(--muted) 94%, var(--text)); }

.surface-card,
.data-card,
.info-card,
.toolbar-card,
.calendar-card {
    border-color: color-mix(in srgb, var(--border) 92%, transparent);
    background: color-mix(in srgb, var(--surface-solid) 91%, transparent);
    box-shadow: 0 10px 32px rgba(20, 55, 61, .055), var(--soft-ring);
    backdrop-filter: blur(16px);
}
.surface-card {
    transition: transform .22s var(--ease), box-shadow .22s ease, border-color .22s ease, background .3s ease;
}
.surface-card:hover { border-color: color-mix(in srgb, var(--accent) 14%, var(--border)); }

.section-head,
.data-card-head {
    padding: 22px var(--card-pad) 0;
}
.section-head h3,
.data-card-head h3 { margin-bottom: 5px; font-size: 18px; }
.section-head p,
.data-card-head p { margin: 0; max-width: 680px; font-size: 13.5px; }

/* --------------------------------------------------------------------------
   5. BUTTONS / FILTERS / FORM CONTROLS
   -------------------------------------------------------------------------- */
.btn {
    min-height: 42px;
    padding: 0 15px;
    border-radius: 11px;
    font-size: 14px !important;
    font-weight: 720;
    letter-spacing: -.01em;
    transition: transform .18s var(--ease), box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    box-shadow: 0 9px 24px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn-primary:hover { box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 29%, transparent); }
.btn-secondary { background: color-mix(in srgb, var(--surface-solid) 86%, transparent); }

.toolbar-card {
    padding: 12px;
    gap: 12px;
    border-radius: 16px;
}
.search-control,
.select-control,
.conversation-search {
    min-height: 42px;
    border-radius: 11px;
    border-color: var(--border);
    background: var(--surface-2);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.search-control:focus-within,
.conversation-search:focus-within {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: 0 0 0 4px var(--accent-faint);
    background: var(--surface-solid);
}
.search-control input,
.conversation-search input,
.select-control select,
textarea,
input,
select { font-size: 14px; }

.segment-tabs {
    gap: 5px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
}
.segment-tab {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 9px;
    transition: .18s ease;
}
.segment-tab.active {
    background: var(--surface-solid);
    color: var(--text-strong);
    box-shadow: 0 3px 12px rgba(19, 52, 58, .08);
}

/* --------------------------------------------------------------------------
   6. OVERVIEW / STAT CARDS
   -------------------------------------------------------------------------- */
.overview-banner {
    min-height: 205px;
    margin-bottom: 18px;
    padding: 34px 38px;
    border-radius: 25px;
    border-color: color-mix(in srgb, var(--accent) 16%, var(--border));
    background:
        radial-gradient(circle at 88% 45%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 15rem),
        linear-gradient(120deg, color-mix(in srgb, var(--accent-soft) 70%, var(--surface-solid)) 0%, var(--surface-solid) 56%, color-mix(in srgb, var(--bg-soft) 62%, var(--surface-solid)) 100%);
    box-shadow: 0 18px 45px rgba(26, 71, 78, .075), var(--soft-ring);
}
.overview-banner::after {
    content: "";
    position: absolute;
    inset: auto auto -45px 45%;
    width: 260px;
    height: 110px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 5%, transparent);
    filter: blur(18px);
}
.banner-label {
    margin-bottom: 13px;
    padding: 6px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    font-size: 10.5px;
}
.overview-banner h2 { font-size: clamp(1.75rem, 2.45vw, 2.45rem); }
.overview-banner p { max-width: 650px; font-size: 15px !important; }
.orbit-center { box-shadow: 0 16px 40px rgba(13,156,166,.28); }

.metric-grid,
.stat-grid { gap: 14px; }
.metric-card,
.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 155px;
    padding: 19px;
}
.metric-card::after,
.stat-card::after {
    content: "";
    position: absolute;
    right: -38px;
    top: -42px;
    width: 105px;
    height: 105px;
    border-radius: 50%;
    background: var(--accent-faint);
    pointer-events: none;
}
.metric-card:hover,
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 34px rgba(22, 59, 66, .085);
}
.metric-icon,
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    position: relative;
    z-index: 1;
}
.metric-value,
.stat-card-value { font-size: clamp(1.65rem, 2.1vw, 2rem); }
.metric-label,
.stat-card-label { font-size: 13.5px !important; }
.metric-card > small,
.stat-card-meta { font-size: 12px !important; }

/* --------------------------------------------------------------------------
   7. TABLES / LISTS
   -------------------------------------------------------------------------- */
.table-wrap { padding: 9px 13px 15px; }
.data-table {
    border-spacing: 0;
    border-collapse: separate;
}
.data-table th {
    height: 44px;
    padding: 10px 12px !important;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-2) 86%, transparent);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px !important;
    font-weight: 800;
    letter-spacing: .055em;
}
.data-table th:first-child { border-left: 1px solid var(--border); border-radius: 10px 0 0 10px; }
.data-table th:last-child { border-right: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.data-table td {
    padding: 14px 12px !important;
    color: var(--text);
    font-size: 13.5px !important;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    vertical-align: middle;
}
.data-table tbody tr { transition: background .18s ease, transform .18s ease; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--accent-faint) 48%, var(--surface-hover)); }
.cell-stack strong,
.cell-title strong { color: var(--text-strong); font-size: 13.5px; }
.cell-stack small,
.cell-title small { margin-top: 2px; color: var(--muted); font-size: 11.5px; }

.status-badge,
.status-pill,
.channel-chip,
.trend-pill {
    min-height: 28px;
    border-radius: 999px;
    font-size: 11.5px !important;
    font-weight: 760;
}
.status-badge { padding: 4px 9px; }
.channel-chip { padding: 4px 9px; }
.mini-action {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    transition: .18s ease;
}
.mini-action:hover { transform: translateY(-1px); background: var(--accent-faint); color: var(--accent-strong); }
.progress { height: 6px; border-radius: 99px; }
.progress span { border-radius: inherit; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }

.list-row {
    padding: 15px 0;
    transition: background .18s ease;
}
.list-row-main strong { font-size: 13.5px; }
.list-row-main small { font-size: 12px; }

/* --------------------------------------------------------------------------
   8. LIVE CHAT — CHANNEL FIRST, DENSER BUT READABLE
   -------------------------------------------------------------------------- */
.channel-tabs-shell {
    margin-bottom: 14px;
    padding: 6px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-solid) 93%, transparent);
    box-shadow: 0 8px 24px rgba(19, 57, 63, .05);
}
.channel-tab {
    min-height: 46px;
    padding: 0 13px;
    border-radius: 11px;
    font-size: 14px !important;
}
.channel-tab:hover { transform: translateY(-1px); }
.channel-tab.active {
    background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface-solid));
    border-color: color-mix(in srgb, var(--accent) 18%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 5px 15px rgba(11, 131, 143, .07);
}
.channel-tab small { font-size: 11px !important; }

.chat-workspace {
    min-height: 680px;
    height: calc(100vh - 232px);
    grid-template-columns: 320px minmax(430px, 1fr) 290px;
    border-radius: 20px;
    border-color: var(--border);
    box-shadow: 0 18px 50px rgba(17, 55, 61, .085);
}
.conversation-pane,
.customer-pane { background: color-mix(in srgb, var(--surface-solid) 91%, var(--bg-soft)); }
.conversation-pane-head { padding: 18px 16px 11px; }
.conversation-pane-head h2 { font-size: 18px !important; }
.conversation-pane-head .eyebrow { font-size: 10.5px !important; }
.conversation-search { margin: 0 12px 11px; padding: 0 11px; }
.conversation-search input { font-size: 14px !important; }
.conversation-list { padding: 0 7px 9px; }
.conversation-item {
    gap: 11px;
    padding: 12px 10px;
    border-radius: 12px;
}
.conversation-item:hover { background: var(--surface-hover); }
.conversation-item.active {
    background: color-mix(in srgb, var(--accent-faint) 92%, var(--surface-solid));
    border-color: color-mix(in srgb, var(--accent) 13%, transparent);
    box-shadow: inset 3px 0 0 var(--accent);
}
.conversation-item-row strong { font-size: 14px !important; }
.conversation-item-row small { font-size: 11.5px !important; }
.conversation-preview { font-size: 12.75px !important; }
.conversation-meta em { font-size: 10.75px !important; }
.unread-count { min-width: 22px; height: 22px; font-size: 10.5px; }

.chat-view-head {
    min-height: 74px;
    padding: 12px 17px;
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
}
.chat-person strong { font-size: 14.5px !important; }
.chat-person span { font-size: 11.5px !important; }
.chat-message-area {
    padding: 24px 22px;
    background:
        linear-gradient(rgba(13,156,166,.024), rgba(13,156,166,.024)),
        radial-gradient(circle at 20px 20px, color-mix(in srgb, var(--border) 50%, transparent) 1px, transparent 1.4px);
    background-size: auto, 24px 24px;
}
.message-bubble {
    max-width: min(72%, 560px);
    padding: 10px 12px 8px;
    border-radius: 15px;
    box-shadow: 0 4px 14px rgba(20, 52, 58, .055);
}
.message-row.incoming .message-bubble { border-bottom-left-radius: 5px; }
.message-row.outgoing .message-bubble {
    border-bottom-right-radius: 5px;
    background: color-mix(in srgb, var(--accent-soft) 78%, var(--surface-solid));
}
.message-bubble p { font-size: 14px !important; line-height: 1.55 !important; }
.message-bubble small { font-size: 10.5px !important; }
.message-composer {
    min-height: 70px;
    padding: 10px 12px;
    gap: 8px;
    background: color-mix(in srgb, var(--surface-solid) 96%, transparent);
}
.message-composer textarea {
    min-height: 42px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 14px !important;
}
.message-composer textarea:focus {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: 0 0 0 4px var(--accent-faint);
}
.send-btn { width: 42px; height: 42px; border-radius: 12px; }
.customer-profile { padding-top: 25px; }
.customer-profile h3 { font-size: 16px !important; }
.detail-label { font-size: 10.75px !important; }
.detail-row small { font-size: 11.5px !important; }
.detail-row strong { font-size: 12.5px !important; }

/* --------------------------------------------------------------------------
   9. CALENDAR / ACCOUNT / PREVIEW / SETTINGS
   -------------------------------------------------------------------------- */
.calendar-card { border-radius: 18px; }
.calendar-toolbar { padding: 16px 18px; }
.calendar-weekday { font-size: 11.5px; }
.calendar-day { min-height: 132px; background: color-mix(in srgb, var(--surface-solid) 96%, transparent); }
.calendar-day:hover { background: var(--surface-hover); }
.calendar-event {
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 11.5px;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}

.account-card {
    min-height: 106px;
    padding: 18px;
    border-radius: 16px;
}
.account-card:hover { transform: translateY(-2px); }
.account-icon { width: 48px; height: 48px; }
.account-card h3 { font-size: 15px; }
.account-card p { font-size: 12.5px; }

.template-preview { padding: 18px; }
.phone-preview {
    border-width: 7px;
    border-color: color-mix(in srgb, var(--text-strong) 92%, #000);
    border-radius: 30px;
    box-shadow: 0 20px 45px rgba(14, 37, 42, .16);
}
.phone-preview-head { background: linear-gradient(135deg, #075a65, #0b7481); }
.preview-bubble { font-size: 13px; border: 1px solid var(--border); }

.theme-choice {
    border-radius: 15px;
    background: var(--surface-2);
}
.theme-choice.active {
    border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
    box-shadow: 0 0 0 3px var(--accent-faint), 0 10px 28px rgba(20, 58, 64, .07);
}
.toggle-switch { box-shadow: inset 0 0 0 1px var(--border); }

/* --------------------------------------------------------------------------
   10. DRAWERS / MODALS
   -------------------------------------------------------------------------- */
.drawer-backdrop { backdrop-filter: blur(5px); }
.drawer {
    width: min(470px, 94vw);
    box-shadow: -18px 0 55px rgba(5, 31, 36, .16);
}
.drawer-head { min-height: 74px; }
.drawer-body { padding: 20px; }
.drawer-field {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   11. DARK THEME REFINEMENTS
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 88% 0%, rgba(41, 185, 197, .07), transparent 30rem),
        radial-gradient(circle at 8% 100%, rgba(24, 114, 126, .06), transparent 28rem),
        var(--bg);
}
html[data-theme="dark"] .surface-card,
html[data-theme="dark"] .data-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .toolbar-card,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .channel-tabs-shell {
    box-shadow: 0 14px 34px rgba(0,0,0,.15), 0 0 0 1px rgba(255,255,255,.015);
}
html[data-theme="dark"] .overview-banner {
    background:
        radial-gradient(circle at 88% 45%, rgba(55, 197, 207, .08), transparent 15rem),
        linear-gradient(120deg, rgba(28, 87, 94, .45), var(--surface-solid) 52%, rgba(18, 42, 46, .92));
}
html[data-theme="dark"] .global-search,
html[data-theme="dark"] .message-composer textarea { box-shadow: none; }
html[data-theme="dark"] .message-row.outgoing .message-bubble { background: rgba(30, 126, 136, .20); }

/* --------------------------------------------------------------------------
   12. MOTION — SUBTLE, PRODUCTIVE
   -------------------------------------------------------------------------- */
@keyframes cyanCardIn {
    from { opacity: 0; transform: translateY(12px) scale(.995); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cyanMessageIn {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
}
.reveal.is-visible,
.reveal { animation: cyanCardIn .48s var(--ease) both; }
.message-row { animation: cyanMessageIn .30s var(--ease) both; }
.message-row:nth-child(3) { animation-delay: .03s; }
.message-row:nth-child(4) { animation-delay: .06s; }
.message-row:nth-child(5) { animation-delay: .09s; }
.data-table tbody tr { animation: cyanCardIn .36s var(--ease) both; }
.data-table tbody tr:nth-child(2) { animation-delay: .025s; }
.data-table tbody tr:nth-child(3) { animation-delay: .05s; }
.data-table tbody tr:nth-child(4) { animation-delay: .075s; }
.data-table tbody tr:nth-child(5) { animation-delay: .10s; }

/* --------------------------------------------------------------------------
   13. RESPONSIVE POLISH
   -------------------------------------------------------------------------- */
@media (max-width: 1260px) {
    .chat-workspace { grid-template-columns: 300px minmax(410px, 1fr); }
    .customer-pane { display: none; }
}

@media (max-width: 1100px) {
    .sidebar { transform: translateX(-105%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: grid !important; }
    .main-column { margin-left: 0 !important; }
    .mobile-menu { display: grid; }
    .sidebar-backdrop.show { display: block; }
}

@media (max-width: 820px) {
    .main-content { padding-top: 24px; }
    .page-intro { align-items: flex-start; flex-direction: column; gap: 14px; }
    .page-actions { width: 100%; }
    .global-search { width: min(300px, 36vw); }
    .metric-grid, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chat-workspace { height: auto; min-height: 660px; grid-template-columns: 285px minmax(360px, 1fr); }
}

@media (max-width: 680px) {
    body { font-size: 15px; }
    .topbar { height: 68px; }
    .global-search, .profile-chip { display: none; }
    .main-content { padding: 20px 14px 40px; }
    .page-intro { padding-left: 13px; }
    .page-intro h1 { font-size: 1.9rem; }
    .overview-banner { padding: 24px 21px; border-radius: 19px; }
    .overview-banner-orbit { display: none; }
    .overview-banner h2 { font-size: 1.6rem; }
    .overview-banner p { font-size: 14px !important; }
    .metric-grid, .stat-grid { grid-template-columns: 1fr; }
    .toolbar-card { align-items: stretch; flex-direction: column; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .search-control { width: 100%; min-width: 0; }
    .chat-workspace { display: block; min-height: 0; border: 0; box-shadow: none; background: transparent; overflow: visible; }
    .conversation-pane { height: 420px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
    .message-pane { min-height: 560px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
    .chat-view { min-height: 560px; }
    .message-bubble { max-width: 88%; }
    .data-table td { font-size: 13px !important; }
    .two-column, .account-grid { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal, .message-row, .data-table tbody tr { animation: none !important; }
    .surface-card, .btn, .nav-item, .nav-subitem { transition-duration: .01ms !important; }
}

/* Drawer records are independently switched by page scripts. */
.drawer-record { display: block; }
.drawer-record[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   14. READABILITY SAFETY NET
   Older page-specific rules intentionally used compact labels. These final
   overrides keep every visible control readable without changing page markup.
   -------------------------------------------------------------------------- */
.message-date span { font-size: 11px !important; }
.customer-note p, .chat-empty-state p { font-size: 13px !important; }
.contact-search input { font-size: 14px !important; }
.filter-chip { min-height: 36px; font-size: 12.5px !important; }
.contacts-list-head { font-size: 11px !important; }
.contact-row { font-size: 13px !important; }
.chart-legend span { font-size: 12px !important; }
.bar-day small, .chart-bar-item small { font-size: 11.5px !important; }
.performance-name strong, .performance-row > div strong { font-size: 13px !important; }
.performance-name small, .performance-row > div small { font-size: 11.5px !important; }
.donut small { font-size: 11px !important; }
.donut-legend span { font-size: 12px !important; }
.donut-legend strong { font-size: 12.5px !important; }
.settings-nav-item { font-size: 13.5px !important; }
.settings-panel-head p { font-size: 13.5px !important; }
.field > span { font-size: 12px !important; }
.field input, .field textarea { font-size: 14px !important; }
.toggle-row strong { font-size: 13.5px !important; }
.toggle-row small { font-size: 12px !important; }
.progress-meta { font-size: 11.5px !important; }
.calendar-event small { font-size: 11px !important; }

/* ========================================================================== 
   V8 SYSTEM UPDATES
   Bootstrap integration, chart upgrade, spacing, scrolling and create modals.
   ========================================================================== */

/* Bootstrap is loaded first; Cyan remains the final visual authority. */
.btn { display:inline-flex; align-items:center; gap:8px; border-radius:12px; font-weight:750; line-height:1; box-shadow:none; }
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow:0 0 0 4px var(--accent-faint) !important; border-color:var(--accent) !important; }

/* Consistent space between cards/boxes throughout all pages. */
.stat-grid,
.metric-grid,
.two-column,
.dashboard-grid,
.analytics-bottom-grid,
.account-grid,
.calendar-shell { gap:20px !important; }
.surface-card + .surface-card { margin-top:0; }
.channel-health-grid { gap:16px !important; }
.channel-tabs-shell { margin-bottom:18px !important; padding:8px !important; }
.channel-tabs { gap:8px !important; }
.channel-tab { padding-inline:14px !important; }
.list-stack { display:grid; gap:8px; }
.list-row { border-radius:12px; }

/* Live chat: independent scroll regions for inbox and message history. */
.chat-workspace {
    height:calc(100vh - 226px) !important;
    min-height:620px;
    max-height:860px;
}
.conversation-pane,
.message-pane,
.chat-view { min-height:0; }
.conversation-list {
    display:grid;
    align-content:start;
    gap:6px;
    overflow-y:auto !important;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
}
.conversation-item { margin:0 !important; }
.chat-view.active {
    min-height:0;
    height:100%;
    display:grid;
    grid-template-rows:auto minmax(0,1fr) auto;
}
.chat-message-area {
    min-height:0;
    overflow-y:auto !important;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
    scroll-behavior:smooth;
}
.conversation-list::-webkit-scrollbar,
.chat-message-area::-webkit-scrollbar,
.customer-pane::-webkit-scrollbar { width:8px; }
.conversation-list::-webkit-scrollbar-thumb,
.chat-message-area::-webkit-scrollbar-thumb,
.customer-pane::-webkit-scrollbar-thumb { background:color-mix(in srgb,var(--muted) 28%,transparent); border-radius:999px; }

/* Shared premium bar diagram used across Overview, Campaigns, Ads, Social and Reports. */
.premium-bar-chart {
    position:relative;
    min-height:286px;
    padding:28px 18px 12px;
    overflow:hidden;
    border-radius:16px;
    background:linear-gradient(180deg,color-mix(in srgb,var(--accent-faint) 34%,transparent),transparent 64%);
}
.bar-chart-grid {
    pointer-events:none;
    position:absolute;
    inset:34px 18px 44px;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
}
.bar-chart-grid span { border-top:1px dashed color-mix(in srgb,var(--border) 88%,transparent); }
.premium-bars {
    position:relative;
    z-index:1;
    height:230px;
    display:flex;
    align-items:flex-end;
    justify-content:space-around;
    gap:12px;
}
.premium-bar-item {
    flex:1;
    min-width:24px;
    max-width:70px;
    height:100%;
    display:grid;
    grid-template-rows:26px minmax(0,1fr) 22px;
    align-items:end;
    outline:none;
}
.premium-bar-value {
    opacity:0;
    transform:translateY(5px);
    justify-self:center;
    padding:4px 7px;
    border:1px solid var(--border);
    border-radius:8px;
    background:var(--surface-solid);
    color:var(--text-strong);
    font-size:11px;
    font-weight:800;
    box-shadow:var(--shadow-sm);
    transition:.18s ease;
}
.premium-bar-item:hover .premium-bar-value,
.premium-bar-item:focus .premium-bar-value { opacity:1; transform:none; }
.premium-bar-track {
    position:relative;
    width:100%;
    height:100%;
    display:flex;
    align-items:flex-end;
    padding:0 3px;
}
.premium-bar-fill {
    width:100%;
    height:var(--bar-height);
    min-height:10px;
    border-radius:10px 10px 4px 4px;
    background:linear-gradient(180deg,#63d8df 0%,#18a8b2 42%,#087b87 100%);
    box-shadow:0 10px 22px rgba(7,137,148,.14), inset 0 1px 0 rgba(255,255,255,.35);
    transform-origin:bottom;
    animation:premiumBarRise .72s var(--ease) both;
    transition:filter .18s ease, transform .18s ease;
}
.premium-bar-item:hover .premium-bar-fill,
.premium-bar-item:focus .premium-bar-fill { filter:saturate(1.16) brightness(1.05); transform:translateY(-2px); }
.premium-bar-item small { text-align:center; color:var(--muted); font-size:11.5px; font-weight:700; }
@keyframes premiumBarRise { from { transform:scaleY(.04); opacity:.25; } to { transform:scaleY(1); opacity:1; } }

/* Bootstrap modal restyled to match Cyan's simple/humble visual system. */
.cyan-modal .modal-dialog { max-width:760px; }
.cyan-modal .modal-content {
    overflow:hidden;
    border:1px solid var(--border);
    border-radius:20px;
    background:var(--surface-solid);
    color:var(--text);
    box-shadow:0 30px 80px rgba(4,34,39,.24);
}
.cyan-modal .modal-header,
.cyan-modal .modal-footer { border-color:var(--border); padding:20px 22px; }
.cyan-modal .modal-header { align-items:flex-start; }
.cyan-modal .modal-header h2 { margin:3px 0 5px; font-size:22px; color:var(--text-strong); }
.cyan-modal .modal-header p { margin:0; color:var(--muted); font-size:13.5px; }
.cyan-modal .modal-body { padding:22px; }
.cyan-modal .btn-close { filter:none; opacity:.62; }
html[data-theme="dark"] .cyan-modal .btn-close { filter:invert(1); }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.form-field { display:grid; gap:7px; min-width:0; }
.form-field.wide { grid-column:1/-1; }
.form-field > span { color:var(--text-strong); font-size:13px; font-weight:750; }
.form-control,
.form-select {
    min-height:46px;
    border:1px solid var(--border);
    border-radius:11px;
    background:var(--surface-2);
    color:var(--text);
    font-size:14px;
}
textarea.form-control { min-height:116px; resize:vertical; }
.form-control::placeholder { color:var(--muted-2); }
.form-note { margin-top:18px; padding:12px 14px; border-radius:11px; background:var(--accent-faint); color:var(--muted); font-size:12px; line-height:1.5; }

/* Team & Agents page. */
.table-toolbar-inline { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.search-control.compact { min-width:210px; }
.channel-inline { display:flex; align-items:center; gap:6px; }
.presence-badge { display:inline-flex; align-items:center; gap:7px; font-size:12.5px; font-weight:750; color:var(--text); }
.presence-badge i { width:8px; height:8px; border-radius:50%; background:#92a2a5; }
.presence-badge.online i { background:#32b77a; box-shadow:0 0 0 4px rgba(50,183,122,.10); }
.presence-badge.busy i { background:#e8a546; }
.presence-badge.away i { background:#d5b24a; }
.capacity-list { padding:10px 20px 20px; display:grid; gap:16px; }
.capacity-row { display:grid; grid-template-columns:120px minmax(120px,1fr) 44px; align-items:center; gap:14px; }
.capacity-copy { display:grid; }
.capacity-copy strong { color:var(--text-strong); font-size:13.5px; }
.capacity-copy small { color:var(--muted); font-size:11.5px; }
.capacity-meter { height:9px; overflow:hidden; border-radius:999px; background:var(--bg-soft); }
.capacity-meter span { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--accent),#51cbd3); }
.capacity-row > strong { font-size:12px; color:var(--text-strong); }

/* Tiny demo feedback after creating items. */
.cyan-toast {
    position:fixed;
    right:22px;
    bottom:22px;
    z-index:1200;
    max-width:340px;
    padding:13px 16px;
    border:1px solid var(--border);
    border-radius:12px;
    background:var(--surface-solid);
    color:var(--text-strong);
    font-size:13.5px;
    font-weight:700;
    box-shadow:0 20px 50px rgba(4,34,39,.18);
    opacity:0;
    transform:translateY(12px);
    pointer-events:none;
    transition:.22s ease;
}
.cyan-toast.show { opacity:1; transform:none; }
.demo-created { animation:demoCreated .45s var(--ease) both; }
@keyframes demoCreated { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

@media (max-width:900px) {
    .chat-workspace { height:auto !important; max-height:none; }
    .conversation-list { max-height:460px; }
    .chat-message-area { max-height:560px; }
    .form-grid { grid-template-columns:1fr; }
    .form-field.wide { grid-column:auto; }
}
@media (max-width:640px) {
    .premium-bar-chart { padding-inline:10px; }
    .premium-bars { gap:7px; }
    .premium-bar-value { display:none; }
    .capacity-row { grid-template-columns:90px minmax(90px,1fr) 38px; gap:9px; }
}


body.cyan-modal-open { overflow: hidden; }
.cyan-modal.cyan-fallback-open {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    background: rgba(8, 30, 39, .54);
    backdrop-filter: blur(6px);
}
.cyan-modal.cyan-fallback-open .modal-dialog {
    width: min(760px, calc(100% - 24px));
    margin: 7vh auto;
}
.cyan-modal.cyan-fallback-open .modal-content {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}
.cyan-modal.cyan-fallback-open .modal-header,
.cyan-modal.cyan-fallback-open .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
}
.cyan-modal.cyan-fallback-open .modal-body { padding: 20px; }
