:root {
  --bg: #111c28;
  --surface: #162331;
  --surface-strong: #1b2a3a;
  --surface-deep: #0d1722;
  --line: #2a3a4b;
  --line-strong: #3b4d61;
  --text: #ffffff;
  --muted: #94a3b4;
  --muted-strong: #bdc7d2;
  --accent: #ffa800;
  --accent-hover: #ffb72e;
  --accent-soft: rgba(255, 168, 0, 0.11);
  --danger: #ff707b;
  --danger-soft: rgba(255, 112, 123, 0.1);
  --connected: #4cd694;
  --connected-soft: rgba(76, 214, 148, 0.1);
  --shadow: 0 22px 60px rgba(4, 10, 17, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--text);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  line-height: 1.4;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand__word {
  display: inline-block;
}

.brand__logo {
  display: block;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg);
}

.brand__logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.55);
}

.brand__logo--hero {
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bot-name {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.container {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 58px 0 80px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 42px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.hero h1 {
  margin: 0 0 15px;
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 800;
  letter-spacing: -0.058em;
  line-height: 0.98;
}

.hero p:not(.eyebrow) {
  max-width: 640px;
  margin: 0;
  color: var(--muted-strong);
  font-size: 16px;
  line-height: 1.55;
}

.hero__side {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero__status {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0 28px;
}

.stat {
  min-height: 144px;
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.stat strong {
  display: block;
  margin: 10px 0 7px;
  color: var(--text);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.055em;
}

.stat--silence {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px;
}

.stat--silence-healthy {
  border-top-color: var(--connected);
}

.stat--silence-alert {
  border-top-color: var(--danger);
}

.silence-chart {
  position: relative;
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
}

.silence-chart canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.silence-chart__value {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  line-height: 1;
}

.silence-chart__value b {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.silence-chart__value span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 7px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.silence-summary {
  min-width: 0;
}

.silence-summary > span {
  color: var(--muted-strong);
  font-weight: 700;
  line-height: 1.25;
}

.silence-legend {
  display: grid;
  gap: 6px;
  margin-top: 11px;
}

.silence-legend span {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.legend-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.legend-dot--healthy {
  background: var(--connected);
}

.legend-dot--danger {
  background: var(--danger);
}

.panel {
  overflow: hidden;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 26px 20px;
}

.panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.groups-table {
  min-width: 1120px;
  table-layout: fixed;
}

.groups-table th:nth-child(1) { width: 15%; }
.groups-table th:nth-child(2) { width: 12%; }
.groups-table th:nth-child(3) { width: 10%; }
.groups-table th:nth-child(4) { width: 15%; }
.groups-table th:nth-child(5) {
  width: 21%;
  line-height: 1.35;
}
.groups-table th:nth-child(6) { width: 9%; }
.groups-table th:nth-child(7) { width: 18%; }

.groups-table td,
.groups-table th {
  padding-right: 12px;
  padding-left: 12px;
}

.groups-table td:first-child,
.groups-table th:first-child {
  padding-left: 26px;
}

.groups-table td:last-child,
.groups-table th:last-child {
  padding-right: 18px;
  padding-left: 8px;
}

th {
  padding: 14px 16px;
  background: var(--surface-deep);
  color: #78899c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 17px 16px;
  border-top: 1px solid var(--line);
  color: #eaf0f6;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

td:first-child,
th:first-child {
  padding-left: 26px;
}

td:last-child,
th:last-child {
  padding-right: 26px;
}

.cell-note {
  overflow: hidden;
  max-width: 220px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-note--error {
  color: #ff9aa3;
}

.cell-note--connected {
  color: var(--connected);
}

code {
  color: #c7d1dc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  color: #a9b6c5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.badge--success {
  border-color: rgba(255, 168, 0, 0.55);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--connected {
  border-color: rgba(76, 214, 148, 0.58);
  background: var(--connected-soft);
  color: var(--connected);
}

.badge--danger {
  border-color: rgba(255, 112, 123, 0.45);
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--warning {
  border-color: #546477;
  color: #d4dde7;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.actions form {
  margin: 0;
}

.message-time {
  display: inline-flex;
  min-width: 220px;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  border: 1px solid currentColor;
  border-radius: 7px;
  background: transparent;
}

.message-time strong {
  font-size: 12px;
  font-weight: 700;
}

.message-time span {
  color: currentColor;
  font-size: 10px;
  opacity: 0.82;
}

.message-time--healthy {
  background: var(--connected-soft);
  color: var(--connected);
}

.message-time--late {
  background: var(--danger-soft);
  color: var(--danger);
}

.message-time--inactive {
  border-color: var(--line-strong);
  background: rgba(120, 137, 156, 0.07);
  color: #9baabb;
}

.action-button {
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  color: #bdc8d4;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.action-button:hover,
.action-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.action-button--danger:hover,
.action-button--danger:focus-visible {
  border-color: var(--danger);
  color: var(--danger);
}

.icon-action {
  display: inline-grid;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  background: transparent;
  color: #bdc8d4;
  cursor: pointer;
  place-items: center;
  text-decoration: none;
}

.icon-action:hover,
.icon-action:focus-visible,
.icon-action--active {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-action--danger:hover,
.icon-action--danger:focus-visible {
  border-color: var(--danger);
  color: var(--danger);
}

.action-icon {
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.action-icon--pause {
  -webkit-mask-image: url('/assets/icons/pause.svg');
  mask-image: url('/assets/icons/pause.svg');
}

.action-icon--play {
  -webkit-mask-image: url('/assets/icons/play.svg');
  mask-image: url('/assets/icons/play.svg');
}

.action-icon--edit {
  -webkit-mask-image: url('/assets/icons/edit.svg');
  mask-image: url('/assets/icons/edit.svg');
}

.action-icon--delete {
  -webkit-mask-image: url('/assets/icons/delete.svg');
  mask-image: url('/assets/icons/delete.svg');
}

.edit-row td {
  padding: 0;
  background: var(--surface-deep);
}

.is-editing {
  background: rgba(255, 168, 0, 0.045);
}

.edit-form {
  display: grid;
  grid-template-columns: 0.75fr 1.05fr 1fr 0.55fr 0.55fr auto;
  align-items: end;
  gap: 12px;
  padding: 20px 26px 24px;
  border-left: 3px solid var(--accent);
}

.edit-form--chat {
  grid-template-columns: 0.75fr 1.2fr 1fr 0.65fr 0.65fr auto;
}

.edit-form--chat .schedule-fields {
  grid-column: 2 / 6;
}

.edit-form--user {
  grid-template-columns: 0.8fr 1.2fr 1fr auto;
}

.edit-form__intro {
  align-self: center;
}

.edit-form__intro .eyebrow {
  margin-bottom: 7px;
  font-size: 9px;
}

.edit-form label {
  display: grid;
  gap: 8px;
  color: #9baabb;
  font-size: 11px;
  font-weight: 700;
}

.edit-form input,
.edit-form select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #0a141f;
  color: var(--text);
}

.edit-form input:focus,
.edit-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 168, 0, 0.12);
}

.edit-form__actions {
  display: flex;
  gap: 8px;
}

.add-form {
  display: grid;
  grid-template-columns: 1.15fr 1.05fr 0.58fr 0.65fr auto;
  align-items: end;
  gap: 12px;
  padding: 22px 26px 26px;
  background: var(--surface-deep);
}

.add-form--users {
  grid-template-columns: 1.3fr 1fr auto;
}

.add-form--chats .schedule-fields {
  grid-column: 1 / 5;
}

.schedule-fields {
  display: grid;
  grid-template-columns: minmax(145px, 1.25fr) minmax(105px, 0.8fr) minmax(105px, 0.8fr);
  gap: 10px;
  min-width: 0;
  padding: 11px 12px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}

.schedule-fields--always [data-schedule-time] {
  opacity: 0.42;
}

.add-form label,
.stack label {
  display: grid;
  gap: 8px;
  color: #9baabb;
  font-size: 11px;
  font-weight: 700;
}

.add-form input,
.add-form select,
.stack input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #0a141f;
  color: var(--text);
}

.add-form input::placeholder,
.stack input::placeholder {
  color: #5f7184;
}

.add-form input:focus,
.add-form select:focus,
.stack input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 168, 0, 0.12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button--primary {
  background: var(--accent);
  color: #111c28;
}

.button--primary:hover,
.button--primary:focus-visible {
  background: var(--accent-hover);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.button--secondary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text);
}

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

.button--ghost {
  border-color: var(--line);
  background: transparent;
  color: #b6c1cd;
}

.button--small {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}

.button--wide {
  width: 100%;
  min-height: 48px;
}

.empty {
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 13px;
}

.notice--success {
  border-left-color: var(--accent);
}

.notice--error {
  border-left-color: var(--danger);
  color: #ffc2c7;
}

.notice--warning {
  border-left-color: #ffffff;
  color: #e4ebf2;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 30px;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, 0.75fr);
  width: min(1080px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-identity {
  display: flex;
  min-height: 620px;
  flex-direction: column;
  justify-content: space-between;
  padding: 38px 44px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.login-identity__logo {
  width: min(340px, 78%);
  align-self: center;
}

.login-identity h2 {
  margin: 0 0 14px;
  font-size: clamp(31px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.login-identity p:last-child {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 42px;
  background: var(--surface);
}

.brand--login {
  margin-bottom: 38px;
}

.login-card__intro h1 {
  margin: 0 0 16px;
  font-size: 39px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.login-card__intro > p:last-child {
  margin-bottom: 28px;
  color: var(--muted);
  line-height: 1.55;
}

.stack {
  display: grid;
  gap: 17px;
}

.login-card__foot {
  margin: 22px 0 0;
  color: #728295;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 900px) {
  .container {
    width: min(100% - 24px, 1280px);
    padding-top: 36px;
  }

  .hero {
    display: block;
  }

  .hero__side {
    justify-content: space-between;
    margin-top: 24px;
  }

  .hero__status {
    align-items: flex-start;
  }

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

  .add-form,
  .add-form--users,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .add-form--chats .schedule-fields,
  .edit-form--chat .schedule-fields {
    grid-column: auto;
  }

  .schedule-fields {
    grid-template-columns: 1fr;
  }

  .panel__head {
    padding: 21px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    max-width: 520px;
  }

  .login-identity {
    display: none;
  }
}

@media (max-width: 1100px) and (min-width: 901px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    height: 68px;
    padding: 0 14px;
  }

  .brand__word,
  .bot-name {
    display: none;
  }

  .brand__logo {
    width: 40px;
    height: 40px;
  }

  .brand__logo--hero {
    display: block;
    width: 74px;
    height: 74px;
  }

  .hero h1 {
    font-size: 39px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .hero__side {
    align-items: flex-end;
  }

  .panel__head {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 30px 24px;
  }

  .login-card__intro h1 {
    font-size: 33px;
  }
}
