/* ============================================================
   Cevox — design system
   Light, product-grade surface with a single teal accent.
   Deliberately not a WhatsApp lookalike.
   Every class hook used by app.js is preserved.
   ============================================================ */

:root {
    /* ---- surfaces ---- */
    --bg:          #f7f8fa;   /* app canvas */
    --bg-1:        #ffffff;   /* cards, sidebar, tables */
    --bg-2:        #ffffff;   /* focused inputs */
    --bg-3:        #f2f4f7;   /* inputs, table heads, chips */
    --bg-hover:    #e8ebf0;

    --border:      #e3e7ee;
    --border-soft: #eef1f5;

    --text:        #101828;
    --text-dim:    #475467;
    --muted:       #8792a6;

    /* Primary is near-black: high contrast, no brand collision with WhatsApp */
    --primary:       #101828;
    --primary-hover: #000000;
    --primary-fg:    #ffffff;
    --primary-soft:  rgba(16, 24, 40, .05);
    --primary-ring:  rgba(16, 24, 40, .13);
    --accent:        #0d9488;

    --ok:      #059669;
    --ok-soft: #e7f6f1;
    --warn:      #b45309;
    --warn-soft: #fdf3e3;
    --danger:      #dc2626;
    --danger-soft: #fdecec;
    --info:      #0369a1;
    --info-soft: #e6f2fa;

    /* ---- scale ---- */
    --r-sm: 7px;
    --r:    11px;
    --r-lg: 16px;
    --radius: var(--r);

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow:    0 4px 14px rgba(16, 24, 40, .07);
    --shadow-lg: 0 22px 52px rgba(16, 24, 40, .16);

    --sidebar-w: 250px;
    --ease: cubic-bezier(.4, 0, .2, 1);

    --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 {
    margin: 0;
    letter-spacing: -.022em;
    font-weight: 650;
}
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }

a { color: inherit; text-decoration: none; }
code {
    font-family: var(--mono);
    font-size: .88em;
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--text-dim);
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.small  { font-size: 12.5px; }
.mono   { font-family: var(--mono); font-size: 13px; }
.error, .err { color: var(--danger); }
.warn { color: var(--warn); }

::selection { background: var(--accent); color: #fff; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ---------- views ---------- */
.view { min-height: 100%; }

/* ============================================================
   LOGIN
   ============================================================ */
#view-login {
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
/* soft ambient glow behind the card */
#view-login::before {
    content: '';
    position: absolute;
    width: 620px; height: 620px;
    background: radial-gradient(circle, rgba(13,148,136,.10) 0%, transparent 70%);
    filter: blur(46px);
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 396px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 38px 34px;
    box-shadow: var(--shadow-lg);
}

.auth-card .brand { text-align: center; margin-bottom: 26px; }
.auth-card .logo {
    width: 50px; height: 50px;
    margin: 0 auto 14px;
    display: grid; place-items: center;
    font-size: 24px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--accent), #14b8a6);
    box-shadow: 0 6px 20px rgba(13,148,136,.28);
}
.auth-card h1 { font-size: 25px; margin-bottom: 5px; }

#login-form { display: flex; flex-direction: column; gap: 15px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 520;
    color: var(--text-dim);
}
label > input,
label > select,
label > textarea { margin-top: 7px; }

input, select, textarea {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    background: var(--bg-2);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e6e' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}
select[multiple] { background-image: none; padding-right: 13px; }
input[type="file"] {
    padding: 9px;
    font-size: 13px;
    cursor: pointer;
}
input[type="file"]::file-selector-button {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    margin-right: 11px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 17px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 560;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease),
                transform .06s var(--ease), box-shadow .15s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

.btn.primary {
    background: var(--primary);
    color: var(--primary-fg);
    box-shadow: 0 1px 2px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.09);
}
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn.ghost {
    background: var(--bg-3);
    border-color: var(--border);
    color: var(--text-dim);
}
.btn.ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--muted);
}

.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn.small { padding: 6px 12px; font-size: 12.5px; }

/* ============================================================
   DASHBOARD SHELL
   ============================================================ */
#view-dashboard {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: var(--bg-1);
    box-shadow: 1px 0 0 var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px 16px;
    overflow-y: auto;
}

