:root{
 --green:#0b654c;--green2:#0f7c5d;--bg:#f3f6f5;--card:#fff;
 --line:#dfe6e2;--text:#17211d;--muted:#68756f;--danger:#b42318;
 --success:#067647;--soft:#eaf4ef;--blue:#2563eb;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Segoe UI,system-ui,-apple-system,Arial,sans-serif;background:var(--bg);color:var(--text)}
button,input,textarea,select{font:inherit}
button{cursor:pointer}
a{text-decoration:none}
.topbar{min-height:104px;background:var(--green);color:#fff;display:flex;justify-content:space-between;align-items:center;padding:14px 22px;gap:20px}
.brand{display:flex;align-items:center;gap:18px}.brand img{width:170px;max-height:76px;object-fit:contain;background:#fff}.brand h1{font-size:30px;margin:0 0 5px}.brand p{margin:0;color:#d9eee7}
.top-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}.usage-pill,.user-chip{background:rgba(255,255,255,.12);padding:9px 12px;border-radius:10px;font-weight:700}
.tabs{display:flex;gap:0;background:#fff;border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20;overflow:auto}
.tabs button{border:0;background:#fff;padding:12px 16px;font-weight:700;white-space:nowrap;color:#3b4943}.tabs button.active{color:var(--green);background:#edf7f2;border-bottom:3px solid var(--green)}
.badge{display:inline-flex;min-width:20px;height:20px;padding:0 5px;align-items:center;justify-content:center;border-radius:20px;background:#d92d20;color:#fff;font-size:11px}
.main{padding:18px;max-width:1800px;margin:auto}.tab-panel{display:none}.tab-panel.active{display:block}
.page-title{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}.page-title h2{font-size:26px;margin:0 0 5px}.page-title p{margin:0;color:var(--muted)}
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:15px;margin-bottom:12px;box-shadow:0 2px 10px rgba(15,44,32,.035)}.card h3{margin:0 0 10px}.compact{padding:12px}
.card-heading{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}
.radio-row{display:flex;gap:24px;flex-wrap:wrap}.radio-row label,.check-label{font-weight:600}
.file-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:12px}.file-box{background:#f7faf9;border:1px dashed #b9c9c2;border-radius:9px;padding:10px}.file-box label{display:block;font-weight:700;margin-bottom:5px}
.hint,.muted{color:var(--muted);font-size:13px}.hint{margin-top:8px}.contact-box{width:100%;min-height:210px;resize:vertical;border:1px solid #bfcac5;border-radius:8px;padding:10px;font-family:Consolas,monospace}
.btn{border:0;border-radius:8px;padding:9px 13px;font-weight:700;display:inline-block}.btn.primary{background:var(--green2);color:#fff}.btn.secondary{background:#e8efec;color:#173c30}.btn.light{background:#fff;color:var(--green)}.btn.full{width:100%;padding:12px}.btn:disabled{opacity:.45;cursor:not-allowed}
.button-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}.file-btn{position:relative}
.guard-row{display:flex;align-items:center;justify-content:space-between;gap:15px;flex-wrap:wrap}.guard-row>div:first-child{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.small-input{width:90px;padding:7px;border:1px solid #c8d1cd;border-radius:7px}.usage-big{font-size:17px;font-weight:800;color:var(--green)}
.sticky-send{position:sticky;bottom:0;background:#e9f4ef;border:1px solid #bfd7cc;border-radius:10px;padding:10px 14px;box-shadow:0 -3px 14px rgba(16,67,48,.08);z-index:10}.consent{display:block;margin-bottom:8px}.send-status{display:grid;grid-template-columns:1fr auto auto;gap:12px;align-items:center}.progress{height:7px;background:#d6dfdb;border-radius:8px;overflow:hidden;margin-top:5px}.progress span{display:block;height:100%;width:0;background:#16a34a}.progress-text{font-weight:800;color:var(--green)}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(220px,1fr));gap:12px}.form-grid label{font-weight:700}.form-grid input,.form-grid select{display:block;width:100%;margin-top:5px;padding:9px 10px;border:1px solid #c7d0cc;border-radius:8px;background:#fff}.form-grid .check-label{display:flex;align-items:end;gap:8px;padding-bottom:8px}.form-grid .check-label input{width:auto;margin:0}.settings-grid{grid-template-columns:repeat(2,minmax(260px,1fr))}.settings-grid .wide{grid-column:1/-1}
.table-card{padding:0}.table-wrap{overflow:auto;max-height:66vh}table{width:100%;border-collapse:collapse;background:#fff}th,td{padding:10px 9px;border-bottom:1px solid #e6ebe8;text-align:left;vertical-align:top;font-size:13px}th{position:sticky;top:0;background:#f3f7f5;z-index:2;color:#395047}.status-confirmed{color:var(--success);font-weight:800}.status-unknown{color:#9a6700;font-weight:700}
.inbox-grid{display:grid;grid-template-columns:360px 1fr;gap:12px;min-height:68vh}.conversation-card,.chat-card{margin:0;padding:0;overflow:hidden}.conversation-list{height:calc(100vh - 270px);min-height:520px;overflow:auto}.conversation{padding:11px 13px;border-bottom:1px solid #e5eae7;cursor:pointer}.conversation:hover,.conversation.active{background:#eaf5f0}.conversation .name{font-weight:800}.conversation .preview{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted);font-size:12px;margin-top:2px}
.chat-card{display:grid;grid-template-rows:auto 1fr auto}.chat-header{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line)}.chat-header h3{margin:0 0 3px}.window-label{font-weight:800}.window-open{color:var(--success)}.window-closed{color:var(--danger)}
.chat-messages{overflow:auto;background:#efeae2;padding:14px;height:calc(100vh - 405px);min-height:360px}.bubble{max-width:78%;padding:9px 11px;border-radius:10px;margin:8px 0;white-space:pre-wrap;word-break:break-word}.bubble.in{background:#fff;margin-right:auto}.bubble.out{background:#d9fdd3;margin-left:auto}.bubble .meta{font-size:10px;color:#69736f;text-align:right;margin-top:5px}.bubble img,.bubble video{display:block;max-width:100%;max-height:360px;border-radius:8px;margin-top:7px}
.reply-panel{border-top:1px solid var(--line);padding:10px;background:#fff}.reply-panel textarea{width:100%;height:74px;resize:vertical;padding:9px;border:1px solid #c7d0cc;border-radius:8px}.reply-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:8px}
.empty{text-align:center;color:var(--muted);padding:25px}
.status-grid{display:grid;grid-template-columns:repeat(4,minmax(220px,1fr));gap:12px;margin-bottom:12px}.status-card{background:#fff;border:1px solid var(--line);border-radius:12px;padding:15px;display:flex;gap:11px;align-items:center}.status-dot{width:12px;height:12px;border-radius:50%;background:#16a34a;box-shadow:0 0 0 4px #dcfce7}.status-dot.bad{background:#dc2626;box-shadow:0 0 0 4px #fee2e2}
.alert{padding:10px 12px;border-radius:8px;margin:10px 0}.alert.info{background:#eff6ff;color:#1d4ed8}.alert.success{background:#ecfdf3;color:#067647}.alert.danger{background:#fef3f2;color:#b42318}
footer{text-align:center;color:#66756e;padding:18px;font-size:12px}
.login-body{min-height:100vh;display:grid;place-items:center;background:linear-gradient(140deg,#084b39,#0b7456 55%,#eef6f2 55%)}.login-shell{width:min(94vw,520px)}.login-brand{display:flex;align-items:center;gap:14px;color:#fff;margin-bottom:14px}.login-brand img{width:135px;background:#fff}.login-brand h1{margin:0;font-size:25px}.login-brand p{margin:4px 0 0;color:#d7eee5}.login-card{background:#fff;border-radius:17px;padding:26px;box-shadow:0 20px 60px rgba(0,0,0,.18)}.login-card h2{margin:4px 0 5px}.login-card label{display:block;font-weight:700;margin-top:13px}.login-card input{width:100%;padding:11px;border:1px solid #c8d1cd;border-radius:8px;margin-top:5px}.eyebrow{font-size:12px;font-weight:900;letter-spacing:.08em;color:var(--green)}.login-footer{text-align:center;color:#fff;margin-top:14px;font-size:12px}
@media(max-width:1050px){.brand h1{font-size:23px}.brand img{width:130px}.status-grid{grid-template-columns:repeat(2,1fr)}.inbox-grid{grid-template-columns:310px 1fr}.topbar{min-height:88px}}
@media(max-width:760px){.topbar{align-items:flex-start;padding:10px}.brand img{width:92px}.brand h1{font-size:18px}.brand p{font-size:11px}.top-actions{display:none}.main{padding:9px}.form-grid,.settings-grid,.file-grid{grid-template-columns:1fr}.settings-grid .wide{grid-column:auto}.send-status{grid-template-columns:1fr}.inbox-grid{display:block}.conversation-list{height:auto;max-height:42vh;min-height:0}.chat-card{margin-top:10px}.chat-messages{height:48vh;min-height:260px}.status-grid{grid-template-columns:1fr}.sticky-send{position:static}.page-title{display:block}.page-title>.button-row{margin-top:8px}}


/* ==========================================================
   INBOX CONTACT SEARCH
   ========================================================== */

.inbox-contact-search{
    padding:0 12px 10px;
    border-bottom:1px solid var(--line);
}

.inbox-contact-search input{
    width:100%;
    padding:10px 12px;
    border:1px solid #c7d0cc;
    border-radius:9px;
    background:#fff;
}

/* ==========================================================
   MESSAGE HISTORY FILTERS + STATISTICS
   ========================================================== */

.history-filter-card{
    margin-bottom:12px;
}

.history-filter-grid{
    display:grid;
    grid-template-columns:
        minmax(150px,.75fr)
        minmax(150px,.75fr)
        minmax(240px,1.5fr)
        auto;
    gap:12px;
    align-items:end;
}

.history-filter-grid label{
    font-weight:700;
}

.history-filter-grid input{
    display:block;
    width:100%;
    margin-top:5px;
    padding:9px 10px;
    border:1px solid #c7d0cc;
    border-radius:8px;
    background:#fff;
}

.history-filter-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.history-stat-grid{
    display:grid;
    grid-template-columns:repeat(6,minmax(130px,1fr));
    gap:10px;
    margin-bottom:12px;
}

.history-stat{
    background:#fff;
    border:1px solid var(--line);
    border-radius:12px;
    padding:14px 15px;
}

.history-stat span{
    display:block;
    color:var(--muted);
    font-size:12px;
    font-weight:700;
    margin-bottom:5px;
}

.history-stat strong{
    display:block;
    font-size:24px;
    line-height:1;
    color:#203029;
}

.history-stat.sent{
    border-left:4px solid #64748b;
}

.history-stat.delivered{
    border-left:4px solid #0f7c5d;
}

.history-stat.read{
    border-left:4px solid #067647;
}

.history-stat.failed{
    border-left:4px solid #b42318;
}

.history-stat.other{
    border-left:4px solid #b7791f;
}

.status-failed{
    color:var(--danger);
    font-weight:800;
}

.status-sent{
    color:#475569;
    font-weight:800;
}

@media(max-width:1200px){
    .history-filter-grid{
        grid-template-columns:repeat(2,minmax(180px,1fr));
    }

    .history-filter-actions{
        grid-column:1/-1;
    }

    .history-stat-grid{
        grid-template-columns:repeat(3,1fr);
    }
}

@media(max-width:700px){
    .history-filter-grid{
        grid-template-columns:1fr;
    }

    .history-search-field,
    .history-filter-actions{
        grid-column:auto;
    }

    .history-stat-grid{
        grid-template-columns:repeat(2,1fr);
    }
}


/* ==========================================================
   INBOX — CLOSED 24H WINDOW TEMPLATE SENDER
   ========================================================== */

.closed-template-panel{
    border-top:1px solid var(--line);
    background:#fff;
    padding:14px;
}

.closed-template-panel[hidden]{
    display:none !important;
}

.closed-template-notice{
    display:flex;
    flex-direction:column;
    gap:3px;
    margin-bottom:12px;
    padding:11px 12px;
    border:1px solid #f1d7a3;
    border-left:4px solid #b7791f;
    border-radius:9px;
    background:#fff9eb;
}

.closed-template-notice strong{
    color:#7a4c00;
}

.closed-template-notice span{
    color:#665c48;
    font-size:13px;
}

.closed-template-grid{
    display:grid;
    grid-template-columns:minmax(260px,1fr) minmax(220px,.8fr);
    gap:12px;
    align-items:end;
}

.closed-template-grid label{
    font-weight:750;
}

.closed-template-grid select,
.closed-template-grid input[type="file"]{
    display:block;
    width:100%;
    margin-top:5px;
    min-height:42px;
    padding:8px 10px;
    border:1px solid #c7d0cc;
    border-radius:8px;
    background:#fff;
}

.closed-template-meta{
    margin-top:9px;
    color:var(--muted);
    font-size:12px;
}

.closed-template-consent{
    display:flex;
    align-items:flex-start;
    gap:8px;
    margin:12px 0;
    font-size:13px;
    color:#34453e;
}

.closed-template-consent input{
    margin-top:3px;
}

#inboxTemplateStatus{
    margin-top:8px;
}

@media(max-width:800px){
    .closed-template-grid{
        grid-template-columns:1fr;
    }
}

/* HiBell Customer Search V2 */
.enhanced-search-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.enhanced-search-grid .check-label {
    min-height: 42px;
    align-self: end;
}

.lead-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin: 14px 0 2px;
}

.lead-summary-grid > div {
    background: #f6faf8;
    border: 1px solid #d9e6e0;
    border-radius: 10px;
    padding: 10px 12px;
}

.lead-summary-grid span {
    display: block;
    font-size: 12px;
    color: #62716b;
    margin-bottom: 3px;
}

.lead-summary-grid strong {
    font-size: 20px;
    color: #075e4c;
}

.lead-score-badge {
    display: inline-flex;
    min-width: 38px;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 12px;
    border: 1px solid transparent;
}
.lead-score-badge.score-high { background:#e6f7ef; color:#086344; border-color:#b8e4d0; }
.lead-score-badge.score-mid { background:#fff7df; color:#7a5b00; border-color:#f1dda0; }
.lead-score-badge.score-low { background:#f2f4f3; color:#5b6661; border-color:#d9dfdc; }

.status-new-lead {
    display: inline-block;
    background: #e8f5ff;
    color: #145f8c;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 700;
}

.lead-status-select {
    min-width: 118px;
    padding: 6px 8px;
    border: 1px solid #cbd7d1;
    border-radius: 7px;
    background: #fff;
}

@media (max-width: 900px) {
    .lead-summary-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}
