:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202c;
  --muted: #697384;
  --line: #dfe4ea;
  --brand: #2764d9;
  --brand-dark: #174aa8;
  --danger: #bb2d3b;
  --ok: #16794a;
  --warn: #9a6500;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #b8c2d1;
}

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

button.primary:hover {
  background: var(--brand-dark);
}

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

button.danger {
  border-color: #f0b9be;
  color: var(--danger);
}

button.iconBtn {
  width: 36px;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

main {
  padding: 24px clamp(18px, 4vw, 48px);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  color: var(--muted);
}

.featureBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.featureBar h2 {
  margin-bottom: 4px;
}

.featureBar p {
  color: var(--muted);
}

.tableWrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  background: #fbfcfd;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.actionsCol {
  width: 310px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.webhookUrl {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.state-connected .dot,
.state-polling .dot {
  background: var(--ok);
}

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

.state-starting .dot,
.state-reconnecting .dot {
  background: var(--warn);
}

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

.hidden {
  display: none !important;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

#watcherForm {
  padding: 20px;
}

.dialogHead,
.dialogActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialogHead {
  margin-bottom: 18px;
}

.dialogActions {
  margin-top: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

label.wide,
label.check {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
}

label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 500;
}

label.check input {
  width: 17px;
  height: 17px;
}

.error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #f0b9be;
  color: var(--danger);
  background: #fff4f5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
}

.loginPage {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.loginShell {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
}

.loginPanel {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loginPanel p {
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar,
  .toolbar,
  .featureBar {
    align-items: stretch;
    flex-direction: column;
  }

  .topActions {
    width: 100%;
  }

  .topActions button {
    flex: 1;
  }

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