/* =====================================================================
   COMMS STUDIO  ·  internal stakeholder alerts
   ===================================================================== */

.cs-page {
    --cs-bg:        #f8fafc;
    --cs-surface:   #ffffff;
    --cs-surface-2: #f7f8fa;
    --cs-surface-3: #f1f3f6;
    --cs-line:      rgba(15, 23, 42, .08);
    --cs-line-2:    rgba(15, 23, 42, .14);
    --cs-ink:       #0f172a;
    --cs-ink-2:     #475569;
    --cs-ink-3:     #94a3b8;
    --cs-accent:    #2563eb;
    --cs-accent-2:  #4f46e5;
    --cs-accent-soft: rgba(37, 99, 235, .08);
    --cs-info:      #2563eb;
    --cs-warn:      #d97706;
    --cs-bad:       #dc2626;
    --cs-good:      #059669;
    --cs-radius:    14px;
    --cs-shadow-card: 0 1px 3px rgba(15,23,42,.04), 0 1px 2px -1px rgba(15,23,42,.05), inset 0 0 0 1px rgba(15,23,42,.06);
    --cs-shadow-pop:  0 16px 36px -10px rgba(15,23,42,.18), 0 0 0 1px rgba(15,23,42,.08);

    background: var(--cs-bg);
}

/* ============================================================
   HERO
   ============================================================ */
.cs-hero {
    position: relative;
    padding: 56px 32px 40px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--cs-line);
}
.cs-hero-bg { position: absolute; inset: 0; pointer-events: none; }
.cs-hero-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(15,23,42,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,23,42,.05) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(ellipse at top right, #000 0%, transparent 60%);
    opacity: .6;
}
.cs-hero-glow {
    position: absolute;
    top: -120px; right: -120px;
    width: 480px; height: 480px;
    background: radial-gradient(circle, rgba(37, 99, 235, .18) 0%, transparent 65%);
    filter: blur(40px);
    animation: csHeroGlow 8s ease-in-out infinite;
}
@keyframes csHeroGlow {
    0%, 100% { transform: translate(0, 0); opacity: .8; }
    50%      { transform: translate(-30px, 20px); opacity: 1; }
}
.cs-hero-scan {
    position: absolute; left: 0; right: 0; top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .35), transparent);
    filter: blur(.5px);
    animation: csScan 6s linear infinite;
}
@keyframes csScan {
    0%   { transform: translateY(-220px); opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(220px); opacity: 0; }
}
.cs-hero-inner {
    position: relative;
    display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: flex-end;
    max-width: 1480px;
}
.cs-hero-left { max-width: 760px; }
.cs-hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 600; color: var(--cs-ink-2);
    text-transform: uppercase; letter-spacing: .08em;
    padding: 6px 12px; border-radius: 999px;
    background: var(--cs-surface);
    box-shadow: inset 0 0 0 1px var(--cs-line);
    margin-bottom: 18px;
    animation: csFadeUp .6s cubic-bezier(.2,.7,.2,1) both;
}
.cs-hero-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--cs-good); box-shadow: 0 0 0 4px rgba(5, 150, 105, .15);
    animation: csPulse 2s ease-in-out infinite;
}
@keyframes csPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(5, 150, 105, .15); }
    50%      { transform: scale(1.4); box-shadow: 0 0 0 6px rgba(5, 150, 105, .08); }
}
.cs-hero-title {
    font-size: clamp(40px, 5vw, 56px);
    font-weight: 700;
    letter-spacing: -.035em;
    line-height: 1.02;
    color: var(--cs-ink);
    margin: 0 0 14px;
    animation: csFadeUp .7s cubic-bezier(.2,.7,.2,1) both;
    animation-delay: .05s;
}
.cs-hero-sub {
    font-size: 15px;
    line-height: 1.65;
    color: var(--cs-ink-2);
    margin: 0;
    max-width: 640px;
    animation: csFadeUp .8s cubic-bezier(.2,.7,.2,1) both;
    animation-delay: .1s;
}
.cs-hero-stats {
    display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px;
    animation: csFadeUp .9s cubic-bezier(.2,.7,.2,1) both;
    animation-delay: .15s;
}
.cs-stat {
    background: var(--cs-surface);
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: var(--cs-shadow-card);
    text-align: center;
}
.cs-stat-val {
    display: block;
    font-size: 28px; font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--cs-ink);
    font-feature-settings: 'tnum';
    margin-bottom: 4px;
}
.cs-stat span {
    font-size: 11px;
    color: var(--cs-ink-2);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 500;
}
@keyframes csFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 1100px) {
    .cs-hero-inner { grid-template-columns: 1fr; }
    .cs-hero-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 720px) {
    .cs-hero { padding: 36px 20px 28px; }
    .cs-hero-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.cs-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    padding: 28px 32px 64px;
    max-width: 1480px;
    align-items: start;
}
@media (max-width: 1100px) {
    .cs-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   LIST PANE
   ============================================================ */
.cs-list-pane {
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-card);
    overflow: hidden;
    position: sticky; top: 24px;
    max-height: calc(100vh - 48px);
    display: flex; flex-direction: column;
    animation: csFadeUp .6s cubic-bezier(.2,.7,.2,1) both .2s;
}
.cs-list-head {
    padding: 16px;
    border-bottom: 1px solid var(--cs-line);
    background: linear-gradient(180deg, #fdfefe 0%, #ffffff 100%);
}
.cs-list-search {
    position: relative;
    display: flex; align-items: center; gap: 8px;
}
.cs-list-search > i {
    position: absolute; left: 12px;
    color: var(--cs-ink-3);
    font-size: 14px;
    pointer-events: none;
}
.cs-list-search input {
    flex: 1;
    padding: 9px 12px 9px 36px;
    background: var(--cs-surface-3);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    color: var(--cs-ink);
    transition: all .2s ease;
}
.cs-list-search input:focus {
    outline: none;
    background: var(--cs-surface);
    border-color: var(--cs-accent);
    box-shadow: 0 0 0 3px var(--cs-accent-soft);
}
.cs-search-kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    color: var(--cs-ink-3);
    pointer-events: none;
}
.cs-search-kbd kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--cs-surface);
    border: 1px solid var(--cs-line);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--cs-ink-2);
}
.cs-list-filters {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    margin-top: 12px;
    align-items: center;
}
.cs-filter-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--cs-ink-3);
}
.cs-chips {
    display: flex; flex-wrap: wrap; gap: 4px;
}
.cs-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px;
    background: var(--cs-surface-2);
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--cs-ink-2);
    cursor: pointer;
    transition: all .15s ease;
}
.cs-chip i { font-size: 10px; }
.cs-chip:hover { background: var(--cs-surface-3); color: var(--cs-ink); }
.cs-chip.active {
    background: var(--cs-ink);
    color: #fff;
    border-color: var(--cs-ink);
}
.cs-chip.active i { color: rgba(255,255,255,.8); }

