/* ============================================================
   Reach — Broadcast Manager
   Design tokens
   ============================================================ */
:root {
    --ink:          #161B2E;
    --ink-soft:     #232A47;
    --ink-border:   #2E3555;
    --paper:        #F1F2ED;
    --card:         #FFFFFF;
    --border:       #E4E6E1;
    --text:         #1B2030;
    --muted:        #6B7280;
    --signal:       #FF5A3C;
    --signal-dark:  #E1471F;
    --success:      #2E8F5C;
    --success-bg:   #E7F5EE;
    --error:        #D9453D;
    --error-bg:     #FBEAE9;
    --radius:       6px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body:    'Inter', sans-serif;
    --font-mono:    'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    background: var(--ink);
    color: #C6CAE0;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px 10px;
    border-bottom: 1px solid var(--ink-border);
    margin-bottom: 18px;
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    letter-spacing: 0.2px;
}
.brand-sub {
    font-size: 11px;
    color: #8890B5;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: #A9AEC9;
    transition: background 0.15s ease, color 0.15s ease;
}
.side-nav-item:hover { background: var(--ink-soft); color: #fff; }
.side-nav-item.active { background: var(--ink-soft); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }

.side-nav-icon { width: 18px; height: 18px; flex-shrink: 0; position: relative; }
.side-nav-icon::before {
    content: '';
    position: absolute; inset: 0;
    background: currentColor;
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
}
.side-nav-icon[data-icon="grid"]::before    { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); }
.side-nav-icon[data-icon="users"]::before   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Ccircle cx='9' cy='8' r='3.2'/%3E%3Cpath d='M2.5 20c0-3.6 3-6 6.5-6s6.5 2.4 6.5 6'/%3E%3Ccircle cx='17.5' cy='8.5' r='2.6'/%3E%3Cpath d='M15 14.3c2.9.4 5 2.6 5 5.7'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Ccircle cx='9' cy='8' r='3.2'/%3E%3Cpath d='M2.5 20c0-3.6 3-6 6.5-6s6.5 2.4 6.5 6'/%3E%3Ccircle cx='17.5' cy='8.5' r='2.6'/%3E%3Cpath d='M15 14.3c2.9.4 5 2.6 5 5.7'/%3E%3C/svg%3E"); }
.side-nav-icon[data-icon="send"]::before    { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M22 2L11 13'/%3E%3Cpath d='M22 2l-7 20-4-9-9-4 20-7z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M22 2L11 13'/%3E%3Cpath d='M22 2l-7 20-4-9-9-4 20-7z'/%3E%3C/svg%3E"); }
.side-nav-icon[data-icon="list"]::before    { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E"); }

.sidebar-footer { border-top: 1px solid var(--ink-border); padding-top: 14px; }
.api-status {
    display: flex; align-items: center; gap: 8px;
    font-size: 11.5px; color: #8890B5; font-family: var(--font-mono);
    margin-bottom: 14px;
}
.api-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(46,143,92,0.2); }

.user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: var(--radius);
    background: var(--ink-soft);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--signal); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 12.5px;
    flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-username { font-size: 11.5px; color: #8890B5; font-family: var(--font-mono); }
.user-logout {
    width: 28px; height: 28px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: #8890B5; flex-shrink: 0; transition: background 0.15s ease, color 0.15s ease;
}
.user-logout:hover { background: rgba(255,90,60,0.15); color: var(--signal); }

.nav-toggle { display: none; }

/* ============================================================
   Content area
   ============================================================ */
.content { margin-left: 240px; padding: 32px 40px 60px; min-height: 100vh; }

.page-head { margin-bottom: 26px; }
.page-eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--signal-dark);
    margin-bottom: 6px;
    display: block;
}
.page-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 4px 0;
}
.page-desc { color: var(--muted); font-size: 14.5px; margin: 0; max-width: 640px; }

/* ============================================================
   Cards & stat grid
   ============================================================ */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 1px 2px rgba(22,27,46,0.04);
}

