:root {
  --bg: #0c0f17;
  --bg-deep: #10141f;
  --card: #1a2233;
  --card-hover: #212c42;
  --text: #eef1f7;
  --muted: #8d96ab;
  --blue: #2c6ed5;
  --blue-dark: #1f52a3;
  --orange: #ef7d00;
  --orange-dark: #c96700;
  --danger: #e5556b;
  --ok: #3ecf8e;
  --border: #262f45;
}

:root[data-theme="claro"] {
  --bg: #eef1f8;
  --bg-deep: #f1f4fa;
  --card: #ffffff;
  --card-hover: #f7f9fd;
  --text: #1e2536;
  --muted: #636c84;
  --blue: #2c6ed5;
  --blue-dark: #1f52a3;
  --orange: #ef7d00;
  --orange-dark: #c96700;
  --danger: #d63a52;
  --ok: #1f9d64;
  --border: #e1e6f0;
}
:root[data-theme="claro"] body {
  background: linear-gradient(180deg, #eef1f8 0%, #eaeef8 100%);
}
:root[data-theme="claro"] .topbar {
  box-shadow: 0 1px 2px rgba(30, 40, 80, 0.05);
}
:root[data-theme="claro"] .card,
:root[data-theme="claro"] .panel-resumen,
:root[data-theme="claro"] .inline-form,
:root[data-theme="claro"] .permisos-editor,
:root[data-theme="claro"] .bitacora-item,
:root[data-theme="claro"] .photo-card {
  box-shadow: 0 1px 3px rgba(30, 40, 80, 0.06), 0 1px 2px rgba(30, 40, 80, 0.04);
}
:root[data-theme="claro"] .card:hover {
  box-shadow: 0 4px 14px rgba(239, 125, 0, 0.12);
}
:root[data-theme="claro"] input[type="text"],
:root[data-theme="claro"] input[type="password"],
:root[data-theme="claro"] input[type="file"],
:root[data-theme="claro"] textarea,
:root[data-theme="claro"] select {
  background: #f6f8fc;
}
:root[data-theme="claro"] .tile-blue {
  background: linear-gradient(135deg, #e4edfb, #d9e6fa);
  border: 1px solid #c9daf5;
}
:root[data-theme="claro"] .tile-orange {
  background: linear-gradient(135deg, #fdecd8, #fbe2c2);
  border: 1px solid #f6d3a6;
}
:root[data-theme="claro"] .panel-titulo { color: var(--orange-dark); }
:root[data-theme="claro"] .whoami { color: var(--orange-dark); }
:root[data-theme="claro"] .flash.error { background: #fbe7ea; border-color: #f3c3cb; }
:root[data-theme="claro"] .flash.ok { background: #e3f7ee; border-color: #b9e8d1; }
:root[data-theme="claro"] .badge-ad { background: #e4edfb; }
:root[data-theme="claro"] .badge-local { background: #eef0f5; }
:root[data-theme="claro"] .pw-reveal { background: #f6f8fc; }
:root[data-theme="claro"] .bitacora-item { background: #fdf6ee; }
:root[data-theme="claro"] .login-box {
  background: #ffffff; border-radius: 20px; padding: 40px 32px;
  box-shadow: 0 8px 30px rgba(30, 40, 80, 0.08); margin-top: 40px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1, .brand, .card-label, .panel-titulo, .item-name, .login-box .subtitle + form label {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--orange);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 38px; width: auto; display: block; }
.topsearch input {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  width: 280px;
  max-width: 40vw;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
}
.topsearch input:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 0.85rem; font-weight: 500; }
.topnav a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.topnav a:hover { color: var(--orange); }
.theme-toggle-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle-btn:hover { border-color: var(--orange); }
.whoami { color: var(--orange); font-weight: 700; }
.logout { color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--danger); }

.container { max-width: 760px; margin: 0 auto; padding: 24px 18px 60px; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 10px 0 18px; letter-spacing: -0.01em; }
.header-icon { font-size: 1.3em; vertical-align: -0.15em; margin-right: 2px; }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.9rem; font-weight: 500; }
.flash.error { background: rgba(229, 85, 107, 0.15); color: var(--danger); border: 1px solid rgba(229,85,107,0.3); }
.flash.ok { background: rgba(62, 207, 142, 0.15); color: var(--ok); border: 1px solid rgba(62,207,142,0.3); }

/* Panel resumen */
.panel-resumen { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 28px; }
.panel-titulo { font-weight: 700; letter-spacing: 1.5px; color: var(--orange); font-size: 0.78rem; margin-bottom: 12px; text-transform: uppercase; }
.panel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.panel-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--bg-deep); border-radius: 10px; font-size: 0.87rem; }
.panel-item b { color: var(--blue); font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; }

/* Login */
.login-box { max-width: 360px; margin: 70px auto; text-align: center; }
.login-logo { max-width: 280px; width: 100%; height: auto; margin-bottom: 18px; }
.login-box .subtitle { color: var(--muted); margin-bottom: 28px; font-size: 0.9rem; }
.login-box form { display: flex; flex-direction: column; gap: 10px; text-align: left; }

label { font-size: 0.8rem; color: var(--muted); margin-top: 12px; display: block; font-weight: 500; }
input[type="text"], input[type="password"], input[type="file"], textarea, select {
  width: 100%;
  padding: 11px 13px;
  margin-top: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
textarea { resize: vertical; font-family: inherit; }
button { cursor: pointer; border: none; border-radius: 10px; font-size: 0.95rem; font-family: 'Space Grotesk', sans-serif; font-weight: 600; }

.login-box button, .item-form .btn-save {
  background: var(--orange); color: white; padding: 13px; margin-top: 18px; letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
}
.login-box button:hover, .item-form .btn-save:hover { background: var(--orange-dark); }
.login-box button:active, .item-form .btn-save:active { transform: scale(0.98); }

/* Grid de módulos */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.card:hover { background: var(--card-hover); transform: translateY(-2px); border-color: var(--orange); }
.card-locked { opacity: 0.5; }
.card-locked:hover { opacity: 0.75; border-color: var(--danger); transform: none; }
.card-locked .card-count { color: var(--danger); }
.lock-icon { font-size: 0.8em; }
.card-icon-tile {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
  border-radius: 13px;
  margin-bottom: 12px;
}
.tile-blue { background: rgba(44, 110, 213, 0.18); }
.tile-orange { background: rgba(239, 125, 0, 0.18); }
.card-label { font-weight: 600; font-size: 1.02rem; letter-spacing: -0.005em; }
.card-count { color: var(--muted); font-size: 0.82rem; margin-top: 5px; }
@media (max-width: 460px) {
  .grid { grid-template-columns: 1fr; }
  .topsearch input { width: 140px; }
  .topbar { padding: 10px 14px; }
}

.cat-header { margin-bottom: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.cat-header h1 { flex: 1; margin: 10px 0; }
.btn-print-link {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  text-decoration: none; padding: 9px 14px; border-radius: 10px; font-size: 0.85rem;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600;
}
.btn-print-link:hover { border-color: var(--orange); color: var(--orange); }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text); text-decoration: none; font-size: 0.92rem; font-weight: 600;
  padding: 10px 12px 10px 8px; margin: -10px 0 4px -8px;
  border-radius: 10px; background: var(--card); border: 1px solid var(--border);
}
.back:hover { color: var(--orange); border-color: var(--orange); }
.back:active { background: var(--card-hover); }
.back::before { content: "←"; font-size: 1.1em; }

.search-bar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search-bar input { flex: 1; min-width: 120px; margin-top: 0; }
.orden-select { width: auto; margin-top: 0; padding: 0 12px; font-size: 0.85rem; flex: none; }
.search-bar button { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 0 16px; }
.search-bar button:hover { border-color: var(--orange); }
.btn-new {
  background: var(--orange); color: white; text-decoration: none; padding: 11px 16px;
  border-radius: 10px; font-size: 0.9rem; font-weight: 600; font-family: 'Space Grotesk', sans-serif;
  display: flex; align-items: center; transition: background 0.15s;
}
.btn-new:hover { background: var(--orange-dark); }

.export-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; font-size: 0.83rem; color: var(--muted); }
.export-bar a { color: var(--blue); text-decoration: none; font-weight: 600; }
.export-bar a:hover { color: var(--orange); }

.item-list { list-style: none; padding: 0; margin: 0; }
.item-list li { border-bottom: 1px solid var(--border); }
.item-list a { display: flex; justify-content: space-between; align-items: center; padding: 15px 6px; color: var(--text); text-decoration: none; transition: background 0.1s; }
.item-list a:hover { background: rgba(44, 110, 213, 0.08); }
.item-name { font-weight: 600; font-size: 0.98rem; }
.item-name-block { display: flex; flex-direction: column; gap: 2px; }
.item-subtitle { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.item-date { color: var(--muted); font-size: 0.78rem; }
.empty { color: var(--muted); text-align: center; margin-top: 50px; font-size: 0.95rem; }

.meta-info { color: var(--muted); font-size: 0.78rem; margin-bottom: 12px; }

.pw-wrap { display: flex; gap: 6px; align-items: center; }
.pw-wrap input { flex: 1; }
.pw-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 11px 13px; border-radius: 10px; margin-top: 5px; }
.pw-toggle:hover { border-color: var(--orange); }

.form-actions { display: flex; gap: 10px; margin-top: 26px; }
.btn-delete { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 13px 18px; }
.btn-delete:hover { background: rgba(229, 85, 107, 0.1); }
.btn-delete-inline { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 7px 12px; font-size: 0.78rem; font-family: 'Inter', sans-serif; font-weight: 500; }
.btn-delete-inline:hover { background: rgba(229, 85, 107, 0.1); }

.doc-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 6px; gap: 12px; flex-wrap: wrap; }
.doc-desc { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.doc-actions { display: flex; gap: 12px; align-items: center; }
.doc-actions a { color: var(--blue); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.doc-actions a:hover { color: var(--orange); }
.doc-rename { position: relative; }
.doc-rename summary {
  cursor: pointer; color: var(--blue); font-size: 0.85rem; font-weight: 600; user-select: none; list-style: none;
}
.doc-rename summary::-webkit-details-marker { display: none; }
.doc-rename summary:hover { color: var(--orange); }
.doc-rename-form {
  position: absolute; right: 0; top: 26px; z-index: 20; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; width: 280px; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); display: flex; flex-direction: column; gap: 8px;
}
.doc-rename-form input { margin-top: 0; width: 100%; }

/* En pantallas angostas (celular), el popup se centra y usa el ancho disponible */
@media (max-width: 640px) {
  .doc-rename[open] { position: static; }
  .doc-rename-form {
    position: fixed; left: 50%; right: auto; top: 50%;
    transform: translate(-50%, -50%); width: 90vw; max-width: 360px; z-index: 100;
  }
  .doc-rename-form::before {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: -1; left: -50vw; top: -50vh; width: 200vw; height: 200vh;
  }
}

.audit-row { display: flex; justify-content: space-between; padding: 13px 6px; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; }

.mod-table {
  margin-top: 10px; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 14px; transition: opacity 0.15s;
}
.mod-table.disabled-block { opacity: 0.35; pointer-events: none; }
.mod-table-head, .mod-table-row {
  display: grid; grid-template-columns: 1.6fr 0.8fr 0.8fr 0.9fr; align-items: center; gap: 6px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.mod-table-row:last-child { border-bottom: none; }
.mod-table-head { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.mod-table-head span:not(:first-child), .mod-table-row label { text-align: center; }
.mod-table-row span:first-child { font-size: 0.86rem; }
.mod-table-row input[type="radio"] { width: auto; margin: 0; }

/* Avatares */
.whoami-link { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.whoami-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; border: 2px solid var(--border); }
.whoami-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--orange); color: white; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.05rem;
}
.user-row-info { display: flex; align-items: center; gap: 12px; }
.user-row-info .whoami-avatar { width: 46px; height: 46px; font-size: 1.15rem; }

/* Perfil */
.profile-header { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.profile-header .profile-avatar { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; border: 3px solid var(--orange); }
.profile-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--orange); color: white; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 2.6rem;
}
.profile-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.15rem; }
.profile-role { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* Reset de contraseña por admin */
.reset-pw-row { padding: 4px 0 14px; margin-top: -6px; }
.inline-reset-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-reset-form input {
  flex: 1; min-width: 160px; margin-top: 0; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-deep); color: var(--text); font-size: 0.85rem;
}
.btn-reset-pw {
  background: transparent; border: 1px solid var(--blue); color: var(--blue);
  padding: 9px 14px; font-size: 0.82rem; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
}
.btn-reset-pw:hover { background: rgba(44, 110, 213, 0.1); }

.badge-ad, .badge-local {
  display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; margin-left: 8px; vertical-align: middle; font-family: 'Space Grotesk', sans-serif;
}
.badge-ad { background: rgba(44, 110, 213, 0.18); color: var(--blue); }
.badge-local { background: rgba(141, 150, 171, 0.18); color: var(--muted); }
.badge-2fa-on {
  display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; margin-left: 6px; vertical-align: middle;
  background: rgba(62, 207, 142, 0.16); color: var(--ok);
}
.badge-2fa-pending {
  display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; margin-left: 6px; vertical-align: middle;
  background: rgba(239, 125, 0, 0.16); color: var(--orange);
}
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; margin: 16px 0; max-width: 420px;
}
.qr-image { width: 220px; height: 220px; background: white; padding: 10px; border-radius: 10px; }
.qr-manual { text-align: center; font-size: 0.82rem; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.qr-secret {
  font-family: monospace; font-size: 1rem; letter-spacing: 0.1em; color: var(--text);
  background: var(--bg-deep); padding: 8px 14px; border-radius: 8px; word-break: break-all;
}
.btn-switch-ad { border-color: var(--blue); color: var(--blue); }
.btn-switch-ad:hover { background: rgba(44, 110, 213, 0.1); }
.btn-delete-permanent {
  background: transparent; border: 1px solid var(--danger); color: var(--danger);
  padding: 6px 10px; font-size: 0.78rem; font-family: 'Inter', sans-serif; font-weight: 500;
}
.btn-delete-permanent:hover { background: rgba(229, 85, 107, 0.15); }

.empresa-select-wrap { display: flex; gap: 8px; align-items: center; }
.empresa-select-wrap select { flex: 1; margin-top: 4px; }
.empresa-add-link {
  flex: none; margin-top: 4px; background: var(--card); border: 1px solid var(--border); color: var(--text);
  text-decoration: none; padding: 11px 12px; border-radius: 10px; font-size: 0.8rem;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; white-space: nowrap;
}
.empresa-add-link:hover { border-color: var(--orange); color: var(--orange); }

/* Widget de patrón (celulares) */
.patron-widget { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8px; }
.patron-svg {
  width: 220px; height: 220px; background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 16px; touch-action: none; cursor: pointer;
}
.patron-line { stroke: var(--orange); stroke-width: 4; stroke-linecap: round; }
.patron-dot { fill: var(--border); stroke: var(--muted); stroke-width: 1.5; transition: r 0.1s; }
.patron-dot-selected { fill: var(--orange); stroke: var(--orange-dark); }
.patron-dot-start { stroke: var(--text); stroke-width: 2.5; }
.patron-step-label {
  fill: white; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px;
  text-anchor: middle; dominant-baseline: central; pointer-events: none; user-select: none;
}
.patron-clear-btn { flex: none; min-width: 0; padding: 8px 16px; font-size: 0.82rem; }

/* Pestañas de la ficha de celular */
.tabbar { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn {
  background: transparent; border: none; color: var(--muted); padding: 10px 14px;
  font-family: 'Space Grotesk', sans-serif; font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.tab-hint { color: var(--muted); font-size: 0.85rem; margin: 10px 0 20px; }
.inline-form { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 18px; }

.sub-list { list-style: none; padding: 0; margin: 0; }
.sub-item { display: flex; justify-content: space-between; align-items: center; padding: 13px 6px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.sub-item-actions { display: flex; align-items: center; gap: 12px; }
.pw-reveal { font-family: monospace; color: var(--muted); cursor: pointer; font-size: 0.85rem; user-select: none; padding: 4px 8px; background: var(--bg-deep); border-radius: 6px; }
.pw-reveal:hover { color: var(--text); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.photo-card img { width: 100%; height: 110px; object-fit: cover; display: block; }
.photo-meta { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; color: var(--muted); gap: 6px; }

.photo-upload-buttons { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn-photo {
  flex: 1; min-width: 140px; padding: 14px 12px; border-radius: 10px; font-size: 0.9rem;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-photo-camera { background: var(--orange); color: white; border-color: var(--orange); }
.btn-photo-camera:hover { background: var(--orange-dark); }
.btn-photo-gallery { background: transparent; color: var(--text); }
.btn-photo-gallery:hover { border-color: var(--blue); color: var(--blue); }

.bitacora { list-style: none; padding: 0; margin: 0; }
.bitacora-item { background: var(--card); border-left: 3px solid var(--orange); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.bitacora-texto { font-size: 0.92rem; line-height: 1.4; }
.bitacora-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 0.75rem; color: var(--muted); }

.check-label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text); font-weight: 500; margin-top: 10px; cursor: pointer; }
.check-label input[type="checkbox"] { width: auto; margin: 0; }
.mod-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin: 8px 0 4px; transition: opacity 0.15s;
}
.mod-grid .check-label { margin-top: 6px; margin-bottom: 6px; font-weight: 400; font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.76rem; margin-top: 8px; }
.permisos-editor {
  background: var(--bg-deep); border-radius: 10px; padding: 16px 16px 18px; margin: 4px 0 16px;
  border-left: 3px solid var(--blue);
}
.btn-save-small {
  display: block;
  width: 100%;
  background: var(--blue); color: white; padding: 12px 14px; margin-top: 18px;
  font-size: 0.9rem; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  letter-spacing: 0.01em;
}
.btn-save-small:hover { background: var(--blue-dark); }
.permisos-editor .mod-grid { background: var(--bg); }
@media (max-width: 460px) { .mod-grid { grid-template-columns: 1fr; } }

/* ===== Mi Agenda ===== */
.agenda-tabbar { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.agenda-tab-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  padding: 9px 16px; border-radius: 10px; font-size: 0.88rem; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
}
.agenda-tab-btn.active { background: var(--orange); color: white; border-color: var(--orange); }
.agenda-pane { display: none; }
.agenda-pane.active { display: block; }

.agenda-form {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px;
}
.agenda-form input[type="text"], .agenda-form textarea, .agenda-form input[type="date"], .agenda-form select { margin-top: 0; }
.agenda-form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.agenda-form-row input, .agenda-form-row select { flex: 1; min-width: 140px; }
.agenda-form button { align-self: flex-start; }
.agenda-compartir summary, .agenda-compartir-inline summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; user-select: none; }
.agenda-compartir-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }

.agenda-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.agenda-item {
  display: flex; align-items: flex-start; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  border-left: 4px solid var(--border);
}
.agenda-item.prioridad-alta { border-left-color: var(--danger); }
.agenda-item.prioridad-baja { border-left-color: var(--muted); }
.agenda-item.prioridad-normal { border-left-color: var(--blue); }
.agenda-item.completada { opacity: 0.55; }
.agenda-item.completada .agenda-title { text-decoration: line-through; }
.agenda-check-form { margin: 0; }
.agenda-check { background: none; border: none; font-size: 1.4rem; padding: 0; color: var(--orange); cursor: pointer; line-height: 1; }
.agenda-body { flex: 1; min-width: 0; }
.agenda-title { font-weight: 600; font-size: 0.98rem; }
.agenda-detail { color: var(--muted); font-size: 0.87rem; margin-top: 3px; white-space: pre-wrap; }
.agenda-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 0.78rem; }
.agenda-fecha { color: var(--muted); }
.agenda-prio-alta { color: var(--danger); font-weight: 700; }
.agenda-shared { color: var(--blue); }
.agenda-done-tag { color: var(--ok); font-weight: 600; }
.agenda-actions, .nota-actions { display: flex; gap: 6px; align-items: flex-start; }
.agenda-del { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.6; }
.agenda-del:hover { opacity: 1; }
.agenda-compartir-inline { position: relative; }
.agenda-compartir-inline summary { list-style: none; font-size: 1rem; }
.agenda-compartir-inline summary::-webkit-details-marker { display: none; }
.agenda-compartir-pop {
  position: absolute; right: 0; top: 24px; z-index: 20; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; width: 220px; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); display: flex; flex-direction: column; gap: 4px;
}
.agenda-edit-pop { width: 260px; gap: 8px; }
.agenda-edit-pop input, .agenda-edit-pop textarea, .agenda-edit-pop select { margin-top: 0; width: 100%; }