.cs-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(15,23,42,.2) transparent;
}
.cs-list::-webkit-scrollbar { width: 6px; }
.cs-list::-webkit-scrollbar-thumb { background: rgba(15,23,42,.2); border-radius: 3px; }

.cs-list-group {
    margin-bottom: 12px;
}
.cs-list-group-head {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cs-ink-3);
}
.cs-list-group-head i { font-size: 10px; }
.cs-list-group-line {
    flex: 1;
    height: 1px;
    background: var(--cs-line);
}
.cs-list-group-count {
    font-size: 10px;
    color: var(--cs-ink-3);
    background: var(--cs-surface-2);
    padding: 2px 6px;
    border-radius: 4px;
}

.cs-item {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transition: background .15s ease;
    animation: csItemIn .35s cubic-bezier(.2,.7,.2,1) both;
    animation-delay: calc(var(--i, 0) * 25ms);
}
@keyframes csItemIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.cs-item::before {
    content: '';
    position: absolute;
    left: -8px; top: 50%;
    width: 3px; height: 0;
    border-radius: 0 2px 2px 0;
    background: var(--cs-accent);
    transform: translateY(-50%);
    transition: height .25s cubic-bezier(.2,.7,.2,1);
}
.cs-item:hover { background: var(--cs-surface-3); }
.cs-item.active { background: var(--cs-accent-soft); }
.cs-item.active::before { height: 24px; }

.cs-item-sev {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 8px;
    font-size: 12px;
}
.cs-item-sev[data-sev='info'] {
    background: rgba(37, 99, 235, .1);
    color: var(--cs-info);
}
.cs-item-sev[data-sev='warning'] {
    background: rgba(217, 119, 6, .1);
    color: var(--cs-warn);
}
.cs-item-sev[data-sev='critical'] {
    background: rgba(220, 38, 38, .1);
    color: var(--cs-bad);
}