.page-head, .stat-grid, .card { animation: fadeInUp 0.35s ease both; }
.stat-grid { animation-delay: 0.04s; }
.card { animation-delay: 0.08s; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--signal);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(22,27,46,0.04);
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.stat-card.alt { border-left-color: var(--success); }
.stat-card.muted-accent { border-left-color: var(--ink-border); }
.stat-label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--muted); margin-bottom: 8px;
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 30px;
    font-weight: 600;
    color: var(--text);
}
.stat-icon {
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: #F4F1E9; color: var(--signal); flex-shrink: 0;
}
.stat-card.alt .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.muted-accent .stat-icon { background: #EEEFF6; color: var(--ink-border); }
.stat-card[data-tone="error"] .stat-icon { background: var(--error-bg); color: var(--error); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--signal); color: #fff; }
.btn-primary:hover { background: var(--signal-dark); }
.btn-primary:disabled { background: #F0B6A8; cursor: not-allowed; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 13px; }
.btn-ghost:hover { color: var(--error); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label {
    display: block; font-size: 13px; font-weight: 600;
    margin-bottom: 6px; color: var(--text);
}
input[type="text"], input[type="tel"], input[type="search"], select, textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--signal);
    box-shadow: 0 0 0 3px rgba(255,90,60,0.12);
}
textarea { resize: vertical; min-height: 110px; font-family: var(--font-body); line-height: 1.5; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.field-error { font-size: 12.5px; color: var(--error); margin-top: 5px; }

/* ============================================================
   Alerts / toasts
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(46,143,92,0.25); }
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: rgba(217,69,61,0.25); }

/* ============================================================
   Table
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted); font-weight: 600;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAF8; }
.phone-cell { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }

.chip {
    display: inline-block; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 100px;
    background: #EEF0F4; color: var(--muted);
}
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-error { background: var(--error-bg); color: var(--error); }

input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--signal); cursor: pointer; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search-box { flex: 1; min-width: 200px; }
.toolbar select { width: auto; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,23,38,0.55);
    display: none; align-items: center; justify-content: center; z-index: 200;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: 8px; width: 100%; max-width: 460px;
    padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============================================================
   Send Message page — recipient picker + composer
   ============================================================ */
.send-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 980px) { .send-layout { grid-template-columns: 1fr; } }

.recipient-list { max-height: 460px; overflow-y: auto; }
.recipient-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.recipient-row:last-child { border-bottom: none; }
.recipient-name { font-weight: 500; font-size: 14px; }
.recipient-phone { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.recipient-group { margin-left: auto; }

.selected-count {
    font-family: var(--font-mono); font-size: 13px; color: var(--signal-dark);
    background: #FFF1EC; padding: 4px 10px; border-radius: 100px; font-weight: 600;
}

.msg-type-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
.msg-type-toggle button {
    flex: 1; padding: 9px; border-radius: var(--radius); border: 1px solid var(--border);
    background: #fff; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted);
}
.msg-type-toggle button.active { border-color: var(--signal); color: var(--signal-dark); background: #FFF6F4; }

.char-count { text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Dispatch console — signature element for the send flow */
.dispatch-console {
    margin-top: 18px; display: none;
}
.dispatch-console.active { display: block; }
.dispatch-meter {
    display: flex; gap: 3px; margin-bottom: 10px;
}
.dispatch-tick {
    flex: 1; height: 8px; border-radius: 2px; background: #EDEEE8;
    transition: background 0.2s ease;
}
.dispatch-tick.done { background: var(--signal); }
.dispatch-tick.fail { background: var(--error); }
.dispatch-status-line {
    font-family: var(--font-mono); font-size: 13px; color: var(--text);
    display: flex; justify-content: space-between; margin-bottom: 14px;
}
.dispatch-log { max-height: 220px; overflow-y: auto; font-size: 13px; }
.dispatch-log-row {
    display: flex; align-items: center; gap: 10px; padding: 7px 4px;
    border-bottom: 1px solid var(--border);
}
.dispatch-log-row:last-child { border-bottom: none; }
.dispatch-log-icon { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.dispatch-log-icon.ok { background: var(--success); }
.dispatch-log-icon.err { background: var(--error); }
.dispatch-log-name { flex: 1; }
.dispatch-log-note { color: var(--muted); font-size: 12px; }

.empty-state {
    text-align: center; padding: 50px 20px; color: var(--muted);
}
.empty-state h4 { font-family: var(--font-display); color: var(--text); margin-bottom: 6px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .content { margin-left: 0; padding: 78px 20px 40px; }
    .nav-toggle {
        display: flex; flex-direction: column; justify-content: center; gap: 4px;
        position: fixed; top: 18px; left: 18px; z-index: 150;
        width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
        background: #fff; cursor: pointer;
    }
    .nav-toggle span { width: 18px; height: 2px; background: var(--text); margin: 0 auto; }
    .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Login page
   ============================================================ */
.auth-body { background: var(--paper); }

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}
@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand-panel { display: none; }
}

.auth-brand-panel {
    background: var(--ink);
    color: #C6CAE0;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-brand-panel::before {
    content: '';
    position: absolute; right: -120px; bottom: -120px;
    width: 360px; height: 360px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.06);
}
.auth-brand-panel::after {
    content: '';
    position: absolute; right: -60px; bottom: -60px;
    width: 240px; height: 240px; border-radius: 50%;
    border: 2px solid rgba(255,90,60,0.15);
}
.auth-brand-mark {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-weight: 700; font-size: 19px; color: #fff;
    z-index: 1;
}
.auth-brand-copy { z-index: 1; margin: 40px 0; }
.auth-brand-copy h1 {
    font-family: var(--font-display); font-size: 34px; font-weight: 700;
    color: #fff; line-height: 1.15; margin: 0 0 16px 0;
}
.auth-brand-copy p { font-size: 14.5px; line-height: 1.6; color: #A9AEC9; max-width: 380px; }

.auth-feature-list { list-style: none; margin: 0 0 40px 0; padding: 0; z-index: 1; }
.auth-feature-list li {
    display: flex; align-items: center; gap: 10px;
    font-size: 13.5px; color: #C6CAE0; padding: 7px 0;
}
.auth-feature-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); flex-shrink: 0; }

.auth-brand-footer { font-family: var(--font-mono); font-size: 11.5px; color: #6B7299; z-index: 1; }

.auth-form-panel {
    display: flex; align-items: center; justify-content: center;
    padding: 40px 24px;
}
.auth-form-card { width: 100%; max-width: 360px; }
.auth-form-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 4px 0 6px 0; }
.auth-hint { font-size: 12.5px; color: var(--muted); margin-top: 18px; text-align: center; line-height: 1.6; }
.auth-hint code { background: #EEEFF0; padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
