:root {
  --bg: #0a0e15;
  --surface-1: #131921;
  --surface-2: #1c2330;
  --border: rgba(6, 182, 212, 0.15);
  --border-strong: rgba(6, 182, 212, 0.35);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #06b6d4;
  --accent-hi: #22d3ee;
  --danger: #ef4444;
  --danger-hi: #f87171;
  --radius-card: 12px;
  --radius-btn: 8px;
  --shadow-glow: 0 0 24px rgba(6, 182, 212, 0.35);
  --shadow-glow-hi: 0 0 32px rgba(6, 182, 212, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --t: 200ms ease;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== LOGIN ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem; position: relative; overflow: hidden;
}
.sonar-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  display: grid; place-items: center;
}
.ring {
  position: absolute; border: 1px solid var(--accent);
  border-radius: 50%; opacity: 0;
  animation: sonarPulse 6s ease-out infinite;
}
.ring.r1 { width: 200px; height: 200px; animation-delay: 0s; }
.ring.r2 { width: 200px; height: 200px; animation-delay: 1.5s; }
.ring.r3 { width: 200px; height: 200px; animation-delay: 3s; }
.ring.r4 { width: 200px; height: 200px; animation-delay: 4.5s; }
@keyframes sonarPulse {
  0%   { transform: scale(0.5); opacity: 0; }
  20%  { opacity: 0.08; }
  100% { transform: scale(6); opacity: 0; }
}
.login-card {
  position: relative; z-index: 1;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 3rem 2.5rem;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 60px rgba(0,0,0,0.5);
}
.login-card .logo { color: var(--accent); margin: 0 auto 1.5rem; width: 96px; }
.login-card .logo svg { width: 100%; height: auto; }
.login-card h1 {
  font-size: 2rem; font-weight: 600;
  margin: 0 0 0.25rem; letter-spacing: 0.5px;
}
.login-card .subtitle {
  margin: 0 0 2rem;
  color: var(--text-dim); font-size: 0.95rem;
}
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card input[type="password"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.login-card button {
  background: var(--accent);
  border: none; color: #001318;
  font-weight: 600;
  padding: 0.85rem;
  border-radius: var(--radius-btn);
  font-size: 1rem; cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: background var(--t), box-shadow var(--t), transform var(--t);
  font-family: inherit;
}
.login-card button:hover { background: var(--accent-hi); box-shadow: var(--shadow-glow-hi); }
.login-card button:active { transform: translateY(1px); }
.login-card button:disabled { opacity: 0.6; cursor: not-allowed; }
.error {
  color: var(--danger-hi);
  font-size: 0.9rem;
  margin: 0;
  text-align: left;
}

/* ===== TOPBAR ===== */
.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: var(--accent); }
.brand-svg { width: 32px; height: 32px; }
.brand-name {
  color: var(--text); font-weight: 600;
  font-size: 1.1rem; letter-spacing: 0.5px;
}
.link-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1rem; border-radius: var(--radius-btn);
  cursor: pointer; font-family: inherit; font-size: 0.9rem;
  transition: color var(--t), border-color var(--t);
}
.link-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ===== MAIN ===== */
.container {
  max-width: 1100px; margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ===== CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 2rem 1.75rem;
  display: flex; flex-direction: column;
  transition: border-color var(--t), transform var(--t);
}
.card:hover { border-color: var(--border-strong); }
.card-icon {
  color: var(--accent); width: 40px; height: 40px;
  margin-bottom: 1.25rem;
}
.card-icon svg { width: 100%; height: 100%; }
.card-title {
  font-size: 1.4rem; font-weight: 600;
  margin: 0 0 0.25rem;
}
.card-ext {
  color: var(--text-dim); font-size: 0.85rem;
  margin: 0 0 1.5rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.card-meta {
  margin-top: auto;
  margin-bottom: 1.25rem;
  color: var(--text-dim); font-size: 0.9rem;
  line-height: 1.6;
}
.card-meta strong { color: var(--text); }
.card-meta .meta-version { color: var(--accent); }
.card-empty {
  color: var(--text-dim); font-size: 0.9rem;
  font-style: italic;
  margin-top: auto; margin-bottom: 1.25rem;
}
.card-notes {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 4.5em;
  overflow: auto;
}
.card-instructions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}
.btn-primary {
  background: var(--accent);
  color: #001318; border: none;
  padding: 0.85rem 1.5rem;
  font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer; font-family: inherit;
  box-shadow: var(--shadow-glow);
  transition: background var(--t), box-shadow var(--t), transform var(--t);
}
.btn-primary:hover { background: var(--accent-hi); box-shadow: var(--shadow-glow-hi); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-primary.block { width: 100%; }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.85rem 1.5rem;
  font-size: 1rem; border-radius: var(--radius-btn);
  cursor: pointer; font-family: inherit;
  transition: background var(--t), border-color var(--t);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-danger {
  background: var(--danger); color: #fff; border: none;
  padding: 0.85rem 1.5rem;
  font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-btn);
  cursor: pointer; font-family: inherit;
  transition: background var(--t);
}
.btn-danger:hover { background: var(--danger-hi); }
.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.card .btn-row .btn-secondary { flex: 1; min-width: 0; }
.card .btn-row .btn-primary { flex: 2; min-width: 0; }
.card .btn-primary.block { margin-bottom: 0.5rem; }

