@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&family=Source+Sans+3:wght@400;600;700&display=swap');

/* ── Brand tokens (ported from synk.it) ───────────────────────────────── */
:root {
  --blue: #29abe2;
  --orange: #da532c;
  --orange-dark: #c44622;

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --border: #ececec;
  --heading: #111111;
  --text: #555555;
  --text-muted: #888888;
  --header-bg: #ffffff;
  --header-border: #ececec;
  --footer-bg: #0a0a0a;
  --footer-text: #777777;
  --toggle-border: #dddddd;

  /* status palette — traffic light; always paired with a text label / tooltip */
  --st-ok: #1f9d55;
  --st-degraded: #e0a80f;
  --st-outage: #cf3721;
  --st-maint: #3b7fc4;
  --st-unknown: #b8bcc2;
  --st-track: #e4e4e4;
}

[data-mode="dark"] {
  --bg: rgb(27, 27, 30);
  --surface: rgb(39, 40, 43);
  --surface-2: rgb(32, 33, 36);
  --border: rgb(44, 45, 45);
  --heading: #cccccc;
  --text: rgb(175, 176, 177);
  --text-muted: rgb(107, 116, 124);
  --header-bg: rgb(27, 27, 30);
  --header-border: rgb(44, 45, 45);
  --footer-bg: #0a0a0a;
  --footer-text: #666666;
  --toggle-border: rgb(63, 65, 68);

  --st-ok: #3fbd77;
  --st-degraded: #e0b13e;
  --st-outage: #e5604c;
  --st-maint: #5b9ad6;
  --st-unknown: #4a4d52;
  --st-track: rgb(44, 45, 45);
  color-scheme: dark;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

main { flex: 1 0 auto; width: 100%; }

h1, h2, h3, h4 { font-family: "Lato", sans-serif; color: var(--heading); line-height: 1.2; }
a { color: var(--blue); }

.accent { color: var(--blue); }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

/* ── Header / footer ──────────────────────────────────────────────────── */
.site-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--header-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 200;
}
.site-header .logo img { height: 42px; width: auto; display: block; }
.header-right { display: flex; align-items: center; gap: 1.75rem; }
.site-nav { display: flex; gap: 1.5rem; font-family: "Lato", sans-serif; font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0.6px; text-transform: uppercase; }
.site-nav a { text-decoration: none; color: var(--text-muted); transition: color 0.2s; }
.site-nav a:hover, .site-nav a.active { color: var(--blue); }
.acct { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }
.acct .who { color: var(--heading); font-weight: 700; max-width: 12ch; overflow: hidden;
  text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.acct a { color: var(--blue); text-decoration: none; }
.acct a:hover { text-decoration: underline; }

#mode-toggle {
  background: none; border: 1px solid var(--toggle-border); border-radius: 4px;
  cursor: pointer; padding: 0.3rem 0.5rem; font-size: 0.95rem; line-height: 1;
  color: var(--text-muted); transition: border-color 0.2s, color 0.2s;
}
#mode-toggle:hover { border-color: var(--blue); color: var(--blue); }

.site-footer {
  flex-shrink: 0;
  padding: 2rem 1.5rem; background: var(--footer-bg); color: var(--footer-text);
  text-align: center; font-size: 0.85rem;
}
.site-footer a { color: var(--footer-text); }
.site-footer a:hover { color: var(--blue); }

@media (max-width: 640px) {
  .site-header { padding: 0.85rem 1.1rem; flex-wrap: wrap; gap: 0.6rem 0.9rem; }
  .header-right { gap: 0.75rem; flex-wrap: wrap; }
  .site-nav { gap: 1rem; font-size: 0.72rem; }
  .acct { font-size: 0.7rem; }
  .acct .who { max-width: 9ch; }
}