.brand-small {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16.5px;
    font-weight: 680;
    letter-spacing: -.02em;
    padding: 0 8px 20px;
}
.brand-small .logo-dot {
    width: 27px; height: 27px;
    border-radius: 8px;
    display: grid; place-items: center;
    font-size: 14px;
    background: linear-gradient(145deg, var(--accent), #14b8a6);
    box-shadow: 0 3px 10px rgba(13,148,136,.26);
    flex-shrink: 0;
}

.team-picker { padding: 0 8px 18px; }
.team-picker .label {
    font-size: 10.5px;
    font-weight: 640;
    letter-spacing: .09em;
    color: var(--muted);
    margin-bottom: 7px;
}
.team-picker select { padding: 8px 12px; font-size: 13.5px; }

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 510;
    color: var(--text-dim);
    cursor: pointer;
    position: relative;
    transition: background .13s var(--ease), color .13s var(--ease);
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .82; }
.sidebar nav a:hover { background: var(--bg-3); color: var(--text); }
.sidebar nav a.active {
    background: var(--bg-3);
    color: var(--text);
    font-weight: 590;
}
.sidebar nav a.active svg { opacity: 1; }
.sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: -14px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 17px;
    border-radius: 0 3px 3px 0;
    background: var(--text);
}

.user-block {
    border-top: 1px solid var(--border-soft);
    padding-top: 14px;
    margin-top: 12px;
}
.user-email {
    font-size: 12.5px;
    color: var(--muted);
    padding: 0 4px 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-block .btn { width: 100%; }

/* ---------- main ---------- */
main {
    overflow-y: auto;
    padding: 30px 34px 60px;
}
.tab { max-width: 1180px; animation: fade .22s var(--ease); }
@keyframes fade {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}

.tab > h2:first-child { margin-bottom: 20px; }

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.tab-header .actions-group { display: flex; gap: 8px; }

/* ---------- cards ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 15px;
}
.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 19px;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.card:hover { border-color: var(--muted); box-shadow: var(--shadow); }
.card h3 {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.card .phone {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}
.card .actions {
    display: flex;
    gap: 7px;
    margin-top: 15px;
    flex-wrap: wrap;
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}

.qr {
    background: var(--bg-3);
    border: 1px solid var(--border);
    padding: 11px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    margin: 13px 0;
}
.qr img { width: 100%; max-width: 208px; display: block; }

/* ---------- status pills ---------- */
.pill, .badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2.5px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .025em;
    text-transform: capitalize;
    background: var(--bg-3);
    color: var(--muted);
    border: 1px solid var(--border);
}
.pill::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.pill.connected, .badge.completed {
    background: var(--ok-soft); color: var(--ok); border-color: transparent;
}
.pill.connecting, .pill.qr, .badge.running {
    background: var(--info-soft); color: var(--info); border-color: transparent;
}
.pill.connecting::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.pill.paused, .badge.paused, .badge.draft {
    background: var(--warn-soft); color: var(--warn); border-color: transparent;
}
.pill.disconnected, .pill.logged_out, .pill.banned,
.badge.failed, .badge.cancelled {
    background: var(--danger-soft); color: var(--danger); border-color: transparent;
}

.chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    background: var(--bg-3);
    color: var(--text-dim);
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 540;
    margin: 1px 3px 1px 0;
}

/* ---------- tables ---------- */
.tbl, .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tbl th, .data-table th {
    text-align: left;
    padding: 11px 15px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--bg-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.tbl td, .data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13.5px;
    vertical-align: middle;
}
.tbl tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr, .data-table tbody tr { transition: background .12s var(--ease); }
.tbl tbody tr:hover, .data-table tbody tr:hover { background: var(--bg-3); }

.table-wrap { overflow-x: auto; border-radius: var(--r); }

/* ---------- empty state ---------- */
.empty {
    text-align: center;
    padding: 52px 24px;
    color: var(--muted);
    background: var(--bg-1);
    border: 1px dashed var(--border);
    border-radius: var(--r);
    font-size: 14px;
}

/* ---------- filters row ---------- */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 17px;
    flex-wrap: wrap;
}
.filters input[type="text"] { flex: 1; min-width: 210px; }
.filters select { width: auto; min-width: 155px; }

/* ---------- panels (inline forms) ---------- */
.panel {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 22px;
    margin-top: 19px;
    box-shadow: var(--shadow);
    animation: fade .2s var(--ease);
}
.panel h3 { margin-bottom: 5px; }
.panel > .muted { margin-top: 0; }
.panel label { margin: 15px 0 6px; }
.row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    flex-wrap: wrap;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 620px;
}
.stack .btn { align-self: flex-start; }

/* ---------- progress ---------- */
.progress {
    height: 6px;
    background: var(--bg-3);
    border-radius: 4px;
    overflow: hidden;
    margin: 11px 0 9px;
}
.progress .bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), #14b8a6);
    transition: width .45s var(--ease);
}

