/* ===== Мини-АТС — пульт оператора =====
   Идея: коммутатор. Линии — ряды с лампами состояния; главный элемент — дисплей набора. */

@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url(fonts/onest-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url(fonts/onest-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url(fonts/onest-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url(fonts/onest-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url(fonts/onest-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url(fonts/onest-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url(fonts/onest-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url(fonts/onest-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --paper: #EEF1F4;
  --panel: #FFFFFF;
  --sunken: #F5F7F9;
  --ink: #1C2430;
  --ink-2: #5A6577;
  --ink-3: #8A97AA;
  --rule: #D8DEE6;
  --cobalt: #2F5BEA;
  --cobalt-ink: #FFFFFF;
  --cobalt-soft: #E4EAFD;
  --lamp-on: #2E9E6B;
  --lamp-ring: #E0A23A;
  --lamp-err: #C8463B;
  --lamp-off: #B9C1CC;
  --hang: #C8463B;
  --focus: #2F5BEA;
  --shadow: 0 1px 2px rgba(28, 36, 48, .06), 0 6px 24px rgba(28, 36, 48, .06);
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171E; --panel: #1A212B; --sunken: #151B23; --ink: #E5EAF1; --ink-2: #A0ABBC; --ink-3: #6E7B8F;
    --rule: #2A3341; --cobalt: #6F8EFF; --cobalt-ink: #0E1420; --cobalt-soft: #1F2A45;
    --lamp-off: #3F4A59; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Onest", system-ui, sans-serif; font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--cobalt); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- лампа: главный знак системы ---------- */
.lamp { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--lamp-off);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,.18); }
.lamp.on { background: var(--lamp-on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lamp-on) 22%, transparent); }
.lamp.ring { background: var(--lamp-ring); animation: ring 1s ease-in-out infinite; }
.lamp.err { background: var(--lamp-err); }
@keyframes ring { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--lamp-ring) 0%, transparent), 0 0 0 3px color-mix(in srgb, var(--lamp-ring) 45%, transparent); } }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { background: var(--panel); border-right: 1px solid var(--rule); display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; font-weight: 700; letter-spacing: -.01em; }
.brand svg { width: 28px; height: 28px; display: block; }
.brand span { color: #1C2430; display: block; }
.brand small { display: block; font-weight: 400; color: var(--ink-2); font-size: 12px; letter-spacing: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-sm); border: 0; background: none; cursor: pointer; text-align: left; color: var(--ink-2); font-weight: 500; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--sunken); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--cobalt-soft); color: var(--cobalt); }
.rail-foot { margin-top: auto; border-top: 1px solid var(--rule); padding-top: 14px; display: grid; gap: 6px; }
.whoami { padding: 0 10px 6px; }
.whoami b { display: block; font-weight: 600; }
.reg { display: flex; align-items: center; gap: 8px; padding: 0 10px 8px; font-size: 13px; color: var(--ink-2); }
.main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- элементы ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--rule); background: var(--panel); border-radius: var(--r-sm); padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--cobalt); color: var(--cobalt-ink); border-color: var(--cobalt); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--lamp-err); }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: var(--sunken); }
.btn.icon { padding: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.input, select.input { width: 100%; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); padding: 9px 11px; }
.input:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px var(--cobalt-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--cobalt); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); }
.panel-pad { padding: 20px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--sunken); border: 1px solid var(--rule); font-size: 12px; color: var(--ink-2); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunken); }
td.num { white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
.dir { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; background: var(--sunken); color: var(--ink-2); }
.dir svg { width: 15px; height: 15px; }
.dir.missed { color: var(--lamp-err); background: color-mix(in srgb, var(--lamp-err) 12%, transparent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--rule); }
.filters .input { width: auto; min-width: 140px; }

/* ---------- пульт: линии-лампы ---------- */
.console { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 24px; align-items: start; }
.lines-board { display: grid; gap: 0; }
.line-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; cursor: pointer; background: none; text-align: left; width: 100%; }
.line-row:last-child { border-bottom: 0; }
.line-row:hover { background: var(--sunken); }
.line-row[aria-pressed="true"] { border-left-color: var(--cobalt); background: var(--cobalt-soft); }
.line-row:disabled { cursor: default; }
.line-row .nm { font-weight: 600; }
.line-row .no { color: var(--ink-2); font-size: 13px; }
.line-row .caps { display: flex; gap: 4px; color: var(--ink-3); }
.line-row .caps svg { width: 15px; height: 15px; }