.cs-item-body { min-width: 0; }
.cs-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-ink);
    line-height: 1.3;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cs-item-meta {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    color: var(--cs-ink-2);
}
.cs-item-channels {
    display: inline-flex; gap: 3px;
    color: var(--cs-ink-3);
}
.cs-item-channels i { font-size: 10px; }
.cs-item-dot {
    width: 3px; height: 3px; border-radius: 50%;
    background: var(--cs-ink-3);
}
.cs-item-fires {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--cs-ink-3);
}

.cs-item-status {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(5, 150, 105, .1);
    color: var(--cs-good);
}
.cs-item-status[data-status='paused'] {
    background: rgba(148, 163, 184, .15);
    color: var(--cs-ink-3);
}

.cs-list-foot {
    border-top: 1px solid var(--cs-line);
    padding: 12px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    background: var(--cs-surface-2);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.cs-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}
.cs-btn-primary {
    background: var(--cs-ink);
    color: #fff;
    box-shadow: inset 0 0 0 1px var(--cs-ink);
}
.cs-btn-primary:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, .25);
}
.cs-btn-secondary {
    background: var(--cs-surface);
    color: var(--cs-ink);
    box-shadow: inset 0 0 0 1px var(--cs-line-2);
}
.cs-btn-secondary:hover {
    background: var(--cs-surface-3);
    transform: translateY(-1px);
}
.cs-btn-ghost {
    background: transparent;
    color: var(--cs-ink-2);
}
.cs-btn-ghost:hover {
    background: var(--cs-surface-3);
    color: var(--cs-ink);
}
.cs-btn-danger {
    background: rgba(220, 38, 38, .08);
    color: var(--cs-bad);
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .2);
}
.cs-btn-danger:hover { background: rgba(220, 38, 38, .15); }

.cs-btn-small {
    padding: 5px 9px;
    font-size: 11px;
    border-radius: 6px;
}

/* ============================================================
   DETAIL — empty state
   ============================================================ */
.cs-detail {
    min-height: 600px;
    position: relative;
}
.cs-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    padding: 80px 32px;
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-card);
    min-height: 540px;
    animation: csFadeUp .6s cubic-bezier(.2,.7,.2,1) both .25s;
}
.cs-empty-art {
    position: relative;
    width: 140px; height: 140px;
    margin-bottom: 28px;
    display: grid; place-items: center;
}
.cs-empty-orb {
    position: absolute;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, .15) 0%, rgba(37, 99, 235, .03) 65%);
    animation: csOrbPulse 3s ease-in-out infinite;
}
@keyframes csOrbPulse {
    0%, 100% { transform: scale(1); opacity: .9; }
    50%      { transform: scale(1.08); opacity: 1; }
}
.cs-empty-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(37, 99, 235, .18);
    animation: csRingExpand 3s ease-out infinite;
}
.cs-empty-ring-1 { width: 60px; height: 60px; animation-delay: 0s; }
.cs-empty-ring-2 { width: 60px; height: 60px; animation-delay: 1s; }
.cs-empty-ring-3 { width: 60px; height: 60px; animation-delay: 2s; }
@keyframes csRingExpand {
    0%   { width: 60px; height: 60px; opacity: 1; }
    100% { width: 140px; height: 140px; opacity: 0; }
}
.cs-empty-icon {
    position: relative;
    font-size: 28px;
    color: var(--cs-accent);
    background: var(--cs-surface);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
    width: 56px; height: 56px;
    border-radius: 50%;
    display: grid; place-items: center;
}
.cs-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--cs-ink);
    margin: 0 0 8px;
    letter-spacing: -.02em;
}
.cs-empty p {
    font-size: 14px;
    color: var(--cs-ink-2);
    max-width: 380px;
    line-height: 1.55;
    margin: 0;
}

/* ============================================================
   DETAIL BODY — alert cards
   ============================================================ */
.cs-detail-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: csFadeUp .35s cubic-bezier(.2,.7,.2,1) both;
}

.cs-card {
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-card);
    overflow: hidden;
}
.cs-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cs-line);
    background: linear-gradient(180deg, #fdfefe 0%, #ffffff 100%);
}
.cs-card-head h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-ink);
    margin: 0;
    display: flex; align-items: center; gap: 8px;
    letter-spacing: -.005em;
}
.cs-card-head h3 i {
    color: var(--cs-ink-3);
    font-size: 12px;
}
.cs-card-body {
    padding: 18px;
}