/* ---------- notice boxes ---------- */
.banner, .ok-box, .err-box, .warn-box {
    border-radius: var(--r);
    padding: 14px 16px;
    margin: 15px 0;
    font-size: 13.5px;
    border: 1px solid;
}
.banner, .ok-box { background: var(--ok-soft);   border-color: rgba(16,185,129,.3);  color: var(--text); }
.err-box         { background: var(--danger-soft); border-color: rgba(244,63,94,.3);  color: var(--text); }
.warn-box        { background: var(--warn-soft); border-color: rgba(245,158,11,.3);  color: var(--text); }
.banner code, .ok-box code {
    display: block;
    margin-top: 8px;
    padding: 9px 12px;
    background: var(--bg);
    border-radius: var(--r-sm);
    font-size: 12.5px;
    word-break: break-all;
    color: var(--ok);
}

.result:empty, .error:empty { display: none; }
.result, .error { font-size: 13.5px; margin: 0; }

/* ---------- code hint ---------- */
.code-hint { margin-top: 26px; }
.code-hint p { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
pre {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 15px 17px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text-dim);
    margin: 0;
}

/* ---------- campaign preview bubbles ---------- */
.preview-box { margin-top: 17px; }
.preview-box b { font-size: 13px; color: var(--muted); }
.bubble {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 13px 13px 13px 4px;
    padding: 10px 14px;
    margin-top: 9px;
    font-size: 13.5px;
    white-space: pre-wrap;
    line-height: 1.55;
}

/* ---------- modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .45);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    z-index: 100;
    animation: fade .16s var(--ease);
}
.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 26px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: pop .2s var(--ease);
}
@keyframes pop {
    from { opacity: 0; transform: scale(.96) translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.modal h3 { margin-bottom: 17px; }
.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 22px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
    #view-dashboard {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 14px;
    }
    .sidebar nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 4px;
    }
    .sidebar nav a { white-space: nowrap; padding: 8px 13px; }
    .sidebar nav a.active::before { display: none; }
    .user-block {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-top: 12px;
    }
    .user-block .btn { width: auto; }
    .user-email { padding-bottom: 0; }
    main { padding: 22px 18px 50px; }
    .cards { grid-template-columns: 1fr; }
    .tab-header { align-items: flex-start; flex-direction: column; }
}

/* ============================================================
   OVERVIEW / DASHBOARD
   ============================================================ */

/* sidebar section headings */
.nav-label {
    font-size: 10.5px;
    font-weight: 640;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 11px 6px;
}
.nav-label:first-child { padding-top: 0; }

/* user block with avatar */
.user-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.avatar {
    width: 29px; height: 29px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--accent), #14b8a6);
    color: #fff;
    font-size: 12.5px;
    font-weight: 650;
    flex-shrink: 0;
}
.user-row .user-email { padding: 0; margin: 0; flex: 1; min-width: 0; }

/* policy strip — what the safety layer is doing right now */
.policy-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 11px 15px;
    font-size: 12.5px;
    color: var(--text-dim);
    margin-bottom: 18px;
}
.policy-strip .sep { color: var(--border); margin: 0 8px; }
.dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.dot.ok   { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* stat tiles */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 13px;
}
.stat-tile {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 17px 18px;
    transition: border-color .15s var(--ease);
}
.stat-tile:hover { border-color: var(--bg-hover); }
.stat-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 520;
    margin-bottom: 7px;
}
.stat-value {
    font-size: 27px;
    font-weight: 660;
    letter-spacing: -.03em;
    line-height: 1.1;
}
.stat-value .of {
    font-size: 16px;
    font-weight: 500;
    color: var(--muted);
}
.stat-note {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 6px;
}
.stat-note.ok   { color: var(--ok); }
.stat-note.warn { color: var(--warn); }
.stat-note.bad  { color: var(--danger); }

/* number-health card internals */
.meter-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 14px;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 3px;
}
.progress .bar.ok   { background: var(--ok); }
.progress .bar.warn { background: var(--warn); }
.progress .bar.bad  { background: var(--danger); }

.tag {
    font-size: 11px;
    font-weight: 580;
    padding: 2.5px 9px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--bg-3);
}
.tag.new         { color: var(--warn);  background: var(--warn-soft);  border-color: transparent; }
.tag.warming     { color: var(--info);  background: var(--info-soft);  border-color: transparent; }
.tag.established { color: var(--ok);    background: var(--ok-soft);    border-color: transparent; }

.warn-box.small { padding: 9px 12px; margin: 10px 0; font-size: 12px; }

/* ---------- inline checkbox label (send-as-voice, etc.) ---------- */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--text-dim);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}