/* ===== MANUAL SECTION (Documentation, sobre) ===== */
.manual-section {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}
.manual-head {
  display: flex; align-items: baseline; gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.manual-title {
  font-size: 1.05rem; font-weight: 600;
  margin: 0;
  color: var(--text);
}
.manual-subtitle {
  color: var(--text-dim); font-size: 0.85rem;
}
.manual-body {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 0.9rem 1.1rem;
  display: flex; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  justify-content: space-between;
}
.manual-info {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 0;
}
.manual-version {
  color: var(--accent); font-weight: 600; font-size: 0.95rem;
}
.manual-meta {
  color: var(--text-dim); font-size: 0.8rem;
}
.manual-notes {
  color: var(--text-dim); font-size: 0.8rem;
  font-style: italic;
  max-width: 60ch;
  white-space: pre-wrap;
}
.manual-empty {
  color: var(--text-dim); font-style: italic;
  margin: 0;
}
.manual-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.manual-actions .btn-primary,
.manual-actions .btn-secondary {
  padding: 0.5rem 1rem; font-size: 0.9rem;
  box-shadow: none;
}
.manual-actions .btn-primary:hover { box-shadow: 0 0 16px rgba(6, 182, 212, 0.35); }
@media (max-width: 600px) {
  .manual-body { flex-direction: column; align-items: stretch; }
  .manual-actions { justify-content: stretch; }
  .manual-actions .btn-primary,
  .manual-actions .btn-secondary { flex: 1; }
}

/* ===== HISTORY ===== */
.history-section {
  margin-top: 3rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.history-toggle {
  width: 100%; background: transparent; border: none;
  color: var(--text); font-family: inherit; font-size: 1rem;
  padding: 1.25rem 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: background var(--t);
}
.history-toggle:hover { background: var(--surface-2); }
.history-toggle .chevron { transition: transform var(--t); color: var(--text-dim); }
.history-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.history-content { padding: 0 1.75rem 1.75rem; }
.history-platform { margin-top: 1.5rem; }
.history-platform h3 {
  font-size: 1rem; font-weight: 600; color: var(--accent);
  margin: 0 0 0.75rem; text-transform: uppercase; letter-spacing: 1px;
}
.history-row {
  display: grid; grid-template-columns: 1fr auto auto auto auto;
  gap: 1rem; align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.history-row:first-of-type { border-top: none; }
.history-row .col-version { color: var(--text); font-weight: 500; }
.history-row .col-version .badge {
  display: inline-block; margin-left: 0.5rem;
  background: var(--accent); color: #001318;
  font-size: 0.7rem; padding: 0.1rem 0.45rem;
  border-radius: 4px; font-weight: 600;
}
.history-row .col-meta { color: var(--text-dim); font-size: 0.85rem; }
.history-row .icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.7rem; border-radius: var(--radius-btn);
  cursor: pointer; font-family: inherit; font-size: 0.85rem;
  transition: color var(--t), border-color var(--t);
}
.history-row .icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.history-row .icon-btn.danger:hover:not(:disabled) { color: var(--danger-hi); border-color: var(--danger); }
.history-row .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 8, 13, 0.78);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  width: 100%; max-width: 480px;
  padding: 2rem;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal.small { max-width: 380px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.close-btn {
  background: transparent; border: none;
  color: var(--text-dim); font-size: 1.5rem; line-height: 1;
  cursor: pointer; padding: 0.25rem 0.5rem;
  border-radius: var(--radius-btn);
  transition: color var(--t);
}
.close-btn:hover { color: var(--text); }
.dropzone {
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-btn);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color var(--t), background var(--t);
  margin-bottom: 1.25rem;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(6, 182, 212, 0.05); }
.dropzone-text { margin: 0; color: var(--text); font-size: 0.95rem; }
.dropzone-hint { margin: 0.5rem 0 0; color: var(--text-dim); font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field > span { color: var(--text-dim); font-size: 0.85rem; }
.field input, .field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-btn);
  font-size: 0.95rem; font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.progress {
  margin: 1rem 0;
}
.progress-track {
  width: 100%; height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 150ms linear;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.6);
}
.progress-text {
  margin: 0.5rem 0 0;
  color: var(--text-dim); font-size: 0.85rem;
}
.modal-actions {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .topbar-inner { padding: 1rem; }
  .container { padding: 1.5rem 1rem; }
  .card { padding: 1.5rem 1.25rem; }
  .cards-grid { gap: 1rem; }
  .history-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .login-card { padding: 2rem 1.5rem; }
}

/* ===== COMMENTS (mini-forum) ===== */
.comments-section { margin-top: 2.5rem; }
.comments-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 1rem; color: var(--text); }
.comment-form {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1.5rem;
}
.comment-form .modal-actions { margin-top: 0.75rem; }
.comments-list { display: flex; flex-direction: column; gap: 0.75rem; }
.comments-empty { color: var(--text-dim); padding: 0.5rem 0; }
.comment {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 0.9rem 1.1rem;
}
.comment-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.comment-name { font-weight: 600; color: var(--accent); font-size: 0.9rem; }
.comment-date { color: var(--text-dim); font-size: 0.8rem; }
.comment-del { margin-left: auto; }
.comment-text { color: var(--text); font-size: 0.95rem; white-space: pre-wrap; word-break: break-word; }

/* ===== UTILITIES ===== */
[hidden] { display: none !important; }