/* === Alert header card === */
.cs-alert-header {
    padding: 22px 24px;
    position: relative;
    background:
        radial-gradient(ellipse at top right, rgba(37, 99, 235, .04) 0%, transparent 40%),
        linear-gradient(180deg, #fefefe 0%, #ffffff 100%);
}
.cs-alert-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--cs-accent);
    opacity: .5;
}
.cs-alert-header.sev-warning::before { background: var(--cs-warn); }
.cs-alert-header.sev-critical::before { background: var(--cs-bad); }

.cs-alert-top {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 10px;
}
.cs-alert-sev-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.cs-alert-sev-chip[data-sev='info'] {
    background: rgba(37, 99, 235, .1);
    color: var(--cs-info);
}
.cs-alert-sev-chip[data-sev='warning'] {
    background: rgba(217, 119, 6, .1);
    color: var(--cs-warn);
}
.cs-alert-sev-chip[data-sev='critical'] {
    background: rgba(220, 38, 38, .1);
    color: var(--cs-bad);
}
.cs-alert-cat-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    color: var(--cs-ink-2);
    background: var(--cs-surface-2);
    box-shadow: inset 0 0 0 1px var(--cs-line);
}
.cs-alert-cat-chip i { font-size: 10px; }
.cs-status-toggle {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(5, 150, 105, .1);
    color: var(--cs-good);
    cursor: pointer;
    transition: all .15s ease;
}
.cs-status-toggle:hover { background: rgba(5, 150, 105, .18); }
.cs-status-toggle[data-status='paused'] {
    background: rgba(148, 163, 184, .15);
    color: var(--cs-ink-3);
}
.cs-status-toggle::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, .15);
    animation: csStatusDot 2s ease-in-out infinite;
}
@keyframes csStatusDot {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.3); }
}

.cs-alert-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--cs-ink);
    margin: 0 0 8px;
    letter-spacing: -.025em;
    line-height: 1.2;
}
.cs-alert-desc {
    font-size: 13px;
    color: var(--cs-ink-2);
    line-height: 1.55;
    margin: 0 0 16px;
    max-width: 720px;
}
.cs-alert-cond {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--cs-surface-2);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--cs-ink-2);
    margin-bottom: 16px;
}
.cs-alert-cond .cs-cond-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cs-ink-3);
}

.cs-alert-stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
    margin-bottom: 16px;
}
.cs-alert-stat {
    background: var(--cs-surface-2);
    padding: 10px 12px;
    border-radius: 8px;
}
.cs-alert-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--cs-ink-3);
    font-weight: 600;
}
.cs-alert-stat-val {
    display: flex; align-items: center; gap: 5px;
    font-size: 16px;
    font-weight: 700;
    color: var(--cs-ink);
    font-feature-settings: 'tnum';
    margin-top: 2px;
}
.cs-alert-stat-val i {
    font-size: 12px; color: var(--cs-ink-3);
}
.cs-alert-stat-sub {
    font-size: 10px;
    color: var(--cs-ink-3);
    margin-top: 2px;
}

.cs-alert-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}

/* === Channel tabs === */
.cs-chan-tabs {
    display: flex; gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--cs-line);
    background: var(--cs-surface-2);
}
.cs-chan-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--cs-ink-2);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
}
.cs-chan-tab:hover { color: var(--cs-ink); background: var(--cs-surface); }
.cs-chan-tab.active {
    background: var(--cs-surface);
    color: var(--cs-ink);
    box-shadow: inset 0 0 0 1px var(--cs-line);
}
.cs-chan-tab i { font-size: 11px; }

/* === Template editor === */
.cs-tpl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 320px;
}
.cs-tpl-edit {
    border-right: 1px solid var(--cs-line);
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.cs-tpl-row {
    display: flex; flex-direction: column; gap: 4px;
}
.cs-tpl-row > label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--cs-ink-3);
}
.cs-tpl-input, .cs-tpl-textarea {
    padding: 8px 10px;
    background: var(--cs-surface-2);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--cs-ink);
    font-family: 'Inter', system-ui, sans-serif;
    resize: vertical;
    transition: all .15s ease;
}
.cs-tpl-input:focus, .cs-tpl-textarea:focus {
    outline: none;
    background: var(--cs-surface);
    border-color: var(--cs-accent);
    box-shadow: 0 0 0 3px var(--cs-accent-soft);
}
.cs-tpl-textarea {
    min-height: 160px;
    line-height: 1.55;
}

