:root {
  color-scheme: light;
  --bg: #edf3fb; --surface: #fff; --soft: #f4f8fe; --thead: #e6eefb;
  --ink: #101c3d; --muted: #4b5b73; --line: #cddbef;
  --head-a: #0d3897; --head-b: #064cc5; --head-ink: #fff;
  --action: #122b58; --action-ink: #fff; --accent: #0954d9; --accent-ink: #fff;
  --blue: #0b48b7; --blue-bg: #e2efff; --green: #086237; --green-bg: #ddf6e8;
  --red: #a80e28; --red-bg: #ffe7eb; --amber: #885308; --amber-bg: #fff2d2;
  --purple: #57229b; --purple-bg: #eee7ff; --gray: #445166; --gray-bg: #e9eef5;
  --shadow: 0 2px 4px #123c7d13; --float: 0 10px 32px #071a3b25;
  font-family: Inter, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg); color: var(--ink);
}
:root[lang=ar] { font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #101010; --surface: #1a1a1a; --soft: #222; --thead: #282828;
  --ink: #f6f6f6; --muted: #bbb; --line: #383838;
  --head-a: #171717; --head-b: #1e1e1e; --head-ink: #fff;
  --action: #303030; --action-ink: #fff; --accent: #e9e9e9; --accent-ink: #171717;
  --blue: #e5e5e5; --blue-bg: #303030; --green: #83e5a7; --green-bg: #292929;
  --red: #ffa4ae; --red-bg: #292929; --amber: #ffdc94; --amber-bg: #292929;
  --purple: #dcc5ff; --purple-bg: #292929; --gray: #dadada; --gray-bg: #262626;
  --shadow: 0 2px 4px #0004; --float: 0 10px 32px #0008;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button, a.btn, summary { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:disabled { cursor: wait; opacity: .66; }
:focus-visible { outline: 2px solid #538cf1; outline-offset: 3px; }
[hidden] { display: none !important; }
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: middle; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: linear-gradient(100deg,var(--head-a),var(--head-b)); color: var(--head-ink); border-bottom: 1px solid #ffffff22; padding: 12px clamp(12px,2vw,32px); }
.brandline, .header-actions, .live-controls, .row-actions, .toolbar, .statusbar, .inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 7px; font-size: clamp(18px,2.25vw,31px); font-weight: 750; white-space: nowrap; }
.brand .icon { width: 1.28em; height: 1.28em; }
.header-title { font-weight: 720; font-size: clamp(15px,1.65vw,22px); border-inline-start: 1px solid #ffffff60; padding-inline-start: 12px; }
.preview-label { font-size: 12px; padding: 4px 8px; border: 1px solid #ffffff60; border-radius: 7px; white-space: nowrap; }
.header-actions { gap: 7px; }
.header-actions .btn, .header-actions summary { background: #ffffff16; border-color: #ffffff38; color: #fff; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-weight: 680; white-space: nowrap; text-align: center; }
.btn:hover, summary:hover { filter: brightness(.96); }
[data-theme=dark] .btn:hover, [data-theme=dark] summary:hover { filter: brightness(1.13); }
.btn.primary { background: var(--action); color: var(--action-ink); border-color: transparent; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.tiny { padding: 4px 8px; min-height: 30px; font-size: 13px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.btn.good { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.btn.on { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.indicator { position: relative; }
.unread { position: absolute; inset-block-start: -4px; inset-inline-end: -4px; border-radius: 99px; min-width: 16px; padding: 0 3px; font-size: 10px; line-height: 16px; background: #d22241; color: #fff; }
.popup { position: relative; }
.popup summary { list-style: none; }
.popup summary::-webkit-details-marker { display: none; }
.popup-panel { position: absolute; z-index: 5; inset-inline-end: 0; top: calc(100% + 10px); min-width: min(310px,88vw); max-height: min(60vh,450px); overflow: auto; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px; box-shadow: var(--float); }
.nav-panel { min-width: min(320px,88vw); display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nav-panel a { display: block; padding: 8px; border-radius: 6px; font-size: 13px; }
.nav-panel a:hover, .nav-panel [aria-current=page] { background: var(--thead); }
.notice { border-block-start: 1px solid var(--line); padding: 9px 2px; display: grid; gap: 4px; font-size: 14px; }
.notice:first-child { border: 0; }
.notice time { font-size: 12px; color: var(--muted); }
.notice-head { justify-content: space-between; }
.live-controls { width: 100%; padding-block-start: 10px; border-block-start: 1px solid #ffffff30; }
.live-controls .btn:not(.on):not(.accent) { background: var(--surface); color: var(--ink); }
.live-controls .rule-sep { width: 1px; height: 28px; background: #ffffff60; margin-inline: 3px; }
#page { max-width: 1820px; margin: 0 auto; padding: clamp(12px,1.5vw,24px); }
h1, h2, h3, p { margin: 0; }
h1 { display: flex; align-items: center; gap: 12px; font-size: clamp(24px,3vw,44px); line-height: 1.15; margin: 0 0 20px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p + p { margin-top: 10px; }
.muted { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; }
.blue { --tone: var(--blue); --tone-bg: var(--blue-bg); }
.green { --tone: var(--green); --tone-bg: var(--green-bg); }
.red { --tone: var(--red); --tone-bg: var(--red-bg); }
.amber { --tone: var(--amber); --tone-bg: var(--amber-bg); }
.purple { --tone: var(--purple); --tone-bg: var(--purple-bg); }
.gray { --tone: var(--gray); --tone-bg: var(--gray-bg); }
.kpi { display: flex; align-items: center; gap: 12px; background: var(--tone-bg); color: var(--tone); border: 1px solid var(--line); border-radius: 13px; min-height: 103px; padding: 12px; }
.kpi b { display: block; font-size: clamp(24px,2.7vw,41px); font-variant-numeric: tabular-nums; }
.kpi small { font-size: clamp(12px,1.25vw,17px); font-weight: 700; }
.kpi .tile-icon, .shortcut .tile-icon { display: grid; place-items: center; background: color-mix(in srgb,var(--tone-bg) 83%,var(--tone) 17%); color: var(--tone); width: 48px; height: 48px; border-radius: 12px; font-size: 25px; flex: 0 0 auto; }
[data-theme=dark] .kpi { background: var(--surface); }
[data-theme=dark] .tile-icon { background: #303030; }
.statusbar { margin: 20px 0 24px; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); box-shadow: var(--shadow); }
.statusbar strong { font-size: 17px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 7px; color: var(--tone,var(--ink)); background: var(--tone-bg,var(--soft)); padding: 4px 8px; font-size: 13px; font-weight: 700; }
.statusbar .pill { border-radius: 99px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.shortcuts { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.shortcut { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; min-height: 106px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.shortcut.feature { color: #fff; border-color: transparent; background: linear-gradient(135deg,#0967ed,#063ab4); }
.shortcut.feature .tile-icon { background: #ffffff23; color: #fff; }
[data-theme=dark] .shortcut.feature { color: #fff; background: #2d2d2d; border-color: #777; }
.shortcut h2 { font-size: clamp(14px,1.55vw,21px); line-height: 1.28; }
.shortcut p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.shortcut.feature p { color: #f0f5ff; }
.shortcut:hover { border-color: #5988c7; }
:root[dir=rtl] .directional { transform: scaleX(-1); }
.toolbar { padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; align-items: flex-end; margin-bottom: 13px; }
.field { display: grid; gap: 4px; color: var(--ink); font-size: 13px; font-weight: 700; min-width: 115px; }
.field.grow { flex: 1; min-width: min(220px,100%); }
input, select { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-height: 36px; width: 100%; }
input[type=checkbox] { width: 16px; min-height: 16px; }
.rollup { display: grid; grid-template-columns: repeat(4,1fr); background: var(--thead); border-radius: 12px; padding: 12px 6px; margin-bottom: 16px; }
.rollup-item { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; padding: 3px 10px; }
.rollup-item + .rollup-item { border-inline-start: 1px solid var(--line); }
.rollup-item b { display: block; font-size: 25px; color: var(--tone); }
.rollup-item .icon { color: var(--tone); font-size: 22px; }
.table-frame { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); background: var(--surface); }
.table-scroll { overflow: auto; border-radius: inherit; }
table { width: 100%; border-collapse: collapse; text-align: start; }
th, td { padding: 11px 13px; text-align: start; }
th { background: var(--thead); font-weight: 760; white-space: nowrap; }
.blocked-table th { background: var(--head-a); color: #fff; }
[data-theme=dark] .blocked-table th { background: var(--thead); }
td { border-top: 1px solid var(--line); }
td b { display: inline-block; }
.knowledge-table th, .knowledge-table td { border-inline-end: 1px solid var(--line); }
.knowledge-table th:last-child, .knowledge-table td:last-child { border-inline-end: 0; }
.phone { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: center; gap: 8px; }
.phone b { font-size: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.phone small { display: block; color: var(--muted); white-space: nowrap; }
.phone .btn { width: 30px; min-height: 29px; }
.carrier { display: grid; gap: 3px; }
.live-table { min-width: 900px; }
.live-table td { vertical-align: top; padding: 10px 12px; }
.live-table td:first-child { width: 27%; border-inline-start: 4px solid var(--tone,var(--blue)); }
.live-table td:nth-child(2) { width: 43%; }
.live-table td:nth-child(3) { width: 13%; }
.live-table td:last-child { width: 17%; }
.live-table .phone b { font-size: clamp(17px,1.7vw,22px); }
.live-summary { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 9px 12px; background: var(--soft); border-radius: 12px 12px 0 0; border-bottom: 1px solid var(--line); }
.live-summary .mini { font-size: 13px; }
.live-summary b { color: var(--tone); font-size: 18px; margin-inline-start: 4px; }
.live-summary .push { margin-inline-start: auto; }
.call-title { color: var(--tone,var(--blue)); font-size: 17px; font-weight: 770; display: flex; align-items: center; gap: 8px; }
.timeline { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.timeline span { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.timeline span + span { border-inline-start: 1px solid var(--line); padding-inline-start: 10px; }
.timeline .icon { color: var(--green); }
.timeline .is-failed .icon { color: var(--red); }
.call-actions { margin-top: 7px; gap: 5px; }
.call-actions .btn { font-size: 12px; }
.call-note { font-size: 13px; }
.digit { display: inline-grid; place-items: center; min-width: 34px; height: 34px; border-radius: 7px; background: var(--action); color: var(--action-ink); font-weight: 740; font-size: 19px; }
.duration { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.card { padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.card h2 { margin-bottom: 10px; }
.card p { color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.card-grid + .card, .card + .card, .card + .table-frame { margin-top: 13px; }
.card .btn { margin-block-start: 10px; }
.settings-list { display: grid; gap: 9px; }
.setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-block-start: 1px solid var(--line); }
.setting:first-child { border: 0; }
.setting .btn { margin: 0; }
.empty { padding: 22px; color: var(--muted); text-align: center; }
.toasts { position: fixed; z-index: 12; top: 12px; left: 50%; transform: translateX(-50%); width: min(475px,calc(100% - 22px)); display: grid; gap: 6px; pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 9px 11px; color: #fff; background: #12623a; border: 1px solid #ffffff44; border-radius: 9px; font-weight: 730; box-shadow: var(--float); }
.toast.red { background: #a0182f; }
.toast.blue { background: #174888; }
.toast .btn { border: 0; color: #fff; background: transparent; min-height: 28px; width: 28px; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-inline-start-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { max-width: min(94vw,640px); width: 100%; max-height: 84vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--surface); padding: 18px; box-shadow: var(--float); }
dialog::backdrop { background: #0008; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 13px; }
.dialog-body { display: grid; gap: 10px; }
.details-list { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 7px 14px; margin: 0; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .kpi { gap: 7px; }
  .kpi .tile-icon, .shortcut .tile-icon { width: 38px; height: 38px; font-size: 19px; }
  .shortcut { padding: 12px; gap: 8px; }
}
@media (max-width: 800px) {
  .kpis, .shortcuts { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .kpi { min-height: 85px; }
}
@media (max-width: 560px) {
  .bar { gap: 8px; }
  .brandline, .header-actions { gap: 6px; }
  .header-title { padding-inline-start: 6px; }
  .preview-label { font-size: 11px; }
  .kpis, .shortcuts, .rollup, .card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kpis, .shortcuts { gap: 8px; }
  .shortcut { min-height: 96px; grid-template-columns: auto minmax(0,1fr); }
  .shortcut > .directional { display: none; }
  .shortcut .tile-icon { width: 29px; height: 29px; border-radius: 6px; font-size: 16px; }
  .shortcut p { font-size: 11px; }
  .statusbar { justify-content: flex-start; }
  .rollup-item:nth-child(3) { border-inline-start: 0; }
  .rollup-item { font-size: 13px; }
  .rollup-item b { font-size: 21px; }
  .field { flex: 1 1 115px; }
  .live-controls .rule-sep { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media print { #header, .toolbar, .row-actions, .toasts, .btn { display: none !important; } #page { padding: 0; } .table-scroll { overflow: visible; } .live-table { min-width: 0; } }

textarea { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; resize: vertical; font: inherit; }
.card-heading, .control-pair, .section-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card-heading { margin-block-end: 10px; }
.card-heading h2 { margin: 0; }
.card-heading .btn, .control-pair .btn { margin: 0; }
.control-pair .field { flex: 1; }
.help-button { min-inline-size: 30px; color: var(--ink); border-radius: 50%; }
.mode-card { border-inline-start: 4px solid var(--tone); background: color-mix(in srgb, var(--surface) 67%, var(--tone-bg)); }
.mode-card h2 { color: var(--tone); }
.mode-card p { max-width: 65ch; }
.directory-grid, .feature-settings { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
.directory-section { min-width: 0; }
.directory-section .card-heading > .danger { margin-inline-start: auto; }
.feature-settings > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.feature-settings .card { margin: 0; }
.feature-settings .card p { margin-block-end: 10px; }
.feature-settings .card .btn:not(.help-button) { margin-block-start: 10px; }
.feature-settings .setting .btn { margin: 0; }
.pagination { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 13px; border-block-start: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.reason-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.call-note .reason-text { margin-block: 4px 6px; }
.section-actions { margin-block-end: 12px; }
.live-connection { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; margin-inline-start: auto; }
.live-connection[data-status=online] .dot { color: #93e7ab; }
.live-connection[data-status=offline] .dot, .live-connection[data-status=connecting] .dot { color: #ffce78; }
.recording-links { padding: 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.recording-links p { margin-block: 8px; }
.recording-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.inline-help { padding: 8px 10px; border-inline-start: 3px solid var(--accent); background: var(--soft); }
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-page main, main.auth-page > section { width: min(100%, 450px); }
.auth-page form { display: grid; gap: 12px; }
@media (max-width: 860px) {
  .directory-grid, .feature-settings { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 420px) {
  .recording-grid { grid-template-columns: minmax(0,1fr); }
}
@media print { .pagination { display: none; } }
