:root {
  --bg: #0b0d10;
  --surface: #111419;
  --surface-raised: #161a20;
  --surface-soft: #0e1115;
  --line: #242a32;
  --line-soft: #1b2027;
  --text: #f1f3f5;
  --muted: #8b949f;
  --muted-strong: #b1b8c0;
  --accent: #6ee7b7;
  --accent-dark: #0d2e24;
  --danger: #fb7185;
  --danger-dark: #351820;
  --warning: #fbbf24;
  --blue: #7da5ff;
  --radius: 12px;
  --sidebar: 208px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .13em;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.login-card h1 {
  margin: 16px 0 5px;
  font-size: 29px;
  letter-spacing: -.04em;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #07120e;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -.05em;
}

.brand-mark.small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 11px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 650;
}

label > small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 450;
  line-height: 1.4;
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: #4f8d75;
  box-shadow: 0 0 0 3px rgb(110 231 183 / 8%);
}

.button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}

.button:hover { background: #1d222a; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { color: #07120e; background: var(--accent); }
.button.primary:hover { background: #8aefc8; }
.button.ghost { background: transparent; border-color: var(--line); }
.button.danger { color: #fecdd3; background: var(--danger-dark); border-color: #642534; }

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.form-error {
  min-height: 17px;
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  background: #0d1014;
  border-right: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 7px 22px;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: -.01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.sidebar nav { display: grid; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.nav-item span { width: 18px; color: #66717e; font-size: 17px; text-align: center; }
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: var(--text); background: var(--surface-raised); }
.nav-item.active span { color: var(--accent); }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 15px 8px 0;
  border-top: 1px solid var(--line-soft);
}

.sidebar-status strong, .sidebar-status small { display: block; }
.sidebar-status strong { font-size: 11px; }
.sidebar-status small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
}

.status-dot.ok { background: var(--accent); }
.status-dot.error { background: var(--danger); }

.workspace {
  width: calc(100% - var(--sidebar));
  min-width: 0;
  margin-left: var(--sidebar);
  padding: 0 26px 32px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.025em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu {
  min-width: 95px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.user-menu span, .user-menu small { display: block; }
.user-menu span { font-size: 11px; font-weight: 700; }
.user-menu small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.summary-card, .detail-card {
  min-width: 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.summary-card small, .detail-card small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.summary-card strong, .detail-card strong {
  display: block;
  overflow: hidden;
  margin-top: 7px;
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-card .trend {
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
}

.panel {
  min-width: 0;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.panel-head {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head h2 { margin: 0; font-size: 14px; font-weight: 680; }
.panel-head > strong { color: var(--text); font-size: 16px; font-weight: 650; }

.chart-panel { contain: inline-size; }

.chart-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 164px;
  min-width: 0;
  overflow: hidden;
  background: var(--surface-soft);
}

.chart-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
}

.detail-chart-stage {
  height: 220px;
  margin-bottom: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.route-head { align-items: flex-end; }

.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.filters input, .filters select {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 10px;
}

.filters input { width: 230px; }

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: #727c88;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .09em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 11px 12px;
  color: var(--muted-strong);
  border-top: 1px solid var(--line-soft);
  vertical-align: middle;
}

tbody tr { transition: background .12s; }
tbody tr[data-client-id] { cursor: pointer; }
tbody tr:hover { background: #15191f; }

.route-name { margin-bottom: 4px; color: var(--text); font-size: 12px; font-weight: 680; }
.route-path { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #20252c;
  color: var(--muted-strong);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge.active, .badge.up, .badge.success { color: var(--accent); background: var(--accent-dark); }
.badge.disabled { color: #9ca3af; }
.badge.error, .badge.down, .badge.failed { color: var(--danger); background: var(--danger-dark); }
.badge.applying, .badge.pending { color: var(--warning); background: #302617; }

.metric-main { color: var(--text); font-size: 11px; font-weight: 650; }
.metric-sub { margin-top: 3px; color: var(--muted); font-size: 9px; }

.empty { padding: 42px 20px; text-align: center; }
.empty > div { color: var(--muted); font-size: 26px; }
.empty h3 { margin: 8px 0 4px; font-size: 14px; }
.empty p { margin: 0; color: var(--muted); font-size: 11px; }

.frontends-intro {
  padding: 12px 16px;
  color: var(--muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 10px;
  line-height: 1.55;
}

.frontend-list { display: grid; gap: 10px; padding: 12px; }

.frontend-card {
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.frontend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.frontend-title { display: flex; align-items: center; gap: 8px; }
.frontend-title > strong { font-size: 14px; }
.frontend-address { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.frontend-address span { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; }
.frontend-address code { color: var(--accent); font-size: 11px; }
.frontend-head p { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.domain-list { border-top: 1px solid var(--line); }

.domain-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, .55fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
}

.domain-row:first-child { border-top: 0; }
.domain-main strong, .domain-main span, .domain-cert span { display: block; }
.domain-main strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.domain-main span, .domain-cert > span:last-child { margin-top: 4px; color: var(--muted); font-size: 9px; }
.domain-actions { display: flex; align-items: center; gap: 6px; }
.domain-empty { padding: 18px 14px; color: var(--muted); font-size: 10px; text-align: center; }

.modal {
  width: min(700px, calc(100% - 28px));
  max-height: 90vh;
  padding: 0;
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid #303741;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 55%);
}

.modal::backdrop { background: rgb(0 0 0 / 68%); }
.modal > form, .detail-modal { padding: 21px; }
.compact-modal { width: min(570px, calc(100% - 28px)); }
.certificate-modal { width: min(640px, calc(100% - 28px)); padding: 21px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.span-2 { grid-column: 1 / -1; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.check input { width: auto; margin: 1px 0; }
.check span { font-size: 11px; }
.check small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 400; line-height: 1.4; }

.warning {
  margin-top: 13px;
  padding: 10px;
  color: #f8d590;
  background: #282115;
  border: 1px solid #4a3a1d;
  border-radius: 8px;
  font-size: 10px;
  line-height: 1.5;
}

.certificate-status {
  min-height: 66px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.certificate-status p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.certificate-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.certificate-method {
  min-height: 94px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.certificate-method:hover { border-color: #4f8d75; background: #121a18; }
.certificate-method:disabled { opacity: .45; cursor: wait; }
.certificate-method strong, .certificate-method span { display: block; }
.certificate-method strong { font-size: 12px; }
.certificate-method span { margin-top: 7px; color: var(--muted); font-size: 9px; line-height: 1.5; }

.dns-challenge {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.copy-field code {
  min-width: 0;
  padding: 10px;
  overflow-wrap: anywhere;
  color: var(--accent);
  background: #090b0e;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 450;
}

.certificate-hint { margin: 0; font-size: 10px; line-height: 1.5; }
.certificate-error {
  max-height: 180px;
  margin: 12px 0 0;
  padding: 11px;
  overflow: auto;
  color: #fecdd3;
  background: var(--danger-dark);
  border: 1px solid #642534;
  border-radius: 8px;
  font: 9px/1.5 "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
}

.detail-modal { width: min(900px, calc(100% - 28px)); }
.action-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.detail-card { padding: 11px; }
.detail-card strong { font-size: 15px; }

.tabs {
  display: flex;
  gap: 2px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  padding: 9px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}

.tabs button.active { color: var(--text); border-color: var(--accent); }
.tab-content { min-height: 240px; padding-top: 14px; }

.periods { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.periods .button { min-height: 30px; padding: 5px 8px; font-size: 9px; }

.reset-row, .revision-row {
  display: grid;
  grid-template-columns: 150px 1fr 120px;
  gap: 14px;
  align-items: center;
  padding: 11px;
  border-bottom: 1px solid var(--line-soft);
}

.timeline { padding: 4px 16px 16px; }
.revision-row { grid-template-columns: 90px 1fr 110px 110px; }
.timeline .revision-row:last-child { border: 0; }

.confirm-modal { width: min(430px, calc(100% - 28px)); padding: 21px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(420px, calc(100% - 36px));
  padding: 10px 13px;
  color: #ccf8e5;
  background: #14251f;
  border: 1px solid #2d604b;
  border-radius: 8px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 45%);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}

.toast.show { opacity: 1; transform: none; }
.toast.error { color: #fecdd3; background: var(--danger-dark); border-color: #6b2937; }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar-actions .ghost { display: none; }
}

@media (max-width: 860px) {
  :root { --sidebar: 64px; }
  .sidebar { padding-inline: 9px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > div, .sidebar-status, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 9px; }
  .nav-item span { width: auto; font-size: 17px; }
  .workspace { padding-inline: 18px; }
  .route-head { display: block; }
  .filters { margin-top: 11px; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .domain-row { grid-template-columns: minmax(180px, 1fr) minmax(130px, .6fr) auto; }
}

@media (max-width: 620px) {
  :root { --sidebar: 0px; }
  .sidebar {
    position: static;
    width: 100%;
    height: 54px;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .brand { margin-right: auto; padding: 0; }
  .brand > div { display: block; }
  .brand small { display: none; }
  .sidebar nav { display: flex; }
  .workspace { width: 100%; margin: 0; padding: 0 11px 22px; }
  .topbar { min-height: 70px; align-items: center; }
  .topbar h1 { font-size: 17px; }
  .topbar .eyebrow, .user-menu, #validate-button { display: none; }
  .topbar-actions { justify-content: flex-end; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card strong { font-size: 16px; }
  .filters { display: grid; width: 100%; }
  .filters input { width: 100%; }
  .panel-head { padding-inline: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2, .check { grid-column: 1; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .reset-row, .revision-row { grid-template-columns: 1fr; }
  .modal > form, .detail-modal { padding: 17px; }
  .frontend-head { display: grid; }
  .frontend-head .action-row { margin: 0; }
  .domain-row { grid-template-columns: 1fr; gap: 9px; }
  .domain-actions { justify-content: flex-start; }
  .certificate-methods { grid-template-columns: 1fr; }
  .certificate-modal { padding: 17px; }
}