.cs-mf-toolbar {
    display: flex; align-items: center; gap: 6px;
    padding: 6px;
    background: var(--cs-surface-2);
    border-radius: 8px;
    flex-wrap: wrap;
}
.cs-mf-toolbar-label {
    font-size: 10px;
    color: var(--cs-ink-3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 4px 6px;
}
.cs-mf-chip {
    display: inline-flex; align-items: center;
    padding: 3px 8px;
    background: var(--cs-surface);
    border: 1px solid var(--cs-line);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--cs-ink-2);
    cursor: pointer;
    transition: all .15s ease;
}
.cs-mf-chip:hover {
    background: var(--cs-accent-soft);
    color: var(--cs-accent);
    border-color: rgba(37, 99, 235, .25);
    transform: translateY(-1px);
}
.cs-mf-toolbar-more {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 11px;
    color: var(--cs-accent);
    cursor: pointer;
    padding: 4px 8px;
    font-weight: 600;
}
.cs-mf-toolbar-more:hover { text-decoration: underline; }

.cs-sms-counter {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px;
    background: var(--cs-surface-2);
    border-radius: 6px;
    font-size: 11px;
    color: var(--cs-ink-2);
}
.cs-sms-bar {
    flex: 1;
    margin: 0 12px;
    height: 4px;
    background: var(--cs-surface-3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.cs-sms-bar-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: var(--cs-good);
    transition: width .3s ease, background .3s ease;
}
.cs-sms-bar-fill.warn { background: var(--cs-warn); }
.cs-sms-bar-fill.bad  { background: var(--cs-bad); }

/* === Preview === */
.cs-tpl-prev {
    padding: 16px;
    background: var(--cs-surface-2);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.cs-tpl-prev-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--cs-ink-3);
    margin-bottom: 10px;
}

.cs-email-preview {
    background: var(--cs-surface);
    border-radius: 8px;
    box-shadow: var(--cs-shadow-card);
    overflow: hidden;
    flex: 1;
    display: flex; flex-direction: column;
}
.cs-email-head {
    padding: 10px 14px;
    border-bottom: 1px solid var(--cs-line);
    background: var(--cs-surface-2);
}
.cs-email-from {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px;
    color: var(--cs-ink);
    margin-bottom: 4px;
}
.cs-email-from-ico {
    width: 24px; height: 24px;
    background: var(--cs-ink);
    color: #fff;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 11px;
    font-weight: 700;
}
.cs-email-subject {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-ink);
    letter-spacing: -.005em;
}
.cs-email-body {
    padding: 14px;
    font-size: 12px;
    line-height: 1.65;
    color: var(--cs-ink);
    white-space: pre-wrap;
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
}

.cs-sms-preview {
    background: var(--cs-ink);
    border-radius: 14px;
    padding: 22px 12px;
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 280px;
}
.cs-sms-phone {
    width: 200px; max-width: 100%;
    background: #ffffff;
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .4);
}
.cs-sms-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--cs-line);
    font-size: 10px;
    color: var(--cs-ink-2);
    font-family: 'JetBrains Mono', monospace;
}
.cs-sms-bubble {
    background: #e9f3ff;
    color: var(--cs-ink);
    padding: 10px 12px;
    border-radius: 16px 16px 16px 4px;
    font-size: 11px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}
.cs-sms-info {
    text-align: center;
    color: rgba(255, 255, 255, .65);
    font-size: 10px;
    margin-top: 8px;
}

