:root {
  --gold: #c9a227;
  --gold-light: #e8c547;
  --t1: #f5f0e6;
  --t2: #c4b8a8;
  --t3: #8a8070;
  --s1: #0d0d10;
  --s2: #141418;
  --s3: #1a1a20;
  --border: rgba(201, 162, 39, 0.28);
  --border-subtle: rgba(201, 162, 39, 0.12);
  --green: #3ddc84;
  --red: #ef4444;
  --amber: #e8c547;
  --blue: #6b8cce;
  --bg: #050508;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --text-base: 0.875rem;
  --text-sm: 0.8125rem;
  --text-xs: 0.75rem;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: var(--text-base);
  line-height: 1.45;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(201,162,39,0.12), transparent 50%),
    var(--bg);
  color: var(--t1);
}
a { color: var(--gold-light); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(13,13,16,0.88);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}
.brand { display: flex; flex-direction: column; gap: 0.15rem; }
.brand b { letter-spacing: 0.02em; font-size: 0.95rem; font-weight: 700; }
.brand span { color: var(--t3); font-size: var(--text-xs); }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }

.summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.stat, .card, .table-wrap, .detail-grid, .modal, .issues-section {
  background: var(--s2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.stat { padding: 0.75rem 0.85rem; min-height: 4.6rem; }
.stat .lbl { color: var(--t3); font-size: var(--text-xs); letter-spacing: 0.03em; }
.stat .val { margin-top: 0.3rem; font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stat.alert { border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.08); }
.stat.muted-stat { opacity: 0.85; }
.stat.muted-stat .val { color: var(--t2); font-size: 1.15rem; }

.section-title {
  margin: 0;
  color: var(--t2);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.section-title-block { margin: 1.25rem 0 0.65rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tab-group { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tab-group .btn.active { border-color: var(--gold); color: var(--gold-light); }

.issues-section { padding: 0.9rem 1rem; margin-bottom: 1rem; }
.issues { display: grid; gap: 0.5rem; }
.issues-empty { padding: 0.35rem 0; }
.issues-more { margin-top: 0.65rem; }
.issue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--s1);
  align-items: start;
}
.issue-archived { opacity: 0.88; }
.issue-main { min-width: 0; }
.issue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.55rem;
  margin-bottom: 0.25rem;
}
.issue-title { font-weight: 600; font-size: var(--text-sm); line-height: 1.35; }
.issue-meta { font-size: var(--text-xs); margin-bottom: 0.2rem; }
.issue-detail, .issue-rec { font-size: var(--text-xs); line-height: 1.45; word-break: break-word; }
.issue-rec { margin-top: 0.3rem; }
.issue-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  flex-shrink: 0;
  min-width: 6.5rem;
}
.sev-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sev-badge.CRITICAL { color: var(--red); background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); }
.sev-badge.WARNING { color: var(--amber); background: rgba(232,197,71,0.12); border-color: rgba(232,197,71,0.35); }
.sev-badge.INFO { color: var(--blue); background: rgba(107,140,206,0.12); border-color: rgba(107,140,206,0.35); }
.sev { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.03em; }
.sev.CRITICAL { color: var(--red); }
.sev.WARNING { color: var(--amber); }
.sev.INFO { color: var(--blue); }
.muted { color: var(--t3); font-size: var(--text-sm); }

.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.75rem; align-items: center; }
input, select, textarea {
  background: var(--s1);
  border: 1px solid var(--border-subtle);
  color: var(--t1);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: var(--text-sm);
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); }
.search { min-width: min(100%, 280px); flex: 1; }

