/* Portal RJSISTEMAS — negro y rojo */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f6f8;
  --line: #e7e7ec;
  --text: #1c1c22;
  --muted: #74747f;
  --red: #d81f30;
  --red-hover: #b5121f;
  --red-soft: #fff1f2;
  --ok: #15803d;
  --warn: #b45309;
  --field: #ffffff;
  --hover: #efeff3;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; color-scheme: light; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
body { min-height: 100vh; }
a { color: var(--red); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #d4d4db; background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.full { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--field); outline: none;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.input.code { font: 600 24px/1 var(--mono); letter-spacing: .4em; text-align: center; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---------- Pantallas de acceso ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  box-shadow: 0 20px 50px -24px rgba(17,17,20,.25);
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; border-top: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-auth { flex-direction: column; text-align: center; gap: 8px; }
.logo-auth { width: auto !important; height: 120px !important; }
.logo-bar { width: auto !important; height: 30px !important; }
.brand-word { font-weight: 800; font-size: 13px; letter-spacing: .32em; color: #111114; margin-left: -2px; }
.brand b { display: block; font-size: 20px; letter-spacing: .04em; }
.brand small { color: var(--muted); }
.auth-card h2 { margin: 0 0 6px; font-size: 18px; }
.auth-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.qr { display: block; width: 200px; height: 200px; margin: 0 auto 12px; border-radius: 10px; background: #fff; padding: 6px; border: 1px solid var(--line); }
.secret { text-align: center; font: 600 14px var(--mono); background: var(--field); border: 1px dashed var(--line); border-radius: 8px; padding: 8px; margin-bottom: 16px; word-break: break-all; }

/* ---------- Estructura principal ---------- */
.topbar {
  box-shadow: inset 0 3px 0 #111114;
  position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.topbar .brand { margin: 0; }
.topbar .brand img { width: 34px; height: 34px; }
.topbar .brand b { font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--red); background: var(--red-soft); box-shadow: inset 0 -2px 0 var(--red); }
.user-menu { position: relative; margin-left: auto; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--red); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 12px 32px rgba(17,17,20,.14);
}
.dropdown .info { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.dropdown button:hover { background: var(--panel-2); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; }

/* ---------- Herramientas ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.active { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card:hover { border-color: #d4d4db; box-shadow: 0 12px 30px -18px rgba(17,17,20,.3); }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.file-icon {
  flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; font: 700 11px var(--mono); text-transform: uppercase;
}
.card h3 { margin: 0; font-size: 16px; line-height: 1.3; word-break: break-word; }
.card .meta { font-size: 12.5px; color: var(--muted); }
.card .desc { font-size: 14px; color: #3b3b44; margin: 0; white-space: pre-wrap; word-break: break-word; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.card .actions .btn.primary { flex: 1 1 120px; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.empty { text-align: center; padding: 50px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Tablas (usuarios y bitácora) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .row { flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #ecfdf3; color: var(--ok); }
.badge.off { background: #f1f1f4; color: var(--muted); }
.badge.warn { background: #fffbeb; color: var(--warn); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* ---------- Ventanas (modales) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(17,17,20,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal .footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.progress { height: 10px; border-radius: 99px; background: var(--field); border: 1px solid var(--line); overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; width: 0; background: var(--red); transition: width .2s; }
.drop {
  border: 2px dashed var(--line); border-radius: 12px; padding: 22px 14px; text-align: center; cursor: pointer;
  color: var(--muted); margin-bottom: 14px;
}
.drop.over, .drop:hover { border-color: var(--red); color: var(--text); background: var(--red-soft); }
.drop b { color: var(--text); word-break: break-all; }
.creds { background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 14px; margin-bottom: 14px; white-space: pre-wrap; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px);
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--red); box-shadow: 0 10px 30px rgba(17,17,20,.15);
  padding: 12px 16px; border-radius: 10px; z-index: 100; transition: transform .25s; max-width: calc(100% - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .topbar .brand b { font-size: 15px; }
  .user-btn .uname { display: none; }
  .user-btn { padding: 4px; }
  .grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
}