.cs-token {
    background: rgba(37, 99, 235, .12);
    color: var(--cs-accent);
    padding: 0 4px;
    border-radius: 3px;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

@media (max-width: 900px) {
    .cs-tpl { grid-template-columns: 1fr; }
    .cs-tpl-edit { border-right: none; border-bottom: 1px solid var(--cs-line); }
    .cs-alert-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RECIPIENTS CARD
   ============================================================ */
.cs-subs {
    display: flex; flex-direction: column; gap: 8px;
}
.cs-sub {
    display: grid;
    grid-template-columns: 32px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: var(--cs-surface-2);
    border-radius: 8px;
    transition: all .15s ease;
    animation: csItemIn .25s ease-out both;
    animation-delay: calc(var(--i, 0) * 30ms);
}
.cs-sub:hover { background: var(--cs-surface-3); }

.cs-sub-avatar {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}
.cs-sub-avatar[data-tone='sapphire'] { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.cs-sub-avatar[data-tone='violet']   { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.cs-sub-avatar[data-tone='teal']     { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.cs-sub-avatar[data-tone='amber']    { background: linear-gradient(135deg, #f59e0b, #b45309); }
.cs-sub-avatar[data-tone='rose']     { background: linear-gradient(135deg, #f43f5e, #be123c); }
.cs-sub-avatar[data-tone='slate']    { background: linear-gradient(135deg, #64748b, #334155); }
.cs-sub-avatar.cs-sub-group {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: var(--cs-ink-2);
    box-shadow: inset 0 0 0 1px var(--cs-line);
}
.cs-sub-info { min-width: 0; }
.cs-sub-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-sub-meta {
    font-size: 11px;
    color: var(--cs-ink-2);
    display: flex; gap: 6px; align-items: center;
}
.cs-sub-channels {
    display: flex; gap: 4px;
}
.cs-sub-ch {
    width: 22px; height: 22px;
    border-radius: 4px;
    display: grid; place-items: center;
    background: var(--cs-surface);
    color: var(--cs-ink-3);
    font-size: 10px;
    cursor: pointer;
    transition: all .15s ease;
    box-shadow: inset 0 0 0 1px var(--cs-line);
}
.cs-sub-ch.on {
    background: var(--cs-accent-soft);
    color: var(--cs-accent);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .25);
}
.cs-sub-ch:hover { transform: scale(1.1); }
.cs-sub-remove {
    background: transparent;
    border: none;
    color: var(--cs-ink-3);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
    transition: all .15s ease;
}
.cs-sub-remove:hover {
    background: rgba(220, 38, 38, .1);
    color: var(--cs-bad);
}

.cs-subs-empty {
    padding: 24px;
    text-align: center;
    color: var(--cs-ink-3);
    font-size: 13px;
}

/* ============================================================
   RECENT-SENDS CARD
   ============================================================ */
.cs-recent {
    display: flex; flex-direction: column;
}
.cs-recent-row {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    gap: 12px;
    padding: 10px 0;
    position: relative;
    border-bottom: 1px solid var(--cs-line);
    align-items: center;
}
.cs-recent-row:last-child { border-bottom: none; }
.cs-recent-row::before {
    content: '';
    position: absolute;
    left: 6px; top: 0; bottom: 0;
    width: 1px;
    background: var(--cs-line);
}
.cs-recent-row:first-child::before { top: 50%; }
.cs-recent-row:last-child::before  { bottom: 50%; }
.cs-recent-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--cs-surface);
    box-shadow: inset 0 0 0 2px var(--cs-good);
    z-index: 1;
}
.cs-recent-row.partial .cs-recent-dot {
    box-shadow: inset 0 0 0 2px var(--cs-warn);
}
.cs-recent-info {
    font-size: 12px;
    color: var(--cs-ink);
}
.cs-recent-time {
    font-weight: 600;
}
.cs-recent-detail {
    font-size: 11px;
    color: var(--cs-ink-2);
    margin-top: 2px;
}
.cs-recent-stats {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--cs-ink-2);
}
.cs-recent-stats strong {
    font-weight: 700;
    color: var(--cs-good);
}
.cs-recent-row.partial .cs-recent-stats strong { color: var(--cs-warn); }

/* ============================================================
   DRAWERS  (recipients · merge fields)
   ============================================================ */
.cs-drawer, .cs-mf-drawer {
    position: fixed;
    top: 0; right: 0;
    width: 440px;
    height: 100vh;
    background: var(--cs-surface);
    box-shadow: -20px 0 40px -10px rgba(15, 23, 42, .15);
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.2,.7,.2,1);
    z-index: 200;
    display: flex; flex-direction: column;
}
.cs-drawer.open, .cs-mf-drawer.open {
    transform: translateX(0);
}
.cs-drawer-head, .cs-mf-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--cs-line);
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.cs-drawer-head h3, .cs-mf-head h3 {
    font-size: 16px; font-weight: 600; color: var(--cs-ink); margin: 0 0 4px;
    letter-spacing: -.015em;
}
.cs-drawer-head small, .cs-mf-head small {
    font-size: 12px; color: var(--cs-ink-2);
}
.cs-drawer-close {
    background: transparent;
    border: none;
    color: var(--cs-ink-3);
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 6px;
    display: grid; place-items: center;
    font-size: 13px;
    transition: all .15s ease;
}
.cs-drawer-close:hover { background: var(--cs-surface-3); color: var(--cs-ink); }

.cs-drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--cs-line);
    background: var(--cs-surface-2);
    padding: 0 12px;
}
.cs-drawer-tab {
    background: transparent;
    border: none;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cs-ink-2);
    cursor: pointer;
    position: relative;
    display: inline-flex; align-items: center; gap: 6px;
}
.cs-drawer-tab i { font-size: 12px; }
.cs-drawer-tab.active {
    color: var(--cs-ink);
    font-weight: 600;
}
.cs-drawer-tab.active::after {
    content: '';
    position: absolute;
    left: 12px; right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--cs-accent);
    border-radius: 2px 2px 0 0;
}
.cs-drawer-count {
    font-size: 10px;
    background: var(--cs-surface);
    color: var(--cs-ink-2);
    padding: 1px 6px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px var(--cs-line);
}

.cs-drawer-body, .cs-mf-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

.cs-drawer-foot {
    padding: 14px 16px;
    border-top: 1px solid var(--cs-line);
    background: var(--cs-surface-2);
    display: flex; justify-content: flex-end; gap: 8px;
}

.cs-scrim, .cs-mf-scrim {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(2px);
    z-index: 150;
    opacity: 0;
    animation: csScrimIn .25s ease-out both;
}
@keyframes csScrimIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Contact rows in drawer */
.cs-drawer-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    align-items: center;
    transition: background .15s ease;
}
.cs-drawer-row:hover { background: var(--cs-surface-2); }
.cs-drawer-row-avatar {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: grid; place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}
.cs-drawer-row-info { min-width: 0; }
.cs-drawer-row-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-ink);
}
.cs-drawer-row-meta {
    font-size: 11px;
    color: var(--cs-ink-2);
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 2px;
}
.cs-drawer-row-meta i {
    font-size: 10px;
    margin-right: 3px;
    color: var(--cs-ink-3);
}
.cs-drawer-row-actions {
    display: flex; gap: 4px;
}
.cs-drawer-row-act {
    background: transparent;
    border: none;
    color: var(--cs-ink-3);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    transition: all .15s ease;
}
.cs-drawer-row-act:hover { background: var(--cs-surface-3); color: var(--cs-ink); }

