:root {
  --bg: #0f1419;
  --bg-elevated: #1a2028;
  --border: #2a3441;
  --text: #e6e9ed;
  --text-dim: #8a96a3;
  --accent: #5cc8ff;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --gray: #6b7280;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
}

[hidden] { display: none !important; }

/* ===== Login overlay ===== */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 0;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: -10px;
  margin-bottom: 8px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-card input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  background: var(--accent);
  color: #06121d;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.login-card button:hover:not(:disabled) { opacity: 0.9; }
.login-card button:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ===== Dashboard ===== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 32px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

h1 {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 13px;
}

.subtitle code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.last-update {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.logout-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

.stat.green .stat-value { color: var(--green); }
.stat.yellow .stat-value { color: var(--yellow); }
.stat.gray .stat-value { color: var(--gray); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 160px;
}

.filter-search {
  flex: 1;
  min-width: 200px;
}

.filter select,
.filter input {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.15s;
}

.filter select:focus,
.filter input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-clear {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  height: 36px;
  transition: all 0.15s;
}

.filter-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  align-self: center;
}

.table-wrap {
  margin-bottom: 32px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
}

.table-wrap > table {
  border: none;
  border-radius: 0;
}

th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(92, 200, 255, 0.04); }

.method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

.method.GET { background: rgba(74, 222, 128, 0.15); color: var(--green); }
.method.POST { background: rgba(92, 200, 255, 0.15); color: var(--accent); }
.method.PUT { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.method.DELETE { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.path-cell {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status.validated { color: var(--green); }
.status.validated::before { background: var(--green); }
.status.validated_partial { color: var(--yellow); }
.status.validated_partial::before { background: var(--yellow); }
.status.ready_to_dispatch { color: var(--accent); }
.status.ready_to_dispatch::before { background: var(--accent); }
.status.pending_user_dispatch { color: var(--red); }
.status.pending_user_dispatch::before { background: var(--red); }
.status.pending { color: var(--gray); }
.status.pending::before { background: var(--gray); }

.endpoint-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.endpoint-header {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.endpoint-header:hover { background: rgba(92, 200, 255, 0.04); }

.endpoint-header .arrow {
  color: var(--text-dim);
  transition: transform 0.15s;
}

.endpoint-card.open .endpoint-header .arrow {
  transform: rotate(90deg);
}

.endpoint-title {
  flex: 1;
  font-weight: 500;
}

.endpoint-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.endpoint-card.open .endpoint-body { display: block; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 16px 0 8px;
}

.kv-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  font-size: 13px;
}

.kv-grid dt {
  color: var(--text-dim);
  font-weight: normal;
}

.kv-grid dd code,
pre code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.scenario {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
}

.scenario-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.scenario-detail {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
}

.expected {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  background: rgba(92, 200, 255, 0.1);
  color: var(--accent);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}

.anomaly {
  background: rgba(251, 191, 36, 0.05);
  border-left: 3px solid var(--yellow);
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  border-radius: 0 4px 4px 0;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--text-dim);
  margin-right: 4px;
  margin-bottom: 4px;
}

/* ===== Tabs ===== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Migration tab ===== */

.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.diff-badge.easy { background: rgba(74, 222, 128, 0.12); color: var(--green); }
.diff-badge.medium { background: rgba(92, 200, 255, 0.12); color: var(--accent); }
.diff-badge.hard { background: rgba(251, 191, 36, 0.12); color: var(--yellow); }
.diff-badge.very-hard { background: rgba(248, 113, 113, 0.12); color: var(--red); }

.impl-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}

.impl-select:focus { outline: none; border-color: var(--accent); }
.impl-select.done { border-color: var(--green); color: var(--green); }
.impl-select.wip { border-color: var(--yellow); color: var(--yellow); }
.impl-select.blocked { border-color: var(--red); color: var(--red); }

.mig-progress {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.mig-progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
  background: linear-gradient(90deg, var(--green), var(--accent));
}

.mig-group {
  margin-bottom: 24px;
}

.mig-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  user-select: none;
}

.mig-group-header:hover { background: rgba(92, 200, 255, 0.04); }

.mig-group-title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mig-group-count {
  font-size: 12px;
  color: var(--text-dim);
}

.mig-group-body {
  display: none;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.mig-group.open .mig-group-body { display: block; }
.mig-group.open .mig-group-header { border-radius: 8px 8px 0 0; }

.mig-row {
  display: grid;
  grid-template-columns: 60px 180px 40px 1fr 100px 110px;
  gap: 8px;
  align-items: center;
  padding: 8px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.api-badge {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  text-transform: lowercase;
}

.api-distribution {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.api-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.api-card-name {
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

.api-card-stats {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.mig-row:last-child { border-bottom: none; }
.mig-row:hover { background: rgba(92, 200, 255, 0.04); }

.mig-deps {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.mig-dep {
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}

footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== DNS Status tab ===== */
.dns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.dns-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dns-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  border-left: 4px solid var(--gray);
}

.dns-card.status-online { border-left-color: var(--green); }
.dns-card.status-offline { border-left-color: var(--red); }
.dns-card.status-unknown { border-left-color: var(--gray); }

.dns-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dns-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray);
}
.dns-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dns-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }

.dns-label {
  font-weight: 600;
  flex: 1;
}

.dns-status-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.dns-status-pill.online { color: var(--green); border-color: var(--green); }
.dns-status-pill.offline { color: var(--red); border-color: var(--red); }

.dns-url {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  word-break: break-all;
}

.dns-evidence-links {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.dns-evidence-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}
.dns-evidence-links a:hover { text-decoration: underline; }

.dns-history-target {
  margin-bottom: 20px;
}

.dns-history-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.dns-history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}

.dns-history-table th,
.dns-history-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.dns-history-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.dns-history-table tbody tr:last-child td { border-bottom: none; }

.dns-history-row.offline td:first-child {
  border-left: 3px solid var(--red);
}

.dns-history-table a {
  color: var(--accent);
  text-decoration: none;
}
.dns-history-table a:hover { text-decoration: underline; }

.dns-hint {
  margin-top: 24px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.dns-hint code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
}
