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

body {
  background: #0f1117;
  color: #e1e4e8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  min-height: 100vh;
  padding: 24px;
}

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid #21262d;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
  background: linear-gradient(135deg, #58a6ff, #8250df);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #8b949e;
}

.key-selector {
  background: #161b22;
  color: #e1e4e8;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 28px 5px 12px;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 120px;
}

.key-selector:hover {
  border-color: #58a6ff;
}

.key-selector:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: #3fb950;
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.4);
}

.status-dot.offline {
  background: #f85149;
  box-shadow: 0 0 8px rgba(248, 81, 73, 0.4);
}

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

.stat-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 20px;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: #30363d;
}

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b949e;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: #f0f6fc;
}

.stat-card .value.green { color: #3fb950; }
.stat-card .value.yellow { color: #d29922; }
.stat-card .value.red { color: #f85149; }
.stat-card .value.blue { color: #58a6ff; }
.stat-card .value.purple { color: #bc8cff; }

.converted {
  font-size: 13px;
  color: #8b949e;
  margin-top: 4px;
  min-height: 0;
}

.converted:empty {
  display: none;
}

.chart-full {
  margin-bottom: 32px;
}

.chart-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.period-selector {
  display: flex;
  gap: 4px;
}

.period-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn:hover {
  background: #30363d;
  color: #c9d1d9;
}

.period-btn.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

#bar-chart {
  height: 280px;
  display: block;
}

.details-section {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 32px;
}

.details-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #8b949e;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.detail-item {
  font-size: 13px;
  color: #c9d1d9;
  line-height: 1.6;
}

.detail-item strong {
  color: #8b949e;
  margin-right: 8px;
}

footer {
  text-align: center;
  font-size: 12px;
  color: #484f58;
  padding-top: 16px;
  border-top: 1px solid #21262d;
}

.settings-btn {
  background: none;
  border: none;
  color: #484f58;
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.settings-btn:hover {
  color: #8b949e;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #21262d;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #e1e4e8;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #f85149;
}

.modal-body {
  padding: 20px 24px 24px;
}

.modal-desc {
  font-size: 13px;
  color: #8b949e;
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 12px;
}

.modal-label:first-child {
  margin-top: 0;
}

.modal-input {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: #e1e4e8;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.modal-error {
  color: #f85149;
  font-size: 13px;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.15s;
}

.modal-btn.primary {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.modal-btn.primary:hover {
  background: #2ea043;
}

.modal-btn.secondary {
  background: #21262d;
  color: #8b949e;
}

.modal-btn.secondary:hover {
  background: #30363d;
  color: #e1e4e8;
}

.managed-keys-list {
  margin-bottom: 16px;
}

.managed-key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  margin-bottom: 8px;
}

.managed-key-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.managed-key-label {
  font-size: 14px;
  color: #e1e4e8;
  font-weight: 500;
}

.managed-key-fp {
  font-size: 12px;
  color: #8b949e;
  font-family: monospace;
}

.managed-key-remove {
  background: none;
  border: 1px solid #30363d;
  color: #f85149;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 12px;
}

.managed-key-remove:hover {
  background: rgba(248, 81, 73, 0.15);
  border-color: #f85149;
}

.managed-keys-empty {
  font-size: 13px;
  color: #484f58;
  text-align: center;
  padding: 12px;
}

.add-key-form {
  border-top: 1px solid #21262d;
  padding-top: 16px;
}

.modal-actions {
  border-top: 1px solid #21262d;
  padding-top: 16px;
  margin-top: 16px;
}

.modal-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid #21262d;
  margin: 0 -24px;
  padding: 0 24px;
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.modal-tab:hover {
  color: #e1e4e8;
}

.modal-tab.active {
  color: #e1e4e8;
  border-bottom-color: #58a6ff;
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

.stats-grid .stat-card.collapsible {
  display: none;
}

body.expanded .stats-grid .stat-card.collapsible {
  display: block;
}

.details-section.collapsible {
  display: none;
}

body.expanded .details-section.collapsible {
  display: block;
}

.toggle-row {
  text-align: center;
  margin-bottom: 24px;
}

.toggle-btn {
  background: none;
  border: 1px solid #30363d;
  color: #8b949e;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover {
  background: #21262d;
  color: #c9d1d9;
  border-color: #484f58;
}

#matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.3;
}

body.matrix-mode .logo {
  animation: logo-pulse 1.5s ease-in-out infinite alternate;
}

.logo.eye-active {
  filter: drop-shadow(0 0 4px rgba(248, 81, 73, 0.6));
}

.logo.eye-active #logo-pupil {
  fill: #f85149;
}

@keyframes logo-pulse {
  0% { filter: drop-shadow(0 0 3px rgba(63, 185, 80, 0.3)); }
  100% { filter: drop-shadow(0 0 8px rgba(63, 185, 80, 0.7)); }
}

/* ── Auth Screen ── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-header h1 {
  font-size: 28px;
  font-weight: 600;
  background: linear-gradient(135deg, #58a6ff, #8250df);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-form {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 32px;
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  color: #e1e4e8;
  margin-bottom: 24px;
  text-align: center;
}

.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 16px;
}

.auth-label:first-of-type {
  margin-top: 0;
}

.auth-input {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  color: #e1e4e8;
  font-family: inherit;
}

.auth-input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.auth-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 24px;
  transition: all 0.15s;
}

.auth-btn.primary {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.auth-btn.primary:hover {
  background: #2ea043;
}

.auth-error {
  color: #f85149;
  font-size: 13px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
}

.auth-success {
  color: #3fb950;
  font-size: 13px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  border-radius: 6px;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #8b949e;
}

.auth-switch a {
  color: #58a6ff;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-form p {
  text-align: center;
  color: #8b949e;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Header Auth Elements ── */
.user-email {
  font-size: 13px;
  color: #8b949e;
}

.logout-btn {
  background: none;
  border: none;
  color: #484f58;
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.logout-btn:hover {
  color: #f85149;
}

/* ── Admin Panel ── */
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.admin-stat {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b949e;
}

.admin-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #f0f6fc;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #21262d;
  color: #8b949e;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #21262d;
  color: #c9d1d9;
}

.admin-table tr:hover td {
  background: rgba(88, 166, 255, 0.04);
}

.admin-total-row td {
  border-top: 2px solid #30363d;
  background: rgba(88, 166, 255, 0.06);
}

.admin-badge {
  display: inline-block;
  background: rgba(188, 140, 255, 0.15);
  color: #bc8cff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-empty,
.admin-error {
  font-size: 13px;
  color: #484f58;
  text-align: center;
  padding: 16px;
}

.admin-error {
  color: #f85149;
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.2);
  border-radius: 6px;
}
