@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=Source+Serif+4:wght@600&display=swap");

:root {
  font-family: "Manrope", sans-serif;
  color: #10243a;
  background: #f5f8fb;
  font-synthesis: none;
  --navy: #062746;
  --navy-2: #0b365d;
  --blue: #147ad6;
  --teal: #078c9b;
  --line: #d8e2ea;
  --muted: #66788c;
  --green: #169b67;
  --red: #db4b4b;
  --app-bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --surface-subtle: #fbfdff;
  --surface-selected: #edf6ff;
  --text: #10243a;
  --text-soft: #17324f;
  --row-line: #e5edf3;
  --input-border: #cbd8e3;
  --icon-border: #bdd0df;
  --progress-bg: #e9f0f3;
  --chart-grid: #dbe4ec;
  --message-bot: #eaf5ff;
  --message-bot-border: #b8d8f3;
  --modal-shadow: rgba(0,0,0,.28);
}

:root[data-theme="dark"] {
  color: #e7eef6;
  background: #0b1118;
  --blue: #53a7f2;
  --teal: #29b8c5;
  --line: #293746;
  --muted: #94a5b7;
  --green: #43c98d;
  --red: #ff7373;
  --app-bg: #0b1118;
  --surface: #121b25;
  --surface-soft: #0f1822;
  --surface-subtle: #0d151e;
  --surface-selected: #152b3d;
  --text: #e7eef6;
  --text-soft: #d8e5f1;
  --row-line: #24313e;
  --input-border: #344556;
  --icon-border: #3b5368;
  --progress-bg: #253440;
  --chart-grid: #2a3947;
  --message-bot: #123047;
  --message-bot-border: #285b7d;
  --modal-shadow: rgba(0,0,0,.58);
}

