*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --sidebar: #1e2a3a;
  --sidebar-hover: #2c3e55;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --card: #ffffff;
  --radius: 8px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: 220px; background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Sidebar ── */
.sidebar-logo { padding: 20px 16px 12px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.sidebar-logo span { color: var(--accent); }
nav a { display: flex; align-items: center; gap: 10px; padding: 11px 16px; color: #94a3b8; text-decoration: none; transition: background .15s, color .15s; cursor: pointer; }
nav a:hover, nav a.active { background: var(--sidebar-hover); color: #fff; }
nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section { padding: 16px 16px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #475569; }

/* ── Topbar ── */
.topbar-title { font-weight: 600; font-size: 16px; }
.user-badge { display: flex; align-items: center; gap: 8px; }
.user-badge .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-badge .name { font-size: 13px; color: var(--muted); }
.btn-logout { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; padding: 4px 8px; border-radius: 4px; }
.btn-logout:hover { background: #fee2e2; }

/* ── Cards / Sections ── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); }
.card-body { padding: 16px 20px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #f8fafc; }
tr:hover td { background: #f8fafc; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-activo, .badge-en_curso, .badge-completada  { background: #dcfce7; color: #15803d; }
.badge-inactivo, .badge-cancelado, .badge-bloqueada { background: #fee2e2; color: #b91c1c; }
.badge-prospecto, .badge-planificacion, .badge-pendiente { background: #fef9c3; color: #854d0e; }
.badge-pausado, .badge-en_revision  { background: #fef3c7; color: #92400e; }
.badge-en_progreso { background: #dbeafe; color: #1d4ed8; }
.badge-admin  { background: #ede9fe; color: #6d28d9; }
.badge-usuario { background: #e0f2fe; color: #0369a1; }
.badge-baja   { background: #f1f5f9; color: #475569; }
.badge-media  { background: #dbeafe; color: #1e40af; }
.badge-alta   { background: #fef3c7; color: #b45309; }
.badge-urgente { background: #fee2e2; color: #991b1b; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; outline: none; transition: border-color .15s; background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input:user-invalid, .field select:user-invalid { border-color: var(--danger); }
.req { color: var(--danger); margin-left: 2px; }
.field textarea { resize: vertical; min-height: 72px; }

/* ── Login ── */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); }
.login-box { background: var(--card); border-radius: 12px; padding: 40px 36px; width: 360px; }
.login-box h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-box p { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* ── Filters ── */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--accent); }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }

/* ── Archivos ── */
.archivos-panel { margin-top: 24px; }
.archivos-panel h4 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.archivos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.archivo-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; cursor: pointer; transition: box-shadow .15s; }
.archivo-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.archivo-card .thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; }
.archivo-card .file-icon { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; border-radius: 4px; font-size: 28px; }
.archivo-card .fname { font-size: 11px; text-align: center; word-break: break-all; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.archivo-card .fsize { font-size: 10px; color: var(--muted); }
.archivo-card .del-btn { position: absolute; top: 4px; right: 4px; background: var(--danger); color: #fff; border: none; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 18px; text-align: center; cursor: pointer; display: none; }
.archivo-card:hover .del-btn { display: block; }
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 12px; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: #eff6ff; color: var(--accent); }

/* ── Preview modal ── */
.preview-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 4px; }
.preview-embed { width: 100%; height: 70vh; border: none; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .num { font-size: 28px; font-weight: 800; color: var(--accent); }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
