:root {
  color-scheme: light;
  font-family: "Inter", "Aptos", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #171b19;
  --muted: #54605a;
  --acid: #dcf78b;
  --dark: #172320;
  --line: #dfe5dd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #729332; outline-offset: 4px; }
.portal-header {
  max-width: 1380px;
  margin: auto;
  padding: 25px clamp(22px, 5vw, 68px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.portal-brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: -.02em; }
.mark {
  width: 24px;
  height: 24px;
  background: var(--acid);
  clip-path: polygon(0 0, 35% 0, 51% 56%, 69% 0, 100% 0, 66% 100%, 33% 100%);
}
.brand-divider { height: 14px; width: 1px; background: currentColor; opacity: .25; }
.portal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 46px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 720;
  font-size: .93rem;
  white-space: nowrap;
}
.portal-button.accent { background: var(--acid); }
.portal-button.accent:hover:enabled, a.portal-button.accent:hover { background: #edffac; }
.portal-button.outline { border-color: var(--line); background: transparent; }
.portal-button.outline:hover:enabled { background: #fff; }

.cover { background: #101916; color: #f4f7ed; }
.cover-main {
  max-width: 1380px;
  min-height: calc(100svh - 78px);
  margin: auto;
  padding: 40px clamp(22px, 5vw, 68px) 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-items: center;
  gap: 40px;
}
.cover-copy h1 {
  font-size: clamp(60px, 10vw, 142px);
  font-weight: 720;
  letter-spacing: -.09em;
  line-height: .96;
  margin: 0 0 25px;
}
.cover-copy h1 span { color: var(--acid); }
.cover-copy p { color: #b7c6bb; font-size: clamp(17px, 2vw, 22px); line-height: 1.55; max-width: 380px; margin: 0 0 30px; }
.signal {
  min-height: 360px;
  aspect-ratio: 1.13;
  display: grid;
  place-items: center;
  border: 1px solid #34463d;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(#a0d6b015 1px, transparent 1px) 50% 50% / 32px 32px,
    linear-gradient(90deg, #a0d6b015 1px, transparent 1px) 50% 50% / 32px 32px,
    radial-gradient(ellipse at center, #365344, #192721 68%);
}
.signal-wave { display: flex; align-items: center; gap: 3%; width: 77%; height: 59%; }
.signal-wave i {
  flex: 1;
  height: var(--level, 16%);
  border-radius: 50px;
  background: linear-gradient(180deg, #f0ffa4, #a3d968);
  box-shadow: 0 0 18px #dafa6450;
}
.signal-wave i:nth-child(2n) { --level: 28%; }
.signal-wave i:nth-child(3n) { --level: 47%; }
.signal-wave i:nth-child(5n) { --level: 69%; }
.signal-wave i:nth-child(7n) { --level: 87%; }
.signal-wave i:nth-child(8) { --level: 100%; }

.login-main {
  display: grid;
  min-height: calc(100svh - 78px);
  place-items: center;
  padding: 25px 20px 75px;
  background: radial-gradient(ellipse at 50% 45%, #253c32, #101916 65%);
}
.login-card {
  width: min(100%, 440px);
  border-radius: 24px;
  padding: clamp(24px, 6vw, 42px);
  background: #f8faf4;
  color: var(--ink);
  box-shadow: 0 20px 85px #0005;
}
.text-link { font-size: .88rem; color: var(--muted); }
.text-link:hover { text-decoration: underline; }
.login-card h1 { font-size: clamp(28px, 6vw, 42px); letter-spacing: -.06em; margin: 21px 0 7px; }
.login-card p { color: var(--muted); line-height: 1.5; margin: 0 0 27px; }
.login-card label { display: block; margin: 0 0 8px; font-size: .88rem; font-weight: 720; }
.login-card select, .login-card input {
  min-height: 49px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #cdd6cc;
  border-radius: 9px;
  color: var(--ink);
  background: white;
}
.login-card select { margin-bottom: 17px; }
.password-input { position: relative; }
.password-input input { padding-right: 92px; }
.password-input button {
  position: absolute;
  inset: 6px 6px 6px auto;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: #eef1ea;
  color: var(--muted);
  font-size: .78rem;
}
.login-card .portal-button { width: 100%; margin-top: 20px; justify-content: space-between; }
.portal-error, .login-card .portal-error { color: #8e302f; margin: 12px 0 0; font-size: .88rem; }

.workspace { background: #f3f5ef; }
.workspace .portal-header { border-bottom: 1px solid var(--line); }
.workspace .mark { background: #53794a; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.role-tag { background: #e5eddf; color: #34533f; padding: 7px 11px; border-radius: 7px; font-size: .85rem; }
.dashboard { width: min(100%, 1120px); margin: auto; padding: 42px clamp(20px, 5vw, 50px) 64px; }
.dashboard h1 { font-size: clamp(35px, 6vw, 62px); letter-spacing: -.065em; margin: 0 0 24px; }
.portal-nav { display: flex; gap: 5px; flex-wrap: wrap; }
.portal-nav a {
  padding: 9px 11px;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--muted);
}
.portal-nav a:hover, .portal-nav a[aria-current="page"] { background: #e5eddf; color: #244333; }
.portal-nav a[aria-current="page"] { font-weight: 720; }
.bitrix-page { max-width: 1200px; }
.connection-panel {
  display: grid;
  grid-template-columns: minmax(130px, 1.4fr) auto repeat(2, minmax(130px, 1fr));
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.connection-panel strong, .connection-panel span { display: block; }
.connection-panel span { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.connection-state strong::before {
  content: "";
  display: inline-block;
  vertical-align: .12em;
  margin-right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9d7947;
}
.connection-state strong[data-state="up"]::before { background: #447745; }
.connection-state strong[data-state="down"]::before { background: #a94442; }
.bitrix-section { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.036em; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-actions .portal-button, .connection-panel .portal-button { min-height: 39px; padding: 8px 12px; }
.hint { color: var(--muted); font-size: .89rem; }
#bitrix-progress:empty { display: none; }
.funnel-list { display: grid; gap: 8px; }
.funnel, .history-entry { border: 1px solid var(--line); background: #fff; border-radius: 11px; }
.funnel summary, .history-entry summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; }
.funnel summary::-webkit-details-marker, .history-entry summary::-webkit-details-marker { display: none; }
.funnel summary::before, .history-entry summary::before {
  content: "";
  display: inline-block;
  flex: 0 0 7px;
  height: 7px;
  border-right: 2px solid #647a68;
  border-bottom: 2px solid #647a68;
  transform: rotate(-45deg);
}
.funnel[open] > summary::before, .history-entry[open] > summary::before { transform: rotate(45deg); }
.funnel-count { margin-left: auto; background: #e9f1e5; color: #2f513c; padding: 4px 9px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.stage-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
.stage-table th, .stage-table td { padding: 8px 16px; border-top: 1px solid var(--line); }
.stage-table thead { background: #f8faf6; color: var(--muted); }
.stage-table tbody th { font-weight: 500; }
.stage-table td, .stage-table thead th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-empty { padding: 0 16px; }
.history-entry { margin-bottom: 8px; }
.history-entry time { margin-left: auto; color: var(--muted); font-size: .82rem; }
.history-body { border-top: 1px solid var(--line); padding: 0 16px 12px; }
.run-badge { background: #eef0eb; color: #485651; padding: 4px 8px; border-radius: 6px; font-size: .8rem; }
.run-badge[data-state="done"] { background: #e9f1e5; color: #2f513c; }
.run-badge[data-state="failed"], .run-badge[data-state="interrupted"] { background: #faeae8; color: #89332f; }

@media (max-width: 720px) {
  .cover-main { grid-template-columns: 1fr; align-content: center; gap: 30px; }
  .signal { min-height: 0; aspect-ratio: 1.66; }
  .portal-header { padding-block: 17px; }
  .workspace .portal-header { flex-wrap: wrap; }
  .portal-nav { order: 3; width: 100%; }
  .connection-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
  .workspace .portal-header { flex-wrap: wrap; }
  .connection-panel { grid-template-columns: 1fr; }
  .history-entry summary { flex-wrap: wrap; }
  .history-entry time { margin-left: 16px; }
}

.settings-card {
  max-width: 760px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.settings-card h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.035em; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.settings-fields label { font-size: .89rem; font-weight: 650; }
.settings-fields select {
  display: block;
  width: 100%;
  min-height: 43px;
  margin-top: 7px;
  padding: 8px 11px;
  border: 1px solid #cdd6cc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 20px; }
.settings-actions .hint { margin: 0; }
@media (max-width: 500px) {
  .settings-fields { grid-template-columns: 1fr; }
}

.settings-telephony { margin-top: 18px; }
.settings-telephony h3 { margin: 22px 0 9px; font-size: 1rem; }
.settings-status-list { margin: 0; }
.settings-status-list > div {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: .89rem;
}
.settings-status-list dd { margin: 0; color: var(--muted); }
.settings-status-list dd[data-state="up"] { color: #34533f; }
.settings-status-list dd[data-state="down"] { color: #8e302f; }
@media (max-width: 500px) {
  .settings-status-list > div { grid-template-columns: 1fr; gap: 4px; }
}

.call-defaults { margin-top: 20px; border-top: 1px solid var(--line); }
.call-defaults .settings-fields { margin-top: 12px; }