:root[data-theme="dark"] th { color: #aebdcb; }

:root[data-theme="dark"] .avatar { background: #253747; color: #d9e8f4; }

:root[data-theme="dark"] .avatar.teal { background: #123c42; color: #6fe0e9; }

:root[data-theme="dark"] .status { background: #143b2d; color: #72d8a6; }

:root[data-theme="dark"] .status.closed,
:root[data-theme="dark"] .status.disabled { background: #29333e; color: #aebac6; }

:root[data-theme="dark"] .status.invited { background: #183752; color: #82bff1; }

:root[data-theme="dark"] .form-error { color: #ff9d9d; background: #351b20; border-color: #633039; }

:root[data-theme="dark"] .danger-icon { color: #ff7777; background: #351b20; border-color: #633039; }

:root[data-theme="dark"] .conversation-item small { color: #72b7ef; }

:root[data-theme="dark"] .button.secondary:hover { background: #172532; }

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--app-bg); color: var(--text); transition: background-color .2s ease, color .2s ease; }

button, input, select, textarea { font: inherit; }

button { cursor: pointer; }

h1, h2, h3, p { margin-top: 0; }

h1 { font-family: "Source Serif 4", serif; font-size: 38px; margin-bottom: 0; letter-spacing: -0.025em; }

h2 { font-size: 18px; }

a { color: inherit; text-decoration: none; }

.eyebrow { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .15em; margin-bottom: 8px; }

.muted { color: var(--muted); }

.button { border-radius: 7px; padding: 11px 17px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; background: var(--surface); color: var(--text-soft); }

.button.primary { border-color: var(--teal); background: linear-gradient(135deg, #087c94, #0695a6); color: white; }

.button.danger { border-color: #c83e3e; background: #c83e3e; color: white; }

.button.secondary:hover { border-color: var(--blue); color: var(--blue); }

.button:disabled { opacity: .55; cursor: default; }

.button.wide { width: 100%; }

.refresh-button { width: 190px; transition: color .2s ease, border-color .2s ease, background-color .2s ease; }

.refresh-button.loading svg { animation: refresh-spin .75s linear infinite; }

.refresh-button.success { color: var(--green); border-color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--surface)); }

.refresh-button.error { color: var(--red); border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }

@keyframes refresh-spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; background: var(--surface); }

.login-brand { background: #000; color: white; padding: 64px 11vw 64px 7vw; display: flex; flex-direction: column; justify-content: space-between; }

.aktobe-logo { display: block; width: min(330px, 68%); height: auto; object-fit: contain; }

.login-brand h1 { font-size: clamp(46px, 5vw, 72px); max-width: 720px; line-height: 1.02; }

.login-brand-copy .eyebrow { margin: 0 0 24px; }

.login-brand .login-title { font-size: clamp(38px, 4vw, 58px); max-width: none; white-space: nowrap; margin: 0 0 28px; line-height: 1.08; }

.login-brand-copy > p:not(.eyebrow) { max-width: 650px; color: #c3d7e8; line-height: 1.75; margin: 0; font-size: 16px; }

.login-trust { display: flex; gap: 10px; color: #a9cadc; font-size: 13px; align-items: center; }

.login-panel { display: grid; place-items: center; padding: 40px; background: var(--surface-soft); }

.login-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--line); padding: 42px; box-shadow: 0 24px 80px rgba(0, 0, 0, .18); }

.login-card h2 { font-family: "Source Serif 4"; font-size: 32px; margin: 4px 0 8px; }

.icon-tile, .metric-icon { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--icon-border); color: var(--blue); border-radius: 8px; margin-bottom: 24px; }

label { display: grid; gap: 7px; font-weight: 700; font-size: 13px; margin: 20px 0; }

input, select, textarea { width: 100%; border: 1px solid var(--input-border); border-radius: 6px; padding: 12px 13px; color: var(--text-soft); background: var(--surface); outline: none; }

input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 122, 214, .1); }

.form-error { color: #a92f2f; background: #fff0f0; border: 1px solid #f2c3c3; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }

.login-secondary-action { width: 100%; margin-top: 14px; border: 0; background: none; color: var(--blue); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 8px; }

.app-shell { height: 100vh; height: 100dvh; min-height: 0; display: grid; grid-template-columns: 238px minmax(0, 1fr); overflow: hidden; }

.sidebar { background: linear-gradient(180deg, #052440, #062d4e); color: #dceaf5; padding: 28px 14px 18px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }

.logo { display: flex; align-items: baseline; gap: 7px; padding: 0 10px 30px; }

.logo span { font-size: 23px; letter-spacing: .08em; font-weight: 800; }

.logo small { color: #2bc1d4; font-weight: 800; }

.sidebar nav { display: grid; gap: 6px; }

.sidebar nav a { display: flex; gap: 13px; align-items: center; padding: 13px 14px; border-radius: 7px; font-size: 14px; }

.sidebar nav a svg { width: 20px; }

.sidebar nav a.active { background: linear-gradient(90deg, #0d5676, #0c6881); color: white; }

.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.13); padding-top: 16px; }

.theme-toggle { width: 100%; padding: 10px; display: flex; align-items: center; gap: 10px; color: #c0d5e4; background: transparent; border: 0; border-radius: 7px; font-size: 13px; text-align: left; }

.theme-toggle:hover { background: rgba(255,255,255,.08); color: white; }

.sidebar-help { padding: 10px; display: flex; align-items: center; gap: 10px; color: #a8bfd2; font-size: 13px; border-radius: 7px; }

.sidebar-help:hover { background: rgba(255,255,255,.08); color: white; }

.sidebar-help.active { background: rgba(255,255,255,.12); color: white; }

.profile-chip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 14px 8px 0; }

.profile-chip strong, .profile-chip small { display: block; font-size: 12px; }

.profile-chip small { color: #98b4c9; margin-top: 4px; }

.profile-chip-link { min-width: 0; border-radius: 5px; padding: 3px 2px; }

.profile-chip-link:hover strong { color: white; }

.profile-chip button { background: none; color: #bcd0df; border: 0; padding: 5px; }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: #dfe9f1; color: #28435c; display: inline-grid; place-items: center; font-weight: 800; font-size: 12px; flex: 0 0 auto; }

.avatar.teal { background: #d9f3f5; color: #087b89; }

.workspace { min-width: 0; min-height: 0; overflow-y: auto; }

.page { padding: 34px 36px 50px; max-width: 1600px; margin: 0 auto; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }

.workspace { background: var(--app-bg); }

.date-filter { border: 1px solid var(--line); padding: 12px 16px; background: var(--surface); border-radius: 7px; font-size: 13px; }

.panel, .metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }

.dashboard-warning { margin-bottom: 18px; padding: 16px 18px; border-color: #f0cf76; background: #fff8e6; }

.dashboard-warning strong { display: block; margin-bottom: 6px; color: #7c5a00; }

.dashboard-warning p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

:root[data-theme="dark"] .dashboard-warning { background: #332b16; border-color: #66511b; }

.metric-card { padding: 22px; display: flex; gap: 16px; min-height: 145px; align-items: flex-start; }

.metric-card .metric-icon { margin: 0; flex: 0 0 auto; }

.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 12px; }

.metric-card strong { display: block; font-family: "Source Serif 4"; font-size: 32px; margin: 5px 0 9px; }

.dashboard-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; }

.chart-panel, .intent-panel { padding: 20px; min-height: 330px; }

.chart-empty { min-height: 250px; display: grid; place-items: center; }

.dashboard-debug { margin-top: 18px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 10px 18px; color: var(--muted); font-size: 11px; }

.dashboard-debug strong { color: var(--text); }

.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

.panel-title h2 { margin: 0; }

.panel-title span, .panel-title a { color: var(--muted); font-size: 12px; }

.panel-title a { color: var(--blue); }

.intent-list { display: grid; gap: 25px; padding: 24px 4px; }

.intent-row { display: grid; grid-template-columns: 145px 1fr 35px 42px; gap: 12px; align-items: center; font-size: 12px; }

.progress { height: 12px; background: var(--progress-bg); }

.progress i { display: block; height: 100%; background: linear-gradient(90deg, #19979c, #078d95); }

.intent-row span { color: var(--muted); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }

th { text-align: left; color: #52687c; font-weight: 700; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }

td { padding: 13px 12px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }

td small { display: block; color: var(--muted); margin-top: 3px; }

.status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 5px; background: #e2f6eb; color: #13774f; font-weight: 700; font-size: 11px; }

.status.closed, .status.disabled { background: #edf0f3; color: #5d6874; }

.status.invited { background: #e6f1ff; color: #1768ad; }

.dialogs-page { max-width: none; height: 100%; min-height: 0; display: flex; flex-direction: column; padding-bottom: 24px; overflow: hidden; }

.dialogs-layout { display: grid; grid-template-columns: 305px minmax(430px, 1fr) 300px; min-height: 0; flex: 1; overflow: hidden; }

.conversation-list, .client-info { min-width: 0; min-height: 0; background: var(--surface); }

.conversation-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; }

.search-box { display: flex; align-items: center; gap: 8px; margin: 15px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; }

.search-box input { border: 0; padding: 11px 4px; box-shadow: none; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 15px 12px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }

.tabs button { border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 9px 4px; font-size: 11px; }

.tabs button.active { color: var(--blue); box-shadow: inset 0 -2px var(--blue); }

.conversation-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.conversation-item { width: 100%; border: 0; border-top: 1px solid var(--row-line); background: var(--surface); text-align: left; padding: 14px 15px; color: var(--text-soft); }

.conversation-item.selected { background: var(--surface-selected); box-shadow: inset 3px 0 var(--blue); }

.conversation-item.unread { background: color-mix(in srgb, var(--surface-selected) 72%, var(--surface)); box-shadow: inset 3px 0 var(--blue); }

.conversation-item.unread strong { font-weight: 800; }

.conversation-item.unread p b { color: var(--blue); }

.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); display: inline-block; margin-right: 7px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 16%, transparent); }

.conversation-item span { display: flex; justify-content: space-between; gap: 8px; }

.conversation-item small { color: #2371b4; margin-top: 5px; }

.conversation-item time { font-size: 11px; }

.conversation-item p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }

.chat-area { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--surface-subtle); }

.chat-header { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; background: var(--surface); }

.chat-actions { display: flex; align-items: center; gap: 8px; }

.icon-button { padding-inline: 12px; }

.client-title { display: flex; gap: 11px; align-items: center; }

.client-title h2 { margin: 0 0 4px; }

.client-title p { margin: 0; font-size: 11px; color: var(--muted); }

.message-stream { min-height: 0; padding: 26px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 0; }

.message { display: flex; gap: 10px; margin-bottom: 22px; max-width: 74%; }

.message.bot { margin-left: auto; flex-direction: row-reverse; }

.message > div { border: 1px solid var(--line); background: var(--surface); padding: 14px 16px; border-radius: 9px; white-space: pre-wrap; line-height: 1.55; font-size: 12px; }

.message.bot > div { background: var(--message-bot); border-color: var(--message-bot-border); }

.message p { margin: 0; }

.message time { display: block; color: var(--muted); font-size: 10px; text-align: right; margin-top: 7px; }

.message-avatar { width: 34px; height: 34px; border-radius: 50%; background: #20a7cd; color: white; display: grid; place-items: center; flex: 0 0 auto; }

.chat-note { padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; display: flex; gap: 8px; align-items: center; background: var(--surface); }

.client-info { border-left: 1px solid var(--line); padding: 20px 17px; overflow-y: auto; }

.client-info h3 { font-size: 13px; }

dl { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 8px; font-size: 11px; border-bottom: 1px solid var(--line); padding-bottom: 22px; }

dt { color: var(--muted); }

dd { margin: 0; text-align: right; font-weight: 700; overflow-wrap: anywhere; }

.lookup-history { margin-top: 22px; }

.lookup-item { display: grid; grid-template-columns: 12px 1fr; gap: 10px; border-left: 1px solid #d7e3ea; padding: 0 0 20px 14px; position: relative; font-size: 10px; }

.lookup-item > i { position: absolute; left: -5px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }

.lookup-item > i.fail { background: var(--red); }

.lookup-item time, .lookup-item small { color: var(--muted); display: block; }

.lookup-item p { margin: 5px 0; }

.lookup-item strong { color: var(--green); }

.empty-state { margin: auto; color: var(--muted); }

.crm-dialogs-page { max-width: none; }

.dialog-filters { padding: 18px; display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }

.dialog-filters label { margin: 0; }

.dialog-filters label span { display: inline-flex; align-items: center; gap: 6px; }

.dialogs-table-panel { padding: 8px 12px 14px; }

.dialogs-table td { max-width: 260px; overflow-wrap: anywhere; }

.clickable-row { cursor: pointer; }

.clickable-row:hover { background: var(--surface-selected); }

.dialog-detail-page { max-width: 1280px; }

.back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--blue); font-size: 12px; font-weight: 800; margin-bottom: 8px; }

.dialog-summary-panel { padding: 20px; margin-bottom: 18px; }

.dialog-summary-panel dl { grid-template-columns: 170px minmax(0, 1fr); border: 0; padding: 0; margin: 0; }

.dialog-summary-panel dd { text-align: left; }

.dialog-chat-panel { min-height: 480px; display: flex; flex-direction: column; overflow: hidden; }

.dialog-message-stream { min-height: 480px; }

.message-meta { grid-template-columns: 90px minmax(0, 1fr); gap: 6px 10px; border: 0; padding: 10px 0 0; margin: 10px 0 0; font-size: 10px; color: var(--muted); }

.message-meta dd { text-align: left; font-weight: 600; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; }

.staff-panel, .roles-panel { padding: 20px; }

.staff-name { display: flex; gap: 10px; align-items: center; }

.staff-name .avatar { width: 32px; height: 32px; }

.staff-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.text-button { border: 0; color: var(--blue); background: none; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }

.text-button.danger, .danger-text { color: #b83232; }

.role-card { display: flex; gap: 13px; padding: 18px 0; border-top: 1px solid var(--line); }

.role-card svg { color: var(--blue); flex: 0 0 auto; }

.role-card.admin svg { color: var(--teal); }

.role-card p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 6px 0 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 14, 23, .68); display: grid; place-items: center; z-index: 10; padding: 20px; }

.modal { width: min(490px, 100%); background: var(--surface); padding: 30px; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 30px 100px var(--modal-shadow); position: relative; }

.modal h2 { font-family: "Source Serif 4"; font-size: 28px; }

.modal-close { position: absolute; right: 18px; top: 18px; color: var(--text); border: 0; background: none; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.delete-modal { width: min(520px, 100%); }

.danger-icon { width: 48px; height: 48px; display: grid; place-items: center; color: #b83232; background: #fff0f0; border: 1px solid #f2c3c3; border-radius: 8px; margin-bottom: 20px; }

.system-page { max-width: 1250px; }

.system-status-grid, .system-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.system-settings-grid { margin-top: 18px; }

.system-status-card { padding: 24px; display: flex; align-items: center; gap: 18px; }

.system-card-icon, .system-setting-icon { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto; color: var(--blue); background: var(--surface-selected); border: 1px solid var(--line); border-radius: 9px; }

.system-status-card small, .system-status-card strong { display: block; }

.system-status-card small { color: var(--muted); font-size: 11px; margin-bottom: 4px; }

.system-status-card strong { font-size: 17px; margin-bottom: 10px; }

.service-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }

.service-status svg { width: 16px; }

.service-status.online { color: var(--green); }

.service-status.offline { color: var(--red); }

.service-status.checking { color: var(--muted); }

.status-spinner { animation: spin .8s linear infinite; }

.system-panel { padding: 22px; }

.system-setting-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; }

.system-setting-row p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }

.system-account { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }

.system-account dl { margin: 0; border: 0; padding: 0; }

.system-checked-at { color: var(--muted); text-align: right; font-size: 11px; margin: 14px 0 0; }

.bot-settings-page { max-width: 1450px; }

.bot-settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

.bot-settings-form { padding: 24px; }

.bot-runtime-status { display: inline-flex; align-items: center; gap: 9px; padding: 9px 13px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--surface); border: 1px solid var(--line); }

.bot-runtime-status i { width: 9px; height: 9px; border-radius: 50%; }

.bot-runtime-status.online { color: var(--green); }

.bot-runtime-status.online i { background: var(--green); box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 16%, transparent); }

.bot-runtime-status.paused { color: #b17619; }

.bot-runtime-status.paused i { background: #d99a34; box-shadow: 0 0 0 5px color-mix(in srgb, #d99a34 16%, transparent); }

.bot-switch-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 20px; }

.bot-switch-row p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }

.switch-control { display: inline-flex; margin: 0; }

.switch-control input { position: absolute; opacity: 0; pointer-events: none; }

.switch-control span { width: 48px; height: 27px; border-radius: 20px; background: #9babb8; padding: 3px; transition: .2s ease; }

.switch-control span::after { content: ""; display: block; width: 21px; height: 21px; border-radius: 50%; background: white; box-shadow: 0 2px 8px rgba(0,0,0,.24); transition: transform .2s ease; }

.switch-control input:checked + span { background: var(--green); }

.switch-control input:checked + span::after { transform: translateX(21px); }

.switch-control input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--blue) 30%, transparent); }

.bot-copy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }

.bot-copy-grid label { position: relative; }

.bot-copy-grid textarea { min-height: 128px; resize: vertical; line-height: 1.5; }

.bot-copy-grid label small { color: var(--muted); font-weight: 400; line-height: 1.45; min-height: 34px; }

.bot-copy-grid label em { color: var(--muted); font-size: 10px; font-style: normal; text-align: right; }

.bot-form-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.bot-form-footer small { color: var(--muted); }

.form-success { color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--green) 40%, var(--line)); padding: 10px 12px; border-radius: 6px; display: flex; align-items: center; gap: 8px; font-size: 13px; }

.bot-security-column { display: grid; gap: 14px; }

.bot-security-card { padding: 22px; }

.bot-security-card > svg { color: var(--teal); margin-bottom: 15px; }

.bot-security-card h2 { margin-bottom: 8px; }

.bot-security-card p { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 0; }

.audit-card { border-left: 3px solid var(--blue); }

.updates-page { max-width: 1050px; }

.updates-count { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 9px 13px; border-radius: 999px; font-size: 12px; font-weight: 700; }

.updates-loading { min-height: 180px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }

.updates-timeline { display: grid; gap: 16px; position: relative; }

.updates-timeline::before { content: ""; position: absolute; left: 25px; top: 34px; bottom: 34px; width: 1px; background: var(--line); }

.update-card { display: grid; grid-template-columns: 52px 1fr; padding: 24px 26px 24px 0; position: relative; overflow: hidden; }

.update-marker { display: flex; justify-content: center; position: relative; z-index: 1; }

.update-marker::before { content: ""; width: 13px; height: 13px; border-radius: 50%; margin-top: 5px; background: var(--blue); border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--blue); }

.update-marker span { position: absolute; top: 25px; font-size: 8px; letter-spacing: .08em; color: var(--teal); font-weight: 900; }

.update-content h2 { font-family: "Source Serif 4"; font-size: 25px; margin: 10px 0 7px; }

.update-content > p { color: var(--muted); line-height: 1.65; font-size: 13px; margin-bottom: 18px; }

.update-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.update-meta strong { color: var(--teal); font-size: 12px; letter-spacing: .04em; }

.update-meta time { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 11px; }

.update-content ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }

.update-content li { display: flex; align-items: flex-start; gap: 9px; color: var(--text-soft); font-size: 12px; line-height: 1.5; }

.update-content li svg { color: var(--green); flex: 0 0 auto; margin-top: 1px; }

.profile-page { max-width: 1150px; }

.profile-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }

.profile-summary, .profile-password { padding: 26px; }

.profile-summary { text-align: center; }

.profile-avatar { width: 86px; height: 86px; display: grid; place-items: center; margin: 0 auto 17px; border-radius: 50%; color: #183b57; background: linear-gradient(145deg, #dceaf5, #b8d8ec); font-family: "Source Serif 4"; font-size: 27px; font-weight: 800; }

.profile-summary h2 { font-family: "Source Serif 4"; font-size: 27px; margin: 12px 0 5px; }

.profile-summary > div > p { color: var(--muted); font-size: 12px; }

.profile-details { display: grid; grid-template-columns: 1fr; gap: 0; margin: 25px 0 0; padding: 5px 0 0; text-align: left; }

.profile-details div { padding: 14px 0; border-bottom: 1px solid var(--row-line); }

.profile-details div:last-child { border-bottom: 0; }

.profile-details dt { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }

.profile-details dd { text-align: left; font-size: 12px; }

.profile-password { max-width: 680px; }

.profile-password .panel-title > div { display: flex; align-items: center; gap: 12px; }

.profile-password .panel-title h2 { margin: 0; }

.profile-password .system-card-icon { width: 42px; height: 42px; }

.profile-password > .muted { font-size: 12px; line-height: 1.6; }

.profile-password > .button { margin-top: 5px; }

.profile-reset-option { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.profile-reset-option strong, .profile-reset-option small { display: block; }

.profile-reset-option strong { font-size: 12px; margin-bottom: 5px; }

.profile-reset-option small { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }

.profile-reset-option .button { flex: 0 0 auto; font-size: 11px; }

.app-loading { min-height: 100vh; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); }

.loader { width: 20px; height: 20px; border: 2px solid #c9d6df; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .system-settings-grid { grid-template-columns: 1fr; }
  .bot-settings-layout { grid-template-columns: 1fr; }.bot-security-column { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1350px) {
  .dialogs-layout { grid-template-columns: 280px 1fr; }.client-info { display: none; }
}

@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }.login-brand { display: none; }
  .app-shell { grid-template-columns: 70px 1fr; }.sidebar { padding-inline: 8px; }.logo small, .logo span, .sidebar nav a:not(.active)::after, .sidebar nav a { font-size: 0; }.sidebar nav a { justify-content: center; }.theme-toggle, .sidebar-help { justify-content: center; }.theme-toggle span, .profile-chip span:not(.avatar), .profile-chip button { display: none; }.sidebar-help { font-size: 0; }
  .page { padding: 24px 16px; }.page-header h1 { font-size: 30px; }.metric-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .system-status-grid { grid-template-columns: 1fr; }.system-setting-row { grid-template-columns: auto 1fr; }.system-setting-row .button { grid-column: 1 / -1; }
  .bot-copy-grid, .bot-security-column { grid-template-columns: 1fr; }.bot-form-footer { align-items: stretch; flex-direction: column; }.bot-form-footer .button { width: 100%; }
  .profile-layout { grid-template-columns: 1fr; }.profile-password { max-width: none; }.profile-reset-option { align-items: stretch; flex-direction: column; }
  .update-card { grid-template-columns: 42px 1fr; padding-right: 18px; }.updates-timeline::before { left: 20px; }.update-meta { align-items: flex-start; flex-direction: column; gap: 6px; }
  .dialogs-layout { grid-template-columns: 1fr; }.conversation-list { display: none; }
}

/* CRM design refresh */

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0F172A;
  background: #F8FAFC;
  --navy: #0F172A;
  --blue: #2563EB;
  --teal: #0284C7;
  --line: #E2E8F0;
  --muted: #64748B;
  --green: #16A34A;
  --red: #DC2626;
  --warning: #F59E0B;
  --info: #0284C7;
  --app-bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-soft: #F1F5F9;
  --surface-subtle: #F8FAFC;
  --surface-selected: #EFF6FF;
  --text: #0F172A;
  --text-soft: #334155;
  --row-line: #E2E8F0;
  --input-border: #CBD5E1;
  --icon-border: #DBEAFE;
  --progress-bg: #E2E8F0;
  --chart-grid: #E2E8F0;
  --chart-grid-strong: #CBD5E1;
  --chart-axis: #64748B;
  --chart-tooltip-bg: #FFFFFF;
  --chart-tooltip-text: #0F172A;
  --chart-tooltip-border: #CBD5E1;
  --chart-tooltip-shadow: rgba(15, 23, 42, .14);
  --message-bot: #F1F5F9;
  --message-bot-border: #E2E8F0;
  --modal-shadow: rgba(15, 23, 42, .22);
}

body { background: #F8FAFC; color: #0F172A; }

h1 { font-family: inherit; font-size: 30px; font-weight: 750; letter-spacing: 0; }

h2 { font-size: 16px; font-weight: 750; color: #0F172A; }

.eyebrow { color: #2563EB; letter-spacing: .08em; }

.page-fluid { max-width: none; }

.app-shell { grid-template-columns: 248px minmax(0, 1fr); background: #F8FAFC; }

.sidebar { background: #FFFFFF; color: #0F172A; border-right: 1px solid #E2E8F0; padding: 20px 14px; }

.logo { display: grid; gap: 2px; padding: 2px 10px 24px; }

.logo span { font-size: 17px; letter-spacing: 0; color: #0F172A; }

.logo small { color: #64748B; font-size: 12px; }

.sidebar nav { gap: 4px; }

.sidebar nav a { color: #475569; border-radius: 8px; padding: 10px 12px; font-weight: 650; }

.sidebar nav a svg { width: 18px; color: #64748B; }

.sidebar nav a:hover { background: #F1F5F9; color: #0F172A; }

.sidebar nav a.active { background: #EFF6FF; color: #1D4ED8; box-shadow: inset 3px 0 #2563EB; }

.sidebar nav a.active svg { color: #2563EB; }

.sidebar-bottom { border-top: 1px solid #E2E8F0; }

.theme-toggle { color: #64748B; }

.theme-toggle svg { color: #94A3B8; }

.theme-toggle:hover { background: #F1F5F9; color: #0F172A; }

.theme-toggle:hover svg { color: #2563EB; }

.profile-chip { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 10px; padding: 10px; }

.profile-chip strong { color: #0F172A; }

.profile-chip small { color: #64748B; }

.profile-chip-link:hover { background: #EFF6FF; }

.profile-chip-link:hover strong { color: #0F172A; }

.profile-chip-link:hover small { color: #475569; }

.profile-chip button { color: #64748B; border-radius: 6px; }

.profile-chip button:hover { background: #E2E8F0; color: #0F172A; }

.workspace { background: #F8FAFC; }

.page { padding: 24px; }

.crm-page-header { gap: 18px; align-items: flex-start; margin-bottom: 18px; }

.crm-page-header h1 { margin-bottom: 6px; }

.crm-page-header p { margin: 0; color: #64748B; font-size: 14px; line-height: 1.5; }

.page-header-actions { display: flex; align-items: center; gap: 10px; }

.ui-button, .button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ui-button-primary, .button.primary { background: #2563EB; border-color: #2563EB; color: #FFFFFF; }

.ui-button-primary:hover, .button.primary:hover { background: #1D4ED8; border-color: #1D4ED8; }

.ui-button-secondary, .button.secondary { background: #FFFFFF; color: #334155; }

.ui-button-secondary:hover, .button.secondary:hover { border-color: #2563EB; color: #1D4ED8; background: #EFF6FF; }

.ui-button-ghost { background: transparent; border-color: transparent; color: #2563EB; padding-inline: 8px; }

.ui-button-ghost:hover { background: #EFF6FF; }

.ui-button-danger, .button.danger { background: #DC2626; border-color: #DC2626; color: #FFFFFF; }

.ui-button-danger:hover, .button.danger:hover { background: #B91C1C; border-color: #B91C1C; color: #FFFFFF; }

.ui-button:disabled, .button:disabled { opacity: .6; cursor: default; }

.danger-outline { color: #B91C1C; border-color: #FECACA; background: #FFFFFF; }

.danger-outline:hover { color: #991B1B; border-color: #DC2626; background: #FEF2F2; }

.hard-delete-button { min-height: 32px; padding-inline: 10px; }

.ui-card, .panel, .metric-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.metric-card { min-height: 118px; padding: 18px; }

.metric-icon { width: 38px; height: 38px; border-radius: 9px; background: #EFF6FF; border-color: #DBEAFE; color: #2563EB; }

.metric-card span, .metric-card small { color: #64748B; }

.metric-card strong { font-family: inherit; font-size: 30px; color: #0F172A; }

.dashboard-grid { gap: 14px; }

.chart-panel, .intent-panel, .dialogs-table-panel, .staff-panel { padding: 16px; }

.panel-title { margin-bottom: 14px; }

.panel-title span, .panel-title a { color: #64748B; }

.panel-title a { color: #2563EB; font-weight: 700; }

.intent-list { gap: 12px; padding: 8px 0; }

.intent-row { grid-template-columns: 150px 1fr 42px 46px; gap: 10px; }

.progress { height: 8px; border-radius: 999px; overflow: hidden; }

.progress i { background: #2563EB; }

.ui-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  white-space: nowrap;
}

.ui-badge-success, .status.active { color: #166534; background: #DCFCE7; border-color: #BBF7D0; }

.ui-badge-warning, .status.invited { color: #92400E; background: #FEF3C7; border-color: #FDE68A; }

.ui-badge-error, .status.blocked, .status.disabled, .status.error { color: #991B1B; background: #FEE2E2; border-color: #FECACA; }

.ui-badge-info { color: #075985; background: #E0F2FE; border-color: #BAE6FD; }

.ui-badge-neutral, .status { color: #334155; background: #F1F5F9; border-color: #E2E8F0; }

.ui-input, input, select, textarea {
  min-height: 36px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background: #FFFFFF;
  color: #0F172A;
  padding: 8px 10px;
  font-size: 13px;
}

.ui-input:focus, input:focus, select:focus, textarea:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

label { gap: 6px; margin: 0; color: #334155; }

.ui-table-wrap, .table-wrap { overflow-x: auto; }

.ui-table, table { border-collapse: collapse; width: 100%; font-size: 12px; }

.ui-table th, th {
  background: #F8FAFC;
  color: #64748B;
  border-bottom: 1px solid #E2E8F0;
  padding: 9px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ui-table td, td { padding: 10px; border-bottom: 1px solid #E2E8F0; color: #0F172A; }

.ui-table tbody tr:hover, .clickable-row:hover { background: #F8FAFC; }

td small { color: #64748B; }

.cell-truncate {
  max-width: 300px;
  max-height: 38px;
  overflow: hidden;
  line-height: 1.45;
}

.ui-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #64748B;
  text-align: center;
  padding: 24px;
}

.ui-state strong { color: #0F172A; font-size: 14px; }

.ui-state p { margin: 0; max-width: 440px; font-size: 13px; line-height: 1.5; }

.ui-state-marker { width: 10px; height: 10px; border-radius: 50%; background: #CBD5E1; }

.ui-state-error .ui-state-marker { background: #DC2626; }

.form-error { color: #991B1B; background: #FEE2E2; border-color: #FECACA; }

.form-success { color: #166534; background: #DCFCE7; border-color: #BBF7D0; }

.dialog-filters { grid-template-columns: 1.4fr repeat(3, minmax(160px, .7fr)); padding: 14px; gap: 12px; }

.dialog-filters label span { color: #64748B; font-size: 12px; font-weight: 750; }

.dialogs-table-panel { margin-top: 14px; }

.dialogs-table td { max-width: 300px; }

.back-link { color: #2563EB; }

.dialog-summary-panel { padding: 16px; }

.detail-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.detail-summary-grid div { display: grid; gap: 5px; padding: 12px; border: 1px solid #E2E8F0; border-radius: 8px; background: #F8FAFC; }

.detail-summary-grid span { color: #64748B; font-size: 11px; font-weight: 750; }

.detail-summary-grid strong { overflow-wrap: anywhere; font-size: 13px; }

.detail-summary-wide { grid-column: span 2; }

.dialog-chat-panel { padding: 0; min-height: 520px; }

.dialog-message-stream { padding: 20px; display: grid; gap: 14px; }

.chat-bubble-row { display: flex; gap: 10px; align-items: flex-start; max-width: 78%; }

.chat-bubble-row.bot { margin-left: auto; flex-direction: row-reverse; }

.chat-bubble { background: #FFFFFF; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }

.chat-bubble-row.bot .chat-bubble { background: #F1F5F9; }

.chat-bubble p { margin: 0; white-space: pre-wrap; line-height: 1.55; font-size: 13px; }

.message-badges { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }

.chat-bubble time { display: block; margin-top: 8px; color: #64748B; font-size: 11px; }

.message-technical { margin-top: 8px; color: #64748B; font-size: 11px; }

.message-technical summary { cursor: pointer; }

.message-technical pre { max-width: min(620px, 70vw); overflow: auto; background: #0F172A; color: #E2E8F0; border-radius: 8px; padding: 10px; }

.message-avatar { background: #2563EB; }

.users-page { display: grid; gap: 14px; }

.staff-actions { gap: 6px; flex-wrap: wrap; }

.staff-name strong { font-size: 13px; }

.roles-panel-inline { padding: 14px; display: grid; gap: 10px; }

.role-list { display: flex; flex-wrap: wrap; gap: 8px; }

.modal { border-radius: 12px; }

.modal h2 { font-family: inherit; }

.hard-delete-modal .muted { line-height: 1.6; }

.delete-confirm-box { display: grid; gap: 4px; padding: 12px; margin: 14px 0; border: 1px solid #FECACA; background: #FEF2F2; border-radius: 10px; }

.delete-confirm-box span { color: #64748B; font-size: 11px; font-weight: 750; }

.delete-confirm-box strong { color: #991B1B; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid #E2E8F0; }
  .logo { padding: 0 4px 10px; }
  .sidebar nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-bottom { display: none; }
  .page { padding: 16px; }
  .crm-page-header { flex-direction: column; }
  .page-header-actions { width: 100%; justify-content: space-between; }
  .metric-grid, .dialog-filters, .detail-summary-grid { grid-template-columns: 1fr; }
  .detail-summary-wide { grid-column: auto; }
  .chat-bubble-row { max-width: 100%; }
}

/* Login screen polish */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(420px, .9fr) minmax(460px, 1.1fr);
  background: #F8FAFC;
}

.login-brand {
  background: #020617;
  color: #FFFFFF;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand::after {
  content: "";
  width: 340px;
  height: 340px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .2);
  filter: blur(80px);
  position: absolute;
  left: -120px;
  bottom: -120px;
  pointer-events: none;
}

.aktobe-logo {
  width: min(300px, 78%);
  height: auto;
  object-fit: contain;
}

.login-brand .login-title {
  color: #FFFFFF;
  font-family: inherit;
  font-size: clamp(36px, 4vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  white-space: normal;
  margin: 0 0 18px;
}

.login-brand-copy > p:not(.eyebrow) {
  color: #CBD5E1;
  max-width: 520px;
  font-size: 15px;
  line-height: 1.7;
}

.login-trust {
  color: #CBD5E1;
  font-size: 13px;
}

.login-panel {
  background: #F8FAFC;
  display: grid;
  place-items: center;
  padding: 48px 32px;
}

.login-card {
  width: min(430px, 100%);
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
}

.login-card h2 {
  font-family: inherit;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 8px 0 10px;
  color: #0F172A;
}

.login-card .muted {
  color: #64748B;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

.login-card input {
  height: 46px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.login-card .button.primary {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  margin-top: 4px;
  font-size: 15px;
}

.login-secondary-action {
  width: 100%;
  margin-top: 18px;
  color: #2563EB;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 750;
}

.login-secondary-action:hover {
  background: #EFF6FF;
}

.icon-tile {
  width: 52px;
  height: 52px;
  margin-bottom: 22px;
  border-radius: 14px;
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: #2563EB;
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { padding: 24px; }
  .login-card { padding: 28px; }
}

/* Dark theme overrides for refreshed UI */

:root[data-theme="dark"] {
  color: #E5E7EB;
  background: #0F172A;
  --app-bg: #0F172A;
  --surface: #111827;
  --surface-soft: #1F2937;
  --surface-subtle: #0B1220;
  --surface-selected: #172554;
  --text: #E5E7EB;
  --text-soft: #CBD5E1;
  --line: #334155;
  --row-line: #273449;
  --input-border: #475569;
  --muted: #94A3B8;
  --blue: #60A5FA;
  --teal: #38BDF8;
  --green: #22C55E;
  --red: #F87171;
  --warning: #FBBF24;
  --info: #38BDF8;
  --progress-bg: #334155;
  --chart-grid: #334155;
  --chart-grid-strong: #52647A;
  --chart-axis: #CBD5E1;
  --chart-tooltip-bg: #F8FAFC;
  --chart-tooltip-text: #0F172A;
  --chart-tooltip-border: #CBD5E1;
  --chart-tooltip-shadow: rgba(0, 0, 0, .42);
  --message-bot: #1E293B;
  --message-bot-border: #334155;
  --modal-shadow: rgba(0, 0, 0, .55);
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .login-page,
:root[data-theme="dark"] .login-panel {
  background: #0F172A;
  color: #E5E7EB;
}

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] .ui-state strong,
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .logo span,
:root[data-theme="dark"] .login-card h2 {
  color: #F8FAFC;
}

:root[data-theme="dark"] .crm-page-header p,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .panel-title span,
:root[data-theme="dark"] td small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .logo small,
:root[data-theme="dark"] .login-card .muted,
:root[data-theme="dark"] .detail-summary-grid span,
:root[data-theme="dark"] .dialog-filters label span,
:root[data-theme="dark"] .chat-bubble time,
:root[data-theme="dark"] .message-technical,
:root[data-theme="dark"] .ui-state {
  color: #94A3B8;
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .ui-card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .chat-bubble {
  background: #111827;
  border-color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

:root[data-theme="dark"] .sidebar {
  border-right-color: #334155;
}

:root[data-theme="dark"] .sidebar nav a {
  color: #CBD5E1;
}

:root[data-theme="dark"] .sidebar nav a svg {
  color: #94A3B8;
}

:root[data-theme="dark"] .sidebar nav a:hover {
  background: #1F2937;
  color: #F8FAFC;
}

:root[data-theme="dark"] .sidebar nav a.active {
  background: #172554;
  color: #BFDBFE;
  box-shadow: inset 3px 0 #60A5FA;
}

:root[data-theme="dark"] .sidebar nav a.active svg,
:root[data-theme="dark"] .panel-title a,
:root[data-theme="dark"] .back-link,
:root[data-theme="dark"] .login-secondary-action,
:root[data-theme="dark"] .ui-button-ghost {
  color: #60A5FA;
}

:root[data-theme="dark"] .sidebar-bottom,
:root[data-theme="dark"] .profile-chip,
:root[data-theme="dark"] .detail-summary-grid div,
:root[data-theme="dark"] .ui-table th,
:root[data-theme="dark"] th {
  background: #1F2937;
  border-color: #334155;
}

:root[data-theme="dark"] .theme-toggle {
  color: #CBD5E1;
}

:root[data-theme="dark"] .theme-toggle svg {
  color: #94A3B8;
}

:root[data-theme="dark"] .theme-toggle:hover {
  background: #1E293B;
  color: #F8FAFC;
}

:root[data-theme="dark"] .theme-toggle:hover svg {
  color: #93C5FD;
}

:root[data-theme="dark"] .profile-chip strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .profile-chip small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .profile-chip-link:hover {
  background: #172554;
}

:root[data-theme="dark"] .profile-chip-link:hover strong {
  color: #FFFFFF;
}

:root[data-theme="dark"] .profile-chip-link:hover small {
  color: #DBEAFE;
}

:root[data-theme="dark"] .profile-chip button:hover,
:root[data-theme="dark"] .ui-table tbody tr:hover,
:root[data-theme="dark"] .clickable-row:hover,
:root[data-theme="dark"] .login-secondary-action:hover,
:root[data-theme="dark"] .ui-button-ghost:hover {
  background: #172554;
}

:root[data-theme="dark"] .ui-button,
:root[data-theme="dark"] .button,
:root[data-theme="dark"] .ui-button-secondary,
:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .ui-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #0B1220;
  border-color: #475569;
  color: #E5E7EB;
}

:root[data-theme="dark"] .ui-button-secondary:hover,
:root[data-theme="dark"] .button.secondary:hover {
  background: #172554;
  border-color: #60A5FA;
  color: #BFDBFE;
}

:root[data-theme="dark"] .ui-button-primary,
:root[data-theme="dark"] .button.primary {
  background: #2563EB;
  border-color: #2563EB;
  color: #FFFFFF;
}

:root[data-theme="dark"] .danger-outline {
  color: #FECACA;
  background: transparent;
  border-color: rgba(248, 113, 113, .45);
}

:root[data-theme="dark"] .danger-outline:hover {
  color: #FFFFFF;
  background: rgba(220, 38, 38, .2);
  border-color: #F87171;
}

:root[data-theme="dark"] .ui-table td,
:root[data-theme="dark"] td {
  border-color: #273449;
  color: #E5E7EB;
}

:root[data-theme="dark"] .metric-icon,
:root[data-theme="dark"] .icon-tile {
  background: #172554;
  border-color: #1D4ED8;
  color: #93C5FD;
}

:root[data-theme="dark"] .progress {
  background: #334155;
}

:root[data-theme="dark"] .progress i {
  background: #60A5FA;
}

:root[data-theme="dark"] .chat-bubble-row.bot .chat-bubble {
  background: #1E293B;
  border-color: #334155;
}

:root[data-theme="dark"] .message-technical pre {
  background: #020617;
  color: #CBD5E1;
}

:root[data-theme="dark"] .login-brand {
  background: #020617;
}

:root[data-theme="dark"] .ui-badge-success,
:root[data-theme="dark"] .status.active {
  color: #BBF7D0;
  background: rgba(22, 163, 74, .18);
  border-color: rgba(34, 197, 94, .35);
}

:root[data-theme="dark"] .ui-badge-warning,
:root[data-theme="dark"] .status.invited {
  color: #FDE68A;
  background: rgba(245, 158, 11, .16);
  border-color: rgba(251, 191, 36, .35);
}

:root[data-theme="dark"] .ui-badge-error,
:root[data-theme="dark"] .status.blocked,
:root[data-theme="dark"] .status.disabled,
:root[data-theme="dark"] .status.error {
  color: #FECACA;
  background: rgba(220, 38, 38, .18);
  border-color: rgba(248, 113, 113, .35);
}

:root[data-theme="dark"] .ui-badge-info {
  color: #BAE6FD;
  background: rgba(2, 132, 199, .2);
  border-color: rgba(56, 189, 248, .35);
}

:root[data-theme="dark"] .ui-badge-neutral,
:root[data-theme="dark"] .status {
  color: #CBD5E1;
  background: #1F2937;
  border-color: #334155;
}

:root[data-theme="dark"] .form-error {
  color: #FECACA;
  background: rgba(220, 38, 38, .16);
  border-color: rgba(248, 113, 113, .35);
}

:root[data-theme="dark"] .form-success {
  color: #BBF7D0;
  background: rgba(22, 163, 74, .16);
  border-color: rgba(34, 197, 94, .35);
}

:root[data-theme="dark"] .delete-confirm-box {
  background: rgba(220, 38, 38, .14);
  border-color: rgba(248, 113, 113, .35);
}

:root[data-theme="dark"] .delete-confirm-box strong {
  color: #FECACA;
}

@media (max-width: 768px) {
  :root[data-theme="dark"] .sidebar {
    border-bottom-color: #334155;
  }
}

/* Modern CRM refresh */

:root {
  --app-bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-soft: #F8FAFC;
  --surface-subtle: #F1F5F9;
  --surface-selected: #EFF6FF;
  --text: #0F172A;
  --text-soft: #334155;
  --muted: #64748B;
  --muted-2: #94A3B8;
  --line: #E2E8F0;
  --row-line: #E2E8F0;
  --blue: #2563EB;
  --blue-hover: #1D4ED8;
  --green: #16A34A;
  --yellow: #F59E0B;
  --red: #DC2626;
  --info: #0284C7;
  --modal-shadow: rgba(15, 23, 42, .16);
}

body {
  background: #F8FAFC;
  color: #0F172A;
}

h1 {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(28px, 3vw, 32px);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0;
}

.app-shell {
  grid-template-columns: 264px minmax(0, 1fr);
  background: #F8FAFC;
}

.sidebar {
  background: #FFFFFF;
  color: #0F172A;
  border-right: 1px solid #E2E8F0;
  padding: 24px 16px 18px;
}

.logo {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 2px 14px;
  align-items: center;
  padding: 0 8px 26px;
}

.brand-icon {
  grid-row: 1 / span 2;
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(21, 92, 156, .12));
}

.logo-title-line,
.mobile-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo-title-line {
  align-self: end;
}

.mobile-brand-icon {
  display: none;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.logo span {
  color: #0F172A;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #FDBA74;
  background: #FFF7ED;
  color: #C2410C;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;
  white-space: nowrap;
}

.env-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #FDBA74;
  background: #FFF7ED;
  color: #C2410C;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo .env-label {
  grid-column: 2;
  margin-top: 6px;
}

.logo small {
  color: #64748B;
  font-size: 12px;
}

.sidebar nav {
  gap: 6px;
}

.sidebar nav a {
  position: relative;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #475569;
  font-size: 14px;
  font-weight: 650;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.sidebar nav a svg {
  width: 18px;
  color: #94A3B8;
  transition: color .16s ease;
}

.sidebar nav a:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.sidebar nav a:hover svg {
  color: #2563EB;
}

.sidebar nav a.active {
  background: #EFF6FF;
  color: #1D4ED8;
  box-shadow: inset 3px 0 #2563EB;
}

.sidebar nav a.active svg {
  color: #2563EB;
}

.sidebar-bottom {
  border-top: 1px solid #E2E8F0;
  padding-top: 16px;
}

.theme-toggle {
  min-height: 38px;
  color: #64748B;
  border-radius: 10px;
  transition: background-color .16s ease, color .16s ease;
}

.theme-toggle:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.profile-chip {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
}

.profile-chip strong {
  color: #0F172A;
  font-size: 14px;
}

.profile-chip small {
  color: #64748B;
  font-size: 13px;
}

.profile-chip-link {
  padding: 4px 6px;
  border-radius: 10px;
}

.profile-chip-link:hover {
  background: #EFF6FF;
}

.profile-chip-link:hover strong {
  color: #0F172A;
}

.profile-chip button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #64748B;
}

.profile-chip button:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.workspace {
  background: #F8FAFC;
}

.page {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.page-fluid {
  max-width: 1480px;
}

.crm-page-header {
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.crm-page-header h1 {
  margin: 0 0 7px;
}

.crm-page-header p {
  color: #64748B;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ui-card,
.panel,
.metric-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.ui-button,
.button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  color: #334155;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.ui-button-sm {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 13px;
}

.ui-button-lg {
  min-height: 46px;
  padding-inline: 18px;
}

.ui-button-primary,
.button.primary {
  background: #2563EB;
  border-color: #2563EB;
  color: #FFFFFF;
}

.ui-button-primary:hover,
.button.primary:hover {
  background: #1D4ED8;
  border-color: #1D4ED8;
}

.ui-button-secondary:hover,
.button.secondary:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
  color: #0F172A;
}

.ui-button-ghost {
  border-color: transparent;
  background: transparent;
  color: #64748B;
}

.ui-button-ghost:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.ui-button-danger,
.button.danger {
  background: #DC2626;
  border-color: #DC2626;
  color: #FFFFFF;
}

.ui-button-danger:hover,
.button.danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

.ui-button-dangerGhost {
  border-color: transparent;
  background: transparent;
  color: #DC2626;
}

.ui-button-dangerGhost:hover {
  background: #FEF2F2;
  border-color: #FECACA;
}

.ui-button:focus-visible,
.button:focus-visible,
.ui-input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2563EB;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .13);
}

.ui-button:disabled,
.button:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

.ui-input,
input,
select,
textarea {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #0F172A;
  padding: 10px 12px;
  font-size: 14px;
}

.ui-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: #94A3B8;
}

.ui-select {
  cursor: pointer;
}

.ui-badge,
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ui-badge-success,
.status.active {
  color: #15803D;
  background: #DCFCE7;
  border-color: #BBF7D0;
}

.ui-badge-warning,
.status.invited {
  color: #A16207;
  background: #FEF3C7;
  border-color: #FDE68A;
}

.ui-badge-error,
.status.blocked,
.status.disabled,
.status.error {
  color: #B91C1C;
  background: #FEE2E2;
  border-color: #FECACA;
}

.ui-badge-info {
  color: #0369A1;
  background: #E0F2FE;
  border-color: #BAE6FD;
}

.ui-badge-neutral,
.status {
  color: #475569;
  background: #F1F5F9;
  border-color: #E2E8F0;
}

.metric-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  display: grid;
  gap: 8px;
  padding: 22px;
  min-height: 154px;
  min-width: 0;
  align-content: start;
}

.kpi-card-top {
  display: flex;
  justify-content: space-between;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #2563EB;
  background: #EFF6FF;
}

.kpi-card-success .kpi-icon {
  color: #16A34A;
  background: #DCFCE7;
}

.kpi-card-warning .kpi-icon {
  color: #F59E0B;
  background: #FEF3C7;
}

.kpi-card-info .kpi-icon {
  color: #0284C7;
  background: #E0F2FE;
}

.kpi-card span,
.kpi-card small {
  color: #64748B;
  font-size: 13px;
}

.kpi-card strong {
  color: #0F172A;
  font-size: clamp(26px, 2.4vw, 32px);
  line-height: 1.05;
  font-weight: 760;
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 24px;
  align-items: start;
}

.period-select {
  width: auto;
  min-width: 116px;
}

.dashboard-analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.dashboard-span-2 {
  grid-column: span 2;
}

.chart-card {
  height: 100%;
  min-height: 340px;
  padding: 22px;
}

.chart-card-body {
  min-height: 260px;
}

.chart-card .ui-state {
  min-height: 260px;
}

.chart-card-title {
  align-items: flex-start;
}

.donut-chart-layout {
  display: grid;
  gap: 12px;
}

.chart-legend-list {
  display: grid;
  gap: 8px;
}

.chart-legend-list div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  color: #64748B;
  font-size: 12px;
}

.chart-legend-list i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.chart-legend-list span {
  min-width: 0;
  color: #334155;
}

.chart-legend-list strong {
  color: #0F172A;
}

.chart-legend-list small {
  color: #64748B;
}

.distribution-list {
  display: grid;
  gap: 14px;
}

.distribution-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
}

.distribution-row strong {
  color: #0F172A;
  font-size: 14px;
}

.distribution-row span,
.distribution-row small {
  color: #64748B;
  font-size: 12px;
}

.distribution-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #E2E8F0;
}

.distribution-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563EB, #0284C7);
}

.lookup-success-empty {
  min-height: 340px;
}

.activity-chart-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-top: 14px;
}

.activity-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.activity-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 650;
}

.activity-chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.activity-chart-legend .messages {
  background: #94A3B8;
}

.activity-chart-legend .dialogs {
  background: #2563EB;
}

.activity-chart-legend .ls-search {
  background: #16A34A;
}

.activity-chart-legend .balance {
  background: #0284C7;
}

.activity-chart-legend .repair {
  background: #F59E0B;
}

.activity-chart-legend .problem {
  background: #DC2626;
}

.activity-chart-legend strong {
  color: #0F172A;
  font-weight: 850;
}

.activity-chart-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.activity-chart-totals span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  color: #64748B;
  background: #F8FAFC;
  font-size: 12px;
  font-weight: 750;
}

.activity-chart-totals strong {
  color: #0F172A;
  font-weight: 850;
}

.activity-chart-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.activity-chart-breakdown-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.activity-chart-breakdown-row span {
  overflow: hidden;
  color: #64748B;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-chart-breakdown-row div {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #E2E8F0;
}

.activity-chart-breakdown-row i {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: #2563EB;
}

.activity-chart-breakdown-row i.ls-search {
  background: #16A34A;
}

.activity-chart-breakdown-row i.balance {
  background: #0284C7;
}

.activity-chart-breakdown-row i.repair {
  background: #F59E0B;
}

.activity-chart-breakdown-row i.problem {
  background: #DC2626;
}

.activity-chart-breakdown-row strong {
  color: #0F172A;
  font-size: 13px;
  font-weight: 850;
}

.dialogs-chart-tooltip {
  display: grid;
  gap: 7px;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--chart-tooltip-border, #E2E8F0);
  border-radius: 12px;
  background: var(--chart-tooltip-bg, #FFFFFF);
  color: var(--chart-tooltip-text, #0F172A);
  box-shadow: 0 12px 28px var(--chart-tooltip-shadow, rgba(15, 23, 42, .12));
  font-size: 12px;
}

.dialogs-chart-tooltip strong {
  margin-bottom: 2px;
  font-size: 13px;
}

.chart-panel,
.intent-panel,
.dialogs-table-panel,
.staff-panel,
.roles-panel,
.dialog-summary-panel,
.dialog-chat-panel {
  padding: 22px;
}

.panel-title {
  margin-bottom: 18px;
}

.panel-title h2 {
  color: #0F172A;
  font-size: 18px;
}

.panel-title span,
.panel-title a {
  color: #64748B;
  font-size: 13px;
}

.panel-title a {
  color: #2563EB;
  font-weight: 700;
}

.activity-bars {
  display: grid;
  gap: 13px;
}

.activity-bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 42px 62px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.activity-bar-row span,
.activity-bar-row small {
  color: #64748B;
}

.activity-bar-row strong {
  color: #0F172A;
  text-align: right;
}

.activity-bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #E2E8F0;
}

.activity-bar-track i {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563EB, #0284C7);
}

.intent-list {
  gap: 14px;
  padding: 4px 0 0;
}

.intent-row {
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) 42px 46px;
  gap: 12px;
  font-size: 13px;
}

.progress {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #E2E8F0;
}

.progress i {
  border-radius: inherit;
  background: #2563EB;
}

.dialog-filters {
  grid-template-columns: minmax(260px, 1.3fr) repeat(3, minmax(150px, .8fr)) auto;
  align-items: end;
  gap: 16px;
  padding: 20px;
}

.dialog-filters label {
  gap: 7px;
}

.dialog-filters label span {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.filter-actions {
  display: flex;
  align-items: end;
  padding-bottom: 0;
}

.ui-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.ui-table {
  min-width: 860px;
  font-size: 14px;
}

.ui-table th,
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 14px 16px;
  color: #64748B;
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ui-table td,
td {
  padding: 14px 16px;
  color: #334155;
  border-bottom: 1px solid #E2E8F0;
  font-size: 14px;
}

.ui-table-compact td {
  padding-top: 11px;
  padding-bottom: 11px;
}

.ui-table tbody tr,
.clickable-row {
  transition: background-color .15s ease;
}

.ui-table tbody tr:hover,
.clickable-row:hover {
  background: #F8FAFC;
}

.cell-truncate {
  max-width: 280px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ui-dropdown {
  position: relative;
  display: inline-flex;
}

.ui-dropdown-trigger {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  color: #64748B;
  background: #FFFFFF;
}

.ui-dropdown-trigger:hover,
.ui-dropdown:focus-within .ui-dropdown-trigger {
  color: #0F172A;
  background: #F8FAFC;
  border-color: #CBD5E1;
}

.ui-dropdown-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 190px;
  padding: 6px;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 14px 32px rgba(15, 23, 42, .14);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}

.ui-dropdown:hover .ui-dropdown-panel,
.ui-dropdown:focus-within .ui-dropdown-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ui-dropdown-item {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #334155;
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}

.ui-dropdown-item:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.ui-dropdown-item.danger {
  color: #DC2626;
}

.ui-dropdown-item.danger:hover {
  background: #FEF2F2;
}

.ui-dropdown-item:disabled {
  color: #CBD5E1;
  cursor: not-allowed;
}

.staff-actions {
  gap: 8px;
}

.users-page {
  max-width: 1360px;
}

.users-page .staff-panel,
.users-page .roles-panel {
  overflow: visible;
}

.users-page .ui-table-wrap {
  overflow: visible;
}

.users-page .ui-table {
  min-width: 0;
  table-layout: fixed;
}

.users-page .ui-table th:nth-child(1),
.users-page .ui-table td:nth-child(1) {
  width: 19%;
}

.users-page .ui-table th:nth-child(2),
.users-page .ui-table td:nth-child(2) {
  width: 23%;
}

.users-page .ui-table th:nth-child(3),
.users-page .ui-table td:nth-child(3) {
  width: 14%;
}

.users-page .ui-table th:nth-child(4),
.users-page .ui-table td:nth-child(4) {
  width: 12%;
}

.users-page .ui-table th:nth-child(5),
.users-page .ui-table td:nth-child(5),
.users-page .ui-table th:nth-child(6),
.users-page .ui-table td:nth-child(6) {
  width: 14%;
}

.users-page .ui-table th:nth-child(7),
.users-page .ui-table td:nth-child(7) {
  width: 14%;
  text-align: right;
}

.users-page .ui-table td {
  vertical-align: middle;
}

.users-page .staff-actions {
  justify-content: flex-end;
}

.users-page .ui-dropdown-panel {
  z-index: 50;
}

.users-page .staff-name,
.users-page td {
  min-width: 0;
}

.users-page td {
  overflow-wrap: anywhere;
}

.audit-page {
  display: grid;
  gap: 16px;
}

.audit-filters {
  display: grid;
  grid-template-columns: minmax(190px, .9fr) minmax(260px, 1.25fr) minmax(150px, .6fr) minmax(150px, .6fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.audit-filters label {
  min-width: 0;
  gap: 7px;
}

.audit-filters label span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: #475569;
  font-size: 13px;
  font-weight: 750;
}

.audit-panel {
  padding: 18px;
}

.audit-panel .ui-table {
  min-width: 1050px;
}

.audit-panel td {
  vertical-align: middle;
}

.audit-detail-modal {
  width: min(980px, calc(100vw - 32px));
}

.audit-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.audit-detail-summary div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: #F8FAFC;
}

.audit-detail-summary span {
  color: #64748B;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.audit-detail-summary strong {
  overflow-wrap: anywhere;
  color: #0F172A;
  font-size: 13px;
}

.audit-json-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audit-json-block:last-child {
  grid-column: 1 / -1;
}

.audit-json-block {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: #FFFFFF;
}

.audit-json-block h3 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #E2E8F0;
  color: #0F172A;
  font-size: 13px;
}

.audit-json-block pre {
  max-height: 280px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: #334155;
  background: #F8FAFC;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-backdrop {
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(520px, 100%);
  padding: 26px;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .18);
}

.modal h2 {
  font-family: inherit;
  font-size: 22px;
  font-weight: 720;
}

.modal-close {
  border-radius: 10px;
}

.modal-close:hover {
  background: #F1F5F9;
}

.modal-actions {
  gap: 10px;
}

.invite-modal {
  width: min(560px, calc(100vw - 32px));
  padding: 28px;
}

.modal-heading {
  display: grid;
  gap: 8px;
  padding-right: 44px;
  margin-bottom: 22px;
}

.modal-heading .eyebrow {
  margin: 0;
  color: #2563EB;
  font-size: 12px;
  letter-spacing: .12em;
}

.modal-heading h2 {
  margin: 0;
  color: #0F172A;
  font-size: 26px;
  line-height: 1.18;
}

.modal-heading .muted {
  margin: 0;
  color: #64748B;
  font-size: 15px;
  line-height: 1.55;
}

.modal-form-grid {
  display: grid;
  gap: 16px;
}

.modal-form-grid label {
  display: grid;
  gap: 7px;
  margin: 0;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.modal-form-grid .ui-input,
.modal-form-grid input,
.modal-form-grid select {
  min-height: 46px;
  padding: 10px 13px;
  font-size: 15px;
  font-weight: 600;
}

.invite-modal .form-error {
  margin: 16px 0 0;
}

.invite-modal .modal-actions {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #E2E8F0;
}

.invite-modal .modal-actions .ui-button {
  min-width: 118px;
}

.ui-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  color: #64748B;
  background: #FFFFFF;
  border: 1px dashed #CBD5E1;
  border-radius: 16px;
  text-align: center;
}

.ui-state strong {
  color: #0F172A;
}

.ui-state p {
  max-width: 460px;
  margin: 0;
  color: #64748B;
  font-size: 14px;
}

.ui-state-marker {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
}

.ui-state-error {
  border-style: solid;
  border-color: #FECACA;
}

.ui-state-error .ui-state-marker {
  background: #FEE2E2;
  border-color: #FECACA;
}

.ui-toast {
  position: sticky;
  top: 0;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-bottom: 16px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid #BBF7D0;
  background: #F0FDF4;
  color: #15803D;
  font-size: 14px;
  font-weight: 650;
}

.ui-toast-error {
  border-color: #FECACA;
  background: #FEF2F2;
  color: #B91C1C;
}

.export-menu {
  position: relative;
  display: inline-flex;
}

.export-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  display: grid;
  min-width: 240px;
  padding: 8px;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #FFFFFF;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .14);
}

.export-menu-panel button,
.export-anonymize {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.export-menu-panel button:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.export-anonymize {
  color: #64748B;
  border-bottom: 1px solid #E2E8F0;
  border-radius: 10px 10px 0 0;
  margin-bottom: 6px;
}

.export-anonymize input {
  min-height: 0;
}

.auto-refresh-status {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: fit-content;
  margin: -12px 0 18px;
  padding: 7px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  background: #FFFFFF;
  color: #64748B;
  font-size: 12px;
  font-weight: 650;
}

.auto-refresh-status > span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94A3B8;
}

.auto-refresh-status > span.is-on {
  background: #16A34A;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, .12);
}

.auto-refresh-status > span.is-off {
  background: #F59E0B;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .12);
}

.auto-refresh-status strong {
  color: #334155;
  font-weight: 700;
}

.auto-refresh-status small {
  color: #64748B;
  font-size: inherit;
  font-weight: 700;
}

.auto-refresh-status em {
  color: #B45309;
  font-style: normal;
}

.ui-table tbody tr.row-updated,
.clickable-row.row-updated {
  background: #EFF6FF;
  transition: background-color 1.8s ease;
}

.detail-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.detail-summary-grid div {
  padding: 14px;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #F8FAFC;
}

.detail-summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: #64748B;
  font-size: 12px;
  font-weight: 650;
}

.detail-summary-grid strong {
  color: #0F172A;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.detail-summary-wide {
  grid-column: span 2;
}

.dialog-chat-panel {
  overflow: hidden;
}

.dialog-chat-title {
  padding: 0;
}

.dialog-message-stream {
  display: grid;
  gap: 16px;
  min-height: 420px;
  max-height: min(680px, 62vh);
  overflow-y: auto;
  padding: 8px 0 2px;
  overscroll-behavior: contain;
}

.chat-bubble-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 78%;
}

.chat-bubble-row.bot {
  justify-self: end;
  flex-direction: row-reverse;
}

.chat-bubble {
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.chat-bubble-row.bot .chat-bubble {
  background: #EFF6FF;
  border-color: #BFDBFE;
}

.chat-bubble p {
  margin: 0;
  color: #0F172A;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chat-bubble time {
  display: block;
  margin-top: 8px;
  color: #64748B;
  font-size: 12px;
}

.message-technical {
  margin-top: 10px;
}

.message-technical summary {
  color: #64748B;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.message-technical pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  background: #0F172A;
  color: #E2E8F0;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .dashboard-analytics-grid,
  .detail-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-span-2 {
    grid-column: span 2;
  }

  .dialog-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .users-page .ui-table-wrap {
    overflow-x: auto;
  }

  .users-page .ui-table {
    min-width: 980px;
    table-layout: auto;
  }

  .users-page .staff-panel {
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #E2E8F0;
    padding: 14px;
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .sidebar nav a {
    white-space: nowrap;
  }

  .sidebar-bottom {
    display: none;
  }

  .page {
    padding: 20px 14px;
  }

  .crm-page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header-actions {
    justify-content: flex-start;
  }

  .metric-grid,
  .dashboard-grid,
  .dashboard-analytics-grid,
  .dialog-filters,
  .detail-summary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-span-2 {
    grid-column: auto;
  }

  .period-select {
    width: 100%;
  }

  .detail-summary-wide {
    grid-column: auto;
  }

  .chat-bubble-row {
    max-width: 100%;
  }
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .app-shell {
  background: #0B1120;
  color: #E5E7EB;
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .ui-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ui-dropdown-panel,
:root[data-theme="dark"] .chat-bubble {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] .logo span,
:root[data-theme="dark"] .kpi-card strong,
:root[data-theme="dark"] .panel-title h2,
:root[data-theme="dark"] .detail-summary-grid strong,
:root[data-theme="dark"] .chat-bubble p,
:root[data-theme="dark"] .profile-chip strong,
:root[data-theme="dark"] .ui-state strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .crm-page-header p,
:root[data-theme="dark"] .logo small,
:root[data-theme="dark"] .kpi-card span,
:root[data-theme="dark"] .kpi-card small,
:root[data-theme="dark"] .panel-title span,
:root[data-theme="dark"] .detail-summary-grid span,
:root[data-theme="dark"] .profile-chip small,
:root[data-theme="dark"] .ui-state p,
:root[data-theme="dark"] .chat-bubble time {
  color: #CBD5E1;
}

:root[data-theme="dark"] .sidebar nav a,
:root[data-theme="dark"] .theme-toggle {
  color: #CBD5E1;
}

:root[data-theme="dark"] .sidebar nav a svg,
:root[data-theme="dark"] .theme-toggle svg {
  color: #94A3B8;
}

:root[data-theme="dark"] .sidebar nav a:hover,
:root[data-theme="dark"] .theme-toggle:hover,
:root[data-theme="dark"] .profile-chip-link:hover,
:root[data-theme="dark"] .ui-table tbody tr:hover,
:root[data-theme="dark"] .clickable-row:hover,
:root[data-theme="dark"] .ui-dropdown-item:hover {
  background: #1E293B;
  color: #F8FAFC;
}

:root[data-theme="dark"] .sidebar nav a.active {
  background: #172554;
  color: #BFDBFE;
  box-shadow: inset 3px 0 #60A5FA;
}

:root[data-theme="dark"] .sidebar nav a.active svg {
  color: #93C5FD;
}

:root[data-theme="dark"] .profile-chip,
:root[data-theme="dark"] .detail-summary-grid div,
:root[data-theme="dark"] .ui-state,
:root[data-theme="dark"] .ui-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .ui-button,
:root[data-theme="dark"] .button,
:root[data-theme="dark"] .ui-dropdown-trigger {
  background: #0F172A;
  border-color: #334155;
  color: #E5E7EB;
}

:root[data-theme="dark"] .ui-table th,
:root[data-theme="dark"] th {
  background: #111827;
  color: #94A3B8;
  border-color: #334155;
}

:root[data-theme="dark"] .ui-table td,
:root[data-theme="dark"] td {
  color: #E5E7EB;
  border-color: #273449;
}

:root[data-theme="dark"] .activity-bar-track,
:root[data-theme="dark"] .progress {
  background: #334155;
}

:root[data-theme="dark"] .chat-bubble-row.bot .chat-bubble {
  background: #172554;
  border-color: #1D4ED8;
}

:root[data-theme="dark"] .ui-dropdown-item {
  color: #E5E7EB;
}

:root[data-theme="dark"] .ui-dropdown-item.danger {
  color: #FCA5A5;
}

:root[data-theme="dark"] .ui-dropdown-item.danger:hover {
  background: rgba(220, 38, 38, .18);
}

:root[data-theme="dark"] .modal-heading h2 {
  color: #F8FAFC;
}

:root[data-theme="dark"] .modal-heading .muted,
:root[data-theme="dark"] .modal-form-grid label {
  color: #CBD5E1;
}

:root[data-theme="dark"] .invite-modal .modal-actions {
  border-top-color: #334155;
}

:root[data-theme="dark"] .auto-refresh-status {
  background: #111827;
  border-color: #334155;
  color: #CBD5E1;
}

:root[data-theme="dark"] .auto-refresh-status strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .auto-refresh-status small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .auto-refresh-status em {
  color: #FDE68A;
}

:root[data-theme="dark"] .ui-table tbody tr.row-updated,
:root[data-theme="dark"] .clickable-row.row-updated {
  background: #172554;
}

:root[data-theme="dark"] .chart-legend-list span,
:root[data-theme="dark"] .chart-legend-list strong,
:root[data-theme="dark"] .distribution-row strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .chart-card .panel-title h2,
:root[data-theme="dark"] .chart-card-title h2,
:root[data-theme="dark"] .panel-title h2 {
  color: #F8FAFC;
}

:root[data-theme="dark"] .chart-card .panel-title span,
:root[data-theme="dark"] .chart-card-title span,
:root[data-theme="dark"] .panel-title span {
  color: #CBD5E1;
}

:root[data-theme="dark"] .chart-legend-list,
:root[data-theme="dark"] .distribution-row span,
:root[data-theme="dark"] .distribution-row small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .distribution-track {
  background: #334155;
}

:root[data-theme="dark"] .recharts-cartesian-grid line {
  stroke: var(--chart-grid-strong);
  opacity: .72;
}

:root[data-theme="dark"] .recharts-text,
:root[data-theme="dark"] .recharts-cartesian-axis-tick-value {
  fill: var(--chart-axis);
}

:root[data-theme="dark"] .recharts-tooltip-wrapper {
  color: #0F172A;
}

:root[data-theme="dark"] .recharts-default-tooltip {
  background: var(--chart-tooltip-bg) !important;
  border-color: var(--chart-tooltip-border) !important;
  color: var(--chart-tooltip-text) !important;
}

:root[data-theme="dark"] .recharts-tooltip-label,
:root[data-theme="dark"] .recharts-tooltip-item {
  color: var(--chart-tooltip-text) !important;
}

:root[data-theme="dark"] .activity-chart-legend span {
  color: #CBD5E1;
}

/* Dialogs workspace refinement */

.crm-dialogs-page {
  max-width: 1440px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.crm-dialogs-page .auto-refresh-status {
  margin: -10px 0 4px;
}

.crm-dialogs-page .dialog-filters {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) repeat(4, minmax(150px, .6fr)) auto;
  gap: 12px;
  align-items: end;
  margin: 0;
  padding: 16px;
  border-radius: 16px;
}

.crm-dialogs-page .mobile-filters-toggle {
  display: none;
}

.crm-dialogs-page .dialog-filters label {
  min-width: 0;
  margin: 0;
  gap: 7px;
}

.crm-dialogs-page .dialog-filters label span {
  color: #475569;
  font-size: 13px;
  font-weight: 750;
}

.crm-dialogs-page .dialog-filters .ui-input {
  min-height: 38px;
  font-size: 13px;
}

.crm-dialogs-page .filter-actions {
  padding: 0;
}

.crm-dialogs-page .dialogs-table-panel {
  margin: 4px 0 0;
  padding: 0;
  overflow: hidden;
}

.crm-dialogs-page .ui-table-wrap {
  max-height: calc(100vh - 360px);
  min-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
}

.crm-dialogs-page .ui-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.crm-dialogs-page .ui-table th {
  top: 0;
  z-index: 3;
  background: #FFFFFF;
}

.crm-dialogs-page .ui-table th,
.crm-dialogs-page .ui-table td {
  padding: 13px 14px;
}

.crm-dialogs-page .ui-table th:nth-child(1),
.crm-dialogs-page .ui-table td:nth-child(1) {
  width: 9%;
}

.crm-dialogs-page .ui-table th:nth-child(2),
.crm-dialogs-page .ui-table td:nth-child(2) {
  width: 12%;
}

.crm-dialogs-page .ui-table th:nth-child(3),
.crm-dialogs-page .ui-table td:nth-child(3) {
  width: 10%;
}

.crm-dialogs-page .ui-table th:nth-child(4),
.crm-dialogs-page .ui-table td:nth-child(4) {
  width: 11%;
}

.crm-dialogs-page .ui-table th:nth-child(5),
.crm-dialogs-page .ui-table td:nth-child(5) {
  width: 22%;
}

.crm-dialogs-page .ui-table th:nth-child(6),
.crm-dialogs-page .ui-table td:nth-child(6) {
  width: 19%;
}

.crm-dialogs-page .ui-table th:nth-child(7),
.crm-dialogs-page .ui-table td:nth-child(7) {
  width: 6%;
}

.crm-dialogs-page .ui-table th:nth-child(8),
.crm-dialogs-page .ui-table td:nth-child(8) {
  width: 11%;
}

.crm-dialogs-page .cell-truncate {
  max-width: none;
  min-height: 0;
  color: #334155;
  line-height: 1.35;
  word-break: break-word;
  -webkit-line-clamp: 2;
}

.crm-dialogs-page .ui-table tbody tr {
  height: 72px;
}

.crm-dialogs-page .ui-table td {
  overflow: hidden;
}

.crm-dialogs-page td strong {
  color: #0F172A;
}

.crm-dialogs-page td small {
  color: #64748B;
  font-size: 12px;
}

.crm-dialogs-page .table-date {
  display: grid;
  gap: 3px;
}

.crm-dialogs-page .table-date strong {
  font-size: 13px;
}

.crm-dialogs-page .table-date small {
  margin: 0;
}

.crm-dialogs-page .dialogs-list-panel {
  min-height: 0;
}

.crm-dialogs-page .dialogs-list-head {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(320px, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #E2E8F0;
  background: #FFFFFF;
  color: #64748B;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.crm-dialogs-page .dialogs-list {
  display: grid;
  max-height: calc(100vh - 360px);
  min-height: 280px;
  overflow-y: auto;
}

.crm-dialogs-page .dialogs-load-more {
  display: flex;
  justify-content: center;
  padding: 14px 18px 18px;
  border-top: 1px solid #E2E8F0;
  background: #FFFFFF;
}

.crm-dialogs-page .dialog-list-row {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(320px, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: center;
  width: 100%;
  min-height: 92px;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid #E2E8F0;
  background: #FFFFFF;
  color: #334155;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.crm-dialogs-page .dialog-list-row:hover {
  background: #F8FAFC;
}

.crm-dialogs-page .dialog-list-row:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .18);
  outline-offset: -3px;
}

.crm-dialogs-page .dialog-list-row.row-updated {
  background: #EFF6FF;
}

.crm-dialogs-page .dialog-list-skeleton-row {
  cursor: default;
  pointer-events: none;
}

.crm-dialogs-page .skeleton-stack {
  display: grid;
  gap: 8px;
}

.crm-dialogs-page .skeleton-stack i {
  display: block;
  height: 12px;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #E2E8F0 0%, #F8FAFC 45%, #E2E8F0 100%);
  background-size: 220% 100%;
  animation: dialogs-skeleton 1.25s ease-in-out infinite;
}

.crm-dialogs-page .skeleton-stack i:nth-child(1) {
  width: 62%;
}

.crm-dialogs-page .skeleton-stack i:nth-child(2) {
  width: 86%;
}

.crm-dialogs-page .skeleton-stack i:nth-child(3) {
  width: 48%;
}

@keyframes dialogs-skeleton {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

.crm-dialogs-page .dialog-list-user,
.crm-dialogs-page .dialog-list-message,
.crm-dialogs-page .dialog-list-result {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.crm-dialogs-page .dialog-user-id-line {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.crm-dialogs-page .dialog-list-user strong {
  overflow: hidden;
  color: #0F172A;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-dialogs-page .copy-telegram-id-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #94A3B8;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.crm-dialogs-page .copy-telegram-id-button:hover {
  border-color: #BFDBFE;
  background: #EFF6FF;
  color: #2563EB;
}

.crm-dialogs-page .copy-telegram-id-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22);
  outline-offset: 2px;
}

.crm-dialogs-page .copy-telegram-id-button.is-copied {
  border-color: #BBF7D0;
  background: #DCFCE7;
  color: #16A34A;
}

.crm-dialogs-page .dialog-list-user small,
.crm-dialogs-page .dialog-list-user time {
  overflow: hidden;
  color: #64748B;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-dialogs-page .dialog-list-message strong,
.crm-dialogs-page .dialog-list-message small,
.crm-dialogs-page .dialog-list-result small {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-height: 1.42;
  word-break: break-word;
}

.crm-dialogs-page .dialog-list-message strong {
  color: #0F172A;
  font-size: 14px;
  font-weight: 750;
  -webkit-line-clamp: 1;
}

.crm-dialogs-page .dialog-list-address strong {
  -webkit-line-clamp: 2;
}

.crm-dialogs-page .dialog-list-address strong.is-muted {
  color: #94A3B8;
  font-weight: 700;
}

.crm-dialogs-page .dialog-list-message small {
  color: #64748B;
  font-size: 13px;
  -webkit-line-clamp: 2;
}

.crm-dialogs-page .dialog-list-result > span {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crm-dialogs-page .dialog-list-result small {
  color: #64748B;
  font-size: 13px;
  -webkit-line-clamp: 2;
}

@media (max-width: 1180px) {
  .crm-dialogs-page .dialog-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-dialogs-page .dialogs-list-head,
  .crm-dialogs-page .dialog-list-row {
    grid-template-columns: minmax(180px, 220px) minmax(260px, 1fr) minmax(220px, 280px);
  }
}

@media (max-width: 768px) {
  .crm-dialogs-page .dialog-filters {
    grid-template-columns: 1fr;
  }

  .audit-filters,
  .audit-detail-summary,
  .audit-json-grid {
    grid-template-columns: 1fr;
  }

  .audit-json-block:last-child {
    grid-column: auto;
  }

  .crm-dialogs-page .dialogs-list-head {
    display: none;
  }

  .crm-dialogs-page .dialogs-list {
    max-height: none;
  }

  .crm-dialogs-page .dialog-list-row {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
    padding: 16px;
  }

  .crm-dialogs-page .ui-table-wrap {
    max-height: none;
    overflow-x: auto;
  }

  .crm-dialogs-page .ui-table {
    min-width: 980px;
  }
}

:root[data-theme="dark"] .crm-dialogs-page .ui-table th {
  background: #111827;
}

:root[data-theme="dark"] .crm-dialogs-page .cell-truncate,
:root[data-theme="dark"] .crm-dialogs-page td strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .crm-dialogs-page td small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .crm-dialogs-page .dialogs-list-head,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row:hover {
  background: #0F172A;
}

:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row.row-updated {
  background: #172554;
}

:root[data-theme="dark"] .crm-dialogs-page .dialog-list-user strong,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-message strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .crm-dialogs-page .dialog-list-user small,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-user time,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-message small,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-result small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .audit-filters label span,
:root[data-theme="dark"] .audit-detail-summary span {
  color: #CBD5E1;
}

:root[data-theme="dark"] .audit-detail-summary div,
:root[data-theme="dark"] .audit-json-block pre {
  background: #0F172A;
  border-color: #334155;
}

:root[data-theme="dark"] .audit-detail-summary strong,
:root[data-theme="dark"] .audit-json-block h3 {
  color: #F8FAFC;
}

:root[data-theme="dark"] .audit-json-block {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] .audit-json-block h3 {
  border-bottom-color: #334155;
}

:root[data-theme="dark"] .audit-json-block pre {
  color: #CBD5E1;
}

:root[data-theme="dark"] .ui-toast-error {
  border-color: #7F1D1D;
  background: #2A1216;
  color: #FCA5A5;
}

:root[data-theme="dark"] .export-menu-panel {
  background: #111827;
  border-color: #334155;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .36);
}

:root[data-theme="dark"] .export-menu-panel button,
:root[data-theme="dark"] .export-anonymize {
  color: #CBD5E1;
}

:root[data-theme="dark"] .export-menu-panel button:hover {
  background: #1E293B;
  color: #F8FAFC;
}

:root[data-theme="dark"] .export-anonymize {
  border-bottom-color: #334155;
}

/* Responsive CRM UI refresh */

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-width: 0;
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
  grid-template-columns: 260px minmax(0, 1fr);
  background: #F8FAFC;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 14px 16px;
  background: #FFFFFF;
  border-right: 1px solid #E2E8F0;
}

.mobile-topbar,
.mobile-nav-backdrop,
.mobile-drawer-close {
  display: none;
}

.workspace {
  min-width: 0;
  background: #F8FAFC;
}

.page,
.page-fluid {
  width: 100%;
  max-width: none;
  padding: clamp(18px, 2.2vw, 32px);
}

.crm-page-header,
.page-header {
  gap: 16px;
}

.crm-page-header h1,
.page-header h1 {
  font-size: clamp(28px, 3vw, 32px);
  line-height: 1.1;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ui-button,
.button,
.ui-input,
input,
select,
textarea,
.ui-dropdown-trigger {
  min-height: 40px;
}

.panel,
.ui-card,
.metric-card,
.chart-card,
.staff-panel,
.roles-panel,
.dialogs-table-panel,
.dialog-summary-panel,
.dialog-chat-panel,
.audit-panel,
.audit-filters,
.dialog-filters {
  border-radius: 18px;
  border-color: #E2E8F0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.metric-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-analytics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.dialog-filters,
.crm-dialogs-page .dialog-filters {
  grid-template-columns: minmax(280px, 1.5fr) minmax(170px, .75fr) minmax(170px, .75fr) minmax(280px, 1fr) auto;
  gap: 12px;
}

.date-range-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.date-range-filter label {
  min-width: 0;
}

.date-range-filter .filter-error {
  grid-column: 1 / -1;
  color: #DC2626;
  font-size: 12px;
  font-weight: 700;
}

.dialogs-list-head,
.crm-dialogs-page .dialogs-list-head,
.dialog-list-row,
.crm-dialogs-page .dialog-list-row {
  grid-template-columns: minmax(190px, 240px) minmax(260px, 1fr) minmax(230px, 320px);
}

.dialog-detail-page {
  display: grid;
  gap: 16px;
}

.dialog-summary-panel {
  position: sticky;
  top: 16px;
  z-index: 4;
}

.detail-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chat-bubble-row {
  max-width: min(78%, 860px);
}

.chat-bubble {
  border-radius: 16px;
}

.users-page .staff-panel,
.audit-panel {
  overflow: hidden;
}

.users-page .ui-table-wrap,
.audit-panel .ui-table-wrap {
  overflow-x: auto;
}

.users-page .ui-table,
.audit-panel .ui-table {
  min-width: 980px;
}

.modal {
  max-height: min(88vh, 760px);
  overflow-y: auto;
}

.invite-modal {
  width: min(640px, calc(100vw - 32px));
}

:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .workspace {
  background: #0F172A;
}

:root[data-theme="dark"] .sidebar {
  background: #111827;
  border-right-color: #334155;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 10px;
  }

  .sidebar .logo span,
  .sidebar .logo small,
  .sidebar nav a,
  .sidebar-bottom .theme-toggle span,
  .sidebar-bottom .profile-chip-link,
  .sidebar-bottom .profile-chip button {
    font-size: 0;
  }

  .sidebar nav a,
  .sidebar-bottom .theme-toggle {
    justify-content: center;
  }

  .sidebar-bottom .profile-chip {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-span-2 {
    grid-column: auto;
  }

  .dialog-filters,
  .crm-dialogs-page .dialog-filters,
  .audit-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid #E2E8F0;
    backdrop-filter: blur(14px);
  }

  .mobile-brand-icon {
    display: block;
    flex: 0 0 auto;
  }

  .mobile-topbar strong,
  .mobile-topbar small {
    display: block;
  }

  .mobile-topbar strong {
    color: #0F172A;
    font-size: 15px;
  }

  .mobile-topbar small {
    color: #64748B;
    font-size: 12px;
  }

  .mobile-menu-button,
  .mobile-drawer-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    background: #FFFFFF;
    color: #0F172A;
  }

  .mobile-drawer-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    border: 0;
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(2px);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    width: min(340px, 86vw);
    height: 100dvh;
    max-height: 100dvh;
    padding: 20px 16px max(16px, env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 58%, #F8FAFC 100%);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 24px 0 80px rgba(15, 23, 42, .22);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar .logo span,
  .sidebar .logo small,
  .sidebar nav a,
  .sidebar-bottom .theme-toggle span {
    font-size: revert;
  }

  .sidebar .logo {
    flex: 0 0 auto;
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 2px 14px;
    min-height: 64px;
    padding: 2px 54px 12px 2px;
  }

  .sidebar .brand-icon {
    width: 60px;
    height: 60px;
  }

  .sidebar .logo span {
    font-size: 23px;
    line-height: 1.1;
  }

  .sidebar .logo small {
    font-size: 15px;
  }

  .sidebar nav {
    flex: 0 0 auto;
    display: grid;
    align-content: start;
    grid-auto-rows: auto;
    gap: 6px;
    margin: 18px 0 12px;
    padding: 0;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .sidebar nav a,
  .sidebar-bottom .theme-toggle {
    justify-content: flex-start;
  }

  .sidebar nav a {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 12px;
    gap: 12px;
    border-radius: 14px;
    color: #475569;
    font-size: 15px;
    font-weight: 750;
    line-height: 1.2;
    white-space: normal;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }

  .sidebar nav a:hover {
    background: #F8FAFC;
    color: #0F172A;
  }

  .sidebar nav a.active {
    background: #EFF6FF;
    color: #2563EB;
    box-shadow: inset 3px 0 #2563EB;
  }

  .sidebar nav a svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
  }

  .sidebar-bottom .profile-chip {
    grid-template-columns: 42px minmax(0, 1fr) 32px;
    justify-items: stretch;
  }

  .sidebar-bottom {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 12px;
    border-top-color: #E5EAF1;
  }

  .sidebar-bottom .profile-chip-link,
  .sidebar-bottom .profile-chip button {
    font-size: revert;
  }

  .workspace {
    min-width: 0;
    min-height: auto;
    overflow: visible;
  }

  .page,
  .page-fluid {
    padding: 16px;
  }

  .crm-page-header,
  .page-header {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 16px;
  }

  .page-header-actions,
  .crm-page-header .page-header-actions {
    width: 100%;
  }

  .page-header-actions > *,
  .crm-page-header .page-header-actions > * {
    flex: 1 1 auto;
  }

  .repair-status-control {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
    width: 100%;
  }

  .repair-status-control .ui-select {
    min-width: 0;
    width: 100%;
  }

  .auto-refresh-status {
    width: 100%;
    overflow: hidden;
    white-space: normal;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

.metric-card,
.chart-card,
.staff-panel,
  .roles-panel,
  .dialog-summary-panel,
  .dialog-chat-panel,
  .audit-panel {
    border-radius: 16px;
    padding: 16px;
  }

  .metric-card strong {
    font-size: 26px;
  }

  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-card {
    min-height: 0;
  }

  .chart-card-body {
    min-height: 230px;
  }

  .dialog-filters,
  .crm-dialogs-page .dialog-filters,
  .audit-filters {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .date-range-filter {
    grid-template-columns: 1fr;
  }

  .crm-dialogs-page .mobile-filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    background: #FFFFFF;
    color: #0F172A;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    font-size: 15px;
    font-weight: 800;
  }

  .crm-dialogs-page .mobile-filters-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .crm-dialogs-page .mobile-filters-toggle strong {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #2563EB;
    color: #FFFFFF;
    font-size: 12px;
    line-height: 1;
  }

  .crm-dialogs-page .mobile-filters-toggle > svg {
    flex: 0 0 auto;
    color: #64748B;
    transition: transform 160ms ease;
  }

  .crm-dialogs-page .mobile-filters-toggle.is-open > svg {
    transform: rotate(180deg);
  }

  .crm-dialogs-page .dialog-filters {
    display: none;
    margin-top: -6px;
  }

  .crm-dialogs-page .dialog-filters.filters-open {
    display: grid;
  }

  .dialogs-list-head,
  .crm-dialogs-page .dialogs-list-head {
    display: none;
  }

  .dialogs-list,
  .crm-dialogs-page .dialogs-list {
    max-height: none;
    min-height: 0;
  }

  .dialog-list-row,
  .crm-dialogs-page .dialog-list-row {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid #E2E8F0;
    margin-bottom: 10px;
  }

  .dialogs-list-panel,
  .crm-dialogs-page .dialogs-list-panel {
    padding: 10px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .dialog-summary-panel {
    position: static;
  }

  .detail-summary-grid {
    grid-template-columns: 1fr;
  }

  .detail-summary-wide {
    grid-column: auto;
  }

  .dialog-message-stream {
    padding: 14px;
  }

  .chat-bubble-row,
  .chat-bubble-row.bot {
    max-width: 100%;
  }

  .message-avatar {
    display: none;
  }

  .message-badges {
    gap: 5px;
  }

  .users-page .ui-table-wrap {
    overflow: visible;
  }

  .users-page .ui-table,
  .users-page .ui-table thead,
  .users-page .ui-table tbody,
  .users-page .ui-table tr,
  .users-page .ui-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .users-page .ui-table thead {
    display: none;
  }

  .users-page .ui-table tr {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    background: #FFFFFF;
  }

  .users-page .ui-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border: 0;
  }

  .users-page .ui-table td::before {
    content: "";
    color: #64748B;
    font-size: 12px;
    font-weight: 750;
  }

  .users-page .ui-table td:nth-child(1)::before { content: "Сотрудник"; }
  .users-page .ui-table td:nth-child(2)::before { content: "Email"; }
  .users-page .ui-table td:nth-child(3)::before { content: "Роль"; }
  .users-page .ui-table td:nth-child(4)::before { content: "Статус"; }
  .users-page .ui-table td:nth-child(5)::before { content: "Последний вход"; }
  .users-page .ui-table td:nth-child(6)::before { content: "Создан"; }
  .users-page .ui-table td:nth-child(7)::before { content: "Действия"; }

  .users-page .staff-actions {
    justify-content: flex-end;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal,
  .invite-modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding: 22px 18px;
  }

  .modal-actions {
    position: sticky;
    bottom: -22px;
    margin: 18px -18px -22px;
    padding: 14px 18px;
    background: var(--surface);
    border-top: 1px solid var(--line);
  }

  .login-page {
    padding: 16px;
  }

  .login-card,
  .login-panel {
    width: 100%;
  }

  :root[data-theme="dark"] .mobile-topbar {
    background: rgba(17, 24, 39, .94);
    border-bottom-color: #334155;
  }

  :root[data-theme="dark"] .mobile-topbar strong,
  :root[data-theme="dark"] .mobile-menu-button {
    color: #F8FAFC;
  }

  :root[data-theme="dark"] .mobile-topbar small {
    color: #CBD5E1;
  }

  :root[data-theme="dark"] .mobile-menu-button,
  :root[data-theme="dark"] .mobile-drawer-close,
  :root[data-theme="dark"] .crm-dialogs-page .mobile-filters-toggle,
  :root[data-theme="dark"] .users-page .ui-table tr,
  :root[data-theme="dark"] .dialog-list-row,
  :root[data-theme="dark"] .crm-dialogs-page .dialog-list-row {
    background: #111827;
    border-color: #334155;
  }

  :root[data-theme="dark"] .crm-dialogs-page .mobile-filters-toggle {
    color: #F8FAFC;
  }

  :root[data-theme="dark"] .crm-dialogs-page .mobile-filters-toggle > svg {
    color: #CBD5E1;
  }
}

@media (max-width: 430px) {
  .sidebar {
    width: min(320px, 90vw);
    padding: 18px 14px max(14px, env(safe-area-inset-bottom));
  }

  .mobile-drawer-close {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .sidebar .logo {
    padding-right: 48px;
  }

  .sidebar .logo span {
    font-size: 21px;
  }

  .sidebar nav {
    gap: 5px;
    margin: 14px 0 10px;
  }

  .sidebar nav a {
    min-height: 46px;
    padding: 10px 11px;
    border-radius: 12px;
    font-size: 14px;
  }

  .sidebar-bottom .profile-chip {
    grid-template-columns: 40px minmax(0, 1fr) 32px;
    gap: 8px;
  }

  .sidebar-bottom .profile-chip .avatar {
    width: 40px;
    height: 40px;
  }
}

/* Sidebar footer polish */

.sidebar-bottom {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid #E2E8F0;
  background: transparent;
}

.sidebar-bottom .theme-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #64748B;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-bottom .theme-toggle:hover {
  background: #F8FAFC;
  border-color: #E2E8F0;
  color: #0F172A;
}

.sidebar-bottom .profile-chip {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 8px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

.sidebar-bottom .profile-chip:hover {
  background: #F8FAFC;
}

.sidebar-bottom .profile-chip .avatar {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.sidebar-bottom .profile-chip-link {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  text-decoration: none;
}

.sidebar-bottom .profile-chip-link:hover {
  background: transparent;
}

.sidebar-bottom .profile-chip strong,
.sidebar-bottom .profile-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-bottom .profile-chip strong {
  color: #0F172A;
  font-size: 13px;
  font-weight: 800;
}

.sidebar-bottom .profile-chip small {
  color: #64748B;
  font-size: 12px;
  font-weight: 650;
}

.sidebar-bottom .profile-chip button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #64748B;
}

.sidebar-bottom .profile-chip button:hover {
  background: #E2E8F0;
}

:root[data-theme="dark"] .sidebar-bottom {
  border-top-color: #334155;
}

:root[data-theme="dark"] .sidebar-bottom .theme-toggle {
  background: transparent;
  border-color: transparent;
  color: #CBD5E1;
}

:root[data-theme="dark"] .sidebar-bottom .theme-toggle:hover,
:root[data-theme="dark"] .sidebar-bottom .profile-chip:hover {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip {
  background: transparent;
  border: 0;
  color: #E5E7EB;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip button:hover {
  background: #1E293B;
}

/* System page layout cleanup */

.system-page {
  max-width: none;
  display: grid;
  gap: 18px;
  align-content: start;
}

.system-page .page-header {
  margin-bottom: 2px;
}

.system-page .system-status-grid,
.system-page .system-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.system-page .system-panel,
.system-page .system-status-card {
  padding: 22px;
  border-radius: 16px;
}

.system-page .system-status-card {
  display: flex;
  align-items: center;
  min-height: 132px;
}

.system-page .panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.system-page .system-setting-row {
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 18px;
  min-height: 76px;
}

.system-page .system-setting-row strong {
  color: var(--text);
  font-size: 15px;
}

.system-page .system-account {
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 18px;
}

.system-page .system-account dl {
  display: grid;
  grid-template-columns: minmax(150px, .42fr) minmax(0, 1fr);
  gap: 0 24px;
  width: 100%;
}

.system-page .system-account dt,
.system-page .system-account dd {
  min-height: 30px;
  padding: 5px 0;
  border-bottom: 1px solid var(--row-line);
}

.system-page .system-account dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.system-page .system-account dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  overflow-wrap: anywhere;
}

.system-page .system-panel > .system-account {
  align-items: start;
}

.system-page > .system-panel .system-account dl {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
}

.system-page .system-checked-at {
  margin: 0;
  padding-right: 4px;
}

.sidebar-bottom {
  display: grid;
  gap: 10px;
}

.sidebar-bottom .theme-toggle {
  margin: 0;
}

.sidebar-bottom .profile-chip {
  margin-top: 0;
}

@media (max-width: 1180px) {
  .system-page .system-status-grid,
  .system-page .system-settings-grid {
    grid-template-columns: 1fr;
  }

  .system-page .system-account dl,
  .system-page > .system-panel .system-account dl {
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .system-page .system-setting-row,
  .system-page .system-account {
    grid-template-columns: 1fr;
  }

  .system-page .system-account dl,
  .system-page > .system-panel .system-account dl {
    grid-template-columns: 1fr;
  }

  .system-page .system-account dt {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .system-page .system-account dd {
    padding-top: 0;
  }
}

/* Operator takeover UI */

.dialog-detail-page .operator-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-detail-page .operator-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-detail-page .operator-panel-header h2 {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.dialog-detail-page .operator-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.dialog-detail-page .operator-compose {
  display: grid;
  gap: 12px;
}

.dialog-detail-page .operator-compose label {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 750;
}

.dialog-detail-page .operator-compose textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.dialog-detail-page .operator-compose textarea::placeholder {
  color: var(--muted);
}

.dialog-detail-page .operator-compose textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .14);
  outline: none;
}

.dialog-detail-page .operator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog-detail-page .operator-readonly,
.dialog-detail-page .operator-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
}

.dialog-detail-page .operator-readonly {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.dialog-detail-page .operator-error {
  border: 1px solid rgba(220, 38, 38, .22);
  background: #FEF2F2;
  color: #B91C1C;
}

.dialog-detail-page .dialog-message-stream {
  align-content: start;
}

.dialog-detail-page .chat-bubble-row {
  width: fit-content;
}

.dialog-detail-page .chat-bubble-row.client {
  justify-self: start;
}

.dialog-detail-page .chat-bubble-row.bot,
.dialog-detail-page .chat-bubble-row.operator {
  justify-self: end;
  flex-direction: row-reverse;
}

.dialog-detail-page .chat-bubble-row.system {
  justify-self: center;
  max-width: min(620px, 100%);
}

.dialog-detail-page .chat-bubble-row.system .message-avatar {
  display: none;
}

.dialog-detail-page .chat-bubble-row.operator .chat-bubble {
  border-color: rgba(37, 99, 235, .28);
  background: #EFF6FF;
}

.dialog-detail-page .chat-bubble-row.bot .chat-bubble {
  border-color: rgba(2, 132, 199, .22);
  background: #F0F9FF;
}

.dialog-detail-page .chat-bubble-row.system .chat-bubble {
  border-style: dashed;
  background: #F8FAFC;
  text-align: center;
}

.dialog-detail-page .message-sender {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.crm-dialogs-page .dialog-assigned {
  color: var(--primary) !important;
  font-weight: 800;
  -webkit-line-clamp: 1 !important;
}

:root[data-theme="dark"] .dialog-detail-page .operator-compose textarea {
  background: #0F172A;
  border-color: #334155;
  color: #F8FAFC;
}

:root[data-theme="dark"] .dialog-detail-page .operator-compose textarea::placeholder {
  color: #64748B;
}

:root[data-theme="dark"] .dialog-detail-page .operator-readonly {
  background: #0F172A;
  border-color: #334155;
  color: #CBD5E1;
}

:root[data-theme="dark"] .dialog-detail-page .operator-error {
  background: rgba(127, 29, 29, .22);
  border-color: rgba(248, 113, 113, .28);
  color: #FCA5A5;
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.operator .chat-bubble {
  background: rgba(37, 99, 235, .18);
  border-color: rgba(96, 165, 250, .35);
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.bot .chat-bubble {
  background: rgba(2, 132, 199, .14);
  border-color: rgba(56, 189, 248, .28);
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.system .chat-bubble {
  background: #0F172A;
  border-color: #334155;
}

:root[data-theme="dark"] .dialog-detail-page .message-sender {
  color: #CBD5E1;
}

:root[data-theme="dark"] .crm-dialogs-page .dialog-assigned {
  color: #93C5FD !important;
}

@media (max-width: 760px) {
  .dialog-detail-page .operator-panel {
    padding: 16px;
  }

  .dialog-detail-page .operator-panel-header,
  .dialog-detail-page .operator-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-detail-page .operator-actions .ui-button {
    width: 100%;
  }

  .dialog-detail-page .chat-bubble-row,
  .dialog-detail-page .chat-bubble-row.bot,
  .dialog-detail-page .chat-bubble-row.operator,
  .dialog-detail-page .chat-bubble-row.system {
    width: 100%;
    max-width: 100%;
  }
}

/* Dialog detail chat refresh */

.dialog-detail-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  min-height: calc(100dvh - 48px);
  max-width: none;
  overflow: visible;
  padding-bottom: 24px;
}

.dialog-detail-page .crm-page-header {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.dialog-detail-page .dialog-header-refresh {
  width: fit-content;
  margin-top: 10px;
}

.repair-status-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: #FFFFFF;
  color: #64748B;
  font-size: 13px;
  font-weight: 750;
}

.repair-status-control .ui-select {
  min-width: 190px;
  height: 38px;
  padding-top: 0;
  padding-bottom: 0;
}

.repair-status-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #E2E8F0;
  background: #F8FAFC;
}

.repair-status-panel-copy {
  display: grid;
  gap: 2px;
  min-width: 170px;
}

.repair-status-panel-copy strong {
  color: #0F172A;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
}

.repair-status-panel-copy span,
.repair-status-panel small {
  color: #64748B;
  font-size: 12px;
  font-weight: 750;
}

.repair-status-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.repair-status-segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  background: #FFFFFF;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.repair-status-segmented button:hover:not(:disabled) {
  border-color: #93C5FD;
  background: #EFF6FF;
  color: #1D4ED8;
}

.repair-status-segmented button.is-active {
  border-color: #2563EB;
  background: #2563EB;
  color: #FFFFFF;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}

.repair-status-segmented button:disabled {
  cursor: not-allowed;
  opacity: .68;
}

:root[data-theme="dark"] .repair-status-control {
  background: #111827;
  border-color: #334155;
  color: #CBD5E1;
}

:root[data-theme="dark"] .repair-status-panel {
  background: rgba(9, 14, 24, .64);
  border-bottom-color: rgba(148, 163, 184, .14);
}

:root[data-theme="dark"] .repair-status-panel-copy strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .repair-status-panel-copy span,
:root[data-theme="dark"] .repair-status-panel small {
  color: #A7B3C4;
}

:root[data-theme="dark"] .repair-status-segmented button {
  background: rgba(15, 23, 42, .74);
  border-color: rgba(148, 163, 184, .20);
  color: #CBD5E1;
}

:root[data-theme="dark"] .repair-status-segmented button:hover:not(:disabled) {
  background: rgba(96, 165, 250, .12);
  border-color: rgba(147, 197, 253, .34);
  color: #DBEAFE;
}

:root[data-theme="dark"] .repair-status-segmented button.is-active {
  background: linear-gradient(180deg, #3B82F6, #2563EB);
  border-color: rgba(147, 197, 253, .42);
  color: #FFFFFF;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .20);
}

.dialog-detail-page > .auto-refresh-status,
.dialog-detail-page > .ui-toast,
.dialog-detail-page > .ui-state {
  flex: 0 0 auto;
}

.dialog-detail-page .dialog-summary-panel {
  flex: 0 0 auto;
  margin-bottom: 0;
  padding: 14px;
}

.dialog-detail-page .dialog-detail-accordion {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
}

.dialog-detail-page .dialog-accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 64px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  text-align: left;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.dialog-detail-page .dialog-accordion-toggle:hover {
  background: var(--surface-subtle);
  border-color: #CBD5E1;
}

.dialog-detail-page .dialog-accordion-toggle > span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dialog-detail-page .dialog-accordion-toggle strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.dialog-detail-page .dialog-accordion-toggle small {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-detail-page .dialog-accordion-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.dialog-detail-page .dialog-accordion-action svg {
  transition: transform 160ms ease;
}

.dialog-detail-page .dialog-accordion-action svg.is-open {
  transform: rotate(180deg);
}

.dialog-detail-page .dialog-accordion-panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.dialog-detail-page .detail-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dialog-detail-page .detail-summary-grid div {
  min-width: 0;
  padding: 12px 13px;
}

.dialog-detail-page .dialog-control-panel {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.dialog-detail-page .dialog-control-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dialog-detail-page .dialog-control-status > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dialog-detail-page .dialog-control-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.dialog-detail-page .dialog-control-status strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-detail-page .dialog-control-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-detail-page .operator-inline-status {
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}

.dialog-detail-page .dialog-control-panel .operator-error,
.dialog-detail-page .dialog-control-panel .operator-readonly {
  grid-column: 1 / -1;
}

.dialog-detail-page .dialog-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.dialog-detail-page .dialog-main-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.dialog-detail-page .dialog-chat-panel {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100dvh - 260px));
  min-height: 520px;
  max-height: none;
  padding: 0;
  overflow: hidden;
}

.dialog-detail-page .dialog-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.dialog-detail-page .dialog-view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #F8FAFC;
}

.dialog-detail-page .dialog-view-tabs button {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.dialog-detail-page .dialog-view-tabs button:hover {
  color: var(--text);
}

.dialog-detail-page .dialog-view-tabs button.is-active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.dialog-detail-page .dialog-chat-header h2 {
  margin: 0 0 3px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.dialog-detail-page .dialog-chat-header span,
.dialog-detail-page .dialog-chat-header small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dialog-detail-page .dialog-message-stream {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, .72), rgba(248, 250, 252, .96));
}

.dialog-detail-page .chat-bubble-row,
.dialog-detail-page .chat-bubble-row.bot,
.dialog-detail-page .chat-bubble-row.operator,
.dialog-detail-page .chat-bubble-row.system {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  width: 100%;
  max-width: 100%;
}

.dialog-detail-page .chat-bubble-row.client {
  justify-content: flex-start;
}

.dialog-detail-page .chat-bubble-row.bot,
.dialog-detail-page .chat-bubble-row.operator {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

.dialog-detail-page .chat-bubble-row.system {
  justify-content: center;
}

.dialog-detail-page .chat-bubble {
  width: fit-content;
  max-width: min(640px, 75%);
  padding: 11px 13px;
  border-radius: 16px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dialog-detail-page .chat-bubble p {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.dialog-detail-page .chat-bubble-row.client .chat-bubble {
  background: #FFFFFF;
}

.dialog-detail-page .chat-bubble-row.bot .chat-bubble {
  background: #EAF3FF;
  border-color: #BFDBFE;
}

.dialog-detail-page .chat-bubble-row.operator .chat-bubble {
  background: #ECFDF5;
  border-color: #BBF7D0;
}

.dialog-detail-page .chat-bubble-row.system .chat-bubble {
  max-width: min(560px, 92%);
  padding: 8px 12px;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.dialog-detail-page .chat-bubble-row.system .message-sender,
.dialog-detail-page .chat-bubble-row.system .message-technical {
  display: none;
}

.dialog-detail-page .chat-bubble-row.system .chat-bubble p {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.dialog-detail-page .message-avatar {
  width: 30px;
  height: 30px;
  color: #FFFFFF;
  background: var(--primary);
}

.dialog-detail-page .chat-bubble-row.operator .message-avatar {
  background: var(--success);
}

.dialog-detail-page .chat-bubble-row.client .message-avatar {
  background: #64748B;
}

.dialog-detail-page .message-badges {
  gap: 5px;
  margin-top: 8px;
}

.dialog-detail-page .message-badges .ui-badge {
  font-size: 11px;
}

.dialog-detail-page .message-technical pre {
  max-width: min(680px, 64vw);
}

.dialog-detail-page .new-messages-button {
  position: absolute;
  right: 18px;
  bottom: 86px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 14px 34px rgba(37, 99, 235, .24);
  font-size: 13px;
  font-weight: 800;
  transition: background-color 160ms ease, transform 160ms ease;
}

.dialog-detail-page .new-messages-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.dialog-detail-page .dialog-composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.dialog-detail-page .dialog-composer textarea {
  width: 100%;
  min-height: 58px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #FFFFFF;
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  line-height: 1.45;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.dialog-detail-page .dialog-composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .14);
  outline: none;
}

.dialog-detail-page .dialog-composer textarea::placeholder {
  color: var(--muted);
}

.dialog-detail-page .client-requests-panel {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: min(760px, calc(100dvh - 120px));
  min-height: 520px;
  max-height: 760px;
  min-width: 0;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.dialog-detail-page .client-requests-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.dialog-detail-page .client-requests-head h2 {
  margin: 0 0 3px;
  color: var(--text);
  font-size: 17px;
  font-weight: 850;
}

.dialog-detail-page .client-requests-head span,
.dialog-detail-page .client-requests-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.dialog-detail-page .client-request-list {
  display: grid;
  align-content: start;
  flex: 1 1 auto;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 6px 8px 8px;
  border: 1px solid #EEF2F7;
  border-radius: 16px;
  background: #F8FAFC;
  scrollbar-color: #CBD5E1 transparent;
  scrollbar-width: thin;
}

.dialog-detail-page .client-request-list::-webkit-scrollbar {
  width: 8px;
}

.dialog-detail-page .client-request-list::-webkit-scrollbar-track {
  background: transparent;
}

.dialog-detail-page .client-request-list::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.dialog-detail-page .client-request-card {
  position: relative;
  display: grid;
  gap: 9px;
  width: 100%;
  min-height: 76px;
  align-content: center;
  padding: 13px 14px 13px 17px;
  overflow: hidden;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #FFFFFF;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dialog-detail-page .client-request-card::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: #94A3B8;
  content: "";
}

.dialog-detail-page .client-request-card:hover {
  border-color: rgba(37, 99, 235, .32);
  background: #FFFFFF;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
}

.dialog-detail-page .client-request-card.is-active {
  border-color: rgba(37, 99, 235, .55);
  background: #EFF6FF;
  box-shadow: 0 12px 26px rgba(37, 99, 235, .12);
}

.dialog-detail-page .client-request-card.is-active::before {
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary);
}

.dialog-detail-page .client-request-card.all-history {
  flex: 0 0 auto;
  background: #F8FAFC;
  min-height: 78px;
  padding: 13px 14px;
}

.dialog-detail-page .client-request-card.all-history::before {
  background: var(--primary);
}

.dialog-detail-page .client-request-card.ls_search::before {
  background: #16A34A;
}

.dialog-detail-page .client-request-card.balance_request::before {
  background: #F59E0B;
}

.dialog-detail-page .client-request-card.repair_request::before {
  background: #2563EB;
}

.dialog-detail-page .client-request-card.problem::before {
  background: #DC2626;
}

.dialog-detail-page .client-request-card.incomplete::before {
  background: #DC2626;
}

.dialog-detail-page .client-request-card-top {
  display: block;
  min-width: 0;
}

.dialog-detail-page .client-request-card strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
  min-width: 0;
}

.dialog-detail-page .client-request-card time,
.dialog-detail-page .client-request-card > span,
.dialog-detail-page .client-request-card p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.dialog-detail-page .client-request-card time {
  flex: 0 0 auto;
  color: #64748B;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.dialog-detail-page .client-request-status {
  justify-self: start;
  padding: 4px 10px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
}

.dialog-detail-page .client-request-status.repair_request,
.dialog-detail-page .client-request-status.balance_request {
  background: #FEF3C7;
  color: #92400E;
}

.dialog-detail-page .client-request-status.ls_search {
  background: #DCFCE7;
  color: #166534;
}

.dialog-detail-page .client-request-status.problem {
  background: #FEE2E2;
  color: #991B1B;
}

.dialog-detail-page .client-request-status.incomplete {
  background: #FEE2E2;
  color: #991B1B;
}

.dialog-detail-page .client-request-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.dialog-detail-page .client-request-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-detail-page .client-request-card p {
  overflow: hidden;
  display: -webkit-box;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-chat-header,
:root[data-theme="dark"] .dialog-detail-page .dialog-composer,
:root[data-theme="dark"] .dialog-detail-page .dialog-accordion-toggle,
:root[data-theme="dark"] .dialog-detail-page .dialog-accordion-panel,
:root[data-theme="dark"] .dialog-detail-page .client-requests-panel {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-view-tabs,
:root[data-theme="dark"] .dialog-detail-page .client-request-card,
:root[data-theme="dark"] .dialog-detail-page .client-request-card.all-history {
  background: #0F172A;
  border-color: #334155;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-list {
  background: #0B1220;
  border-color: #1E293B;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-view-tabs button.is-active,
:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active {
  background: #172554;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card strong,
:root[data-theme="dark"] .dialog-detail-page .client-requests-head h2 {
  color: #F8FAFC;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card time,
:root[data-theme="dark"] .dialog-detail-page .client-request-card > span,
:root[data-theme="dark"] .dialog-detail-page .client-request-meta,
:root[data-theme="dark"] .dialog-detail-page .client-request-card p,
:root[data-theme="dark"] .dialog-detail-page .client-requests-head span,
:root[data-theme="dark"] .dialog-detail-page .client-requests-head small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-accordion-toggle:hover {
  background: #0F172A;
  border-color: #475569;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-accordion-toggle strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-accordion-toggle small {
  color: #CBD5E1;
}

:root[data-theme="dark"] .dialog-detail-page .dialog-message-stream {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .88), rgba(15, 23, 42, .98));
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.client .chat-bubble {
  background: #111827;
  border-color: #334155;
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.bot .chat-bubble {
  background: rgba(37, 99, 235, .16);
  border-color: rgba(96, 165, 250, .34);
}

:root[data-theme="dark"] .dialog-detail-page .chat-bubble-row.operator .chat-bubble {
  background: rgba(22, 163, 74, .16);
  border-color: rgba(74, 222, 128, .32);
}

:root[data-theme="dark"] .dialog-detail-page .dialog-composer textarea {
  background: #0F172A;
  border-color: #334155;
  color: #F8FAFC;
}

:root[data-theme="dark"] .dialog-detail-page .new-messages-button {
  box-shadow: 0 14px 34px rgba(37, 99, 235, .36);
}

:root[data-theme="dark"] .crm-dialogs-page .skeleton-stack i {
  background: linear-gradient(90deg, #1E293B 0%, #334155 45%, #1E293B 100%);
  background-size: 220% 100%;
}

@media (max-width: 1180px) {
  .dialog-detail-page .dialog-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
  }

  .dialog-detail-page .detail-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-detail-page .dialog-chat-panel {
    height: min(720px, calc(100dvh - 240px));
    min-height: 500px;
  }
}

@media (max-width: 900px) {
  .dialog-detail-page {
    min-height: calc(100dvh - 32px);
    gap: 12px;
    overflow: visible;
    padding-bottom: 16px;
  }

  .dialog-detail-page .dialog-accordion-toggle {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    padding: 14px;
  }

  .dialog-detail-page .dialog-accordion-toggle small {
    white-space: normal;
  }

  .dialog-detail-page .dialog-workspace {
    grid-template-columns: 1fr;
  }

  .dialog-detail-page .client-requests-panel {
    position: static;
    height: min(620px, 72dvh);
    min-height: 420px;
    max-height: 620px;
    order: 2;
  }

  .dialog-detail-page .client-request-list {
    display: grid;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 4px 2px 0;
    scroll-snap-type: none;
  }

  .dialog-detail-page .client-request-card {
    min-width: 0;
  }

  .dialog-detail-page .detail-summary-grid,
  .dialog-detail-page .dialog-control-panel,
  .dialog-detail-page .dialog-composer {
    grid-template-columns: 1fr;
  }

  .dialog-detail-page .dialog-control-actions,
  .dialog-detail-page .dialog-chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-detail-page .dialog-view-tabs {
    width: 100%;
  }

  .dialog-detail-page .dialog-view-tabs button {
    flex: 1 1 0;
  }

  .dialog-detail-page .dialog-control-actions .ui-button,
  .dialog-detail-page .dialog-composer .ui-button {
    width: 100%;
  }

  .dialog-detail-page .dialog-chat-panel {
    height: 500px;
    min-height: 500px;
  }

  .dialog-detail-page .dialog-message-stream {
    padding: 14px;
  }

  .dialog-detail-page .new-messages-button {
    right: 14px;
    bottom: 96px;
  }

  .dialog-detail-page .chat-bubble {
    max-width: calc(100% - 38px);
  }

  .dialog-detail-page .chat-bubble-row.system .chat-bubble {
    max-width: 100%;
  }

  .dialog-detail-page .message-technical pre {
    max-width: 82vw;
  }
}

@media (max-width: 520px) {
  .dialog-detail-page .client-requests-panel {
    height: min(560px, 70dvh);
    min-height: 380px;
    padding: 12px;
  }

  .dialog-detail-page .client-request-list {
    padding: 7px 5px;
  }

  .dialog-detail-page .client-request-card {
    min-height: 78px;
    padding: 11px 11px 11px 15px;
  }

  .dialog-detail-page .client-request-card-top {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .dialog-detail-page .client-request-card time {
    text-align: left;
  }
}

/* Final dark theme polish */

:root[data-theme="dark"] {
  color-scheme: dark;
  color: #E5E7EB;
  background: #0B1220;
  --app-bg: #0B1220;
  --surface: #111827;
  --surface-soft: #162033;
  --surface-subtle: #0F172A;
  --surface-muted: #1E293B;
  --surface-selected: rgba(37, 99, 235, .22);
  --text: #F8FAFC;
  --text-soft: #D8E2EE;
  --text-secondary: #AAB7C7;
  --muted: #94A3B8;
  --muted-2: #738196;
  --line: #253246;
  --border: #253246;
  --row-line: #1F2A3D;
  --input-border: #334155;
  --icon-border: #334155;
  --progress-bg: #263247;
  --blue: #60A5FA;
  --teal: #38BDF8;
  --green: #4ADE80;
  --red: #F87171;
  --warning: #FBBF24;
  --info: #38BDF8;
  --chart-grid: #263247;
  --chart-grid-strong: #3A4A62;
  --chart-axis: #AAB7C7;
  --chart-tooltip-bg: #111827;
  --chart-tooltip-text: #F8FAFC;
  --chart-tooltip-border: #334155;
  --chart-tooltip-shadow: rgba(0, 0, 0, .45);
  --message-bot: #17243A;
  --message-bot-border: #284262;
  --modal-shadow: rgba(0, 0, 0, .62);
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .page,
:root[data-theme="dark"] .page-fluid,
:root[data-theme="dark"] .login-page,
:root[data-theme="dark"] .login-panel {
  background: #0B1220;
  color: #E5E7EB;
}

:root[data-theme="dark"] .workspace {
  background:
    linear-gradient(180deg, #0B1220 0%, #0F172A 100%);
}

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] .crm-page-header h1,
:root[data-theme="dark"] .page-header h1,
:root[data-theme="dark"] .logo span,
:root[data-theme="dark"] .kpi-card strong,
:root[data-theme="dark"] .metric-card strong,
:root[data-theme="dark"] .panel-title h2,
:root[data-theme="dark"] .chart-card-title h2,
:root[data-theme="dark"] .ui-state strong,
:root[data-theme="dark"] .staff-name strong,
:root[data-theme="dark"] .dialog-list-user strong,
:root[data-theme="dark"] .dialog-list-message strong,
:root[data-theme="dark"] .detail-summary-grid strong,
:root[data-theme="dark"] .client-requests-head h2,
:root[data-theme="dark"] .client-request-card strong,
:root[data-theme="dark"] .chat-bubble p,
:root[data-theme="dark"] .message-sender,
:root[data-theme="dark"] .profile-chip strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .crm-page-header p,
:root[data-theme="dark"] .page-header p,
:root[data-theme="dark"] .logo small,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .panel-title span,
:root[data-theme="dark"] .chart-card-title span,
:root[data-theme="dark"] .kpi-card span,
:root[data-theme="dark"] .kpi-card small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .dialog-filters label span,
:root[data-theme="dark"] .dialog-list-user small,
:root[data-theme="dark"] .dialog-list-user time,
:root[data-theme="dark"] .dialog-list-message small,
:root[data-theme="dark"] .dialog-list-result small,
:root[data-theme="dark"] .detail-summary-grid span,
:root[data-theme="dark"] .client-request-meta,
:root[data-theme="dark"] .client-request-card p,
:root[data-theme="dark"] .client-requests-head span,
:root[data-theme="dark"] .client-requests-head small,
:root[data-theme="dark"] .chat-bubble time,
:root[data-theme="dark"] .message-technical,
:root[data-theme="dark"] .ui-state p,
:root[data-theme="dark"] .profile-chip small,
:root[data-theme="dark"] td small {
  color: #AAB7C7;
}

:root[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, #101827 0%, #0E1624 100%);
  border-right-color: #253246;
  box-shadow: inset -1px 0 0 rgba(148, 163, 184, .04);
}

:root[data-theme="dark"] .sidebar nav a,
:root[data-theme="dark"] .theme-toggle {
  color: #AAB7C7;
}

:root[data-theme="dark"] .sidebar nav a svg,
:root[data-theme="dark"] .theme-toggle svg {
  color: #8292A8;
}

:root[data-theme="dark"] .sidebar nav a:hover,
:root[data-theme="dark"] .theme-toggle:hover,
:root[data-theme="dark"] .profile-chip-link:hover {
  background: rgba(96, 165, 250, .10);
  color: #F8FAFC;
}

:root[data-theme="dark"] .sidebar nav a:hover svg,
:root[data-theme="dark"] .theme-toggle:hover svg {
  color: #93C5FD;
}

:root[data-theme="dark"] .sidebar nav a.active {
  background: rgba(37, 99, 235, .18);
  color: #DBEAFE;
  box-shadow: inset 3px 0 #60A5FA;
}

:root[data-theme="dark"] .sidebar nav a.active svg {
  color: #93C5FD;
}

:root[data-theme="dark"] .sidebar-bottom {
  border-top-color: #253246;
}

:root[data-theme="dark"] .ui-card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .staff-panel,
:root[data-theme="dark"] .roles-panel,
:root[data-theme="dark"] .dialogs-table-panel,
:root[data-theme="dark"] .dialog-summary-panel,
:root[data-theme="dark"] .dialog-chat-panel,
:root[data-theme="dark"] .dialog-control-panel,
:root[data-theme="dark"] .client-requests-panel,
:root[data-theme="dark"] .audit-panel,
:root[data-theme="dark"] .audit-filters,
:root[data-theme="dark"] .dialog-filters,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ui-dropdown-panel,
:root[data-theme="dark"] .profile-chip {
  background: #111827;
  border-color: #253246;
  color: #E5E7EB;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .025);
}

:root[data-theme="dark"] .metric-icon,
:root[data-theme="dark"] .icon-tile,
:root[data-theme="dark"] .system-card-icon,
:root[data-theme="dark"] .system-setting-icon {
  background: rgba(96, 165, 250, .13);
  border-color: rgba(96, 165, 250, .25);
  color: #93C5FD;
}

:root[data-theme="dark"] .ui-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .ui-dropdown-trigger,
:root[data-theme="dark"] .ui-button,
:root[data-theme="dark"] .button,
:root[data-theme="dark"] .ui-button-secondary,
:root[data-theme="dark"] .button.secondary {
  background: #0F172A;
  border-color: #334155;
  color: #E5E7EB;
}

:root[data-theme="dark"] .ui-input::placeholder,
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #718096;
}

:root[data-theme="dark"] .ui-input:focus,
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  border-color: #60A5FA;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .16);
}

:root[data-theme="dark"] .ui-button-secondary:hover,
:root[data-theme="dark"] .button.secondary:hover,
:root[data-theme="dark"] .ui-button-ghost:hover,
:root[data-theme="dark"] .button.secondary:hover {
  background: rgba(96, 165, 250, .12);
  border-color: rgba(96, 165, 250, .42);
  color: #BFDBFE;
}

:root[data-theme="dark"] .ui-button-primary,
:root[data-theme="dark"] .button.primary {
  background: #2563EB;
  border-color: #3B82F6;
  color: #FFFFFF;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .24);
}

:root[data-theme="dark"] .ui-button-primary:hover,
:root[data-theme="dark"] .button.primary:hover {
  background: #1D4ED8;
}

:root[data-theme="dark"] .danger-outline,
:root[data-theme="dark"] .ui-button-danger,
:root[data-theme="dark"] .button.danger {
  border-color: rgba(248, 113, 113, .34);
}

:root[data-theme="dark"] .danger-outline {
  background: rgba(127, 29, 29, .16);
  color: #FCA5A5;
}

:root[data-theme="dark"] .danger-outline:hover {
  background: rgba(127, 29, 29, .28);
  color: #FECACA;
}

:root[data-theme="dark"] .auto-refresh-status,
:root[data-theme="dark"] .mobile-filters-toggle {
  background: rgba(17, 24, 39, .88);
  border-color: #253246;
  color: #AAB7C7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

:root[data-theme="dark"] .auto-refresh-status strong,
:root[data-theme="dark"] .mobile-filters-toggle strong {
  color: #E5E7EB;
}

:root[data-theme="dark"] .auto-refresh-status small {
  color: #94A3B8;
}

:root[data-theme="dark"] .crm-dialogs-page .copy-telegram-id-button {
  color: #94A3B8;
}

:root[data-theme="dark"] .crm-dialogs-page .copy-telegram-id-button:hover {
  border-color: rgba(96, 165, 250, .34);
  background: rgba(37, 99, 235, .16);
  color: #93C5FD;
}

:root[data-theme="dark"] .crm-dialogs-page .copy-telegram-id-button.is-copied {
  border-color: rgba(74, 222, 128, .34);
  background: rgba(22, 163, 74, .16);
  color: #86EFAC;
}

:root[data-theme="dark"] .ui-table th,
:root[data-theme="dark"] th,
:root[data-theme="dark"] .dialogs-list-head,
:root[data-theme="dark"] .crm-dialogs-page .dialogs-list-head {
  background: #162033;
  border-color: #253246;
  color: #94A3B8;
}

:root[data-theme="dark"] .ui-table td,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .dialog-list-row,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row {
  background: #111827;
  border-color: #253246;
  color: #E5E7EB;
}

:root[data-theme="dark"] .ui-table tbody tr:hover,
:root[data-theme="dark"] .clickable-row:hover,
:root[data-theme="dark"] .dialog-list-row:hover,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row:hover {
  background: #162033;
}

:root[data-theme="dark"] .ui-table tbody tr.row-updated,
:root[data-theme="dark"] .clickable-row.row-updated,
:root[data-theme="dark"] .dialog-list-row.row-updated,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row.row-updated {
  background: rgba(37, 99, 235, .18);
}

:root[data-theme="dark"] .ui-state {
  background: #111827;
  color: #AAB7C7;
}

:root[data-theme="dark"] .ui-badge-success,
:root[data-theme="dark"] .status.active {
  background: rgba(34, 197, 94, .15);
  border-color: rgba(74, 222, 128, .28);
  color: #86EFAC;
}

:root[data-theme="dark"] .ui-badge-warning,
:root[data-theme="dark"] .status.invited {
  background: rgba(251, 191, 36, .15);
  border-color: rgba(251, 191, 36, .30);
  color: #FDE68A;
}

:root[data-theme="dark"] .ui-badge-error,
:root[data-theme="dark"] .status.blocked,
:root[data-theme="dark"] .status.disabled,
:root[data-theme="dark"] .status.error {
  background: rgba(248, 113, 113, .14);
  border-color: rgba(248, 113, 113, .30);
  color: #FCA5A5;
}

:root[data-theme="dark"] .ui-badge-info {
  background: rgba(56, 189, 248, .14);
  border-color: rgba(56, 189, 248, .28);
  color: #7DD3FC;
}

:root[data-theme="dark"] .ui-badge-neutral,
:root[data-theme="dark"] .status {
  background: #1E293B;
  border-color: #334155;
  color: #CBD5E1;
}

:root[data-theme="dark"] .detail-summary-grid div,
:root[data-theme="dark"] .dialog-accordion-toggle,
:root[data-theme="dark"] .dialog-accordion-panel,
:root[data-theme="dark"] .client-request-list {
  background: #0F172A;
  border-color: #253246;
}

:root[data-theme="dark"] .client-request-card,
:root[data-theme="dark"] .client-request-card.all-history {
  background: #162033;
  border-color: #2C3A50;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .20);
}

:root[data-theme="dark"] .client-request-card:hover {
  background: #1B2740;
  border-color: #3B4D68;
}

:root[data-theme="dark"] .client-request-card.is-active {
  background: rgba(37, 99, 235, .20);
  border-color: rgba(96, 165, 250, .55);
}

:root[data-theme="dark"] .dialog-message-stream {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .96), rgba(11, 18, 32, .98));
}

:root[data-theme="dark"] .dialog-chat-header,
:root[data-theme="dark"] .dialog-composer {
  background: #111827;
  border-color: #253246;
}

:root[data-theme="dark"] .chat-bubble-row.client .chat-bubble,
:root[data-theme="dark"] .chat-bubble {
  background: #162033;
  border-color: #2C3A50;
  color: #E5E7EB;
}

:root[data-theme="dark"] .chat-bubble-row.bot .chat-bubble {
  background: #17243A;
  border-color: #284262;
}

:root[data-theme="dark"] .chat-bubble-row.operator .chat-bubble {
  background: rgba(22, 101, 52, .20);
  border-color: rgba(74, 222, 128, .26);
}

:root[data-theme="dark"] .chat-bubble-row.system .chat-bubble {
  background: transparent;
  border-color: transparent;
  color: #94A3B8;
}

:root[data-theme="dark"] .message-technical pre,
:root[data-theme="dark"] .audit-json-block pre {
  background: #020617;
  border-color: #253246;
  color: #D8E2EE;
}

:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .chart-card .ui-state {
  background: #111827;
}

:root[data-theme="dark"] .recharts-cartesian-grid line {
  stroke: #334155;
  opacity: .55;
}

:root[data-theme="dark"] .recharts-text,
:root[data-theme="dark"] .recharts-cartesian-axis-tick-value {
  fill: #AAB7C7;
}

:root[data-theme="dark"] .recharts-default-tooltip {
  background: #111827 !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
}

:root[data-theme="dark"] .recharts-tooltip-label,
:root[data-theme="dark"] .recharts-tooltip-item {
  color: #F8FAFC !important;
}

:root[data-theme="dark"] .modal-backdrop,
:root[data-theme="dark"] .mobile-nav-backdrop {
  background: rgba(2, 6, 23, .68);
  backdrop-filter: blur(4px);
}

:root[data-theme="dark"] .form-error,
:root[data-theme="dark"] .ui-toast-error {
  background: rgba(127, 29, 29, .22);
  border-color: rgba(248, 113, 113, .30);
  color: #FCA5A5;
}

:root[data-theme="dark"] .form-success,
:root[data-theme="dark"] .ui-toast-success {
  background: rgba(22, 101, 52, .22);
  border-color: rgba(74, 222, 128, .28);
  color: #86EFAC;
}

@media (max-width: 767px) {
  :root[data-theme="dark"] .mobile-topbar {
    background: rgba(15, 23, 42, .94);
    border-bottom-color: #253246;
  }

  :root[data-theme="dark"] .sidebar {
    background:
      linear-gradient(180deg, #111827 0%, #0F172A 100%);
    border-right-color: #253246;
  }

  :root[data-theme="dark"] .mobile-menu-button,
  :root[data-theme="dark"] .mobile-drawer-close {
    background: #111827;
    border-color: #334155;
    color: #F8FAFC;
  }
}

/* Dark theme refinement: softer hierarchy, less visual noise */

:root[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #070B12;
  --surface: #101725;
  --surface-soft: #141D2D;
  --surface-subtle: #0C1320;
  --surface-muted: #1A2536;
  --surface-selected: rgba(59, 130, 246, .16);
  --text: #F3F7FC;
  --text-soft: #D6DFEA;
  --text-secondary: #A7B3C4;
  --muted: #8B99AD;
  --muted-2: #68778D;
  --line: #243044;
  --border: #243044;
  --row-line: #1C2738;
  --input-border: #2D3A50;
  --icon-border: #2F3D53;
  --progress-bg: #263247;
  --blue: #6EA8FE;
  --teal: #38BDF8;
  --green: #5EEA96;
  --red: #FB7185;
  --warning: #FACC15;
  --info: #38BDF8;
  --chart-grid: rgba(148, 163, 184, .18);
  --chart-grid-strong: rgba(148, 163, 184, .28);
  --chart-axis: #94A3B8;
  --chart-tooltip-bg: #F8FAFC;
  --chart-tooltip-text: #0F172A;
  --chart-tooltip-border: rgba(148, 163, 184, .45);
  --chart-tooltip-shadow: rgba(0, 0, 0, .38);
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .page,
:root[data-theme="dark"] .page-fluid {
  background:
    radial-gradient(circle at 18% -8%, rgba(37, 99, 235, .13), transparent 32rem),
    radial-gradient(circle at 96% 8%, rgba(14, 165, 233, .08), transparent 28rem),
    #070B12;
  color: var(--text-soft);
}

:root[data-theme="dark"] .workspace {
  border-left-color: rgba(148, 163, 184, .10);
}

:root[data-theme="dark"] .crm-page-header h1,
:root[data-theme="dark"] .page-header h1 {
  color: #F8FAFC;
  letter-spacing: 0;
}

:root[data-theme="dark"] .crm-page-header p,
:root[data-theme="dark"] .page-header p {
  color: #A7B3C4;
}

:root[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, rgba(14, 21, 34, .98), rgba(9, 14, 24, .98));
  border-right-color: rgba(148, 163, 184, .14);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .025);
}

:root[data-theme="dark"] .sidebar .brand-icon {
  filter: drop-shadow(0 10px 22px rgba(37, 99, 235, .16));
}

:root[data-theme="dark"] .sidebar nav a,
:root[data-theme="dark"] .theme-toggle {
  color: #98A6BA;
}

:root[data-theme="dark"] .sidebar nav a svg,
:root[data-theme="dark"] .theme-toggle svg {
  color: #7D8CA3;
}

:root[data-theme="dark"] .sidebar nav a:hover,
:root[data-theme="dark"] .theme-toggle:hover {
  background: rgba(148, 163, 184, .08);
  color: #E8EEF7;
}

:root[data-theme="dark"] .sidebar nav a.active {
  background:
    linear-gradient(90deg, rgba(59, 130, 246, .20), rgba(59, 130, 246, .08));
  color: #EAF2FF;
  box-shadow:
    inset 3px 0 #60A5FA,
    inset 0 0 0 1px rgba(96, 165, 250, .12);
}

:root[data-theme="dark"] .sidebar nav a.active svg {
  color: #93C5FD;
}

:root[data-theme="dark"] .sidebar-bottom {
  border-top-color: rgba(148, 163, 184, .14);
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip,
:root[data-theme="dark"] .profile-chip {
  background: rgba(20, 29, 45, .82);
  border-color: rgba(148, 163, 184, .13);
  box-shadow: none;
}

:root[data-theme="dark"] .profile-chip .avatar,
:root[data-theme="dark"] .avatar {
  background: #233247;
  color: #E8EEF7;
}

:root[data-theme="dark"] .ui-card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .staff-panel,
:root[data-theme="dark"] .roles-panel,
:root[data-theme="dark"] .dialogs-table-panel,
:root[data-theme="dark"] .dialog-summary-panel,
:root[data-theme="dark"] .dialog-chat-panel,
:root[data-theme="dark"] .dialog-control-panel,
:root[data-theme="dark"] .client-requests-panel,
:root[data-theme="dark"] .audit-panel,
:root[data-theme="dark"] .audit-filters,
:root[data-theme="dark"] .dialog-filters,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ui-dropdown-panel {
  background:
    linear-gradient(180deg, rgba(18, 27, 42, .98), rgba(14, 22, 36, .98));
  border-color: rgba(148, 163, 184, .16);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, .22),
    inset 0 1px 0 rgba(255, 255, 255, .035);
}

:root[data-theme="dark"] .kpi-card {
  background:
    linear-gradient(180deg, rgba(19, 29, 45, .98), rgba(14, 22, 36, .98));
}

:root[data-theme="dark"] .kpi-card:hover,
:root[data-theme="dark"] .chart-card:hover {
  border-color: rgba(148, 163, 184, .24);
}

:root[data-theme="dark"] .kpi-icon,
:root[data-theme="dark"] .metric-icon,
:root[data-theme="dark"] .icon-tile {
  background: rgba(96, 165, 250, .11);
  border-color: rgba(147, 197, 253, .18);
  color: #93C5FD;
}

:root[data-theme="dark"] .kpi-card-success .kpi-icon {
  background: rgba(34, 197, 94, .12);
  border-color: rgba(134, 239, 172, .18);
  color: #86EFAC;
}

:root[data-theme="dark"] .kpi-card-warning .kpi-icon {
  background: rgba(250, 204, 21, .13);
  border-color: rgba(253, 230, 138, .18);
  color: #FDE68A;
}

:root[data-theme="dark"] .kpi-card-info .kpi-icon {
  background: rgba(56, 189, 248, .12);
  border-color: rgba(125, 211, 252, .18);
  color: #7DD3FC;
}

:root[data-theme="dark"] .kpi-card strong,
:root[data-theme="dark"] .metric-card strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .kpi-card span,
:root[data-theme="dark"] .kpi-card small,
:root[data-theme="dark"] .metric-card span,
:root[data-theme="dark"] .metric-card small,
:root[data-theme="dark"] .panel-title span,
:root[data-theme="dark"] .chart-card-title span {
  color: #9AA8BA;
}

:root[data-theme="dark"] .ui-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .ui-dropdown-trigger,
:root[data-theme="dark"] .ui-button,
:root[data-theme="dark"] .button,
:root[data-theme="dark"] .ui-button-secondary,
:root[data-theme="dark"] .button.secondary {
  background: rgba(9, 14, 24, .72);
  border-color: rgba(148, 163, 184, .20);
  color: #E8EEF7;
}

:root[data-theme="dark"] .ui-input:hover,
:root[data-theme="dark"] input:hover,
:root[data-theme="dark"] select:hover,
:root[data-theme="dark"] textarea:hover,
:root[data-theme="dark"] .ui-dropdown-trigger:hover {
  border-color: rgba(148, 163, 184, .34);
}

:root[data-theme="dark"] .ui-input:focus,
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  border-color: rgba(96, 165, 250, .78);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .13);
}

:root[data-theme="dark"] .ui-button-primary,
:root[data-theme="dark"] .button.primary {
  background: linear-gradient(180deg, #3B82F6, #2563EB);
  border-color: rgba(147, 197, 253, .38);
  box-shadow: 0 12px 24px rgba(37, 99, 235, .18);
}

:root[data-theme="dark"] .auto-refresh-status,
:root[data-theme="dark"] .mobile-filters-toggle,
:root[data-theme="dark"] .period-select,
:root[data-theme="dark"] .ui-badge-neutral {
  background: rgba(20, 29, 45, .72);
  border-color: rgba(148, 163, 184, .18);
}

:root[data-theme="dark"] .ui-table th,
:root[data-theme="dark"] th,
:root[data-theme="dark"] .dialogs-list-head,
:root[data-theme="dark"] .crm-dialogs-page .dialogs-list-head {
  background: rgba(15, 23, 42, .74);
  border-color: rgba(148, 163, 184, .14);
  color: #91A0B6;
}

:root[data-theme="dark"] .ui-table td,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .dialog-list-row,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row {
  background: rgba(16, 23, 37, .72);
  border-color: rgba(148, 163, 184, .12);
}

:root[data-theme="dark"] .ui-table tbody tr:hover,
:root[data-theme="dark"] .clickable-row:hover,
:root[data-theme="dark"] .dialog-list-row:hover,
:root[data-theme="dark"] .crm-dialogs-page .dialog-list-row:hover {
  background: rgba(30, 41, 59, .74);
}

:root[data-theme="dark"] .activity-chart-summary {
  border-top-color: rgba(148, 163, 184, .12);
}

:root[data-theme="dark"] .activity-chart-totals span {
  background: rgba(15, 23, 42, .62);
  border-color: rgba(148, 163, 184, .16);
  color: #A7B3C4;
}

:root[data-theme="dark"] .activity-chart-totals strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .activity-chart-legend strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .activity-chart-breakdown-row span {
  color: #A7B3C4;
}

:root[data-theme="dark"] .activity-chart-breakdown-row div {
  background: rgba(148, 163, 184, .17);
}

:root[data-theme="dark"] .activity-chart-breakdown-row strong {
  color: #F8FAFC;
}

@media (max-width: 900px) {
  .activity-chart-summary {
    grid-template-columns: 1fr;
  }

  .activity-chart-totals {
    justify-content: flex-start;
  }

  .activity-chart-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

:root[data-theme="dark"] .recharts-cartesian-grid line {
  stroke: rgba(148, 163, 184, .18);
}

:root[data-theme="dark"] .recharts-text,
:root[data-theme="dark"] .recharts-cartesian-axis-tick-value {
  fill: #8D9AAF;
}

:root[data-theme="dark"] .recharts-default-tooltip,
:root[data-theme="dark"] .dialogs-chart-tooltip {
  background: #F8FAFC !important;
  border: 1px solid rgba(148, 163, 184, .36) !important;
  color: #0F172A !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .30) !important;
}

:root[data-theme="dark"] .recharts-tooltip-label,
:root[data-theme="dark"] .recharts-tooltip-item,
:root[data-theme="dark"] .dialogs-chart-tooltip strong,
:root[data-theme="dark"] .dialogs-chart-tooltip span {
  color: #0F172A !important;
}

:root[data-theme="dark"] .distribution-track,
:root[data-theme="dark"] .progress,
:root[data-theme="dark"] .activity-bar-track {
  background: rgba(148, 163, 184, .17);
}

:root[data-theme="dark"] .dialog-message-stream {
  background:
    radial-gradient(circle at 50% 0%, rgba(59, 130, 246, .08), transparent 22rem),
    #0A101B;
}

:root[data-theme="dark"] .chat-bubble-row.client .chat-bubble,
:root[data-theme="dark"] .chat-bubble {
  background: #151F30;
  border-color: rgba(148, 163, 184, .16);
}

:root[data-theme="dark"] .chat-bubble-row.bot .chat-bubble {
  background: #10233A;
  border-color: rgba(96, 165, 250, .22);
}

:root[data-theme="dark"] .chat-bubble-row.operator .chat-bubble {
  background: #102A22;
  border-color: rgba(94, 234, 150, .22);
}

@media (max-width: 767px) {
  :root[data-theme="dark"] .mobile-topbar {
    background: rgba(9, 14, 24, .96);
    border-bottom-color: rgba(148, 163, 184, .14);
  }

  :root[data-theme="dark"] .sidebar {
    background:
      linear-gradient(180deg, #0E1522 0%, #090E18 100%);
  }
}

/* Dark theme detail fixes */

:root[data-theme="dark"] .dialog-detail-page .client-requests-panel {
  background:
    linear-gradient(180deg, rgba(18, 27, 42, .96), rgba(12, 19, 32, .96));
  border-color: rgba(148, 163, 184, .20);
}

:root[data-theme="dark"] .dialog-detail-page .client-request-list {
  background: rgba(7, 11, 18, .44);
  border-color: rgba(148, 163, 184, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  scrollbar-color: #3D4B61 transparent;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card,
:root[data-theme="dark"] .dialog-detail-page .client-request-card.all-history {
  background: rgba(15, 23, 42, .80);
  border-color: rgba(148, 163, 184, .18);
  box-shadow: none;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card:hover {
  background: rgba(23, 35, 54, .92);
  border-color: rgba(148, 163, 184, .30);
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active {
  background:
    linear-gradient(180deg, rgba(30, 64, 175, .36), rgba(30, 41, 88, .40));
  border-color: rgba(96, 165, 250, .70);
  box-shadow: 0 14px 30px rgba(37, 99, 235, .14);
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card > span:not(.client-request-status),
:root[data-theme="dark"] .dialog-detail-page .client-request-card p,
:root[data-theme="dark"] .dialog-detail-page .client-request-meta,
:root[data-theme="dark"] .dialog-detail-page .client-request-card time {
  color: #A7B3C4;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-status {
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(30, 41, 59, .88);
  color: #E2E8F0;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-status.ls_search {
  background: rgba(22, 163, 74, .20);
  border-color: rgba(74, 222, 128, .34);
  color: #BBF7D0;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-status.balance_request,
:root[data-theme="dark"] .dialog-detail-page .client-request-status.repair_request {
  background: rgba(245, 158, 11, .18);
  border-color: rgba(251, 191, 36, .36);
  color: #FDE68A;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-status.problem {
  background: rgba(220, 38, 38, .18);
  border-color: rgba(248, 113, 113, .34);
  color: #FECACA;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-status.incomplete {
  background: rgba(220, 38, 38, .18);
  border-color: rgba(248, 113, 113, .34);
  color: #FECACA;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status {
  background: rgba(15, 23, 42, .54);
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status.ls_search {
  color: #CFFFE1;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status.balance_request,
:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status.repair_request {
  color: #FFF2B8;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status.problem {
  color: #FFD2D2;
}

:root[data-theme="dark"] .dialog-detail-page .client-request-card.is-active .client-request-status.incomplete {
  color: #FFD2D2;
}

:root[data-theme="dark"] .sidebar-bottom {
  gap: 10px;
  padding: 12px 0 0;
  border-top-color: rgba(148, 163, 184, .14);
  background: transparent;
}

:root[data-theme="dark"] .sidebar-bottom .theme-toggle {
  min-height: 42px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #A7B3C4;
}

:root[data-theme="dark"] .sidebar-bottom .theme-toggle:hover {
  background: rgba(148, 163, 184, .08);
  border-color: rgba(148, 163, 184, .16);
  color: #F8FAFC;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip {
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 10px;
  min-height: 62px;
  padding: 8px;
  background: rgba(15, 23, 42, .56);
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 14px;
  box-shadow: none;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip:hover {
  background: rgba(20, 29, 45, .78);
  border-color: rgba(148, 163, 184, .20);
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip .avatar {
  background: #233247;
  color: #EAF2FF;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip button {
  color: #8190A6;
}

:root[data-theme="dark"] .sidebar-bottom .profile-chip button:hover {
  background: rgba(148, 163, 184, .10);
  color: #EAF2FF;
}

/* Overview analytics focused on requests */

.metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.overview-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.overview-breakdown-card {
  padding: 22px;
}

.overview-breakdown-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.overview-breakdown-row {
  display: grid;
  gap: 8px;
}

.overview-breakdown-row > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overview-breakdown-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.overview-breakdown-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.overview-breakdown-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #E2E8F0;
}

.overview-breakdown-track i {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: #2563EB;
}

.overview-breakdown-track i.ls-search {
  background: #16A34A;
}

.overview-breakdown-track i.balance {
  background: #0284C7;
}

.overview-breakdown-track i.repair {
  background: #F59E0B;
}

.overview-breakdown-track i.problem {
  background: #DC2626;
}

.overview-breakdown-track i.repair-type-service_request {
  background: #2563EB;
}

.overview-breakdown-track i.repair-type-order_keys {
  background: #0284C7;
}

.overview-breakdown-track i.repair-type-install_handset {
  background: #16A34A;
}

.overview-breakdown-track i.repair-type-connect_smart_intercom_app {
  background: #F59E0B;
}

.overview-breakdown-track i.repair-type-install_smart_intercom_entrance {
  background: #7C3AED;
}

.overview-repair-by-type-card {
  padding: 22px;
}

.overview-repair-by-type-card details {
  display: grid;
  gap: 16px;
}

.overview-repair-by-type-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.overview-repair-by-type-card summary::-webkit-details-marker {
  display: none;
}

.overview-repair-by-type-card summary span {
  display: grid;
  gap: 4px;
}

.overview-repair-by-type-card summary strong {
  color: #0F172A;
  font-size: 20px;
  line-height: 1.2;
}

.overview-repair-by-type-card summary small {
  color: #64748B;
  font-size: 13px;
  font-weight: 700;
}

.overview-repair-by-type-card summary::after {
  content: "Показать";
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
}

.overview-repair-by-type-card details[open] summary::after {
  content: "Скрыть";
}

.overview-repair-by-type-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.overview-repair-by-type-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(120px, auto));
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #F8FAFC;
}

.overview-repair-by-type-row strong {
  color: #0F172A;
  font-size: 14px;
}

.overview-repair-by-type-row span {
  color: #64748B;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.overview-repair-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.overview-repair-status {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #F8FAFC;
}

.overview-repair-status span {
  color: #64748B;
  font-size: 12px;
  font-weight: 800;
}

.overview-repair-status strong {
  color: #0F172A;
  font-size: 24px;
  line-height: 1;
}

.overview-repair-status.pending {
  border-color: #FDE68A;
  background: #FFFBEB;
}

.overview-repair-status.sent {
  border-color: #BBF7D0;
  background: #F0FDF4;
}

.overview-repair-status.cancelled {
  border-color: #FECACA;
  background: #FEF2F2;
}

:root[data-theme="dark"] .overview-breakdown-track {
  background: rgba(148, 163, 184, .17);
}

:root[data-theme="dark"] .overview-repair-by-type-card summary strong,
:root[data-theme="dark"] .overview-repair-by-type-row strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .overview-repair-by-type-card summary small,
:root[data-theme="dark"] .overview-repair-by-type-row span {
  color: #A7B3C4;
}

:root[data-theme="dark"] .overview-repair-by-type-card summary::after,
:root[data-theme="dark"] .overview-repair-by-type-row {
  border-color: rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .58);
}

:root[data-theme="dark"] .overview-repair-status {
  background: rgba(15, 23, 42, .62);
  border-color: rgba(148, 163, 184, .14);
}

:root[data-theme="dark"] .overview-repair-status span {
  color: #A7B3C4;
}

:root[data-theme="dark"] .overview-repair-status strong {
  color: #F8FAFC;
}

:root[data-theme="dark"] .overview-repair-status.pending {
  border-color: rgba(251, 191, 36, .28);
  background: rgba(245, 158, 11, .10);
}

:root[data-theme="dark"] .overview-repair-status.sent {
  border-color: rgba(74, 222, 128, .24);
  background: rgba(22, 163, 74, .10);
}

:root[data-theme="dark"] .overview-repair-status.cancelled {
  border-color: rgba(248, 113, 113, .24);
  background: rgba(220, 38, 38, .10);
}

@media (max-width: 1500px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .overview-breakdown-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-repair-status-grid {
    grid-template-columns: 1fr;
  }

  .overview-repair-by-type-row {
    grid-template-columns: 1fr;
  }
}

/* Environment marker */

.logo .logo-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo .logo-title-line > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo .env-badge,
.mobile-topbar .env-badge,
.logo .env-label,
.mobile-topbar .env-label {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 20px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #FDBA74;
  background: #FFF7ED;
  color: #C2410C;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;
  white-space: nowrap;
}

.logo .env-label {
  grid-column: 2;
  margin-top: 6px;
}

.mobile-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

:root[data-theme="dark"] .logo .env-badge,
:root[data-theme="dark"] .mobile-topbar .env-badge,
:root[data-theme="dark"] .logo .env-label,
:root[data-theme="dark"] .mobile-topbar .env-label {
  border-color: rgba(251, 191, 36, .42);
  background: rgba(251, 191, 36, .16);
  color: #FCD34D;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .logo .env-badge {
    display: none;
  }

  .logo .env-label {
    display: none;
  }
}

@media (max-width: 767px) {
  .sidebar .logo .logo-title-line {
    flex-wrap: wrap;
  }

  .mobile-brand-title {
    flex-wrap: wrap;
    row-gap: 4px;
  }
}
