:root {
  --indigo: #4f46e5;
  --indigo-d: #4338ca;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --green: #10b981;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

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

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
.m0 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { text-align: right; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
code { background: #eef2ff; color: var(--indigo-d); padding: .1rem .35rem; border-radius: 5px; font-size: .85em; }

/* ---------- Topbar ---------- */
.planea-topbar {
  height: 58px;
  background: linear-gradient(90deg, #4f46e5, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.planea-topbar .brand { color: #fff; font-weight: 700; font-size: 1.2rem; }
.planea-topbar .brand:hover { text-decoration: none; opacity: .92; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right .user { color: #e0e7ff; font-size: .9rem; }
.role-badge { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; padding: .12rem .45rem; border-radius: 20px; margin-left: .25rem; }
.role-admin { background: #fde68a; color: #92400e; }
.role-gestor { background: #c7d2fe; color: #3730a3; }
.btn-logout { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: .35rem .7rem; cursor: pointer; font-size: .85rem; }
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ---------- Layout ---------- */
.planea-layout { display: flex; min-height: calc(100vh - 58px); }
.planea-sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex-shrink: 0;
}
.planea-sidebar a {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem; border-radius: 9px;
  color: var(--ink); font-weight: 500;
}
.planea-sidebar a:hover { background: #f8fafc; text-decoration: none; }
.planea-sidebar a.active { background: #eef2ff; color: var(--indigo-d); }
.planea-sidebar a i { font-size: 1.05rem; }
.sidebar-foot { margin-top: auto; padding: .5rem .4rem; }
.geo-warn { font-size: .72rem; color: var(--orange); }
.planea-main { flex: 1; min-width: 0; padding: 1.5rem 2rem; }

/* ---------- Headings ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.page-head .actions { display: flex; gap: .5rem; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-title { font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-title i { color: var(--indigo); }
.chart-box { position: relative; height: 280px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; display: flex; align-items: center; gap: .9rem; }
.kpi-ico { width: 46px; height: 46px; border-radius: 11px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.3rem; flex-shrink: 0; }
.bg-indigo { background: var(--indigo); }
.bg-green { background: var(--green); }
.bg-orange { background: var(--orange); }
.bg-blue { background: var(--blue); }
.kpi-num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: .82rem; }

/* ---------- Grids ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-3 .card { margin-bottom: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stats-grid .card { margin-bottom: 0; }
.mini-chart { position: relative; height: 240px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.grid-2-1 .card { margin-bottom: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table-plain { width: 100%; border-collapse: collapse; }
.table-plain th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--line); padding: .55rem .6rem; }
.table-plain td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-plain tr:last-child td { border-bottom: none; }
.table-plain th.num, .table-plain td.num { text-align: right; }
.table-plain .dest { max-width: 320px; }
.table-plain .dest a { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; color: var(--muted); }
.short { font-weight: 600; font-family: ui-monospace, monospace; }
.row-actions { display: flex; align-items: center; gap: .5rem; }
.row-actions a, .row-actions button { color: var(--muted); background: none; border: none; cursor: pointer; font-size: 1rem; padding: .15rem; }
.row-actions a:hover { color: var(--indigo); text-decoration: none; }
.row-actions button:hover { color: var(--red); }
.row-actions .owner { margin-left: .25rem; }
.acts { width: 1%; }

/* ---------- Pills ---------- */
.pill { font-size: .72rem; padding: .18rem .55rem; border-radius: 20px; font-weight: 600; }
.pill-on { background: #dcfce7; color: #166534; }
.pill-off { background: #e2e8f0; color: #475569; }
.pill-warn { background: #fef3c7; color: #92400e; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-light, .btn-xs, .btn-primary-inline {
  display: inline-flex; align-items: center; gap: .4rem;
  border-radius: 9px; padding: .55rem .95rem; font-weight: 600; font-size: .9rem;
  cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-d); text-decoration: none; color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: #f8fafc; text-decoration: none; }
.btn-xs { padding: .25rem .6rem; font-size: .8rem; background: #eef2ff; color: var(--indigo-d); }
.btn-xs:hover { background: #e0e7ff; text-decoration: none; }
.btn-primary-inline { background: var(--indigo); color: #fff; margin-top: 1rem; }
.btn-primary-inline:hover { background: var(--indigo-d); color: #fff; text-decoration: none; }

/* ---------- Forms ---------- */
.form-card { max-width: 1000px; }
form label { display: block; font-weight: 600; font-size: .85rem; margin: .9rem 0 .35rem; }
form label.req::after { content: " *"; color: var(--red); }
form label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
form input[type=text], form input[type=password], form input[type=number], form input[type=datetime-local] {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; background: #fff;
}
form input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
form input:disabled { background: #f8fafc; color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); margin: .35rem 0 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.4rem; }

/* ---------- Alerts ---------- */
.alert-ok, .alert-error { padding: .7rem 1rem; border-radius: 9px; margin-bottom: 1rem; font-size: .9rem; display: flex; align-items: center; gap: .5rem; }
.alert-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Link summary ---------- */
.link-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.link-summary .big { font-size: 1.6rem; }
.dest-inline { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* ---------- Login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.login-card { background: #fff; width: 360px; max-width: 92vw; padding: 2.2rem; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.login-brand { font-size: 1.7rem; font-weight: 700; color: var(--indigo); text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-top: .25rem; margin-bottom: 1.4rem; }
.login-card label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .35rem; }
.login-card input { width: 100%; padding: .65rem .7rem; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; }
.login-card input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.btn-primary-full { display: block; box-sizing: border-box; text-align: center; text-decoration: none; width: 100%; margin-top: 1.3rem; background: var(--indigo); color: #fff; border: none; padding: .7rem; border-radius: 9px; font-weight: 600; font-size: .95rem; cursor: pointer; }
.btn-primary-full:hover { background: var(--indigo-d); color: #fff; text-decoration: none; }

/* ---------- Error ---------- */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.error-card { background: #fff; padding: 2.5rem; border-radius: 16px; box-shadow: var(--shadow); text-align: center; max-width: 420px; }
.error-icon { font-size: 2.6rem; color: var(--orange); }
.error-card h1 { font-size: 1.4rem; margin: .6rem 0; }
.error-card p { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2-1 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .planea-sidebar { width: 64px; }
  .planea-sidebar a span, .planea-sidebar a { font-size: 0; }
  .planea-sidebar a i { font-size: 1.2rem; }
  .geo-warn { display: none; }
}

/* ---------- Instalador ---------- */
.install-page { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5, #7c3aed); padding: 3rem 1rem; }
.install-card { background: #fff; width: 520px; max-width: 94vw; padding: 2.2rem; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.install-brand { font-size: 1.7rem; font-weight: 700; color: var(--indigo); text-align: center; }
.install-sub { text-align: center; color: var(--muted); margin-top: .25rem; margin-bottom: 1.4rem; }
.install-h1 { font-size: 1.3rem; margin: 0 0 1rem; }
.install-card label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .35rem; }
.install-card input[type=text], .install-card input[type=password] { width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; }
.install-card input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.install-checks { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.install-checks li { display: flex; align-items: flex-start; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.install-checks .ico { font-weight: 700; width: 1.4rem; text-align: center; }
.install-checks li.ok .ico { color: var(--green); }
.install-checks li.bad .ico { color: var(--red); }
.db-choice { margin-bottom: 1rem; }
.db-choice .radio { display: block; font-weight: 500; padding: .5rem .2rem; cursor: pointer; }
.config-box { width: 100%; font-family: ui-monospace, monospace; font-size: .8rem; border: 1px solid var(--line); border-radius: 9px; padding: .7rem; background: #f8fafc; }

/* ---------- Selector de idioma ---------- */
.lang-switch { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: .3rem .45rem; font-size: .82rem; cursor: pointer; }
.lang-switch option { color: #1e293b; }
.login-lang, .install-lang { text-align: right; margin-bottom: .4rem; }
.login-lang .lang-switch, .install-lang .lang-switch { background: #fff; color: var(--ink); border: 1px solid var(--line); }

/* ---------- Ayuda ---------- */
.help-section { margin-bottom: 1.25rem; }
.help-section h2 { font-size: 1.05rem; margin: 0 0 .4rem; display: flex; align-items: center; gap: .5rem; }
.help-section h2 i { color: var(--indigo); }
.help-section p { margin: 0; color: #334155; }
.token-box { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.token-box code { font-size: .9rem; padding: .45rem .7rem; background: #f1f5f9; word-break: break-all; }

/* ---------- Selector de idioma (enlaces) ---------- */
.lang-switch { display: inline-flex; gap: 2px; align-items: center; background: none; border: 0; padding: 0; }
.lang-opt { color: #e0e7ff; font-size: .74rem; font-weight: 600; padding: .2rem .4rem; border-radius: 6px; text-decoration: none; line-height: 1; }
.lang-opt:hover { background: rgba(255,255,255,.18); text-decoration: none; color: #fff; }
.lang-opt.active { background: rgba(255,255,255,.28); color: #fff; }
.login-lang, .install-lang { display: flex; justify-content: flex-end; }
.login-lang .lang-opt, .install-lang .lang-opt { color: var(--muted); }
.login-lang .lang-opt:hover, .install-lang .lang-opt:hover { background: #eef2ff; color: var(--indigo-d); }
.login-lang .lang-opt.active, .install-lang .lang-opt.active { background: var(--indigo); color: #fff; }

.login-forgot { text-align: center; margin-top: 1rem; font-size: .9rem; }
.login-forgot a { color: var(--indigo); text-decoration: none; }
.login-forgot a:hover { text-decoration: underline; }
.alert-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 9px; padding: .7rem .9rem; margin-bottom: 1rem; font-size: .9rem; }

.planea-sidebar .nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; font-weight: 700; padding: 1rem 1rem .35rem; }
.planea-sidebar a.nav-sub { padding-left: 1.9rem; font-size: .92rem; }

.links-search { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 560px; }
.links-search input { flex: 1; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; flex-wrap: wrap; gap: .6rem; }
.pager-nav { display: flex; gap: .5rem; align-items: center; }


/* ---------- Cajas de complementos en el formulario de enlace ---------- */
.lk-core { max-width: 720px; }
.lk-addons-title { display:flex; align-items:center; gap:.5rem; font-weight:700; color:var(--ink,#0f172a); margin:1.6rem 0 .5rem; font-size:1rem; }
.lk-addons { display:grid; grid-template-columns:repeat(auto-fill,minmax(330px,1fr)); gap:1rem; }
.lk-addon { border:1px solid var(--line,#e2e8f0); border-radius:12px; padding:14px 16px; background:var(--bg2,#f8fafc); }
.lk-addon-head { display:flex; align-items:center; gap:.5rem; font-weight:700; font-size:.9rem; color:var(--ink,#0f172a); margin-bottom:.3rem; }
.lk-addon-head i { color:var(--indigo,#6366f1); }
.lk-addon label:first-of-type { margin-top:.4rem; }
.lk-addon .hint { margin-bottom:0; }
@media (max-width: 720px){ .lk-core { max-width:100%; } }

/* Campo con icono (p. ej. email) */
.field-icon { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 9px; padding: 0 .75rem; background: #fff; transition: border-color .15s, box-shadow .15s; }
.field-icon:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.field-icon > i { color: #94a3b8; font-size: 1.05rem; }
.field-icon input { border: 0 !important; outline: 0; flex: 1; padding: .6rem 0; background: transparent; font: inherit; min-width: 0; }
.field-hint { display: flex; align-items: center; gap: .35rem; margin: .35rem 0 .2rem; font-size: .8rem; color: #64748b; }
.field-hint i { font-size: .8rem; color: #94a3b8; }

.planea-topbar .brand-logo { height: 30px; width: auto; display: block; }

.lang-row{display:flex;align-items:center;gap:.45rem}
.lang-row .lang-flag{width:22px;height:16px;border-radius:3px;box-shadow:0 0 0 1px rgba(15,23,42,.14);object-fit:cover;flex:0 0 auto}

.nav-updot{display:inline-block;width:9px;height:9px;border-radius:50%;background:#f59e0b;margin-left:7px;vertical-align:middle;box-shadow:0 0 0 3px rgba(245,158,11,.25)}
