:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #9a6700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.alert {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #f2c94c;
  border-radius: 8px;
  background: #fff8df;
  color: var(--warning);
}

.hidden {
  display: none;
}

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

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  margin-bottom: 16px;
}

.settings-panel {
  margin-bottom: 16px;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.settings-form select,
.settings-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--text);
  font-size: 15px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.switch-row span {
  display: grid;
  gap: 3px;
}

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

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #f0f3f6;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #8f1b12;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.status-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

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

.password-form {
  display: grid;
  gap: 12px;
}

.password-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.password-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 16px;
}

.bot-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.recipients {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.recipients li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.recipients button {
  min-height: 32px;
  padding: 0 10px;
}

.events-panel {
  min-height: 260px;
}

.events {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.events li {
  display: grid;
  grid-template-columns: 90px 80px 1fr;
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.events li:last-child {
  border-bottom: 0;
}

.level-error {
  color: var(--danger);
}

.level-warning {
  color: var(--warning);
}

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
}

.toast {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(27, 31, 36, 0.16);
  padding: 12px 14px;
  animation: toast-in 180ms ease-out;
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast-success {
  border-left: 4px solid var(--accent);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid #2563eb;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .controls,
  .grid,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .events li {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