@media (max-width: 640px) {
  .agenda-compartir-pop {
    position: fixed; left: 50%; right: auto; top: 50%;
    transform: translate(-50%, -50%); width: 90vw; max-width: 360px; z-index: 100;
  }
  .agenda-compartir-pop::before {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: -1; left: -50vw; top: -50vh; width: 200vw; height: 200vh;
  }
}
.agenda-icon-link { text-decoration: none; font-size: 1rem; opacity: 0.7; line-height: 1; }
.agenda-icon-link:hover { opacity: 1; }
.btn-cancel {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 11px 20px; border-radius: 10px; text-decoration: none; font-size: 0.9rem;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; display: inline-block;
}
.btn-cancel:hover { border-color: var(--muted); color: var(--text); }

.notas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.nota-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  border-top: 3px solid var(--orange); display: flex; flex-direction: column;
}
.nota-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.nota-body { color: var(--muted); font-size: 0.87rem; white-space: pre-wrap; flex: 1; }
.nota-actions { justify-content: flex-end; margin-top: 8px; }

/* Notas: tarjeta compacta con vista previa recortada */
.nota-link { text-decoration: none; color: inherit; display: block; flex: 1; }
.nota-link:hover .nota-title { color: var(--orange); }
.nota-preview {
  color: var(--muted); font-size: 0.83rem; margin-top: 6px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap;
}
.agenda-title-link { text-decoration: none; color: inherit; }
.agenda-title-link:hover .agenda-title { color: var(--orange); }
.agenda-detail-corto {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

/* Lectura de nota a pantalla completa */
.nota-lectura {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 28px; white-space: pre-wrap; line-height: 1.7; font-size: 0.95rem;
  color: var(--text); margin-top: 12px;
}

/* Campo de texto con botón para abrir enlaces */
.url-field-wrap { display: flex; gap: 8px; align-items: center; }
.url-field-wrap input { flex: 1; }
.btn-open-url {
  flex: none; margin-top: 4px; background: var(--card); border: 1px solid var(--border);
  color: var(--blue); padding: 11px 14px; border-radius: 10px; font-size: 0.8rem;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.btn-open-url:hover { border-color: var(--orange); color: var(--orange); }
.btn-open-url[hidden] { display: none; }

/* Botón para copiar contraseña sin revelarla */
.pw-copy {
  flex: none; margin-top: 4px; background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 11px 13px; border-radius: 10px; font-size: 0.95rem;
  cursor: pointer; line-height: 1;
}
.pw-copy:hover { border-color: var(--orange); }
.pw-copy-ok { border-color: var(--ok); color: var(--ok); }

/* Vista previa de campos clave en los listados */
.item-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.preview-chip {
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 20px;
  padding: 3px 10px; font-size: 0.74rem; color: var(--text); font-weight: 400;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview-chip b { color: var(--muted); font-weight: 600; }
.item-name-block { min-width: 0; flex: 1; }
.item-name { word-break: break-word; }

/* Imágenes adjuntas a un registro */
.img-upload-bar { margin: 12px 0 16px; }
.img-upload-form { display: flex; gap: 10px; flex-wrap: wrap; }
.img-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}
.img-btn:hover { border-color: var(--orange); color: var(--orange); }
.img-btn-camara { border-color: var(--blue); }

.img-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 12px;
}
.img-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column;
}
.img-card img {
  width: 100%; height: 150px; object-fit: cover; display: block; background: var(--bg-deep);
}
.img-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; font-size: 0.74rem; color: var(--muted); gap: 8px;
}
.img-del { background: none; border: none; cursor: pointer; font-size: 0.95rem; opacity: 0.6; }
.img-del:hover { opacity: 1; }
