/* X9 PrintLab — panel de licencias. Mismo tema oscuro que la aplicación de escritorio (ui/style.py). */
:root {
  --bg: #0f1216;
  --panel: #161a20;
  --card: #12161c;
  --input: #0d1015;
  --border: #232b34;
  --border-strong: #2b333d;
  --text: #dfe6ee;
  --text-strong: #ffffff;
  --muted: #8b98a7;
  --section: #7f8c9c;
  --primary: #2f6bff;
  --primary-hover: #3b76ff;
  --primary-pressed: #2557d6;
  --primary-border: #5b8cff;
  --focus: #3f78ff;
  --selected: #223145;
  --btn: #222932;
  --btn-hover: #2b333e;
  --btn-border: #333d49;
  --danger: #7a2230;
  --danger-hover: #8f2a3a;
  --danger-border: #a3384a;
  --danger-text: #ffe3e6;
  --ok: #6fdc9a;
  --warn: #f4c25b;
  --bad: #ff8a9a;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: #8fb1ff; text-decoration: none; }
a:hover { color: #b5cbff; text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; }
p { margin: 0 0 10px; }
code, .mono { font-family: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.offscreen { position: fixed; top: 0; left: -10000px; width: 1px; height: 1px; opacity: 0; }

/* ------------------------------------------------------------------ estructura */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--panel);
  border-right: 1px solid #232a33;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-strong);
}
.brand:hover { text-decoration: none; color: var(--text-strong); }
.brand img { width: 40px; height: auto; }
.brand-name { display: flex; flex-direction: column; font-weight: 800; font-size: 15px; letter-spacing: .2px; }
.brand-name small { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; flex: 1; }
.nav-section {
  font-size: 10.5px; font-weight: 800; color: var(--section); letter-spacing: 1px;
  text-transform: uppercase; padding: 12px 10px 4px;
}
.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: #b8c4d1;
  font-weight: 600;
  border: 1px solid transparent;
}
.nav a:hover { background: #1d2530; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--selected); color: var(--text-strong); border-color: var(--primary); }
.sidebar-foot { padding: 14px 16px 18px; border-top: 1px solid var(--border); }
.sidebar-foot .who { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 8px; }
.env-tag {
  display: inline-block; margin-bottom: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .5px; text-transform: uppercase; background: #2a2412; color: var(--warn);
  border: 1px solid #5c4a1a;
}
.content { flex: 1; min-width: 0; padding: 26px 32px 48px; }
.content-inner { max-width: 1240px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head .sub { color: var(--muted); margin-top: 4px; }
.footer-note { margin-top: 32px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ tarjetas */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title {
  font-size: 11px; font-weight: 800; color: var(--section); letter-spacing: 1px; text-transform: uppercase;
  margin: 0 0 10px;
}
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.stat .label { font-size: 11px; font-weight: 800; color: var(--section); letter-spacing: 1px; text-transform: uppercase; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--text-strong); margin-top: 2px; }
.stat .hint { font-size: 12px; color: var(--muted); }
a.stat { display: block; color: inherit; transition: border-color .15s ease; }
a.stat:hover { border-color: var(--primary); text-decoration: none; color: inherit; }
.stat .value.small { font-size: 16px; padding-top: 8px; padding-bottom: 3px; }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 11px; font-weight: 800; color: var(--section); letter-spacing: .8px; text-transform: uppercase; }
.facts dd { margin: 2px 0 0; color: var(--text); word-break: break-word; }

/* ------------------------------------------------------------------ tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--card); }
table.data th {
  text-align: left; background: var(--panel); color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; padding: 9px 12px; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: #151a21; }
table.data tr.row-off td { color: var(--muted); }
table.data tr.row-alert td { background: rgba(163, 56, 74, .08); }
table.data .primary-cell { color: var(--text-strong); font-weight: 600; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ insignias */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-active { background: rgba(46, 160, 90, .14); color: var(--ok); border-color: rgba(46, 160, 90, .45); }
.badge-suspended { background: rgba(230, 160, 40, .13); color: var(--warn); border-color: rgba(230, 160, 40, .45); }
.badge-revoked { background: rgba(220, 70, 90, .14); color: var(--bad); border-color: rgba(220, 70, 90, .45); }
.badge-expired { background: rgba(139, 152, 167, .14); color: #b3bfcc; border-color: rgba(139, 152, 167, .4); }
.badge-deactivated { background: rgba(139, 152, 167, .1); color: var(--muted); border-color: rgba(139, 152, 167, .3); }
.chip {
  display: inline-block; padding: 0 7px; margin: 0 4px 2px 0; border-radius: 6px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border-strong); color: #b8c4d1; background: #1a2028;
}
.chip-warn { color: var(--warn); border-color: rgba(230, 160, 40, .45); }
.chip-bad { color: var(--bad); border-color: rgba(220, 70, 90, .5); background: rgba(122, 34, 48, .25); }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--btn); color: var(--text); border: 1px solid var(--btn-border); border-radius: 8px;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); color: var(--text); text-decoration: none; }
.btn:active { background: #1c2530; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary-border); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-primary:active { background: var(--primary-pressed); }
.btn-danger { background: var(--danger); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-hover); color: var(--danger-text); }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------------------ formularios */
form { margin: 0; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label, .label {
  font-size: 12px; font-weight: 700; color: #aebccb;
}
.field .help { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea {
  width: 100%; background: var(--input); color: #e6edf5; border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 8px 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px rgba(63, 120, 255, .18); }
textarea { min-height: 92px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.inline-fields { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { margin-bottom: 0; flex: 1 1 140px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .grow { flex: 1 1 260px; }

/* ------------------------------------------------------------------ avisos */
.alert {
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid; font-weight: 600;
}
.alert-ok { background: rgba(46, 160, 90, .1); border-color: rgba(46, 160, 90, .45); color: #a6eec3; }
.alert-danger { background: rgba(122, 34, 48, .35); border-color: var(--danger-border); color: var(--danger-text); }
.alert-warn { background: rgba(230, 160, 40, .1); border-color: rgba(230, 160, 40, .45); color: #f8d690; }
.alert-info { background: rgba(47, 107, 255, .1); border-color: rgba(91, 140, 255, .45); color: #c5d6ff; }

/* ------------------------------------------------------------------ clave y mensaje */
.keybox {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: #0b0e12; border: 1px dashed var(--primary-border); border-radius: var(--radius); padding: 18px 20px;
  margin: 10px 0 14px;
}
.keybox .key {
  font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 24px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--text-strong); word-break: break-all; user-select: all;
}
pre.message {
  white-space: pre-wrap; word-break: break-word; background: #0b0e12; border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 14px 16px; margin: 8px 0 12px; font-family: Consolas, "Cascadia Mono", Menlo, monospace;
  font-size: 13px; color: #d6dee8; max-height: 420px; overflow: auto;
}

/* ------------------------------------------------------------------ cronología */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 132px 14px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .when { color: var(--muted); font-size: 12px; white-space: nowrap; padding-top: 1px; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: #4b5664; }
.timeline .tone-ok .dot { background: #2ea05a; }
.timeline .tone-warn .dot { background: #e6a028; }
.timeline .tone-danger .dot { background: #dc465a; }
.timeline .tone-audit .dot { background: var(--primary); }
.timeline .what { min-width: 0; }
.timeline .title { font-weight: 600; color: var(--text); }
.timeline .meta { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ paginación */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ acceso */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 30px 30px 24px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-brand img { width: 96px; height: auto; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { color: var(--muted); margin: 0; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ peligro */
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.card .card { background: #0f1318; margin: 14px 0 0; padding: 14px 16px; }
.danger-zone { border-color: rgba(163, 56, 74, .55); }
.danger-zone .section-title { color: #e08a98; }
details.more { margin-top: 4px; }
details.more summary { cursor: pointer; color: #8fb1ff; font-weight: 600; margin-bottom: 10px; }

/* ------------------------------------------------------------------ adaptable */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 8px 10px; }
  .nav-section { display: none; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .timeline .dot { display: none; }
}

/* Alta inicial (Cloudflare): código QR del TOTP */
.qr { display: block; margin: 8px 0; padding: 8px; background: #fff; border-radius: 8px; width: 200px; height: 200px; }

/* Ventas (tienda) */
.tabs { margin-bottom: 12px; }
.break { word-break: break-all; }