/* ── Layout primitives ───────────────────────────────────────────────── */
.wrap { max-width: 960px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.wrap-narrow { max-width: 620px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.wrap-wide { max-width: 1600px; margin: 0 auto; padding: 2.5rem clamp(1rem, 4vw, 3rem); }
.page-head { text-align: center; margin-bottom: 2.5rem; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 900; margin-bottom: 0.6rem; }
.page-head p { color: var(--text); max-width: 620px; margin: 0 auto; }

/* ── Tiles (ported from synk.it Services grid) ────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.tile {
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 2rem; text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--blue);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.tile-icon { color: var(--blue); margin-bottom: 1.15rem; display: block; }
.tile h3 { font-size: 1.15rem; margin-bottom: 0.4rem; font-weight: 700; }
.tile p { font-size: 0.92rem; color: var(--text); }
.tile .tile-arrow {
  margin-top: auto; padding-top: 1.25rem; font-size: 0.82rem;
  font-family: "Lato", sans-serif; font-weight: 700; color: var(--blue);
  opacity: 0; transform: translateX(-4px); transition: opacity 0.2s, transform 0.2s;
}
.tile:hover .tile-arrow { opacity: 1; transform: translateX(0); }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; gap: 1rem; } }

/* ── Cards / panels ──────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.5rem;
}
.card + .card { margin-top: 1rem; }

/* ── Forms ───────────────────────────────────────────────────────────── */
label { display: block; font-family: "Lato", sans-serif; font-weight: 700;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 0.4rem; }
.field { margin-bottom: 1.25rem; }
input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], input[type="url"], input[type="email"],
select, textarea {
  width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--heading);
  font: inherit; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.checkbox { display: flex; align-items: center; gap: 0.55rem; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; text-transform: none; letter-spacing: 0; font-weight: 400;
  font-family: inherit; font-size: 0.95rem; color: var(--text); }
.help { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.35rem; }

button, .btn {
  display: inline-block; background: var(--orange); color: #fff; border: none;
  padding: 0.8rem 1.9rem; border-radius: 4px; text-decoration: none; cursor: pointer;
  font-family: "Lato", sans-serif; font-weight: 700; font-size: 0.95rem;
  letter-spacing: 0.3px; transition: background 0.15s, opacity 0.15s;
}
button:hover, .btn:hover { background: var(--orange-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn-ghost:hover { background: var(--blue); color: #fff; }

/* ── Result / code blocks ────────────────────────────────────────────── */
.result {
  border: 1px solid var(--blue); border-radius: 6px; padding: 1rem;
  background: var(--surface-2); word-break: break-all; font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9rem;
}
.muted { color: var(--text-muted); }
.err { color: var(--st-outage); }
.ok { color: var(--st-ok); }

/* ── Status pills (webstatus) ────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.6rem;
  border-radius: 999px; font-family: "Lato", sans-serif; font-weight: 700;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
  border: 1px solid currentColor;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-operational { color: var(--st-ok); }
.s-degraded { color: var(--st-degraded); }
.s-outage { color: var(--st-outage); }
.s-maintenance { color: var(--st-maint); }
.s-unknown { color: var(--st-unknown); }

/* ── webstatus dashboard ─────────────────────────────────────────────── */
.status-toolbar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.status-toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button {
  background: var(--surface); color: var(--text-muted); border: none; border-radius: 0;
  padding: 0.3rem 0.7rem; font-size: 0.78rem; font-family: "Lato", sans-serif; font-weight: 700;
  letter-spacing: 0.4px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--blue); color: #fff; }

/* status dot + legend */
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; background: var(--st-unknown); }
.dot.d-operational { background: var(--st-ok); }
.dot.d-degraded { background: var(--st-degraded); }
.dot.d-outage { background: var(--st-outage); }
.dot.d-maintenance { background: var(--st-maint); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }

/* timeline / swimlanes */
.timeline { margin-bottom: 2rem; }
.tl-row { display: grid; grid-template-columns: minmax(120px, 180px) 1fr auto; gap: 0.75rem; align-items: center; padding: 0.25rem 0; }
.tl-label {
  font-size: 0.85rem; color: var(--heading); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; display: flex; align-items: center; gap: 0.5rem;
}
.tl-cells { display: flex; gap: 1px; height: 22px; }
.tl-cells i { flex: 1 1 0; min-width: 0; background: var(--st-track); border-radius: 1px; }
.tl-cells i.c-operational { background: var(--st-ok); }
.tl-cells i.c-degraded { background: var(--st-degraded); }
.tl-cells i.c-outage { background: var(--st-outage); }
.tl-cells i.c-maintenance { background: var(--st-maint); }
.tl-cells i.c-unknown { background: var(--st-track); }
.tl-up { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* compact service grid — min() keeps it from overflowing a narrow viewport */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 0.75rem; }
.svc {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0; overflow: hidden; transition: border-color 0.15s;
}
.svc.open { border-color: var(--blue); }
.svc-head {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.85rem;
  cursor: pointer; user-select: none;
}
.svc-head .name { flex: 1; font-weight: 700; font-family: "Lato", sans-serif; font-size: 0.92rem;
  color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-head .up { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.svc-head .chev { color: var(--text-muted); transition: transform 0.15s; font-size: 0.7rem; }
.svc.open .svc-head .chev { transform: rotate(90deg); }
.svc.stale .svc-head .name::after { content: " · stale"; color: var(--st-outage); font-weight: 400; font-size: 0.75rem; }

.svc-detail { padding: 0 0.85rem 0.85rem; border-top: 1px solid var(--border); font-size: 0.86rem; }
.svc-detail > * { margin-top: 0.7rem; }
.svc-detail .row-link { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.svc-detail a { color: var(--blue); text-decoration: none; }
.svc-detail a:hover { text-decoration: underline; }
.svc-del {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 4px; padding: 0.15rem 0.5rem; font-size: 0.75rem; cursor: pointer;
}
.svc-del:hover { border-color: var(--st-outage); color: var(--st-outage); }

.uptime { display: flex; gap: 1px; margin: 0.4rem 0; height: 26px; align-items: stretch; }
.uptime i { flex: 1 1 0; min-width: 0; border-radius: 1px; background: var(--st-track); }
.uptime i.u-operational { background: var(--st-ok); }
.uptime i.u-degraded { background: var(--st-degraded); }
.uptime i.u-outage { background: var(--st-outage); }
.uptime i.u-maintenance { background: var(--st-maint); }
.uptime i.u-unknown { background: var(--st-track); }

.svc-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.svc-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.35rem 0; border-top: 1px solid var(--border); font-size: 0.84rem;
}
.svc-list.incidents li a { color: var(--blue); text-decoration: none; }
.svc-list.incidents li a:hover { text-decoration: underline; }

/* manage panel */
.catalog { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cat-item {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.3rem 0.85rem; font-size: 0.82rem; font-family: inherit;
  font-weight: 400; letter-spacing: 0; cursor: pointer;
}
.cat-item:hover:not([disabled]) { border-color: var(--blue); color: var(--blue); background: var(--surface-2); }
.cat-item[disabled] { opacity: 0.5; cursor: default; }

/* ── webstatus: mobile ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .wrap-wide { padding: 1.25rem 0.9rem 3rem; }

  .status-toolbar {
    gap: 0.6rem 0.75rem;
    padding-bottom: 0.9rem; border-bottom: 1px solid var(--border);
  }
  .status-toolbar h1 { flex-basis: 100%; }         /* title on its own line */
  .status-toolbar .spacer { display: none; }
  .status-toolbar #manageBtn { margin-left: auto; }
  .seg button { padding: 0.35rem 0.85rem; font-size: 0.8rem; }

  .legend { gap: 0.5rem 0.9rem; font-size: 0.75rem; }

  /* stack each swimlane: label above, full-width bar below */
  .tl-row { display: block; padding: 0.5rem 0; }
  .tl-label { font-size: 0.82rem; margin-bottom: 0.25rem; }
  .tl-up { display: none; }
  .tl-cells { height: 24px; }
  #timeline { padding: 0.85rem !important; }

  .svc-grid { gap: 0.6rem; }
  .svc-head { padding: 0.8rem 0.9rem; }            /* comfortable tap target */
  .svc-head .name { font-size: 0.95rem; }
}