/* ---------- дисплей набора: запоминающийся элемент ---------- */
.dialer { padding: 22px 22px 24px; }
.display { position: relative; border-radius: var(--r-md); background: var(--sunken); padding: 16px 16px 12px; margin-bottom: 16px; border: 1px solid var(--rule); }
.display .via { font-size: 13px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; min-height: 20px; }
.display input { width: 100%; border: 0; background: none; font-size: 40px; line-height: 1.15; font-weight: 500; letter-spacing: .02em; padding: 6px 36px 2px 0; outline: none; }
.display input::placeholder { color: var(--ink-3); font-weight: 400; }
.display .erase { position: absolute; right: 10px; bottom: 14px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { height: 58px; border-radius: var(--r-md); border: 1px solid var(--rule); background: var(--panel); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.key b { font-size: 22px; font-weight: 500; }
.key small { font-size: 10px; color: var(--ink-3); margin-top: 3px; letter-spacing: .08em; }
.key:hover { background: var(--sunken); }
.key:active { transform: translateY(1px); }
.call-btn { margin-top: 14px; width: 100%; height: 54px; border-radius: var(--r-md); border: 0; background: var(--lamp-on); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; }
.call-btn svg { width: 20px; height: 20px; }
.call-btn:disabled { background: var(--lamp-off); cursor: not-allowed; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 10px; min-height: 20px; }

/* ---------- активный разговор ---------- */
.incall { padding: 22px; display: grid; gap: 18px; }
.incall .who { font-size: 32px; font-weight: 500; letter-spacing: .02em; line-height: 1.2; word-break: break-all; }
.incall .state { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.incall .timer { font-size: 18px; color: var(--ink); font-weight: 500; }
.call-ctrls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ctrl { height: 64px; border: 1px solid var(--rule); background: var(--panel); border-radius: var(--r-md); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.ctrl svg { width: 20px; height: 20px; color: var(--ink); }
.ctrl[aria-pressed="true"] { background: var(--cobalt-soft); border-color: var(--cobalt); color: var(--cobalt); }
.hang-btn { width: 100%; height: 54px; border: 0; border-radius: var(--r-md); background: var(--hang); color: #fff; font-size: 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; justify-content: center; cursor: pointer; }
.hang-btn svg { width: 20px; height: 20px; transform: rotate(135deg); }

/* ---------- входящий: единственная заметная анимация ---------- */
.incoming { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -140%); z-index: 50; width: min(560px, calc(100vw - 24px)); background: var(--ink); color: var(--paper); border-radius: var(--r-lg); padding: 16px 16px 16px 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; box-shadow: 0 18px 50px rgba(0,0,0,.28); visibility: hidden; transition: transform .38s cubic-bezier(.2,.9,.25,1.15), visibility 0s linear .38s; }
.incoming.show { transform: translate(-50%, 0); visibility: visible; transition: transform .38s cubic-bezier(.2,.9,.25,1.15), visibility 0s; }
.incoming .lamp { width: 14px; height: 14px; }
.incoming .num { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.incoming .sub { font-size: 13px; opacity: .75; }
.incoming .acts { display: flex; gap: 8px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; }
.round svg { width: 22px; height: 22px; }
.round.answer { background: var(--lamp-on); }
.round.decline { background: var(--hang); }
.round.decline svg { transform: rotate(135deg); }

/* ---------- история справа ---------- */
.side { display: grid; gap: 24px; }
.recent-item { color: inherit; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--rule); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover { background: var(--sunken); }
.recent-item .n { font-weight: 500; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px; border-bottom: 1px solid var(--rule); }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(400px, 100%); }
.login .board { display: flex; gap: 8px; margin-bottom: 22px; }
.login .board .lamp { width: 12px; height: 12px; }
.login h1 { margin-bottom: 6px; }
.login form { display: grid; gap: 14px; margin-top: 22px; }
.login .err { color: var(--lamp-err); font-size: 14px; min-height: 21px; }

/* ---------- диалоги и уведомления ---------- */
dialog { border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--panel); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(18, 23, 30, .45); }
dialog form { display: grid; gap: 14px; padding: 22px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.secret { font-size: 20px; font-weight: 600; letter-spacing: .04em; background: var(--sunken); border: 1px dashed var(--ink-3); border-radius: var(--r-sm); padding: 10px 12px; user-select: all; word-break: break-all; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; word-break: break-all; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; max-width: 360px; box-shadow: var(--shadow); }
.toast.err { background: var(--lamp-err); color: #fff; }
.assign-table td, .assign-table th { padding: 8px 10px; }
audio.player { height: 34px; width: 220px; vertical-align: middle; }

/* ---------- адаптив ---------- */
@media (max-width: 960px) {
  .console { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; padding: 6px; z-index: 40; border-right: 0; border-top: 1px solid var(--rule); overflow-x: auto; }
  .brand, .rail-foot .whoami, .reg { display: none; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; flex: 1; align-items: center; }
  .rail-foot { margin: 0; border: 0; padding: 0; display: flex; }
  .main { padding: 18px 14px 96px; }
  .grid2 { grid-template-columns: 1fr; }
  .display input { font-size: 32px; }
  audio.player { width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
