:root {
  --bg: #f4f6fb; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2563eb; --primary-d: #1d4ed8; --side: #0f1e3d; --side-t: #c7d2fe;
  --ok: #059669; --warn: #d97706; --err: #dc2626; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 17px; margin: 26px 0 10px; display: flex; gap: 8px; align-items: center; }
h3 { margin: 0 0 8px; font-size: 15px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-t); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 6px 18px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 11px; color: var(--side-t); }
.logo { background: linear-gradient(135deg, #3b82f6, #ec4899); color: #fff; font-weight: 700; border-radius: 9px; width: 34px; height: 34px; display: inline-grid; place-items: center; font-size: 13px; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; margin: 14px 8px 4px; }
.sidebar nav a { color: var(--side-t); padding: 7px 10px; border-radius: 7px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a.active { background: rgba(59,130,246,.25); color: #fff; }
.sidebar nav a.small-link { font-size: 12.5px; opacity: .8; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; font-size: 12.5px; }
.sidebar-foot .me { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.sidebar-foot .me a { color: #fff; }
.sidebar-foot .version { display: block; margin-top: 8px; color: var(--side-t); opacity: .6; font-size: 11.5px; }
.linklike { background: none; border: 0; padding: 0; color: var(--side-t); cursor: pointer; font: inherit; }
.content .linklike { color: var(--primary); }
.linklike.danger, .content .linklike.danger { color: var(--err); }

.content { padding: 24px 32px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; gap: 12px; }
.count { background: #e0e7ff; color: #3730a3; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.info { background: #eff6ff; border-color: #bfdbfe; }
.card.sim { border-color: #fcd34d; background: #fffbeb; }
.card.done { border-color: #6ee7b7; background: #ecfdf5; }
.narrow { max-width: 560px; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn.wide { width: 100%; padding: 10px; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
input:disabled { background: #f3f4f6; color: var(--muted); }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span2 { grid-column: span 2; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 240px; }
.filters select { width: auto; }
.inline-form { display: flex; gap: 10px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.inline-form input[name=nombre] { max-width: 340px; }
.inline-form input[type=file] { width: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; }
.table td { padding: 10px 14px; border-bottom: 1px solid #f1f2f5; vertical-align: top; }
.table.compact td { padding: 7px 14px; font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.rowlink { cursor: pointer; } .rowlink:hover td { background: #f8faff; }
.table .num { text-align: right; } .nowrap { white-space: nowrap; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.table .dim td { opacity: .5; }
.row-actions { white-space: nowrap; display: flex; gap: 12px; }
.detail { font-size: 12px; max-width: 420px; word-break: break-word; }

.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; font-weight: 600; background: #f3f4f6; color: #374151; vertical-align: middle; }
.tag-activo, .tag-agregar { background: #d1fae5; color: #065f46; }
.tag-inactivo, .tag-eliminar { background: #fee2e2; color: #991b1b; }
.tag-warn { background: #fef3c7; color: #92400e; }
.tag-modificar { background: #dbeafe; color: #1e40af; }
.tag-importar { background: #ede9fe; color: #5b21b6; }
.role { font-size: 10.5px; padding: 1px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.role-admin { background: #fce7f3; color: #9d174d; } .role-editor { background: #dbeafe; color: #1e40af; } .role-lector { background: #e5e7eb; color: #374151; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.flash ul { margin: 6px 0; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 24px; margin: 0; }
.facts .wide { grid-column: span 3; }
.facts dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 14.5px; }
.pre { white-space: pre-wrap; }
.add-contact summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.add-contact[open] summary { margin-bottom: 14px; }

.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 14px; }
pre.key, pre.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; user-select: all; }
pre.code { user-select: text; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 10px 0; }
.stats div { background: rgba(255,255,255,.7); border-radius: 8px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 22px; } .stats span { font-size: 11.5px; color: var(--muted); }
.errors { max-height: 260px; overflow: auto; font-size: 12.5px; color: #92400e; }
.steps li { margin-bottom: 4px; }
.changelog h3 { margin-top: 18px; } .changelog h3:first-child { margin-top: 0; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 15% 20%, #60a5fa 0, transparent 40%), radial-gradient(circle at 85% 80%, #f472b6 0, transparent 40%), linear-gradient(135deg, #1e3a8a, #6d28d9); }
.login-card { display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 60px rgba(15,23,42,.35); max-width: 860px; width: 100%; }
.login-art { background: linear-gradient(160deg, #3b82f6, #8b5cf6 60%, #ec4899); color: #fff; padding: 36px; display: flex; flex-direction: column; justify-content: center; }
.login-art svg { width: 100%; max-width: 320px; margin-bottom: 16px; }
.login-art h2 { margin: 0 0 6px; font-size: 20px; } .login-art p { margin: 0; opacity: .9; }
.login-form { padding: 40px 36px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-form h1 { margin: 0 0 4px; }
.brand-lg { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--side); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; }
  .facts { grid-template-columns: 1fr 1fr; } .facts .wide { grid-column: span 2; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .login-card { grid-template-columns: 1fr; } .login-art { display: none; }
}
