/* RTB SMS UI System V4 — presentation only */
:root{
  --rtb-bg:#f3f5f8;--rtb-surface:#fff;--rtb-surface-subtle:#f7f8fa;--rtb-surface-raised:#fff;
  --rtb-text:#172033;--rtb-text-secondary:#526074;--rtb-text-muted:#7b8798;
  --rtb-border:#dfe4eb;--rtb-border-strong:#c8d0dc;
  --rtb-primary:#1f5fbf;--rtb-primary-hover:#184d9b;--rtb-primary-subtle:#edf4ff;
  --rtb-success:#18794e;--rtb-warning:#9a6700;--rtb-danger:#b42318;--rtb-info:#275d9f;
  --rtb-sidebar:#111a29;--rtb-sidebar-hover:#1b283b;--rtb-sidebar-active:#263854;
  --rtb-space-1:4px;--rtb-space-2:8px;--rtb-space-3:12px;--rtb-space-4:16px;
  --rtb-space-5:20px;--rtb-space-6:24px;--rtb-space-8:32px;--rtb-space-10:40px;--rtb-space-12:48px;
  --rtb-radius-sm:5px;--rtb-radius-md:8px;--rtb-radius-lg:12px;
  --rtb-shadow-raised:0 8px 24px rgba(21,31,48,.08);--rtb-shadow-modal:0 20px 56px rgba(15,23,42,.22);
  --bg:var(--rtb-bg);--card:var(--rtb-surface);--text:var(--rtb-text);--muted:var(--rtb-text-secondary);
  --line:var(--rtb-border);--primary:var(--rtb-primary);--primary-dark:var(--rtb-primary-hover);
  --danger:var(--rtb-danger);--sidebar:var(--rtb-sidebar);--radius:var(--rtb-radius-md);--shadow:none;
  --surface-page:var(--rtb-bg);--surface-card:var(--rtb-surface);--surface-muted:var(--rtb-surface-subtle);
  --surface-dark:var(--rtb-sidebar);--surface-dark-soft:#25344a;--text-primary:var(--rtb-text);
  --text-secondary:var(--rtb-text-secondary);--border-default:var(--rtb-border);--accent-primary:var(--rtb-primary);
}
*{scrollbar-color:#bac3d0 transparent}
html{background:var(--rtb-bg)}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei UI","Microsoft YaHei",sans-serif;font-size:14px;line-height:1.5;letter-spacing:.005em;background:var(--rtb-bg);color:var(--rtb-text)}
a{color:var(--rtb-primary);text-underline-offset:2px}
:focus-visible{outline:3px solid rgba(31,95,191,.28)!important;outline-offset:2px}
::selection{background:#cfe0fb;color:#10243f}

/* Global shell */
.sidebar{width:224px;padding:22px 14px 16px;background:var(--rtb-sidebar);border-right:1px solid rgba(255,255,255,.06)}
.brand{padding:0 10px 20px;border-bottom:1px solid rgba(255,255,255,.09)}
.brand strong{font-size:18px;line-height:1.2;letter-spacing:.035em;color:#fff}
.brand span{margin-top:7px;color:#8fa0b7;font-size:11px;line-height:1.45}
.sidebar nav{gap:3px;padding-top:16px}
.sidebar nav a{position:relative;padding:9px 12px;border-radius:var(--rtb-radius-sm);color:#b7c2d1;font-size:13px;font-weight:520;transition:background-color .14s,color .14s}
.sidebar nav a:hover{background:var(--rtb-sidebar-hover);color:#edf3fb}
.sidebar nav a.active{background:var(--rtb-sidebar-active);color:#fff;font-weight:650}
.sidebar nav a.active:before{content:"";position:absolute;left:0;top:8px;bottom:8px;width:2px;border-radius:2px;background:#7eb1ff}
.sidebar-bottom{padding:15px 9px 0;color:#c8d2df;font-size:12px}
.workspace{margin-left:224px}
.header{height:60px;padding:0 24px;background:rgba(255,255,255,.96);border-color:var(--rtb-border);backdrop-filter:saturate(120%) blur(8px)}
.header h1{font-size:16px;font-weight:680;letter-spacing:0;color:var(--rtb-text)}
.header-meta{gap:14px;font-size:12px;color:var(--rtb-text-secondary)}
.content{max-width:1560px;padding:24px clamp(20px,2vw,32px) 40px}
.page-actions{margin-bottom:18px;align-items:center}
.page-actions h2,.title-row h2{font-size:21px;line-height:1.3;font-weight:720;letter-spacing:-.01em}
.page-actions p{margin:5px 0 0;color:var(--rtb-text-secondary)}

/* Surfaces and section hierarchy */
.card{padding:19px 20px;margin-bottom:18px;border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-md);box-shadow:none}
.card-title{margin-bottom:14px}.card h3,.card-title h3{font-size:15px;font-weight:680;margin-bottom:13px}
.section-heading{font-size:15px;font-weight:680;color:var(--rtb-text)}
.muted{color:var(--rtb-text-secondary)}.small{color:var(--rtb-text-muted)}
.notice,.alert{padding:11px 13px;border:1px solid #c9d9ee;border-radius:var(--rtb-radius-md);background:#f2f7fd;color:#244d7c}
.notice.warning{border-color:#ecd5a6;background:#fff9ed;color:#79540a}
.alert.error{border:1px solid #efc4c0;background:#fff5f4;color:#912018}
.empty{padding:32px 20px!important;color:var(--rtb-text-muted)}

/* Metrics: compact strip, not card wall */
.metrics{gap:0;border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-md);overflow:hidden;background:var(--rtb-surface);margin-bottom:18px}
.metric{min-width:0;padding:15px 17px;border:0;border-right:1px solid var(--rtb-border);border-radius:0;box-shadow:none;background:var(--rtb-surface)}
.metric:last-child{border-right:0}.metric span{margin-bottom:7px;color:var(--rtb-text-secondary);font-size:12px;font-weight:560}
.metric strong{font-size:24px;line-height:1.15;font-weight:740;font-variant-numeric:tabular-nums;color:var(--rtb-text)}
.dashboard-kpis .metric{min-height:92px}.dashboard-kpis .metric-link{transition:background-color .14s}.dashboard-kpis .metric-link:hover{transform:none;box-shadow:none;background:#f8fafc;border-color:transparent}
.dashboard-kpis .metric-link small{margin-top:5px;font-size:11px}

/* Buttons */
.btn{min-height:36px;padding:0 13px;border-radius:var(--rtb-radius-sm);font-size:13px;font-weight:630;box-shadow:none;transition:background-color .14s,border-color .14s,color .14s}
.btn.primary{background:var(--rtb-primary);border-color:var(--rtb-primary);color:#fff}.btn.primary:hover{background:var(--rtb-primary-hover);border-color:var(--rtb-primary-hover)}
.btn.secondary{background:#fff;border-color:var(--rtb-border-strong);color:var(--rtb-text)}.btn.secondary:hover{background:var(--rtb-surface-subtle);border-color:#aeb8c6}
.btn.danger,.btn.danger-btn{background:#fff;border-color:#dfaaa5;color:var(--rtb-danger)}.btn.danger:hover,.btn.danger-btn:hover{background:#fff5f4;border-color:#cb746c}
.btn.disabled,.btn:disabled{background:#eef1f4!important;border-color:#e1e5ea!important;color:#9099a6!important;cursor:not-allowed}
.small-btn{min-height:30px;padding:0 9px;font-size:12px}.link-button{color:#9fb0c5}
.actions,.form-actions,.row-actions{gap:8px}

/* Forms */
label{margin-top:14px;color:#354154;font-size:13px;font-weight:630}
input,select,textarea{min-height:38px;margin-top:6px;padding:8px 10px;border:1px solid var(--rtb-border-strong);border-radius:var(--rtb-radius-sm);background:#fff;color:var(--rtb-text);transition:border-color .14s,box-shadow .14s}
input:hover,select:hover,textarea:hover{border-color:#aab5c4}
input:focus,select:focus,textarea:focus{border-color:var(--rtb-primary);box-shadow:0 0 0 3px rgba(31,95,191,.12);outline:0}
input:disabled,select:disabled,textarea:disabled{background:#f0f2f5;color:#808a99}
textarea{line-height:1.55}.field-help{color:var(--rtb-text-muted)}
.filters{gap:8px;margin-bottom:14px}.form-actions{margin-top:18px}
.radio{font-weight:500}.radio input{accent-color:var(--rtb-primary)}

/* Tables */
.table-wrap{border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-md);background:#fff}
table{font-size:13px}.card>.table-wrap{margin-left:0;margin-right:0}
th{padding:10px 11px;background:#f5f7f9;color:#596679;font-size:11px;font-weight:680;letter-spacing:.015em;border-bottom:1px solid var(--rtb-border-strong)}
td{padding:11px;border-bottom:1px solid #e7ebf0;color:#263247}
tbody tr:last-child td{border-bottom:0}tbody tr:hover{background:#fafbfd}
td.numeric,th.numeric,.numeric{text-align:right;font-variant-numeric:tabular-nums}
.task-table thead th{background:#f5f7f9}.task-table tbody td{height:50px}.task-table tbody tr:hover{background:#f8fafc}
.task-table-wrap{border-color:var(--rtb-border)}

/* Status language */
.badge{min-height:22px;padding:2px 7px;border:1px solid transparent;border-radius:999px;background:#eef1f4;color:#596474;font-size:11px;font-weight:620}
.badge.completed,.badge.valid{border-color:#b9dccd;background:#edf8f3;color:var(--rtb-success)}
.badge.scheduled,.badge.queued{border-color:#c7d9f1;background:#eff5fd;color:var(--rtb-info)}
.badge.sending{border-color:#ebd19a;background:#fff8e9;color:var(--rtb-warning)}
.badge.failed,.badge.partial_failed,.badge.danger,.badge.invalid{border-color:#efc4c0;background:#fff3f2;color:var(--rtb-danger)}
.badge.cancelled,.badge.duplicate,.badge.blacklisted{border-color:#e8d5ae;background:#faf5e9;color:#87600f}

/* Tabs, toolbars, pagination */
.tabs{gap:0;margin-bottom:16px;border-color:var(--rtb-border)}.tabs a{padding:9px 12px;font-size:13px}.tabs a.active{font-weight:650}
.inbox-filter-chips a{padding:6px 9px;border-radius:var(--rtb-radius-sm);background:#fff}.inbox-filter-chips a.active{background:var(--rtb-primary-subtle)}
.pagination{gap:14px;padding-top:14px;font-size:13px}
.bulk-bar,.task-bulk-bar{border-radius:var(--rtb-radius-sm)}

/* Wizard, mapping, data review */
.wizard-steps{gap:0;margin-bottom:18px;border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-md);overflow-x:auto;background:#fff}
.wizard-steps a,.wizard-steps span{min-width:125px;padding:9px 10px;border-bottom:0;border-right:1px solid var(--rtb-border);font-size:12px}
.wizard-steps b{width:22px;height:22px;border-radius:50%;font-size:11px}.wizard-steps .active{background:var(--rtb-primary-subtle);box-shadow:inset 0 -2px var(--rtb-primary)}
.dropzone{padding:28px;border-color:#9eabbc;border-radius:var(--rtb-radius-md);background:#f8fafc}
.field-mapping-card{max-width:none}.mapping-table td,.mapping-table th{vertical-align:middle}.mapping-state{font-weight:630}
.mapping-conflict-warning{border-radius:var(--rtb-radius-md)}
.paste-review-table .state-error{background:#fff6f5}.paste-review-table .state-warning{background:#fffbf2}
.cell-error{outline:2px solid #d04437;outline-offset:-2px}

/* Message editor / preview */
.content-split{grid-template-columns:minmax(0,58fr) minmax(320px,42fr);gap:18px}
.phone-preview{min-height:420px;border-radius:var(--rtb-radius-md);background:#eef1f5}
.phone-screen{width:min(300px,88%);min-height:410px;padding:38px 18px 18px;border:6px solid #273345;border-radius:24px}
.phone-screen p{border-radius:11px 11px 11px 3px;background:#e9f1fc}

/* Conversation */
.inbox-layout{grid-template-columns:minmax(300px,34%) minmax(0,1fr);gap:14px}
.conversation-list{border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-md);background:#fff}.conversation{padding:11px 12px}.conversation.selected{background:var(--rtb-primary-subtle);box-shadow:inset 3px 0 var(--rtb-primary)}
.conversation-detail .conversation-head.v3{background:var(--rtb-sidebar);border-radius:var(--rtb-radius-md) var(--rtb-radius-md) 0 0}
.conversation-detail .unified-conversation-body{border-color:var(--rtb-border);box-shadow:none}
.conversation-workspace-v42{gap:20px}.conversation-sidebar-v42{padding-left:18px}
.communication-pane>.section-heading,.sidebar-section-heading,.notes-section>h3,.reply-composer-heading,.conversation-status-summary>h3,.conversation-management.compact-v2>h3{padding:8px 10px;border-radius:var(--rtb-radius-sm);background:#293950;color:#f7f9fc;font-size:13px}
.timeline-v4{gap:12px;padding:12px 6px;background:#f8f9fb}.timeline-v4 .message p{border-radius:10px}.activity-list,.notes-list{background:#f8f9fb;border-radius:var(--rtb-radius-sm)}
.internal-note{padding:9px 0}.reply-composer{padding-top:14px}

/* Matching, templates, settings */
.rule-groups{gap:12px}.rule-group{padding:16px}.keyword-chips{gap:6px;margin:11px 0}.keyword-chip{padding:5px 8px;border-radius:var(--rtb-radius-sm);background:#f4f6f8;font-size:12px}
.template-preview{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;line-height:1.5}
.settings-grid{gap:16px}.status-line{padding:10px 0}.provider-gates .status-line{border-bottom-color:var(--rtb-border)}
.live-gate-control{border-left:3px solid var(--rtb-warning);padding-left:13px}

/* Modal / overlays */
.modal{background:rgba(12,20,32,.54);backdrop-filter:blur(2px)}
.modal-card,.mapping-replace-card{border:1px solid var(--rtb-border);border-radius:var(--rtb-radius-lg);box-shadow:var(--rtb-shadow-modal)}
.detail-drawer{box-shadow:-12px 0 32px rgba(15,23,42,.16)}
.task-overflow-menu{border-radius:var(--rtb-radius-md);box-shadow:var(--rtb-shadow-raised)}

/* Login: restrained trust-first entry */
.login-page{display:grid;place-items:center;min-height:100svh;padding:32px;background:#e9edf3;background-image:linear-gradient(90deg,rgba(17,26,41,.035) 1px,transparent 1px),linear-gradient(rgba(17,26,41,.035) 1px,transparent 1px);background-size:32px 32px}
.login-card{width:min(408px,calc(100% - 32px));padding:34px 34px 27px;border:1px solid #d5dce6;border-radius:var(--rtb-radius-lg);box-shadow:0 16px 38px rgba(20,31,48,.11)}
.login-brand-block{margin:0 0 26px;text-align:center}.login-brand-block .login-brand{font-size:21px;letter-spacing:.06em;color:var(--rtb-primary)}
.login-brand-block h1{margin:8px 0 0;font-size:18px;font-weight:680;color:var(--rtb-text)}
.login-card form label{font-size:12px}.login-card form label+label{margin-top:17px}.login-card form input{min-height:42px;margin-top:7px}
.login-card form .btn{min-height:42px;margin-top:18px}.login-card .secure-note{margin-top:23px;color:#8a94a3;letter-spacing:.04em}

@media(max-width:1199px){
  .content{padding-inline:22px}.conversation-workspace-v42{grid-template-columns:1fr}.conversation-sidebar-v42{padding:18px 0 0;border-left:0;border-top:1px solid var(--rtb-border)}
  .metrics.six,.dashboard-kpis{grid-template-columns:repeat(3,1fr)}.metrics.six .metric:nth-child(3),.dashboard-kpis .metric:nth-child(3){border-right:0}
}
@media(max-width:1024px){
  .sidebar{width:210px}.workspace{margin-left:210px}.content{padding:20px}.header{padding-inline:20px}
  .header-meta{gap:9px}.settings-grid{grid-template-columns:1fr}.content-split{grid-template-columns:1fr}.phone-preview{min-height:440px}
  .inbox-layout{grid-template-columns:minmax(280px,38%) minmax(0,1fr)}
}
@media(max-width:780px){
  .sidebar{width:224px}.workspace{margin-left:0}.header{height:56px;padding-inline:16px}.content{padding:16px 14px 30px}
  .header-meta .badge{display:none}.page-actions{align-items:stretch}.card{padding:16px}
  .metrics,.metrics.six,.dashboard-kpis{display:grid;grid-template-columns:repeat(2,1fr)}.metric{border-right:1px solid var(--rtb-border);border-bottom:1px solid var(--rtb-border)}
  .metric:nth-child(2n){border-right:0}.metric:nth-last-child(-n+2){border-bottom:0}
  .wizard-steps{grid-template-columns:none;display:flex}.wizard-steps a,.wizard-steps span{flex:0 0 132px}
  .inbox-layout{grid-template-columns:1fr}.conversation-list{max-height:none}.table-wrap{max-width:100%;overflow-x:auto}
  .login-page{padding:18px}.login-card{padding:30px 23px 24px}
}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}

/* Scheduler/edit UI V1: keep status and action columns on the same table baseline. */
.task-table td.task-actions{display:table-cell;vertical-align:middle;white-space:nowrap}
.task-table td.task-actions>.task-view,.task-table td.task-actions>.task-overflow{vertical-align:middle}
.task-table td.task-actions>.task-overflow{display:inline-block;margin-left:8px}

/* Campaign owner/status filter V1. */
.task-filter-toolbar{grid-template-columns:minmax(220px,1fr) minmax(150px,190px) minmax(140px,170px) 160px 72px}
@media(max-width:1180px){.task-filter-toolbar{grid-template-columns:minmax(220px,1fr) repeat(2,minmax(140px,1fr));}.task-filter-toolbar input[type=date]{grid-column:1/3}.task-filter-toolbar .btn{grid-column:3}}
@media(max-width:760px){.task-filter-toolbar{grid-template-columns:1fr}.task-filter-toolbar input[type=date],.task-filter-toolbar .btn{grid-column:auto}}
