:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e4e7ef;
  --border-strong: #d3d8e4;
  --text: #1c2233;
  --text-2: #5b6478;
  --text-3: #8b93a7;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef0ff;
  --accent-text: #3f37c9;
  --green: #12a150;
  --green-soft: #e6f6ed;
  --red: #dc2f45;
  --red-soft: #fdecee;
  --amber: #c27803;
  --amber-soft: #fdf4e3;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --teal: #0d9488;
  --teal-soft: #e2f5f3;
  --purple: #8b3fd9;
  --purple-soft: #f3eafd;
  --gray-soft: #eef0f4;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
  --shadow: 0 1px 3px rgba(20, 24, 40, .06), 0 6px 20px rgba(20, 24, 40, .06);
  --shadow-lg: 0 20px 60px rgba(20, 24, 40, .25);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b24;
    --surface-2: #1c212c;
    --border: #262c39;
    --border-strong: #333a4a;
    --text: #e7eaf2;
    --text-2: #a3abbe;
    --text-3: #6f788c;
    --accent: #7c74ff;
    --accent-2: #8f88ff;
    --accent-soft: #24234a;
    --accent-text: #b4afff;
    --green: #3ccf7f;
    --green-soft: #15301f;
    --red: #ff6b7d;
    --red-soft: #3a1820;
    --amber: #f2b53a;
    --amber-soft: #352914;
    --blue: #6aa1ff;
    --blue-soft: #172440;
    --teal: #3ad1c2;
    --teal-soft: #112f2d;
    --purple: #c08cff;
    --purple-soft: #2a1d3d;
    --gray-soft: #232937;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 15px !important; height: 15px !important; }
i[data-icon] { display: inline-flex; font-style: normal; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.brand--center { justify-content: center; margin-bottom: 8px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #7c3aed);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .35);
  position: relative;
}
.brand-logo::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/20px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z'/%3E%3Cpath d='M12 10v6'/%3E%3Cpath d='m9 13 3-3 3 3'/%3E%3C/svg%3E");
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; flex: none; }
.dot--ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot--err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 16px;
}

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a, .nav-link-muted {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; text-decoration: none; border: 0; background: none;
  cursor: pointer; width: 100%; text-align: left;
}
.nav a:hover, .nav-link-muted:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-footer { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--border); padding-top: 12px; }
.nav-link-muted { font-size: 13px; padding: 7px 12px; }

.main { padding: 28px 32px 48px; min-width: 0; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--text-3); }
.card-body { padding: 18px; }
.card + .card { margin-top: 18px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }

