@font-face {
  font-family: "CynetIQ";
  src: url("/cynetiqFont.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root,
html[data-theme="dark"] {
  --bg: #090807;
  --bg-elev: #14100e;
  --bg-card: rgba(22, 17, 14, 0.88);
  --ink: #f6eee6;
  --muted: #9a8a7c;
  --line: rgba(232, 145, 78, 0.16);
  --line-strong: rgba(232, 145, 78, 0.32);
  --cyan: #3ec8ff;
  --violet: #a56bff;
  --mars: #e10600;
  --mars-bright: #ff2a1f;
  --green: #5dce7a;
  --warn: #e0a04a;
  --down: #e06a5c;
  --glow: rgba(62, 200, 255, 0.12);
  --font: "CynetIQ", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --page-bg:
    radial-gradient(ellipse 80% 50% at 50% 120%, rgba(168, 75, 34, 0.32), transparent 55%),
    radial-gradient(ellipse 55% 40% at 12% -5%, rgba(62, 200, 255, 0.1), transparent 50%),
    radial-gradient(ellipse 45% 35% at 95% 8%, rgba(165, 107, 255, 0.1), transparent 45%),
    linear-gradient(180deg, #0f0c0a 0%, var(--bg) 40%, #0c0a09 100%);
}

html[data-theme="light"] {
  --bg: #f4efe9;
  --bg-elev: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.92);
  --ink: #1b1410;
  --muted: #6f5f52;
  --line: rgba(168, 75, 34, 0.16);
  --line-strong: rgba(168, 75, 34, 0.28);
  --cyan: #1590b8;
  --violet: #7a4fd6;
  --mars: #b00000;
  --mars-bright: #8a0000;
  --green: #2f9a4a;
  --warn: #b07a20;
  --down: #c24a3c;
  --glow: rgba(225, 6, 0, 0.08);
  --shadow: 0 14px 40px rgba(40, 24, 12, 0.1);
  --page-bg:
    radial-gradient(ellipse 70% 45% at 10% -10%, rgba(225, 6, 0, 0.14), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(62, 200, 255, 0.08), transparent 50%),
    linear-gradient(180deg, #faf6f2 0%, var(--bg) 50%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page-bg);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.wrap {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px 24px 72px;
}

/* —— Topbar —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand picture { display: block; line-height: 0; }
.brand img {
  height: 48px;
  width: auto;
  max-width: 56px;
  object-fit: contain;
  display: block;
}
.brand-copy strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--mars));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-copy span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  height: 48px;
  padding: 0 16px 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.logout-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.logout-btn:hover {
  color: #fff8f2;
  border-color: transparent;
  background: linear-gradient(135deg, var(--mars), #b00000);
  filter: none;
}
.logout-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.pref-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pref-switch__label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.pref-switch__track {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent),
    var(--bg-elev);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.pref-chip {
  min-width: 40px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.pref-chip--icon {
  min-width: 38px;
  padding: 0;
}
.pref-chip:hover:not(.active) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}
.pref-chip.active {
  color: #fff8f2;
  background: linear-gradient(135deg, var(--mars), #b00000 55%, var(--violet));
  box-shadow: 0 6px 16px rgba(225, 6, 0, 0.28);
}
html[data-theme="light"] .pref-chip.active {
  box-shadow: 0 6px 14px rgba(196, 95, 40, 0.22);
}

/* legacy seg (unused) */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
}
.seg button {
  min-width: 42px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active {
  background: linear-gradient(135deg, var(--mars), #b00000);
  color: #fff8f2;
}
.seg button:hover:not(.active) { color: var(--ink); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* —— Sections —— */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.section-label {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.section-head .section-label { margin: 0; }

.bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* —— Status strip —— */
.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.status-col {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(10px);
}
.status-col .section-label { margin-bottom: 14px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  font-size: 14px;
}
.row + .row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row a { color: var(--cyan); }
.row a:hover { color: var(--ink); }
.row .mono {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* —— Dots —— */
.dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}
.dot.live { color: var(--green); }
.dot.down { color: var(--down); }
.dot.maint { color: var(--warn); }
.dot.unknown { color: var(--muted); }

/* —— Sites —— */
.sites {
  display: grid;
  gap: 10px;
}
.site {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto auto;
  align-items: center;
  gap: 16px 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.site:hover {
  border-color: var(--line-strong);
}
.site h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.meta a { color: var(--cyan); }
.meta a:hover { color: var(--ink); }
.flags {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.actions { display: flex; justify-content: flex-end; }

/* —— Buttons —— */
button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 10px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--mars), #b00000);
  color: #fff8f2;
  transition: filter 0.15s ease, transform 0.1s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled,
button:disabled:hover,
button:disabled:active {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.92);
  transform: none;
  box-shadow: none;
  pointer-events: none;
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
button.ghost:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  filter: none;
}
button.warn {
  background: transparent;
  color: var(--warn);
  border: 1px solid rgba(224, 160, 74, 0.45);
}
button.warn:hover {
  background: rgba(224, 160, 74, 0.1);
  filter: none;
}
button.primary {
  background: linear-gradient(135deg, #49c46a, #2f9a4a);
  color: #06140a;
}
html[data-theme="light"] button.primary { color: #fff; }

/* —— Login —— */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}
.login-shell {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
}
.login-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.login-card {
  display: grid;
  gap: 16px;
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.login-card picture { display: block; line-height: 0; }
.login-card .logo {
  height: 72px;
  width: auto;
  max-width: 88px;
  object-fit: contain;
}
.login-card h1 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.login-card .lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.login-card label {
  display: grid;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.login-card input {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 13px 14px;
  font: inherit;
  font-size: 16px;
  border-radius: 12px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--mars);
  box-shadow: 0 0 0 3px rgba(225, 6, 0, 0.18);
}
.err { color: var(--down); margin: 0; font-size: 13px; }
.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
}

/* —— Dialog —— */
body.dialog-open { overflow: hidden; }
.dialog-root[hidden] { display: none; }
.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 3, 0.72);
  backdrop-filter: blur(4px);
}
.dialog-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 26px 24px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}
.dialog-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.dialog-panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.dialog-body {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .status-strip { grid-template-columns: 1fr 1fr; }
  #ssl-status { grid-column: 1 / -1; }
}

/* —— Mobile —— */
@media (max-width: 760px) {
  .wrap { padding: 12px 14px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px;
  }
  .brand {
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .brand img { height: 36px; max-width: 42px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy span {
    font-size: 9px;
    letter-spacing: 0.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .userbar {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
  }
  .user-label { display: none; }
  .pref-switch { gap: 0; }
  .pref-switch__label { display: none; }
  .pref-switch__track {
    padding: 2px;
    gap: 1px;
  }
  .pref-chip {
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0 8px;
    font-size: 11px;
  }
  .pref-chip--icon {
    min-width: 34px;
    width: 34px;
    padding: 0;
  }
  .pref-chip--icon svg { width: 15px; height: 15px; }
  .icon-btn { width: 34px; height: 34px; min-height: 34px; }
  .logout-btn {
    min-width: 34px;
    width: 34px;
    min-height: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
  }
  .logout-btn span { display: none; }
  .logout-btn svg { width: 18px; height: 18px; }
  .status-strip { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: stretch; }
  .bulk-actions button { flex: 1; min-height: 44px; }
  .site {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .flags {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .actions { width: 100%; }
  .actions button { width: 100%; min-height: 44px; }
  .login-body {
    align-items: start;
    padding: 18px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .login-tools {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
  }
  .login-tools .pref-switch {
    width: auto;
    justify-content: flex-end;
  }
  .login-tools .pref-switch__label { display: none; }
  .login-tools .pref-switch__track { margin-left: 0; }
  .login-card { padding: 24px 18px 20px; }
  .dialog-root { align-items: end; padding: 0; }
  .dialog-panel {
    width: 100%;
    border-radius: 18px 18px 0 0;
  }
  .dialog-actions {
    flex-direction: column-reverse;
  }
  .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .brand-copy span { display: none; }
}

@media (max-width: 420px) {
  .bulk-actions { flex-direction: column; }
  .bulk-actions button { width: 100%; }
}
