:root {
    color-scheme: light;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-soft: #fbfcfe;
    --text: #172033;
    --muted: #768196;
    --line: #e6ebf2;
    --primary: #2672ff;
    --primary-soft: #edf4ff;
    --navy: #08294b;
    --navy-deep: #06213d;
    --whatsapp: #18bf76;
    --whatsapp-soft: #e9fbf3;
    --sms: #7c55f5;
    --sms-soft: #f2edff;
    --blue: #3478f6;
    --cyan: #22a8c7;
    --amber: #f59f32;
    --danger: #ef5c68;
    --success: #18a96f;
    --shadow: 0 6px 22px rgba(36, 55, 88, .06);
    --shadow-lg: 0 18px 48px rgba(36, 55, 88, .10);
    --radius: 15px;
    --sidebar-width: 222px;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { direction: rtl; font-family: inherit; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
code { direction: ltr; unicode-bidi: isolate; background: #eff3f8; color: #43506a; border-radius: 6px; padding: 2px 6px; }
.app-icon { width: 22px; height: 22px; display: block; flex: 0 0 auto; }

/* Application shell - sidebar fixed on the RIGHT for Arabic */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
    grid-template-areas: "main sidebar";
    direction: ltr;
}
.sidebar {
    grid-area: sidebar;
    direction: rtl;
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, var(--navy-deep), var(--navy));
    color: #fff;
    padding: 18px 12px 16px;
    display: flex;
    flex-direction: column;
    border-inline-start: 1px solid rgba(255,255,255,.04);
    z-index: 40;
    overflow-y: auto;
}
.app-main { grid-area: main; direction: rtl; min-width: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #2b83ff, #2463f4); box-shadow: 0 10px 24px rgba(38,114,255,.34); }
.brand-mark .app-icon { width: 27px; height: 27px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 20px; line-height: 1.1; }
.brand-copy span { color: #9bb2ca; font-size: 10px; margin-top: 5px; white-space: nowrap; }
.main-nav { display: flex; flex-direction: column; gap: 7px; }
.nav-caption { color: #6f8aa5; font-size: 10px; font-weight: 700; padding: 4px 15px 1px; }
.nav-separator { height: 1px; background: rgba(255,255,255,.07); margin: 8px 8px 5px; }
.nav-item { min-height: 48px; padding: 0 14px; border-radius: 10px; display: flex; align-items: center; gap: 13px; color: #d1dce8; font-size: 13px; position: relative; transition: .18s ease; }
.nav-item .app-icon { width: 21px; height: 21px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(38,114,255,.42), rgba(38,114,255,.16)); box-shadow: inset -4px 0 0 #2f82ff; }
.nav-item.active::after { content: ""; position: absolute; inset-inline-end: 8px; width: 5px; height: 5px; border-radius: 50%; background: #55a0ff; }
.nav-static { opacity: .72; cursor: default; }
.sidebar-status-card { margin-top: auto; border: 1px solid rgba(255,255,255,.10); background: rgba(255,255,255,.055); border-radius: 13px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sidebar-status-card > span { color: #93abc2; font-size: 10px; }
.sidebar-status-card > div { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; }
.sidebar-status-card strong { font-size: 11px; }
.sidebar-status-card small { color: #80d9b4; font-size: 9px; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,255,255,.04); }
.whatsapp-dot { background: var(--whatsapp); }
.sms-dot { background: #8c70ff; }
.sidebar-logout { margin-top: 12px; }
.sidebar-logout button { width: 100%; min-height: 46px; border: 0; border-top: 1px solid rgba(255,255,255,.08); background: transparent; color: #d5dfeb; display: flex; align-items: center; gap: 12px; padding: 12px 10px 0; }
.sidebar-logout button:hover { color: #fff; }

/* Topbar */
.topbar { height: 78px; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto auto minmax(260px, 440px) 1fr; align-items: center; gap: 18px; padding: 0 28px; position: sticky; top: 0; z-index: 30; direction: rtl; }
.topbar-profile { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #dceaff, #eef4ff); color: #235ec8; font-weight: 800; border: 2px solid #fff; box-shadow: 0 4px 12px rgba(32,64,116,.12); }
.user-meta { display: flex; flex-direction: column; min-width: 100px; }
.user-meta strong { font-size: 12px; }
.user-meta span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.profile-chevron { width: 14px; height: 14px; color: #8b96a8; transform: rotate(90deg); }
.topbar-actions { display: flex; align-items: center; gap: 5px; }
.topbar-icon { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: #3a4658; display: grid; place-items: center; position: relative; }
.topbar-icon:hover { background: #f1f5fa; }
.topbar-icon .app-icon { width: 20px; height: 20px; }
.notification-button b { position: absolute; top: 2px; inset-inline-start: 1px; width: 17px; height: 17px; border-radius: 50%; background: #2c7cff; color: #fff; font-size: 9px; display: grid; place-items: center; border: 2px solid #fff; }
.global-search { height: 44px; border: 1px solid #e1e7ef; border-radius: 10px; background: #fff; display: flex; align-items: center; gap: 10px; padding: 0 14px; color: #8a95a8; }
.global-search .app-icon { width: 19px; height: 19px; }
.global-search input { border: 0; outline: 0; background: transparent; flex: 1; color: var(--text); min-width: 0; }
.global-search input::placeholder { color: #aab2bf; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 10px; }
.page-content { max-width: 1600px; margin: 0 auto; padding: 24px 28px 40px; }
.sidebar-backdrop { display: none; }

/* Page heading and toolbar */
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; color: #8b95a7; font-size: 10px; margin-bottom: 7px; }
.breadcrumbs .app-icon { width: 12px; height: 12px; transform: rotate(180deg); }
.breadcrumbs strong { color: #4c5a70; font-weight: 600; }
.page-heading h1 { margin: 0; font-size: 29px; letter-spacing: -.04em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.live-badge, .channel-badge { min-height: 37px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; color: #546075; font-size: 11px; box-shadow: var(--shadow); }
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(24,169,111,.12); }
.channel-badge .app-icon { width: 18px; height: 18px; }
.whatsapp-channel { color: #087e50; background: #f3fcf7; border-color: #d5f4e5; }
.sms-channel { color: #6248d5; background: #f8f5ff; border-color: #e7e0ff; }
.compact-toolbar { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); min-height: 68px; padding: 10px 12px; display: flex; align-items: flex-end; gap: 9px; margin-bottom: 18px; }
.toolbar-control { min-height: 42px; border: 1px solid #dfe5ed; border-radius: 9px; display: flex; align-items: center; gap: 9px; padding: 0 12px; color: #526074; font-size: 11px; background: #fff; }
.toolbar-control .app-icon { width: 17px; height: 17px; }
.toolbar-icon-button { width: 42px; height: 42px; border: 1px solid #dfe5ed; border-radius: 9px; background: #fff; color: #667389; display: grid; place-items: center; flex: 0 0 auto; }
.toolbar-icon-button:hover { background: #f5f8fc; color: var(--primary); }
.toolbar-icon-button .app-icon { width: 18px; height: 18px; }
.dashboard-filter-toolbar { flex-wrap: wrap; }
.toolbar-select { min-width: 145px; display: flex; flex-direction: column; gap: 4px; }
.toolbar-select > span { color: #8b95a7; font-size: 9px; padding-inline: 3px; }
.toolbar-select select, .toolbar-select input { height: 40px; border: 1px solid #dfe5ed; border-radius: 9px; background: #fff; color: #334155; padding: 0 10px; outline: none; min-width: 0; width: 100%; }
.toolbar-select select:focus, .toolbar-select input:focus { border-color: #8eb3ff; box-shadow: 0 0 0 3px rgba(38,114,255,.08); }
.wide-control { min-width: 128px; }
.grow-control { flex: 1; min-width: 210px; }
.apply-filter { height: 40px; border: 0; border-radius: 9px; color: #fff; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; font-size: 11px; box-shadow: 0 6px 16px rgba(38,114,255,.16); }
.apply-filter .app-icon { width: 16px; height: 16px; }
.whatsapp-apply { background: var(--whatsapp); }
.sms-apply { background: var(--sms); }

/* KPI cards */
.metrics-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.metrics-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric-card { min-width: 0; min-height: 145px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 15px 15px 13px; position: relative; overflow: hidden; }
.metric-card-head { display: flex; align-items: center; gap: 9px; }
.metric-icon { width: 37px; height: 37px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, currentColor 11%, white); flex: 0 0 auto; }
.metric-icon .app-icon { width: 19px; height: 19px; }
.metric-label { color: #556175; font-size: 11px; line-height: 1.45; }
.metric-value { display: block; margin-top: 15px; color: #142035; font-size: clamp(20px, 2vw, 27px); letter-spacing: -.04em; direction: ltr; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-footer { margin-top: 8px; display: flex; align-items: center; gap: 5px; min-height: 17px; }
.metric-trend { color: currentColor; font-weight: 700; font-size: 10px; direction: ltr; }
.metric-subtitle { color: #8b95a7; font-size: 9px; }
.metric-spark { position: absolute; inset-inline-start: 14px; bottom: 11px; width: 74px; height: 24px; display: flex; align-items: flex-end; gap: 3px; opacity: .18; transform: skewX(-12deg); }
.metric-spark i { width: 8px; border-radius: 5px 5px 0 0; background: currentColor; }
.metric-spark i:nth-child(1){height:35%}.metric-spark i:nth-child(2){height:55%}.metric-spark i:nth-child(3){height:42%}.metric-spark i:nth-child(4){height:75%}.metric-spark i:nth-child(5){height:58%}.metric-spark i:nth-child(6){height:88%}
.tone-blue { color: #3478f6; }
.tone-green { color: #18bf76; }
.tone-violet { color: #8557ef; }
.tone-cyan { color: #1ca7c5; }
.tone-emerald { color: #18a96f; }
.tone-amber { color: #f39a2d; }

/* Dashboard overview */
.home-toolbar { width: fit-content; }
.overview-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.mini-kpi { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 15px; min-height: 120px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto auto; gap: 2px 11px; }
.mini-kpi > div { grid-row: 1 / 4; width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, currentColor 11%, white); display: grid; place-items: center; }
.mini-kpi > div .app-icon { width: 20px; height: 20px; }
.mini-kpi span { color: #6e7a8f; font-size: 10px; }
.mini-kpi strong { color: #172033; font-size: 19px; margin-top: 3px; }
.mini-kpi small { color: #939dac; font-size: 9px; margin-top: 4px; }
.system-overview-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.system-overview-card { min-height: 270px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; display: grid; grid-template-columns: 62px 1fr; grid-template-rows: 1fr auto; gap: 20px; position: relative; overflow: hidden; transition: .2s ease; }
.system-overview-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.system-overview-card::after { content:""; position:absolute; width:180px; height:180px; border-radius:50%; inset-inline-start:-80px; top:-85px; opacity:.07; background:currentColor; }
.system-overview-icon { width: 60px; height: 60px; border-radius: 18px; background: color-mix(in srgb, currentColor 12%, white); display: grid; place-items: center; }
.system-overview-icon .app-icon { width: 30px; height: 30px; }
.system-overview-copy span { font-size: 10px; font-weight: 700; color: currentColor; }
.system-overview-copy h2 { color: #172033; margin: 7px 0 9px; font-size: 22px; }
.system-overview-copy p { color: var(--muted); font-size: 11px; line-height: 1.8; margin: 0; }
.system-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 15px; }
.system-tags b { color: #657287; background: #f5f7fa; border: 1px solid #ebeff4; padding: 5px 8px; border-radius: 7px; font-size: 8px; }
.system-overview-action { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; display: flex; justify-content: space-between; align-items: center; color: currentColor; font-weight: 700; font-size: 11px; }
.system-overview-action .app-icon { width: 15px; height: 15px; transform: rotate(180deg); }
.whatsapp-overview { color: var(--whatsapp); }
.sms-overview { color: var(--sms); }
.dashboard-note { margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 15px 17px; display: flex; gap: 12px; align-items: flex-start; }
.dashboard-note > .app-icon { width: 20px; height: 20px; color: var(--primary); }
.dashboard-note strong { font-size: 11px; }
.dashboard-note p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }

/* Panels and analytics */
.analytics-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(310px,.75fr); gap: 15px; margin-bottom: 15px; }
.sms-analytics-grid { grid-template-columns: minmax(360px,.85fr) minmax(0,1.25fr); }
.dashboard-panel { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.panel-heading > .app-icon { color: #8a95a7; width: 17px; height: 17px; }
.chart-legend { display: flex; align-items: center; gap: 12px; color: #6c788c; font-size: 10px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i, .donut-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-whatsapp { background: var(--whatsapp); }
.legend-blue { background: #3478f6; }
.legend-violet { background: var(--sms); }
.legend-muted { background: #d9dfe8; }
.legend-danger { background: var(--danger); }
.line-chart-shell { width: 100%; overflow: hidden; }
.line-chart { width: 100%; height: 275px; color: var(--whatsapp); }
.chart-grid-line { stroke: #edf0f5; stroke-width: 1; stroke-dasharray: 4 5; }
.chart-area { fill: url(#areaFill); color: var(--whatsapp); }
.chart-line { fill: none; stroke: var(--whatsapp); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: #fff; stroke: var(--whatsapp); stroke-width: 3; }
.chart-axis-html-label { width: 100%; height: 100%; display: flex; align-items: center; color: #8d97a8; font-size: 10px; line-height: 1; white-space: nowrap; direction: ltr; }
.chart-axis-y { justify-content: flex-end; padding-inline-end: 4px; }
.chart-axis-x { justify-content: center; text-align: center; }
.chart-empty { height: 260px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.donut-content { min-height: 270px; display: grid; grid-template-columns: 175px 1fr; align-items: center; gap: 22px; }
.donut-chart { --donut-value: 0; width: 168px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(currentColor calc(var(--donut-value) * 1%), #e8edf4 0); }
.donut-chart::after { content:""; width: 100px; height: 100px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px #edf1f5; }
.donut-chart > div { position: absolute; z-index: 1; display: flex; flex-direction: column; align-items: center; }
.donut-chart strong { font-size: 22px; color: #172033; direction: ltr; }
.donut-chart span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.whatsapp-donut { color: var(--whatsapp); }
.sms-donut { color: var(--sms); }
.donut-legend { display: flex; flex-direction: column; gap: 15px; }
.donut-legend > div { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; color: #667287; font-size: 10px; }
.donut-legend strong { color: #273247; direction: ltr; }
.results-pill { min-height: 28px; border-radius: 8px; background: #f4f6f9; color: #68758a; display: inline-flex; align-items: center; padding: 0 9px; font-size: 9px; white-space: nowrap; }
.ranking-strip-panel { margin-bottom: 15px; }
.agent-cards-row { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; }
.agent-rank-card { min-width: 0; background: #fbfcfe; border: 1px solid #edf0f5; border-radius: 11px; padding: 11px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; }
.rank-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e9fbf3; color: #0c8a58; font-weight: 800; }
.agent-rank-card > div { min-width: 0; display: flex; flex-direction: column; }
.agent-rank-card strong { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-rank-card small { color: var(--muted); font-size: 8px; margin-top: 3px; }
.agent-rank-card b { direction: ltr; font-size: 11px; }
.agent-rank-card .progress-track { grid-column: 2 / -1; }
.compact-ranking-list { display: flex; flex-direction: column; gap: 10px; }
.compact-ranking-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 7px 0 11px; border-bottom: 1px solid #eef1f5; }
.compact-ranking-row:last-child { border-bottom: 0; }
.sms-rank-avatar { background: #f1ecff; color: #684bd8; }
.ranking-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ranking-copy strong { font-size: 10px; }
.ranking-copy small { color: var(--muted); font-size: 8px; }
.ranking-value { display: flex; flex-direction: column; align-items: flex-end; }
.ranking-value strong { font-size: 11px; direction: ltr; }
.ranking-value small { color: var(--muted); font-size: 8px; margin-top: 4px; direction: ltr; }
.progress-track { width: 100%; height: 5px; border-radius: 99px; background: #edf1f5; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--primary); }
.progress-whatsapp { background: var(--whatsapp); }
.progress-sms { background: var(--sms); }
.progress-warning { background: var(--amber); }
.progress-danger { background: var(--danger); }
.alert-summary-panel { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 15px; padding: 13px; }
.alert-summary-card { min-height: 90px; border: 1px solid #edf0f5; border-radius: 11px; padding: 13px; display: flex; align-items: center; gap: 12px; }
.alert-summary-card > .app-icon { width: 24px; height: 24px; }
.alert-summary-card div { display: flex; flex-direction: column; }
.alert-summary-card span { color: #657186; font-size: 9px; }
.alert-summary-card strong { color: #172033; font-size: 21px; margin-top: 3px; direction: ltr; }
.alert-summary-card small { color: #98a1b0; font-size: 8px; margin-top: 3px; }
.danger-summary { color: var(--danger); background: #fffafb; }
.warning-summary { color: var(--amber); background: #fffdf8; }
.muted-summary { color: #8190a6; background: #fbfcfe; }
.status-pill { min-height: 24px; padding: 0 9px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 8px; white-space: nowrap; }
.status-success { background: #e8f9f1; color: #0c8958; }
.status-warning { background: #fff4df; color: #ac6908; }
.status-danger { background: #ffebee; color: #b53c4c; }
.status-neutral { background: #eef2f7; color: #536176; }
.status-muted { background: #f2f4f7; color: #8c96a6; }

/* Data table */
.data-panel { padding: 0; overflow: hidden; }
.data-panel .panel-heading { padding: 16px 18px 13px; margin: 0; border-bottom: 1px solid var(--line); }
.table-heading { align-items: center; }
.table-actions { display: flex; align-items: center; gap: 9px; }
.inline-search { width: 260px; height: 36px; border: 1px solid #dfe5ed; border-radius: 9px; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.inline-search .app-icon { width: 16px; height: 16px; color: #8d97a8; }
.inline-search input { border: 0; outline: 0; flex: 1; min-width: 0; background: transparent; font-size: 10px; }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.data-table th { background: #fbfcfe; color: #68758a; font-size: 9px; font-weight: 700; text-align: right; padding: 11px 15px; border-bottom: 1px solid #e8ecf2; white-space: nowrap; }
.data-table td { color: #435066; font-size: 9px; padding: 10px 15px; border-bottom: 1px solid #edf0f4; white-space: nowrap; }
.data-table tbody tr:hover { background: #fbfdff; }
.identity-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.table-avatar { width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.whatsapp-avatar { background: #e7f9f0; color: #0a8a57; }
.sms-avatar { background: #f0ebff; color: #6748d7; }
.identity-cell > div { display: flex; flex-direction: column; }
.identity-cell strong { color: #273247; font-size: 9px; }
.identity-cell small { color: #97a0ae; font-size: 8px; margin-top: 2px; }
.ltr-cell { direction: ltr; text-align: right; font-family: Consolas, monospace; }
.table-progress-cell { display: grid; grid-template-columns: 72px 38px; align-items: center; gap: 6px; }
.table-progress-cell span { color: #788397; font-size: 8px; direction: ltr; }

/* Loading and errors */
.loading-panel { min-height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; gap: 13px; }
.loading-panel > div:last-child { display: flex; flex-direction: column; gap: 4px; }
.loading-panel strong { font-size: 12px; }
.loading-panel span { color: var(--muted); font-size: 10px; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #e7ebf1; border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 12px; margin-bottom: 16px; }
.alert-danger { background: #fff2f4; border: 1px solid #ffd8dd; color: #973346; }
.alert.compact { padding: 12px; }
.alert-icon { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; background: currentColor; color: #fff; font-weight: 800; }
.alert strong { font-size: 11px; }
.alert p { margin: 4px 0 0; font-size: 9px; line-height: 1.6; }
.empty-page { min-height: 65vh; display: grid; place-items: center; text-align: center; }

/* Login kept compatible and refreshed */
.login-layout { min-height: 100vh; background: #f5f8fc; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px,.85fr) minmax(520px,1.15fr); direction: ltr; }
.login-visual { direction: rtl; background: linear-gradient(145deg, #061f3a, #0a345d); color: #fff; padding: 42px 52px; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.visual-glow { position: absolute; border-radius: 50%; opacity: .45; }
.visual-glow-one { width: 430px; height: 430px; background: radial-gradient(circle, rgba(38,114,255,.52), transparent 68%); top: -180px; inset-inline-end: -120px; }
.visual-glow-two { width: 410px; height: 410px; background: radial-gradient(circle, rgba(24,191,118,.28), transparent 70%); bottom: -190px; inset-inline-start: -130px; }
.login-brand { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.brand-mark.large { width: 54px; height: 54px; font-size: 17px; }
.login-brand > div:last-child { display: flex; flex-direction: column; }
.login-brand strong { font-size: 18px; }
.login-brand span { color: #a9bfd3; font-size: 10px; margin-top: 4px; }
.visual-content { margin: auto 0; max-width: 620px; position: relative; z-index: 1; }
.eyebrow { color: var(--primary); font-weight: 700; font-size: 10px; }
.eyebrow.light { color: #89b8ff; }
.visual-content h1 { font-size: clamp(36px,4vw,56px); line-height: 1.25; letter-spacing: -.045em; margin: 13px 0 17px; }
.visual-content > p { color: #b5c5d5; line-height: 1.9; font-size: 14px; }
.visual-features { display: flex; flex-direction: column; gap: 11px; margin-top: 28px; color: #d8e2ec; font-size: 11px; }
.visual-features span { color: #45d99b; margin-left: 7px; }
.visual-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; position: relative; z-index: 1; }
.visual-stats > div { border-top: 1px solid rgba(255,255,255,.13); padding-top: 13px; display: flex; flex-direction: column; }
.visual-stats strong { font-size: 19px; }
.visual-stats span { color: #91a8bd; font-size: 9px; margin-top: 4px; }
.login-form-panel { direction: rtl; display: grid; place-items: center; padding: 40px; }
.login-form-card { width: min(410px,100%); }
.login-form-heading { margin-bottom: 23px; }
.login-form-heading h2 { margin: 7px 0; font-size: 30px; }
.login-form-heading p { color: var(--muted); font-size: 10px; line-height: 1.7; }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field > span { color: #4e5b70; font-size: 10px; font-weight: 700; }
.input-with-icon { position: relative; }
.input-with-icon input { width: 100%; height: 44px; border: 1px solid #dce3ec; border-radius: 9px; padding: 0 40px 0 12px; outline: 0; }
.input-icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: #98a2b2; }
.checkbox-field { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.btn { min-height: 42px; border: 0; border-radius: 9px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.login-security-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 20px; padding: 11px; background: #f1f4f8; border-radius: 9px; }
.login-security-note p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.6; }

/* Responsive RTL behavior */
@media (max-width: 1320px) {
    .metrics-grid-6 { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .agent-cards-row { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .overview-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 1040px) {
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .sidebar { position: fixed; inset: 0 0 0 auto; width: var(--sidebar-width); transform: translateX(105%); transition: transform .22s ease; }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(7,24,43,.48); }
    .topbar { grid-template-columns: auto auto 1fr auto; padding: 0 18px; }
    .menu-button { display: block; }
    .analytics-grid, .sms-analytics-grid { grid-template-columns: 1fr; }
    .system-overview-grid { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .login-form-panel { min-height: 100vh; }
}
@media (max-width: 760px) {
    .topbar { grid-template-columns: auto 1fr auto; gap: 10px; height: 68px; }
    .topbar-actions { display: none; }
    .global-search { grid-column: 2; height: 40px; }
    .user-meta, .profile-chevron { display: none; }
    .page-content { padding: 18px 15px 30px; }
    .page-heading { align-items: flex-start; }
    .metrics-grid-6 { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .metric-card { min-height: 135px; }
    .donut-content { grid-template-columns: 1fr; justify-items: center; }
    .donut-legend { width: 100%; }
    .agent-cards-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .alert-summary-panel { grid-template-columns: 1fr; }
    .table-heading { align-items: flex-start; flex-direction: column; }
    .table-actions { width: 100%; }
    .inline-search { flex: 1; width: auto; }
    .overview-kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .global-search input::placeholder { color: transparent; }
    .page-heading { flex-direction: column; }
    .heading-actions { width: 100%; }
    .channel-badge, .live-badge { width: 100%; justify-content: center; }
    .compact-toolbar { align-items: stretch; }
    .toolbar-select, .grow-control { min-width: calc(50% - 5px); flex: 1; }
    .apply-filter { flex: 1; }
    .metrics-grid-6, .overview-kpis, .agent-cards-row { grid-template-columns: 1fr; }
    .system-overview-card { grid-template-columns: 52px 1fr; padding: 19px; }
    .system-overview-icon { width: 50px; height: 50px; }
    .login-form-panel { padding: 23px; }
}