.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-icon svg { width: 21px; height: 21px; }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.stat-sub { color: var(--text-3); font-size: 12px; }
.tone-indigo { background: var(--accent-soft); color: var(--accent-text); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-teal { background: var(--teal-soft); color: var(--teal); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-purple { background: var(--purple-soft); color: var(--purple); }
.tone-gray { background: var(--gray-soft); color: var(--text-2); }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius);
  background: var(--amber-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  margin-bottom: 18px;
}
.notice .icon { color: var(--amber); margin-top: 2px; }
.notice--info { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.notice--info .icon { color: var(--blue); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn--primary:hover { background: var(--accent-2); }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { filter: brightness(1.07); background: var(--red); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn--block { width: 100%; height: 40px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn--danger:hover { color: var(--red); background: var(--red-soft); border-color: transparent; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }
.form-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { margin: 0; color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: 8px; font-size: 13px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 21px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--text-2); font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin-top: 10px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; padding: 4px 0; }
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.check code { color: var(--text-3); font-size: 11.5px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.muted { color: var(--text-3); }
.empty { padding: 42px 16px; text-align: center; color: var(--text-3); }
.empty .icon { width: 34px; height: 34px; margin-bottom: 8px; opacity: .6; }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.path-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.path-chip .icon { width: 13px; height: 13px; color: var(--amber); }
a.path-chip:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- Conexión ---------- */
.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; align-items: center; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kv dd code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-block { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 44px 10px 12px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; white-space: pre; }
.code-block .icon-btn { position: absolute; top: 5px; right: 5px; }
.code-label { font-size: 12px; color: var(--text-3); margin: 12px 0 5px; font-weight: 600; }

/* ---------- Explorador ---------- */
.explorer { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
.explorer > * { min-width: 0; }
.tree { padding: 8px; max-height: calc(100vh - 170px); overflow: auto; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree > ul { padding-left: 0; }
.tree-node { display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 7px; cursor: pointer; color: var(--text); min-width: 0; }
.tree-node:hover { background: var(--surface-2); }
.tree-node.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.tree-node .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tree-node .icon { width: 16px; height: 16px; }
.tree-node .folder-ico { color: var(--amber); }
.tree-toggle { width: 18px; height: 18px; display: grid; place-items: center; border: 0; background: none; padding: 0; color: var(--text-3); cursor: pointer; border-radius: 4px; flex: none; }
.tree-toggle .icon { width: 14px; height: 14px; transition: transform .12s; }
.tree-toggle.open .icon { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }
.user-count { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 650; color: var(--accent-text); background: var(--accent-soft); border-radius: 99px; padding: 1px 7px 1px 5px; flex: none; }
.user-count .icon { width: 11px !important; height: 11px !important; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--text-2); padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.crumbs a:last-child { color: var(--text); }
.crumbs .sep { color: var(--text-3); }
.crumbs .sep .icon { width: 14px; height: 14px; }
.file-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-name .icon { color: var(--text-3); }
.file-name .folder-ico { color: var(--amber); fill: color-mix(in srgb, var(--amber) 18%, transparent); }
.file-name a, .file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; }
.dropzone { position: relative; }
.dropzone.dragging::after {
  content: "Suelta los archivos para subirlos aquí"; position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent); border: 2px dashed var(--accent); border-radius: var(--radius);
  color: var(--accent-text); font-weight: 650; font-size: 15px; z-index: 2;
}
.access-list { display: grid; gap: 8px; }
.access-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.access-item .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; text-transform: uppercase; }

.folder-picker { border: 1px solid var(--border); border-radius: 9px; max-height: 170px; overflow: auto; padding: 4px; background: var(--surface-2); margin-top: 6px; }
.folder-picker button { display: flex; align-items: center; gap: 7px; width: 100%; border: 0; background: none; padding: 5px 8px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13px; }
.folder-picker button:hover { background: var(--surface); }
.folder-picker button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.folder-picker .icon { width: 15px; height: 15px; color: var(--amber); }

/* ---------- Actividad ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.filters select, .filters input[type=text] { width: auto; height: 34px; }
.filters input[type=text] { min-width: 200px; flex: 1; max-width: 320px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
tr.fresh td { animation: fresh 2.2s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.detail-cell { color: var(--text-2); font-size: 13px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-compact td { padding: 8px 14px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 28, .48); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px 16px; z-index: 50; animation: fade .15s ease-out; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease-out; margin: auto; }
.modal--sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-head h2 { font-size: 17px; letter-spacing: -.01em; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; max-width: calc(100vw - 36px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .18s ease-out; max-width: 420px; }
.toast .icon { width: 17px; height: 17px; }
.toast--error { background: var(--red); color: #fff; }
.toast--ok .icon { color: var(--green); }

.section-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0 0 10px; }
.stack { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.hstack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.help { color: var(--text-3); font-size: 12.5px; margin: 6px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .explorer { grid-template-columns: minmax(0, 1fr); }
  .tree { max-height: 260px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar .brand div { display: none; }
  .sidebar .brand { padding: 0; }
  .brand-logo { width: 32px; height: 32px; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 8px 10px; }
  .nav a span, .sidebar-footer span { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; display: flex; border: 0; padding: 0; }
  .main { padding: 20px 16px 40px; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-icon { display: none; }
  .stat-value { font-size: 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .page-head h1 { font-size: 20px; }
  .card-head { flex-wrap: wrap; }
  .form-row, .perm-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }

  /* Tablas como tarjetas apiladas */
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  table.rtable tr:last-child { border-bottom: 0; }
  table.rtable td { border: 0; padding: 3px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; max-width: none; white-space: normal; }
  table.rtable td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: 12px; font-weight: 600; flex: none; }
  table.rtable td.td-main { padding-bottom: 6px; }
  table.rtable td.td-actions { justify-content: flex-end; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
  table.rtable td.td-empty, table.rtable td.hide-sm { display: none; }
  .filters select, .filters input[type=text] { flex: 1 1 140px; max-width: none; min-width: 0; }
  table.rtable tbody tr:hover td { background: transparent; }
  table.rtable .detail-cell { text-align: right; overflow-wrap: anywhere; }
  table.rtable code { overflow-wrap: anywhere; text-align: right; }
}
