/* Кабинет Телеком-Дом — светлый кабинет в стиле МТС, акцент #ff0032 */
:root {
  --ink: #1d2023;
  --text: #2c3036;
  --muted: #3f474f;
  --line: #e7eaee;
  --line-strong: #d6dbe1;
  --bg: #f2f3f7;
  --card: #ffffff;
  --accent: #ff0032;
  --accent-dark: #e30611;
  --accent-soft: #fff0f2;
  --gray-btn: #f2f3f7;
  --gray-btn-hover: #e6e8ee;
  --ok: #12824a;
  --warn: #8a5300;
  --danger: #c4001f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 32, 35, .04), 0 6px 20px rgba(29, 32, 35, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Arial, sans-serif;
  --side: 320px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { margin: 0; font: 17px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.85rem; line-height: 1.2; margin: 0 0 16px; color: var(--ink); font-weight: 800; letter-spacing: -.01em; }
h2, .card h3, .card > h3 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 14px; color: var(--ink); font-weight: 750; }
h4 { font-size: 0.95rem; margin: 10px 0 6px; color: var(--ink); font-weight: 700; }
a { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted, .hint { color: var(--muted); }
.small { font-size: .95rem; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 16px 12px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 4px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-logo {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.brand-text { display: grid; min-width: 0; line-height: 1.2; }
.brand-text b { font-size: 1rem; font-weight: 800; white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.menu-toggle { display: none; }
.side-nav { display: grid; gap: 2px; margin-top: 14px; align-content: start; justify-items: stretch; flex: 1; min-height: 0; overflow: auto; }
.side-nav a, .side-nav button.nav {
  display: flex; align-items: flex-start; justify-content: flex-start; gap: 10px; width: 100%;
  margin: 0; padding: 9px 8px; border-radius: 12px; border: 0; background: transparent;
  color: var(--ink); font-weight: 700; font-size: 1rem; line-height: 1.3; text-align: left; text-decoration: none; position: relative;
  white-space: normal; overflow: visible;
}
.side-nav a:hover, .side-nav button.nav:hover { background: var(--bg); }
.side-nav a.active, .side-nav button.nav.active { background: var(--accent-soft); color: var(--accent-dark); }
.side-nav a.active::before, .side-nav button.nav.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 4px 4px 0; background: var(--accent);
}
.side-nav .ico { width: 22px; height: 22px; margin: 0; display: grid; place-items: center; color: var(--ink); flex-shrink: 0; }
.side-nav .ico svg { width: 20px; height: 20px; display: block; }
.side-nav a.active .ico, .side-nav button.nav.active .ico { color: var(--accent); }
.side-label {
  margin: 16px 0 6px; padding: 0 8px; font-size: 1rem; font-weight: 800;
  text-transform: none; letter-spacing: 0; color: var(--ink); text-align: left; line-height: 1.3;
}
.side-label:first-child { margin-top: 4px; }
.side-user { margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.side-user .who b { color: var(--ink); font-weight: 700; font-size: .92rem; display: block; }
.side-user .who small { color: var(--muted); font-size: .8rem; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  min-height: 64px; padding: 10px 22px; display: flex; flex-direction: column; gap: 8px;
}
.topbar-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-weight: 700; color: var(--ink); white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bot-pills { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.bot-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 999px; padding: 6px 12px 6px 8px; font-weight: 650; font-size: .9rem;
}
.bot-pill:hover { background: var(--bg); }
.bot-pill.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.bot-pill .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bot-pill .off { font-size: .75rem; color: var(--muted); font-weight: 600; }
.main { padding: 22px 24px 40px; flex: 1; }

/* Hero + stats */
.hero {
  border-radius: 24px; padding: 32px 36px; margin: 0 0 22px;
  background: linear-gradient(105deg, #eef3ff 0%, #f7f0ff 48%, #fff0f4 100%);
  color: var(--ink);
}
.hero h1 { font-size: 2.1rem; margin: 0 0 10px; }
.hero-kicker { margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.hero-text { max-width: 760px; font-size: 1.02rem; color: #3a3f45; margin-bottom: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0 0 22px; }
.stats .card { display: grid; gap: 2px; padding: 16px 18px; }
.stats b { font-size: 1.8rem; color: var(--ink); line-height: 1.1; font-weight: 800; }
.stats span { color: var(--muted); font-size: .88rem; }
.stat-ok b { color: var(--ok); }
.stat-warn b { color: var(--warn); }
.stat-bad b { color: var(--danger); }

/* Cards, buttons, forms */
.card { background: var(--card); border: 0; border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.edit-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }

button, .btn, .button {
  font: inherit; font-weight: 700; font-size: 1.05rem;
  background: var(--ink); color: #fff;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 20px; min-height: 44px;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
button:hover, .btn:hover, .button:hover { background: #000; text-decoration: none; }
.btn-primary, .btn-red, .button.btn-red { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-red:hover { background: var(--accent-dark); }
.btn-ghost, .btn-light { background: var(--gray-btn); color: var(--ink); border-color: transparent; }
.btn-ghost:hover, .btn-light:hover { background: var(--gray-btn-hover); }
.btn-sm { min-height: 44px; padding: 8px 18px; font-size: 1rem; border-radius: 12px; }
.btn-danger { background: #fff; color: var(--danger); border-color: #ffc2cc; }
.btn-danger:hover { background: var(--accent-soft); }

label { display: grid; gap: 6px; font-size: 1rem; font-weight: 650; color: var(--ink); min-width: 0; }
input.inp, select.inp, textarea.inp, input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  font: inherit; font-weight: 400; font-size: 1rem; color: var(--ink);
  padding: 10px 14px; min-height: 46px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: #fff;
  width: 100%; min-width: 0;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]), select { height: 46px; }
textarea { resize: vertical; line-height: 1.45; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(29, 32, 35, .08); }
input:disabled, select:disabled, textarea:disabled { background: #f7f8fa; color: #3a3f45; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--accent); padding: 0; height: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--text); cursor: pointer; }
.rr { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.rr .inp, .rr input, .rr select { width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hint { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 16px; color: #2c333a; font-size: 1rem; margin: 0 0 10px; }
.hint b { color: var(--ink); font-weight: 600; }
.field { display: grid; gap: 6px; font-size: 1rem; font-weight: 650; color: var(--ink); }
.days-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.day-chk { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; font-weight: 650; user-select: none; }
.day-chk:has(input:checked) { border-color: var(--ink); background: var(--bg); }
.day-chk input { margin: 0; }


/* Tables + pills */
.table-wrap, .table-card { overflow-x: auto; }
.table-card { padding: 0; }
table, .tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td, table th, table td { padding: 11px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.tbl th, table th { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: #fafbfc; }
.tbl tr:last-child td { border-bottom: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 650; border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-good, .pill-green { background: #e6f6ed; color: var(--ok); }
.pill-warn, .pill-amber { background: #fff3d6; color: var(--warn); }
.pill-bad, .pill-red { background: var(--accent-soft); color: var(--danger); }
.pill-info { background: #eef3ff; color: #2157c5; }
.pill-mute, .pill-gray { background: #eef0f3; color: #4e5660; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }
.auth-top { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px; }
.auth { display: grid; place-items: center; padding: 40px 16px; }
.login-card { background: #fff; border-radius: 24px; box-shadow: var(--shadow); width: 100%; max-width: 420px; padding: 36px 32px; display: grid; gap: 14px; }
.login-card h1 { font-size: 1.6rem; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 8px; }
.err { color: var(--danger); font-size: .9rem; min-height: 20px; font-weight: 600; }
.captcha-row { display: flex; gap: 10px; align-items: end; }
.captcha-row > div { flex: 1; }
.captcha-q { font-weight: 800; font-size: 1.15rem; color: var(--ink); background: var(--bg); border-radius: 12px; padding: 10px 14px; min-height: 46px; display: flex; align-items: center; }

/* Modal, toast */
.modal-back { position: fixed; inset: 0; background: rgba(29,32,35,.4); display: none; place-items: center; z-index: 80; padding: 20px; }
.modal-back.show, .modal-back[style*="flex"], .modal-back[style*="grid"] { display: grid; }
.modal { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 24px; width: min(640px, 100%); max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 99; display: none; box-shadow: var(--shadow); max-width: 360px; }
.pre { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px; max-height: 240px; overflow: auto; font-size: .9rem; }
.mrow { display: grid; grid-template-columns: 200px 1fr 90px; gap: 8px; align-items: start; margin: 6px 0; }
.obj.mrow { grid-template-columns: 220px 1fr 40px; }
audio { width: 220px; height: 36px; }
.bot-mini { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.bot-mini b { display: block; }
.fc .fc-overdue, .fc-event.fc-overdue { background: var(--accent-soft) !important; border-color: var(--danger) !important; color: var(--danger) !important; }
.fc { background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }

.bot-meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.bot-meta .field { min-width: 140px; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 40; transform: translateX(-110%); transition: transform .2s;
    width: var(--side); box-shadow: var(--shadow);
  }
  .side.open { transform: none; }
  .menu-toggle { display: inline-flex; background: var(--gray-btn); color: var(--ink); min-height: 36px; padding: 6px 12px; }
  .topbar { padding: 10px 14px; }
  .main { padding: 16px 14px 32px; }
  .hero { padding: 22px; }
  .mrow, .obj.mrow { grid-template-columns: 1fr; }
}

/* v3: видимые переключатели и панели действий */
.bot-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; font-weight: 650; font-size: .9rem; color: var(--text); }
.bot-switch input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.bot-switch .track { width: 44px; height: 24px; border-radius: 999px; background: #c5c9d0; position: relative; transition: background .15s; flex-shrink: 0; }
.bot-switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .15s; }
.bot-switch.on { border-color: #bfe6cf; background: #f1fbf5; }
.bot-switch.on .track { background: var(--ok); }
.bot-switch.on .knob { left: 23px; }
.bot-switch:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.bot-switch .bs-lbl b { color: var(--muted); }
.bot-switch.on .bs-lbl b { color: var(--ok); }
.onoff { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.onoff.on { background: #e6f6ed; color: var(--ok); }
.onoff.off { background: #eef0f3; color: #4e5660; }
.pagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin: 0 0 16px; position: sticky; top: 8px; z-index: 15; }
.pagebar.editing { border: 2px solid var(--accent); }
.pagebar .mode { font-weight: 750; font-size: .85rem; border-radius: 999px; padding: 4px 10px; }
.pagebar .mode-view { background: #eef0f3; color: #4e5660; }
.pagebar .mode-edit { background: var(--accent-soft); color: var(--accent-dark); }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: #fafbfd; }
.bot-pill .onoff { margin-left: 2px; }
@media (max-width: 900px) { .topbar-actions { margin-left: 0; width: 100%; } .topbar-row { flex-wrap: wrap; } .pagebar { position: static; } }

/* Recordings */
.period { display: flex; flex-wrap: wrap; gap: 6px; }
.period button { min-height: 38px; padding: 6px 12px; background: var(--gray-btn); color: var(--ink); font-size: .88rem; border-radius: 10px; }
.period button:hover { background: var(--gray-btn-hover); }
.period button.on { background: var(--ink); color: #fff; }
.period button.on:hover { background: #000; }
audio.rec-player { width: 220px; max-width: 28vw; height: 36px; vertical-align: middle; }
.tx { margin: 8px 0 4px; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: .9rem; line-height: 1.45; }
.tx .tx-bot { color: #2157c5; margin: 0 0 6px; }
.tx .tx-cli { color: var(--ink); margin: 0 0 6px; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; }
.pager .muted { color: var(--muted); font-size: .9rem; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Voice */
.voice-list { display: grid; gap: 8px; }
.voice-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.voice-row.on { border-color: var(--accent); background: var(--accent-soft); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 0; height: auto; padding: 0; border: 0; }
.spinning::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Telephony form: disabled controls must not look clickable; saved password hint */
.check:has(input:disabled) { cursor: default; }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { cursor: not-allowed; opacity: .7; }
.pw-saved { color: #1a7f37; font-weight: 650; margin-left: 8px; }
#t_reg_hint { max-width: 52rem; }

/* Larger controls and rounded on/off switches */
button.btn-primary, button.btn-light, button.btn-danger, .btn-primary, .btn-light, .btn-danger {
  min-height: 48px; padding: 10px 20px;
}
.bot-switch { font-size: 1rem; padding: 8px 14px; }
.bot-switch .track { width: 48px; height: 28px; }
.bot-switch .knob { width: 22px; height: 22px; top: 3px; left: 3px; }
.bot-switch.on .knob { left: 23px; }

.sw {
  display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none;
  padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line-strong);
  background: #fff; margin: 8px 0; font-weight: 650; color: var(--ink); width: fit-content; max-width: 100%;
}
.sw input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.sw .track { width: 52px; height: 30px; border-radius: 999px; background: #c5c9d0; position: relative; transition: background .15s; flex-shrink: 0; }
.sw .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28); transition: left .15s; }
.sw.on { border-color: #bfe6cf; background: #f1fbf5; }
.sw.on .track { background: var(--ok); }
.sw.on .knob { left: 25px; }
.sw:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.sw .sw-txt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; line-height: 1.35; }
.sw .sw-txt b { font-weight: 750; }
.sw .sw-state { font-weight: 800; color: #5a6168; }
.sw.on .sw-state { color: var(--ok); }
.sw .sw-hint { flex-basis: 100%; font-size: .95rem; font-weight: 500; color: #3a3f45; }
.sw:has(input:disabled) { cursor: default; opacity: .92; }
input[type="checkbox"]:disabled + .track, .sw:has(input:disabled) { cursor: default; }

.pill { font-size: .95rem; padding: 5px 12px; }
#trunkReg, #trunkStop, #trunkRefresh { min-height: 44px; }

.sw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0; }
