/* Digital Choice brand: orange #ea573e, ink #151515, sand #f5f3f1, Outfit.
   Orange is kept for the brand and focus states; red/green mean down/up. */
:root {
  --brand: #ea573e;
  --brand-deep: #cb4b35;
  --brand-soft: #fdeee9;
  --bg: #f5f3f1;
  --card: #ffffff;
  --ink: #151515;
  --muted: #6b6560;
  --line: #e7e2dd;
  --up: #15803d;
  --up-soft: #e8f6ec;
  --down: #c81e1e;
  --down-soft: #fdecec;
  --pending: #9a948e;
  --empty-bar: #e7e2dd;
  --shadow: 0 1px 2px rgba(21, 21, 21, .04), 0 4px 16px rgba(21, 21, 21, .04);
  --dc-brand: var(--brand);
  --dc-ink: #1c2021;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --card: #161616; --ink: #f5f3f1; --muted: #a39d97; --line: #2a2826;
    --up: #34d399; --up-soft: #0f2a1f; --down: #f87171; --down-soft: #341414; --pending: #77716b;
    --empty-bar: #2a2826; --brand-soft: #2e1813; --shadow: none; --dc-ink: #f5f3f1; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --card: #161616; --ink: #f5f3f1; --muted: #a39d97; --line: #2a2826;
  --up: #34d399; --up-soft: #0f2a1f; --down: #f87171; --down-soft: #341414; --pending: #77716b;
  --empty-bar: #2a2826; --brand-soft: #2e1813; --shadow: none; --dc-ink: #f5f3f1; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }

/* Logo (inline SVG injected by app.js) */
.logo svg { display: block; width: 100%; height: auto; }
.logo-lg { width: 190px; margin: 0 auto 8px; }
.logo-sm { width: 112px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line); }
.btn-danger { color: var(--down); }
.btn-danger:hover { border-color: var(--down); }
.btn-block { width: 100%; padding: 11px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
input, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-error { color: var(--down); font-size: 13px; min-height: 1em; margin: 10px 0 0; }
label.check { display: flex; align-items: center; gap: 8px; margin: 0; padding-top: 34px; font-size: 14px; }
label.check input { width: auto; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px; text-align: center; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; }
.login-card p.muted { margin: 4px 0 8px; }
.login-card label, .login-card .form-error { text-align: left; }
.login-card .btn-block { margin-top: 14px; }

/* Top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar::before { content: ""; display: block; height: 3px; background: var(--brand); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-tag {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft); padding: 3px 8px; border-radius: 6px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }

/* Overview banner */
.overview {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow); border-left: 5px solid var(--up);
}
.overview.is-down { border-left-color: var(--down); background: linear-gradient(90deg, var(--down-soft), var(--card) 60%); }
.overview.is-pending { border-left-color: var(--pending); }
.overview h1 { font-size: 22px; }
.overview .sub { color: var(--muted); font-size: 14px; }
.counts { display: flex; gap: 22px; }
.count b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; }
.count span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.count.c-up b { color: var(--up); }
.count.c-down b { color: var(--down); }

.note {
  margin-top: 14px; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  background: var(--brand-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* Project cards */
.grid { margin-top: 18px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px 6px; box-shadow: var(--shadow);
}
.card.has-down { border-color: var(--down); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h2 { font-size: 17px; }
.svc { padding: 12px 0; border-top: 1px solid var(--line); }
.svc:first-of-type { border-top: 0; }
.svc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.role { font-weight: 600; text-transform: capitalize; }
.svc a.url { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; word-break: break-all; margin-top: 2px; }
.svc a.url:hover { color: var(--brand); text-decoration: underline; }
.meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.svc.down .meta { color: var(--down); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--bg); color: var(--pending);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.down::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.paused { color: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }

.bars { display: flex; gap: 2px; height: 22px; margin-top: 10px; align-items: stretch; }
.bars i { flex: 1; border-radius: 2px; background: var(--empty-bar); min-width: 2px; }
.bars i.u { background: var(--up); opacity: .85; }
.bars i.d { background: var(--down); }
.bars-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }

.svc-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* Incidents */
.panel {
  margin-top: 22px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 17px; margin-bottom: 8px; }
.inc { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.inc:first-child { border-top: 0; }
.inc .what { font-weight: 500; }
.inc .when, .inc .why { color: var(--muted); font-size: 13px; }
.inc .dur { text-align: right; font-weight: 500; }
.inc .dur.open { color: var(--down); }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0 10px; }

.foot { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted); }

/* Dialog */
dialog {
  width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px;
  padding: 24px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(11, 11, 11, .45); }
dialog h2 { font-size: 19px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100vw - 32px);
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .topbar-inner { justify-content: center; }
  .actions { justify-content: center; }
  .counts { gap: 16px; }
  .row-2 { grid-template-columns: 1fr; }
  label.check { padding-top: 0; }
}
