:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --border: #e3e6eb;
  --primary: #2453d6;
  --primary-ink: #ffffff;
  --up: #12805c;
  --up-bg: #e3f5ed;
  --down: #c62a2f;
  --down-bg: #fde8e8;
  --idle: #6b7280;
  --idle-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #1a2029;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2b3340;
    --primary: #5b86f5;
    --up: #3ccf91;
    --up-bg: #143528;
    --down: #ff6b6f;
    --down-bg: #3d1b1d;
    --idle: #a0a8b5;
    --idle-bg: #252c37;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .75rem; overflow-x: auto; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem; height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar nav { display: flex; gap: .25rem; overflow-x: auto; }
.topbar nav a { color: var(--muted); padding: .4rem .7rem; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.topbar-right form { margin: 0; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: 1.2rem; justify-content: center; margin-bottom: 1.25rem; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 4px var(--up-bg); }
.me { color: var(--text); font-size: .9rem; }
.bell { position: relative; color: var(--muted); display: flex; }
.bell:hover { color: var(--text); }
.bell-count { position: absolute; top: -6px; right: -9px; background: var(--down); color: #fff; font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.bell-count[hidden] { display: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.container.narrow { max-width: 420px; padding-top: 10vh; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.auth h1 { justify-content: center; }
.form-card { max-width: 760px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin-bottom: .25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.actions form { margin: 0; }
.back { display: inline-block; margin-bottom: .75rem; font-size: .9rem; color: var(--muted); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-value.small-value { font-size: 1.25rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-up .stat-value { color: var(--up); }
.stat-down .stat-value { color: var(--down); }

.table-wrap { overflow-x: auto; margin: -.25rem; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .65rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: .35rem .4rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .right { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table form { margin: 0; }
.row-down td { background: color-mix(in srgb, var(--down-bg) 45%, transparent); }
.site-name { font-weight: 600; color: var(--text); }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge-up { color: var(--up); background: var(--up-bg); }
.badge-down { color: var(--down); background: var(--down-bg); }
.badge-unknown, .badge-paused { color: var(--idle); background: var(--idle-bg); }
.badge-new { color: var(--primary-ink); background: var(--primary); margin-left: .4rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-up { background: var(--up); }
.dot-down { background: var(--down); }

.strip { display: flex; gap: 2px; height: 34px; }
.tick { flex: 1; min-width: 2px; border-radius: 2px; }
.tick-up { background: var(--up); opacity: .75; }
.tick-down { background: var(--down); }
.tick:hover { opacity: 1; outline: 2px solid var(--text); }
.strip-legend { display: flex; justify-content: space-between; margin-top: .35rem; }

.events { list-style: none; margin: 0 0 .75rem; padding: 0; }
.event { padding: .6rem 0 .6rem .8rem; border-left: 3px solid var(--idle); margin-bottom: .5rem; }
.event-down { border-color: var(--down); }
.event-up { border-color: var(--up); }
.event.unread { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.event-title { font-weight: 600; }
.plain { margin: 0 0 1.25rem; padding-left: 1.1rem; }

.form { display: flex; flex-direction: column; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; }
.form label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.form .row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form .row .grow { flex: 1 1 220px; }
.form-card .form { gap: 1rem; }
form.form > .card { margin-bottom: 0; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
.w-sm { width: 140px; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.form-actions { display: flex; gap: .5rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem .9rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, var(--border)); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn[disabled] { opacity: .6; cursor: wait; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; }
button.link:hover { color: var(--text); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: var(--up-bg); color: var(--up); }
.flash-error { background: var(--down-bg); color: var(--down); }
.danger-zone { border-color: color-mix(in srgb, var(--down) 30%, var(--border)); }
.empty { text-align: center; padding: 2rem 1rem; }
.empty .btn { margin: .25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error-text { color: var(--down); }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--idle); border-radius: 8px; padding: .75rem 1rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
.toast-down { border-left-color: var(--down); }
.toast-up { border-left-color: var(--up); }
.toast strong { display: block; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: .6rem 1rem; gap: .5rem 1rem; }
  .topbar nav { order: 3; width: 100%; }
  .container { padding: 1rem 1rem 2rem; }
  .truncate { max-width: 180px; }
}
