:root {
  --primary: #6d2ce0;
  --primary-dark: #5a1fc4;
  --primary-light: #f1eafd;
  --bg: #f6f5fa;
  --card: #ffffff;
  --text: #1f1c2e;
  --muted: #7a7691;
  --border: #e6e3f0;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(40, 20, 90, .07);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
}
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6d2ce0 0%, #9b4dff 50%, #c86dd7 100%);
}
.login-card {
  background: var(--card); border-radius: 20px; padding: 40px; width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { font-size: 26px; font-weight: 800; color: var(--primary); text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; transition: border .15s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card .btn-block { margin-top: 22px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 12.5px; gap: 10px; flex-wrap: wrap; }
.auth-links a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }
.form-success { color: var(--green); font-size: 13px; margin-top: 12px; text-align: center; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: #171331; color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar-logo { font-size: 19px; font-weight: 800; padding: 24px 20px; color: #c9b3f5; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar nav a {
  color: #bdb8d6; text-decoration: none; padding: 11px 14px; border-radius: 10px;
  font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 8px; }
.user-email { font-size: 12px; color: #bdb8d6; margin-bottom: 8px; word-break: break-all; }
.main { flex: 1; margin-left: 230px; padding: 32px 36px; max-width: 1200px; }

/* ---------- Componentes ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 24px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn {
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .15s, background .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-danger { background: #fdeaea; color: var(--red); }
.btn-ghost { background: rgba(255,255,255,.1); color: #ddd; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-value { font-size: 30px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card h3 { font-size: 16px; margin-bottom: 14px; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.project-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.project-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-card h4 { font-size: 16.5px; }
.project-card .client { color: var(--muted); font-size: 13px; }
.project-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.project-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* Toggle estilo make.com */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; background: #d5d2e2; border-radius: 24px; transition: background .2s;
}
.toggle .slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.chip-pending { background: #eef1f6; color: #57607a; }
.chip-processing { background: #fff4e0; color: var(--amber); }
.chip-published { background: #e5f7ec; color: var(--green); }
.chip-error { background: #fdeaea; color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td a { color: var(--primary); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23, 19, 49, .55); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 18px; padding: 28px; width: 560px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 70px rgba(0,0,0,.35);
}
.modal h3 { font-size: 19px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.modal label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; color: #46425e; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 13.5px; outline: none; font-family: inherit; background: #fff;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--primary); }
.modal textarea { resize: vertical; min-height: 60px; }
.modal .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-error { color: var(--red); font-size: 13px; margin-top: 12px; text-align: center; }

/* ---------- Logs ---------- */
.log-list { font-family: 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
.log-row { padding: 7px 10px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.log-time { color: var(--muted); white-space: nowrap; }
.log-info { color: var(--text); }
.log-success { color: var(--green); }
.log-error { color: var(--red); }
.log-warn { color: var(--amber); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #171331; color: #fff;
  padding: 13px 20px; border-radius: 12px; font-size: 14px; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 420px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

@media (max-width: 800px) {
  .sidebar { width: 64px; }
  .sidebar-logo { font-size: 15px; padding: 20px 8px; text-align: center; }
  .sidebar nav a { text-align: center; padding: 11px 6px; }
  .sidebar-footer, .user-email { display: none; }
  .main { margin-left: 64px; padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}
