:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2128;
  --muted: #5b6672;
  --line: #dde2e7;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok-bg: #dcf5e3; --ok: #116329;
  --warn-bg: #fff4d6; --warn: #7a5200;
  --bad-bg: #ffe3e3; --bad: #a1131f;
  --info-bg: #ddeeff; --info: #0b4ea2;
  --off-bg: #eceff2; --off: #4a535c;
  --control-line: #7d8995;           /* 3.6:1 on white: visible field and button borders */
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main, .top { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 16px 4px; }
h1 { font-size: 1.35rem; margin: 0; }
h2, h3 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.system { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
        background: var(--card); border: 1px solid var(--line); font-size: .92rem; }
.chip b { font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title { font-weight: 650; font-size: 1.05rem; margin: 0; }
.hint { margin: -2px 0 12px; padding: 8px 12px; border-radius: 10px; background: var(--bg); color: var(--text); font-size: .92rem; }
.banner { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.banner:empty { margin: 0; padding: 0; }
.bars { letter-spacing: 1px; }
.card-sub { color: var(--muted); font-size: .9rem; }

.badge { flex: none; padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.badge.online { background: var(--ok-bg); color: var(--ok); }
.badge.offline { background: var(--bad-bg); color: var(--bad); }
.badge.dhcp { background: var(--warn-bg); color: var(--warn); }
.badge.rotating { background: var(--info-bg); color: var(--info); }
.badge.absent { background: var(--off-bg); color: var(--off); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.big-ip { font-size: 1.15rem; font-weight: 650; }
.facts dd.big-ip { overflow-wrap: normal; }
@media (max-width: 440px) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
}

.proxy { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
/* label on its own line, the proxy string uses the full width, copy button beside it */
.proxy-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; margin-bottom: 10px; }
.proxy-row code { min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--bg);
                  font: .86rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.proxy-label { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); font-weight: 600; }

.copy { position: relative; flex: none; }
.tip { position: absolute; inset-block-end: calc(100% + 6px); inset-inline-end: 0; padding: 3px 8px;
       border-radius: 8px; background: var(--text); color: #fff; font-size: .8rem; white-space: nowrap;
       opacity: 0; pointer-events: none; transition: opacity .15s; }
.copy-button[data-copied] + .tip, .copy-button[data-failed] + .tip { opacity: 1; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1 1 auto; }
.btn { min-height: 44px; min-inline-size: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--control-line);
       background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--text); }
.btn:focus-visible, .link:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger-outline { color: var(--bad); }
.btn.small { padding: 0 10px; font-size: .88rem; }
.btn[disabled], .btn[aria-disabled="true"], .link[aria-disabled="true"] { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; padding: 10px 8px; }

.setting { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
select, input[type="text"], input[type="password"], input[type="url"] {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--control-line); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
.linkbox { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 8px; }
.linkbox input { min-width: 0; font-size: .86rem; }
@media (max-width: 480px) {
  .linkbox { grid-template-columns: 1fr 1fr; }
  .linkbox input { grid-column: 1 / -1; }
  .linkbox .btn { width: 100%; }
}

details.card summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
pre#logs { margin: 12px 0 0; max-height: 360px; overflow: auto; font: .78rem/1.4 ui-monospace, Consolas, monospace;
           white-space: pre-wrap; overflow-wrap: anywhere; }

/* notifications: one fixed region, newest on top; also shown in the cards themselves */
.toasts { position: fixed; inset-inline: 0; inset-block-end: 12px; z-index: 10; display: flex; flex-direction: column;
          align-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%;
         padding: 10px 10px 10px 14px; border-radius: 12px; background: var(--text); color: #fff;
         box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.toast p { margin: 0; flex: 1; }
.toast .close { flex: none; min-width: 44px; min-height: 44px; border: 0; border-radius: 8px; background: rgba(255,255,255,.14);
                color: #fff; font: inherit; cursor: pointer; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } }
}

dialog { border: 0; border-radius: var(--radius); padding: 20px; max-width: min(440px, calc(100vw - 32px)); }
dialog h2 { margin-bottom: 8px; }
dialog p { margin: 0 0 16px; color: var(--muted); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgba(20, 26, 33, .45); overflow: hidden; overscroll-behavior: contain; }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login form { display: grid; gap: 12px; }
.login label { font-weight: 600; font-size: .92rem; }
.login .field { display: grid; gap: 6px; }
.login .pwrow { display: flex; gap: 8px; }
.login .pwrow input { flex: 1; min-width: 0; }
.err { color: var(--bad); min-height: 1.4em; margin: 0; }

/* per-modem extras: passwordless access, own log */
.field-label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.linkbox.wl { grid-template-columns: 1fr auto; }
.slotlogbox { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.slotlogbox summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
pre.slotlog { margin: 4px 0 0; max-height: 260px; overflow: auto; font: .76rem/1.4 ui-monospace, Consolas, monospace;
              white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
#tg p { margin: 0 0 10px; }
#tg a { color: var(--accent); font-weight: 600; }
