:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #fff;
  --ink: #172436;
  --muted: #506177;
  --line: #dce4ef;
  --accent: #1452a0;
  --accent-strong: #103f7d;
  --accent-soft: #e8f1ff;
  --good: #176345;
  --good-bg: #e3f5ed;
  --danger: #a32d3c;
  --radius: 16px;
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.45rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { font-size: 1.17rem; line-height: 1.3; letter-spacing: -.015em; }
p + p { margin-top: .6rem; }
a { color: var(--accent-strong); text-underline-offset: .22em; }
:focus-visible { outline: 3px solid #3475ce; outline-offset: 3px; }
.shell { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; padding: 1.45rem 0 1.15rem; }
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 750; line-height: 1.18; text-decoration: none; color: var(--ink); }
.brand-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: white; background: var(--accent-strong); font-size: 1.2rem; flex: none; }
.brand-sub { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
nav { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
.topbar nav a { min-height: 44px; display: inline-flex; align-items: center; padding: .5rem .76rem; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 650; font-size: .93rem; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--accent-strong); background: var(--accent-soft); }
main.shell { display: grid; gap: 1rem; padding-block: 1.8rem; }
main.centered { min-height: 100vh; align-content: center; width: min(440px, calc(100% - 2rem)); }
.login-panel { display: grid; gap: 1.35rem; }
.page-head { display: flex; justify-content: space-between; gap: .85rem; align-items: center; flex-wrap: wrap; }
.page-head p { margin-top: .42rem; }
.compact { margin-bottom: .45rem; }
.panel, .metric { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: clamp(1rem, 2.4vw, 1.5rem); min-width: 0; }
.panel > h2:not(:last-child), .panel > p:not(:last-child) { margin-bottom: .79rem; }
.grid { display: grid; gap: .8rem; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { display: grid; align-content: space-between; gap: .5rem; }
.metric span { color: var(--muted); font-size: .93rem; }
.metric strong { font-size: clamp(1.6rem, 4vw, 2.35rem); line-height: 1.15; font-variant-numeric: tabular-nums; }
.current { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.current h2 { margin-bottom: .4rem; }
.current > div { min-width: 0; overflow-wrap: anywhere; }
.muted, .empty, dt { color: var(--muted); }
.notice { padding: .8rem 1rem; border-radius: 11px; background: var(--accent-soft); color: var(--accent-strong); }
.notice.error { background: #fae7ec; color: var(--danger); }
.stack { display: grid; justify-items: start; gap: .9rem; }
.stack > label:not(.inline), .stack > .grid, .stack > section { width: 100%; }
.panel.stack > h2, .panel.stack > p { margin-bottom: 0; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
label { display: grid; gap: .35rem; font-weight: 650; font-size: .94rem; min-width: 0; }
label .muted { font-weight: 400; }
input, textarea, select, button { font: inherit; }
input:not([type="checkbox"]), textarea, select {
  max-width: 100%; width: 100%; min-width: 0; min-height: 45px; border: 1px solid #aebdd0;
  border-radius: 9px; padding: .55rem .68rem; background: #fff; color: var(--ink);
  font-size: 1rem; font-weight: 450;
}
select {
  appearance: none;
  background: linear-gradient(45deg, transparent 48%, var(--muted) 50%) calc(100% - 16px) center / 5px 5px no-repeat,
              linear-gradient(135deg, var(--muted) 50%, transparent 52%) calc(100% - 11px) center / 5px 5px no-repeat, #fff;
  padding-right: 1.65rem;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: 21px; height: 21px; flex: none; margin: 0; accent-color: var(--accent); }
.inline { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
label.inline { min-height: 44px; flex-wrap: nowrap; }
button, .button {
  display: inline-flex; justify-content: center; align-items: center; text-align: center;
  min-height: 44px; padding: .55rem .95rem; border-radius: 9px; font-size: .94rem;
  font-weight: 700; border: 1px solid transparent; text-decoration: none; cursor: pointer;
}
.primary { background: var(--accent-strong); color: #fff; }
.primary:hover { background: #0a3267; }
.secondary { background: #fff; border-color: #b6c7dd; color: var(--accent-strong); }
.secondary:hover { background: var(--accent-soft); }
.danger { background: var(--danger); color: #fff; }
.danger:hover { background: #842131; }
.text-btn { background: transparent; color: var(--accent-strong); text-decoration: underline; text-underline-offset: .22em; }
.activity, .record-list { list-style: none; margin: 0; padding: 0; width: 100%; }
.activity li, .record-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem .8rem; padding: .85rem 0; }
.activity li:first-child, .record-list li:first-child { padding-top: .25rem; }
.activity li:last-child, .record-list li:last-child { padding-bottom: .25rem; }
.activity li + li, .record-list li + li { border-top: 1px solid var(--line); }
.activity li span, .record-list li p { font-size: .88rem; }
.record-name { font-weight: 750; overflow-wrap: anywhere; }
.badges { display: flex; gap: .38rem; flex-wrap: wrap; }
.badge { display: inline-flex; background: var(--accent-soft); color: var(--accent-strong); border-radius: 8px; padding: .24rem .55rem; font-size: .86rem; font-weight: 700; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.muted { background: #eef1f6; color: var(--muted); }
.filter { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem 1rem; }
.filter label:first-child { flex: 1 1 15rem; }
.pager, .footer { margin-top: 1rem; display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.footer { margin-top: 0; border-top: 1px solid var(--line); padding-block: .6rem 1rem; font-size: .88rem; color: var(--muted); }
.facts, .summary { display: grid; margin: 0 0 1rem; gap: .65rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.facts dd, .summary dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.summary { margin-top: 1rem; margin-bottom: 0; }
.summary dd { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.message-preview { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; width: min(100%, 32rem); }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: .85rem; }
.monitor details { margin-top: .8rem; }
.monitor details form { margin-top: .55rem; max-width: 32rem; }
.remote-browser { margin-top: 1rem; }
.remote-browser-stage { position: relative; width: min(100%, 30rem); margin-inline: auto; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #eef1f6; min-height: 18rem; }
.remote-browser-stage img { display: block; width: 100%; height: auto; min-height: 18rem; background: transparent; }
.remote-browser-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 1.5rem; text-align: center; color: var(--muted); background: #eef1f6; pointer-events: none; }
.remote-browser.is-loaded .remote-browser-overlay { display: none; }
.remote-keyboard { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; font-size: 16px; cursor: crosshair; }
.status-dot { display: inline-block; width: .7rem; height: .7rem; margin-right: .35rem; border-radius: 50%; background: #98a2b3; }
.status-dot.state-working { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.status-dot.state-warning { background: #eab308; box-shadow: 0 0 0 3px #fef9c3; }
.status-dot.state-no-response { background: #f97316; box-shadow: 0 0 0 3px #ffedd5; }
.status-dot.state-danger { background: #dc2626; box-shadow: 0 0 0 3px #fee2e2; }
.status-dot.state-off { background: #667085; }
.bot-status.state-working { color: #15803d; }
.bot-status.state-warning { color: #a16207; }
.bot-status.state-no-response { color: #c2410c; }
.bot-status.state-danger { color: #b91c1c; }
.bot-status.state-off, .bot-status.state-unchecked { color: var(--muted); }
summary { color: var(--accent-strong); font-weight: 680; cursor: pointer; min-height: 44px; padding: .6rem 0; }
@media (max-width: 800px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 450px) {
  .shell { width: calc(100% - 1.5rem); }
  .topbar { padding-bottom: .5rem; }
  .topbar nav a { padding-inline: .62rem; }
  main.shell { padding-block: 1rem; }
  .footer { gap: 0 .4rem; }
  .footer > span { flex-basis: 100%; }
}

.token-input {
  width: 100%;
  max-width: 42rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: .55rem;
}
[hidden] { display: none !important; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin-top: 1rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .91rem;
}
.data-table th,
.data-table td {
  padding: .7rem .65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.data-table th {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.blacklist-table { min-width: 76rem; }
.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  min-width: 10rem;
}
.table-actions form { margin: 0; }
.preview-result {
  display: grid;
  gap: .85rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.danger-zone {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }
  .data-table thead { display: none; }
  .blacklist-table { min-width: 0; }
  .data-table tr {
    margin-bottom: .75rem;
    padding: .7rem .8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .data-table td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 38%) minmax(0, 1fr);
    gap: .6rem;
    padding: .42rem 0;
    border: 0;
  }
  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }
  .table-actions { display: flex; }
  .table-actions::before { flex-basis: 100%; }
}