/* Merge field drawer rows */
.cs-mf-group {
    margin-bottom: 16px;
}
.cs-mf-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cs-ink-3);
    margin-bottom: 8px;
}
.cs-mf-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px;
    background: var(--cs-surface-2);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all .15s ease;
}
.cs-mf-row:hover {
    background: var(--cs-accent-soft);
    transform: translateX(2px);
}
.cs-mf-row-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--cs-accent);
}
.cs-mf-row-label {
    font-size: 12px;
    color: var(--cs-ink);
    font-weight: 500;
}
.cs-mf-row-sample {
    font-size: 11px;
    color: var(--cs-ink-3);
}

/* ============================================================
   MODAL
   ============================================================ */
.cs-modal {
    position: fixed; inset: 0;
    z-index: 250;
    display: grid; place-items: center;
    padding: 24px;
}
.cs-modal-scrim {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(4px);
    animation: csScrimIn .25s ease-out both;
}
.cs-modal-dialog {
    position: relative;
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-pop);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    animation: csDlgIn .3s cubic-bezier(.2,.7,.2,1) both;
}
.cs-modal-wide { max-width: 720px; }
@keyframes csDlgIn {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cs-modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--cs-line);
    display: flex; align-items: center; justify-content: space-between;
}
.cs-modal-head h3 {
    font-size: 16px; font-weight: 600; color: var(--cs-ink); margin: 0;
    letter-spacing: -.015em;
}
.cs-modal-close {
    background: transparent;
    border: none;
    color: var(--cs-ink-3);
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 6px;
    display: grid; place-items: center;
    transition: all .15s ease;
}
.cs-modal-close:hover { background: var(--cs-surface-3); color: var(--cs-ink); }
.cs-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}
.cs-modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--cs-line);
    background: var(--cs-surface-2);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* form rows used in add-contact / add-group modals */
