:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --secondary: #334155;
  --success: #15803d;
  --border: #dbe3ef;
  --warning-bg: #fff7ed;
  --warning-border: #fed7aa;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: linear-gradient(135deg, #0f766e, #164e63);
  color: white;
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  opacity: 0.9;
}

.container {
  width: min(1280px, 94%);
  margin: 24px auto 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.warning-card {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  margin-bottom: 20px;
}

.grid-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.admin-layout {
  grid-template-columns: 1.3fr 1fr;
}

h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: Arial, Helvetica, sans-serif;
  outline: none;
  background: white;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-light {
  background: #e5e7eb;
  color: #111827;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.help-text {
  color: var(--muted);
  margin-top: -6px;
  font-size: 14px;
}

.templates-list,
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.template-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.template-item label {
  display: flex;
  gap: 10px;
  cursor: pointer;
  align-items: flex-start;
}

.template-title {
  font-weight: 700;
}

.template-category {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.preview-card {
  margin-top: 20px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

#resultadoNota {
  min-height: 360px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.copy-message {
  margin: 10px 0 0;
  font-weight: 700;
  color: var(--success);
}

.variables-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

code {
  background: #e2e8f0;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 13px;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.admin-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
}

.admin-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.admin-item p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-inactive {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 900px) {
  .grid-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 18px;
  }

  .topbar h1 {
    font-size: 22px;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions form {
  margin: 0;
}

.login-container {
  max-width: 560px;
}

.login-card {
  margin-top: 28px;
}

.login-card h2 {
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  margin-top: 0;
}

.error-message {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 14px 0;
  font-weight: 700;
}

.hidden {
  display: none;
}

.full-width {
  width: 100%;
}

@media (max-width: 900px) {
  .topbar-actions {
    width: 100%;
  }
}

.login-topbar {
  justify-content: center;
  text-align: center;
}

.login-footer-link {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.login-footer-link a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
  margin-left: 4px;
}

.login-footer-link a:hover {
  text-decoration: underline;
}
