:root {
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --bg: #f4f5fb;
  --card: #fff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --side: #17153b;
  --side-text: #c7c9e8;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --gray-bg: #f3f4f6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 230px; flex-shrink: 0; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.on { background: var(--primary); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side-foot { padding: 12px 18px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot b { color: #fff; display: block; }
.side-foot button { margin-top: 8px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.topbar { display: none; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }

/* Cards & grid */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi.ok .v { color: var(--ok); } .kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); }
.two { grid-template-columns: 1fr 1fr; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: #fafafe; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f7fe; }
td.r, th.r { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-activa { background: var(--ok-bg); color: var(--ok); }
.b-en_gracia { background: var(--warn-bg); color: var(--warn); }
.b-vencida, .b-revocada { background: var(--bad-bg); color: var(--bad); }
.b-suspendida, .b-gray { background: var(--gray-bg); color: #4b5563; }
.b-plan { background: #eef2ff; color: var(--primary-d); }

/* Forms */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff;
  color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500;
}
.btn:hover { border-color: #c7c9e8; }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.pri:hover { background: var(--primary-d); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--side-text); padding: 0; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
input, select, textarea {
  font: inherit; color: var(--text); border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=search] { min-width: 240px; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
label.f small { color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
label.chk { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
label.chk input { width: auto; }

/* Plan picker */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.plan-opt { border: 2px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; text-align: center; background: #fff; font: inherit; color: inherit; }
.plan-opt b { display: block; text-transform: capitalize; }
.plan-opt .p { font-size: 18px; font-weight: 700; margin-top: 4px; }
.plan-opt .m { font-size: 12px; color: var(--muted); }
.plan-opt.on { border-color: var(--primary); background: #eef2ff; }

/* License key */
.key { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; letter-spacing: .04em; }
.key-big { font-size: 20px; padding: 12px 16px; background: #eef2ff; border-radius: 8px; display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
pre.code { background: #0f0e2a; color: #e0e7ff; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; margin: 0; }

/* Bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 34px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(135deg, #17153b, #4f46e5); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 4px; display: flex; gap: 10px; align-items: center; }
.login .btn { width: 100%; justify-content: center; margin-top: 6px; }
.err { color: var(--bad); min-height: 20px; margin: 4px 0; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 14, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 720px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e1b4b; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.toast.bad { background: var(--bad); }

@media (max-width: 860px) {
  .layout { display: block; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .main { padding: 16px; }
  .two, .row, .row3 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .filters input, .filters select, .filters input[type=search] { min-width: 0; width: 100%; }
  .plans { grid-template-columns: 1fr; }
}
