@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #EFEDE7;
  --text: #2B2A28;
  --text-muted: #726F68;
  --accent: #6E8C7C;
  --accent-soft: #DCE5DF;
  --accent-2: #96768A;
  --border: #E3E0D8;
  --danger: #B5654F;
  --shadow: 0 1px 2px rgba(43, 42, 40, 0.04), 0 8px 24px rgba(43, 42, 40, 0.05);
  --radius: 14px;
  --transition: 180ms ease;
}

:root[data-theme="dark"] {
  --bg: #14171B;
  --surface: #1B1F24;
  --surface-2: #21262C;
  --text: #E9E7E2;
  --text-muted: #9B978F;
  --accent: #8FB39F;
  --accent-soft: #253530;
  --accent-2: #B497A8;
  --border: #2A2F35;
  --danger: #C97B62;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* Layout geral */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  font-size: 1.05rem;
}

.rail-brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}
.rail-brand .dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.92rem;
  border: none;
  background: transparent;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.main {
  padding: 28px 40px 60px;
  max-width: 920px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.topbar h1 { font-size: 1.6rem; }
.topbar p { color: var(--text-muted); margin: 6px 0 0; font-size: 0.92rem; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px;
  display: flex;
  gap: 2px;
}
.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.theme-toggle button.active {
  background: var(--accent);
  color: var(--surface);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.card .subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* Seletor de intervalo */
.interval-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.interval-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.interval-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

/* Switch liga/desliga */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.switch-label { font-size: 0.9rem; }
.switch-label .status { color: var(--text-muted); font-size: 0.8rem; display: block; margin-top: 2px; }

.switch {
  width: 46px; height: 26px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: background var(--transition);
}
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}
.switch.on { background: var(--accent-soft); border-color: var(--accent); }
.switch.on .knob { transform: translateX(20px); background: var(--accent); }

/* Botões */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}
.btn-primary:hover { opacity: 0.92; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Selo de assinatura — elemento de assinatura visual do portal */
.seal-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-top: 14px;
}
.seal {
  flex-shrink: 0;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  outline: 1px dashed var(--accent);
  outline-offset: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
}
.seal span {
  font-size: 0.62rem;
  color: var(--accent);
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}
.seal-info .fingerprint {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
}
.seal-info .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
}

.pubkey-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--text-muted);
  margin-top: 12px;
}

.instructions {
  margin-top: 14px;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.mode-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.mode-card {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
}
.mode-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.mode-card h3 { font-size: 0.95rem; margin-bottom: 4px; }
.mode-card p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.history-item:last-child { border-bottom: none; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; }
.tag.sucesso { background: var(--accent-soft); color: var(--accent); }
.tag.falhou { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
}
.login-footer {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  max-width: 340px;
  line-height: 1.5;
}
.app-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
}
.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.field input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.error-msg { color: var(--danger); font-size: 0.82rem; margin-top: 10px; }

.hidden { display: none !important; }

.server-select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  max-width: 220px;
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .rail { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 20px; }
}