.table-wrap { overflow: hidden; padding: 0.25rem 0; }
.deploy-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.deploy-table th,
.deploy-table td {
  padding: 0.55rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  font-size: var(--text-sm);
  word-break: break-word;
}
.deploy-table th {
  color: var(--t3);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.deploy-table th:nth-child(1) { width: 22%; }
.deploy-table th:nth-child(2) { width: 12%; }
.deploy-table th:nth-child(3) { width: 11%; }
.deploy-table th:nth-child(4) { width: 13%; }
.deploy-table th:nth-child(5) { width: 15%; }
.deploy-table th:nth-child(6) { width: 13%; }
.deploy-table th:nth-child(7) { width: 8%; }
.deploy-table tr { cursor: pointer; }
.deploy-table tr:hover td { background: rgba(201,162,39,0.06); }
.deployment-id { font-size: var(--text-xs); line-height: 1.3; }
.domain-line { font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; }
.cell-date { font-size: var(--text-xs); white-space: nowrap; }
.cell-issues { text-align: center; font-weight: 700; }
.cell-issues.has-issues { color: var(--amber); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border-radius: 999px; padding: 0.12rem 0.5rem; font-size: var(--text-xs); font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.ACTIVE { color: var(--green); background: rgba(61,220,132,0.1); }
.EXPIRING { color: var(--amber); background: rgba(232,197,71,0.12); }
.EXPIRED, .REVOKED, .OFFLINE { color: var(--red); background: rgba(239,68,68,0.1); }
.ONLINE { color: var(--green); background: rgba(61,220,132,0.1); }
.STALE { color: var(--amber); background: rgba(232,197,71,0.12); }
.UNKNOWN { color: var(--t3); background: rgba(255,255,255,0.04); }

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t1);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: border-color 0.15s var(--ease);
}
.btn-sm { padding: 0.35rem 0.6rem; font-size: var(--text-xs); }
.btn:hover { border-color: var(--gold); }
.btn-primary {
  background: linear-gradient(90deg, #8a6d12 0%, #c9a227 50%, #e8c547 100%);
  color: #1a1404;
  border: 0;
  font-weight: 700;
}
.btn-danger { border-color: rgba(239,68,68,0.55); color: #fecaca; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin: 1rem 0;
  padding: 1rem 1.1rem;
}
.detail-id { font-size: 1.1rem; margin: 0 0 0.25rem; word-break: break-all; }
.detail-badges { text-align: right; }
.revoked-note { color: var(--red); margin: 0.35rem 0 0; font-size: var(--text-sm); }
.detail-grid { display: grid; grid-template-columns: 1.35fr 0.95fr; gap: 0; margin-bottom: 0.5rem; }
.pane { padding: 1rem 1.1rem; }
.pane + .pane { border-left: 1px solid var(--border-subtle); }
.pane-issues .issue { grid-template-columns: minmax(0, 1fr) auto; }
.kv { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.4rem 0.65rem; font-size: var(--text-sm); }
.kv-row { display: contents; }
.kv-key { font-size: var(--text-xs); }
.error-spaced { margin-top: 0.8rem; }
.env-banner {
  margin: 0.85rem 1.5rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(20, 20, 24, 0.92);
  font-size: var(--text-sm);
}
.env-banner-prod {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}
.env-banner-dev {
  border-color: rgba(232, 197, 71, 0.45);
  background: rgba(232, 197, 71, 0.08);
}
.env-banner-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  align-items: center;
}
.env-banner-main strong {
  color: var(--gold-light);
  letter-spacing: 0.06em;
  font-size: var(--text-xs);
}
.env-banner-note { margin-top: 0.45rem; font-size: var(--text-xs); }
.pane-title { margin: 0 0 0.75rem; }
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.status-hint { font-size: var(--text-xs); max-width: 28rem; line-height: 1.4; }
.pane-issues-wrap { margin-top: 0.75rem; }
.prod-warning {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  font-size: var(--text-sm);
  margin: 0 0 0.75rem;
}
.actions { display: flex; gap: 0.45rem; flex-wrap: wrap; margin: 0.85rem 0; }
.history { margin-top: 1rem; padding: 0.9rem 1rem; }
.history-sub { margin: 0.5rem 0 0.35rem; font-size: var(--text-xs); color: var(--t3); font-weight: 600; }
.hist-item { padding: 0.55rem 0; border-bottom: 1px solid var(--border-subtle); }
.hist-title { font-size: var(--text-sm); }
.hist-meta { font-size: var(--text-xs); margin-top: 0.15rem; }
.history-archive { margin-top: 0.5rem; }
.history-toggle { margin-bottom: 0.35rem; }
.history-archive-list { border-top: 1px solid var(--border-subtle); padding-top: 0.25rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(420px, 100%); padding: 1.4rem; }
.login-card h1 { margin: 0 0 0.3rem; font-size: 1.25rem; }
.totp-input { font-size: 1.4rem; letter-spacing: 0.25em; text-align: center; padding: 0.6rem; }
.qr-code { display: block; margin: 0.75rem auto; max-width: 220px; }
.recovery-codes { display: grid; gap: 0.35rem; margin: 1rem 0; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; text-align: left; padding: 0; }
.security-section { max-width: 640px; }
.security-page { min-height: 100vh; display: flex; flex-direction: column; }
.security-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem 3rem;
}
.security-card {
  width: min(460px, 100%);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.security-card-head { text-align: center; margin-bottom: 1.25rem; }
.security-card-head h1 {
  margin: 0.75rem 0 0.35rem;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.security-subtitle { margin: 0; color: var(--t3); font-size: var(--text-sm); }
.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.security-badge.on {
  color: var(--green);
  background: rgba(61, 220, 132, 0.1);
  border: 1px solid rgba(61, 220, 132, 0.35);
}
.security-badge.off {
  color: var(--amber);
  background: rgba(232, 197, 71, 0.08);
  border: 1px solid rgba(232, 197, 71, 0.3);
}
.security-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.security-meta {
  text-align: center;
  color: var(--t3);
  font-size: var(--text-xs);
  margin: 0 0 1rem;
}
.security-actions { display: grid; gap: 0.55rem; margin-top: 0.5rem; }
.security-actions .btn { width: 100%; text-align: center; padding: 0.65rem 1rem; }
.security-divider {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 1.35rem 0 1rem;
}
.security-footer { display: grid; gap: 0.5rem; }
.security-footer .btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--t2);
}
.security-footer .btn-ghost:hover { border-color: var(--border); color: var(--t1); }
.security-reconnect-panel {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}
.security-reconnect-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-align: center;
}
.stack { display: grid; gap: 0.65rem; margin-top: 1rem; }
.error { color: #fecaca; background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.35); padding: 0.65rem 0.75rem; border-radius: 10px; font-size: var(--text-sm); }
.notice-ok { color: #bbf7d0; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35); }

.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62);
  display: grid; place-items: center; padding: 1rem; z-index: 20;
}
.modal { width: min(520px, 100%); padding: 1.1rem; }
.modal h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.boot-skeleton { max-width: 1280px; margin: 2rem auto; padding: 0 1.5rem; }
.sk-bar, .sk-card { background: linear-gradient(90deg, #141418, #1d1d24, #141418); background-size: 200% 100%; animation: shine 1.2s infinite; border-radius: var(--radius); }
.sk-bar { height: 72px; margin-bottom: 1rem; }
.sk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.sk-card { height: 88px; }
@keyframes shine { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (max-width: 1200px) {
  .summary { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--border-subtle); }
  .issue { grid-template-columns: 1fr; }
  .issue-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; }
}
@media (max-width: 700px) {
  .wrap, .topbar { padding-left: 1rem; padding-right: 1rem; }
  .deploy-table th:nth-child(2),
  .deploy-table td:nth-child(2) { display: none; }
}