.cs-form {
    display: flex; flex-direction: column; gap: 12px;
}
.cs-form-row {
    display: flex; flex-direction: column; gap: 4px;
}
.cs-form-row > label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--cs-ink-3);
}
.cs-form-row input,
.cs-form-row select {
    padding: 9px 12px;
    background: var(--cs-surface-2);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--cs-ink);
    font-family: 'Inter', system-ui, sans-serif;
    transition: all .15s ease;
}
.cs-form-row input:focus,
.cs-form-row select:focus {
    outline: none;
    background: var(--cs-surface);
    border-color: var(--cs-accent);
    box-shadow: 0 0 0 3px var(--cs-accent-soft);
}
.cs-form-tabs {
    display: flex; gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    background: var(--cs-surface-2);
    border-radius: 8px;
}
.cs-form-tab {
    flex: 1;
    padding: 6px 10px;
    background: transparent;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--cs-ink-2);
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
}
.cs-form-tab.active {
    background: var(--cs-surface);
    color: var(--cs-ink);
    box-shadow: var(--cs-shadow-card);
}

/* Subscribe picker */
.cs-sub-picker {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.cs-sub-picker-col h4 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cs-ink-3);
    margin: 0 0 8px;
}
.cs-sub-picker-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
    padding-right: 4px;
}
.cs-sub-picker-item {
    display: grid;
    grid-template-columns: 24px 28px 1fr;
    gap: 8px;
    padding: 8px 10px;
    background: var(--cs-surface-2);
    border-radius: 6px;
    align-items: center;
    cursor: pointer;
    transition: all .15s ease;
}
.cs-sub-picker-item:hover { background: var(--cs-surface-3); }
.cs-sub-picker-item input { cursor: pointer; }
.cs-sub-picker-item.checked {
    background: var(--cs-accent-soft);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .2);
}
.cs-sub-picker-avatar {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: grid; place-items: center;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}
.cs-sub-picker-name {
    font-size: 13px; font-weight: 500; color: var(--cs-ink);
}
.cs-sub-picker-role {
    font-size: 11px; color: var(--cs-ink-2);
}

@media (max-width: 720px) {
    .cs-sub-picker { grid-template-columns: 1fr; }
    .cs-drawer, .cs-mf-drawer { width: 92vw; }
}

/* ============================================================
   TEST FIRE MODAL
   ============================================================ */
.cs-test-stage {
    display: grid; grid-template-columns: 30px 1fr auto; gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: var(--cs-surface-2);
    margin-bottom: 6px;
    align-items: center;
    opacity: .3;
    transition: all .3s ease;
}
.cs-test-stage.run {
    opacity: 1;
    background: var(--cs-accent-soft);
}
.cs-test-stage.done {
    opacity: 1;
    background: rgba(5, 150, 105, .08);
}
.cs-test-icon {
    width: 26px; height: 26px;
    border-radius: 6px;
    display: grid; place-items: center;
    background: var(--cs-surface);
    color: var(--cs-ink-3);
    font-size: 11px;
}
.cs-test-stage.run .cs-test-icon {
    color: var(--cs-accent);
    background: var(--cs-surface);
}
.cs-test-stage.run .cs-test-icon i {
    animation: csSpin 1s linear infinite;
}
@keyframes csSpin { to { transform: rotate(360deg); } }
.cs-test-stage.done .cs-test-icon {
    background: var(--cs-good);
    color: #fff;
}
.cs-test-name {
    font-size: 13px; font-weight: 600; color: var(--cs-ink);
}
.cs-test-sub {
    font-size: 11px; color: var(--cs-ink-2);
}
.cs-test-status {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--cs-ink-3);
}
.cs-test-stage.done .cs-test-status { color: var(--cs-good); }

/* ============================================================
   TOASTS
   ============================================================ */
.cs-toast-stack {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.cs-toast {
    pointer-events: auto;
    background: var(--cs-ink);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, .25);
    display: flex; align-items: center; gap: 8px;
    font-size: 13px;
    font-weight: 500;
    min-width: 220px;
    animation: csToastIn .3s cubic-bezier(.2,.7,.2,1);
}
.cs-toast i { color: var(--cs-good); }
.cs-toast.warn i { color: var(--cs-warn); }
.cs-toast.bad i  { color: var(--cs-bad); }
.cs-toast.out { animation: csToastOut .25s ease-out forwards; }
@keyframes csToastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes csToastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }
