:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1f2430;
  --text-muted: #7a8194;
  --primary: #1f2530;
  --primary-dark: #0e1218;
  --primary-soft: #eceef1;
  --success: #16a34a;
  --success-soft: #e8f8ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #0891b2;
  --warning-soft: #e5f8fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 38, 0.04), 0 8px 24px rgba(20, 24, 38, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; color: var(--text-muted); }

/* ---------- Layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}

.sidebar-nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar-nav .icon { width: 18px; text-align: center; opacity: 0.8; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip strong { display: block; font-size: 13.5px; }
.user-chip a { font-size: 12px; color: var(--text-muted); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.main-content {
  flex: 1;
  padding: 28px 34px;
  max-width: 1200px;
}

.content-narrow { max-width: 520px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }

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

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

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

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

/* ---------- Stat tiles ---------- */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-tile .stat-value { font-size: 26px; font-weight: 700; }
.stat-tile .stat-label { color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: filter 0.1s ease;
}
.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text); }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; font-size: 13.5px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-activo, .badge-media { background: var(--primary-soft); color: var(--primary-dark); }
.badge-pausado, .badge-baja { background: var(--warning-soft); color: var(--warning); }
.badge-terminado { background: var(--success-soft); color: var(--success); }
.badge-alta { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables & lists ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.row-link { color: var(--text); font-weight: 600; }

.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.project-item:hover { border-color: var(--primary); }
.project-item .meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Pendientes ---------- */
.pendiente-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.pendiente-item:last-child { border-bottom: none; }
.pendiente-item.done .pendiente-title { text-decoration: line-through; color: var(--text-muted); }
.pendiente-item input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--success); cursor: pointer; }
.pendiente-title { font-weight: 600; }
.pendiente-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.pendiente-actions { margin-left: auto; }
.empty-state { color: var(--text-muted); font-size: 13.5px; padding: 18px 0; text-align: center; }

/* ---------- Timeline (avances) ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-header { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--text-muted); margin-bottom: 3px; }
.timeline-header strong { color: var(--text); }
.timeline-text { color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; font-size: 13.5px; }
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--primary-dark); }

/* ---------- Files ---------- */
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.file-item:last-child { border-bottom: none; }
.file-name { font-weight: 600; }
.file-meta { font-size: 12px; color: var(--text-muted); }

/* ---------- Login ---------- */
.login-body { margin: 0; min-height: 100vh; background: var(--bg); }
.login-split { display: flex; min-height: 100vh; }

.login-logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
  margin: 0 auto 14px;
}
.login-logo.small { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }

/* Left panel: brand / pitch */
@keyframes loginDrift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.06); }
}
@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-left {
  flex: 1 1 55%;
  background: linear-gradient(155deg, var(--primary-dark) 0%, var(--primary) 62%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 60px 64px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(480px circle at 12% 15%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(420px circle at 88% 20%, rgba(255, 255, 255, 0.10), transparent 55%),
    radial-gradient(560px circle at 75% 90%, var(--warning) 0%, transparent 45%);
  opacity: 0.35;
  animation: loginDrift 18s ease-in-out infinite alternate;
  pointer-events: none;
}
.login-left::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(155deg, rgba(0, 0, 0, 0.6), transparent 65%);
  mask-image: linear-gradient(155deg, rgba(0, 0, 0, 0.6), transparent 65%);
  pointer-events: none;
}
.login-left-inner { position: relative; z-index: 1; max-width: 520px; animation: loginFadeUp 0.6s ease both; }

.login-logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.login-left-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.16); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.login-logo-row strong { display: block; font-size: 14px; }
.login-logo-row span { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }

.login-left-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 100px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
  color: var(--warning);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  margin-bottom: 22px;
}
.login-left-badge svg { flex-shrink: 0; }

.login-left-title { font-size: 38px; line-height: 1.15; font-weight: 800; letter-spacing: -0.015em; margin-bottom: 16px; }
.login-left-title .highlight {
  background: linear-gradient(90deg, var(--warning) 0%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-left-desc { color: rgba(255, 255, 255, 0.85); font-size: 15px; line-height: 1.55; max-width: 440px; margin-bottom: 34px; }

.login-feature-list {
  list-style: none; margin: 0 0 40px; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px;
}
.login-feature-list li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; transition: transform 0.2s ease; }
.login-feature-list li:hover { transform: translateX(2px); }
.login-feature-icon {
  width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-left-footer { position: relative; font-size: 12px; color: rgba(255, 255, 255, 0.6); border-top: 1px solid rgba(255, 255, 255, 0.18); padding-top: 18px; }

/* Right panel: form */
.login-right { flex: 1 1 45%; display: flex; align-items: center; justify-content: center; background: var(--surface); padding: 40px; }
.login-right-inner { width: 100%; max-width: 380px; animation: loginFadeUp 0.6s ease 0.08s both; }

.login-badge-secure {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 100px;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  margin-bottom: 18px;
}
.login-right-inner h2 { font-size: 27px; margin-bottom: 6px; }
.login-subtitle { margin-bottom: 26px; }

.login-form { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.login-field { display: flex; flex-direction: column; gap: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }

.input-icon-group { position: relative; display: flex; align-items: center; }
.input-icon-group .input-icon {
  position: absolute; left: 13px; display: flex; color: var(--text-muted); opacity: 0.65;
  pointer-events: none; transition: color 0.15s ease, opacity 0.15s ease;
}
.input-icon-group input {
  width: 100%; padding: 11px 38px 11px 38px; font-size: 14px; font-weight: 400; text-transform: none;
  border-radius: 10px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-icon-group input:focus ~ .input-icon,
.input-icon-group:focus-within .input-icon { color: var(--primary); opacity: 1; }
.input-icon-group input:focus { box-shadow: 0 0 0 4px var(--primary-soft); }
.input-icon-toggle {
  position: absolute; right: 6px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  opacity: 0.6; padding: 7px; line-height: 1; border-radius: 6px; transition: opacity 0.15s ease, background 0.15s ease;
}
.input-icon-toggle:hover { opacity: 1; background: var(--bg); }

.btn-login {
  margin-top: 6px; padding: 12px 16px; font-size: 14.5px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 1px 2px rgba(20, 24, 38, 0.06), 0 10px 20px -8px color-mix(in srgb, var(--primary) 55%, transparent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-login:hover {
  filter: none;
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(20, 24, 38, 0.08), 0 14px 26px -8px color-mix(in srgb, var(--primary) 60%, transparent);
}
.btn-login:active { transform: translateY(0); }
.login-right-footer { text-align: center; margin-top: 28px; font-size: 12px; color: var(--text-muted); }

@media (max-width: 860px) {
  .login-split { flex-direction: column; }
  .login-left, .login-right { flex: none; width: 100%; }
  .login-left { padding: 44px 28px; }
  .login-left-title { font-size: 30px; }
  .login-feature-list { grid-template-columns: 1fr; margin-bottom: 28px; }
  .login-right { padding: 36px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-left::before { animation: none; }
  .login-left-inner, .login-right-inner { animation: none; }
}

.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-error { background: var(--danger); }
