:root {
  --background: #f4f6f9;
  --surface: #fff;
  --text: #1b2540;
  --muted: #5f6c88;
  --border: #d9e3f1;
  --blue: #113d8d;
  --blue-dark: #0b2c66;
  --blue-soft: #eef4ff;
  --red: #d62c33;
  --red-dark: #b71f26;
  --red-soft: #fff3f4;
  --green: #23653b;
  --green-soft: #e9f6ed;
  --shadow: 0 14px 36px rgba(22, 35, 64, .08);
}

/* Rediseño independiente de la vista interna: referencia visual, lógica intacta. */
body:has(.archive-detail-panel) .archive-page-heading .btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 22%, transparent);
}
body:has(.archive-detail-panel) .archive-page-heading .btn-primary:hover { background: var(--blue-dark); }
body:has(.archive-detail-panel) .archive-detail-panel {
  position: relative;
  padding: 1.5rem 0 2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
body:has(.archive-detail-panel) .archive-detail-actions {
  position: absolute;
  top: 1.5rem;
  right: 0;
  z-index: 2;
}
body:has(.archive-detail-panel) .archive-detail-actions .btn {
  min-height: 3.1rem;
  padding: .75rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--blue);
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(11,44,102,.06);
}
body:has(.archive-detail-panel) .archive-detail-title {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  min-height: 150px;
  margin: 0 0 1.35rem;
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(11,44,102,.06);
}
body:has(.archive-detail-panel) .archive-detail-icon {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--archive-color, var(--blue)) 12%, white);
  color: var(--archive-color, var(--blue));
}
body:has(.archive-detail-panel) .archive-detail-icon svg { width: 54px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
body:has(.archive-detail-panel) .archive-detail-copy h2 { margin: .12rem 0 0; color: var(--blue-dark); font-size: clamp(1.6rem, 2.2vw, 2.1rem); }
body:has(.archive-detail-panel) .archive-detail-copy p { margin: .25rem 0 .9rem; color: var(--muted); font-size: .98rem; }
body:has(.archive-detail-panel) .archive-detail-metrics { display: flex; flex-wrap: wrap; gap: 0; color: var(--muted); font-size: .9rem; }
body:has(.archive-detail-panel) .archive-detail-metrics span { display: inline-flex; align-items: baseline; gap: .35rem; padding-right: 1.15rem; }
body:has(.archive-detail-panel) .archive-detail-metrics span + span { padding-left: 1.15rem; border-left: 1px solid var(--border); }
body:has(.archive-detail-panel) .archive-detail-metrics b { color: var(--blue-dark); font-size: 1rem; }
body:has(.archive-detail-panel) .archive-count { align-self: start; padding-top: .2rem; color: var(--muted); font-weight: 750; }
body:has(.archive-detail-panel) .partition-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; padding: 0; }
body:has(.archive-detail-panel) .partition-card {
  display: block;
  min-height: 0;
  padding: 1.15rem 1.35rem 1.1rem 1.55rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(11,44,102,.055);
}
body:has(.archive-detail-panel) .partition-card-head { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: .8rem; }
body:has(.archive-detail-panel) .partition-icon { width: 52px; height: 52px; flex-basis: 52px; border-radius: 15px; background: color-mix(in srgb, var(--partition-color, var(--blue)) 12%, white); color: var(--partition-color, var(--blue)); }
body:has(.archive-detail-panel) .partition-icon svg { width: 32px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
body:has(.archive-detail-panel) .partition-card-head strong { color: var(--text); font-size: 1.12rem; }
body:has(.archive-detail-panel) .partition-card-head small { margin-top: .22rem; color: var(--muted); font-size: .88rem; }
body:has(.archive-detail-panel) .partition-stats { display: flex; align-items: center; justify-content: flex-end; gap: 1.35rem; margin: 0; color: var(--muted); font-size: .9rem; }
body:has(.archive-detail-panel) .partition-stats span { display: inline-flex; align-items: baseline; gap: .32rem; white-space: nowrap; }
body:has(.archive-detail-panel) .partition-stats b { color: var(--text); font-size: 1rem; }
body:has(.archive-detail-panel) .partition-collections-title { margin: 1.15rem 0 .55rem; color: var(--text); font-size: .88rem; }
body:has(.archive-detail-panel) .partition-collections { display: grid; gap: .55rem; }
body:has(.archive-detail-panel) .partition-collections a { min-height: 3.2rem; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
body:has(.archive-detail-panel) .partition-collections a::before { content: ""; width: 26px; height: 22px; border-radius: 5px; background: color-mix(in srgb, var(--partition-color, var(--blue)) 18%, white); }
body:has(.archive-detail-panel) .partition-collections a { grid-template-columns: 26px minmax(0,1fr) auto 18px; }
body:has(.archive-detail-panel) .partition-collections a span { grid-column: 2; }
body:has(.archive-detail-panel) .partition-collections a small { grid-column: 3; }
body:has(.archive-detail-panel) .partition-collections a svg { grid-column: 4; }
body:has(.archive-detail-panel) .partition-card-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: .9rem 0 0; }
body:has(.archive-detail-panel) .partition-card-actions .btn { border-color: color-mix(in srgb, var(--partition-color, var(--blue)) 55%, white); color: var(--partition-color, var(--blue)); }
body:has(.archive-detail-panel) .partition-card > .muted-copy { margin: 1rem 0 0; padding: 1.35rem; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }
@media (max-width: 800px) {
  body:has(.archive-detail-panel) .archive-detail-panel { padding: .75rem 0 1.25rem; }
  body:has(.archive-detail-panel) .archive-detail-actions { position: static; margin: 0 0 .75rem; }
  body:has(.archive-detail-panel) .archive-detail-title { grid-template-columns: 60px minmax(0, 1fr); padding: 1rem; }
  body:has(.archive-detail-panel) .archive-detail-icon { width: 60px; height: 60px; border-radius: 14px; }
  body:has(.archive-detail-panel) .archive-detail-icon svg { width: 38px; }
  body:has(.archive-detail-panel) .archive-count { display: none; }
  body:has(.archive-detail-panel) .partition-card-head { grid-template-columns: 46px minmax(0, 1fr); }
  body:has(.archive-detail-panel) .partition-icon { width: 46px; height: 46px; flex-basis: 46px; }
  body:has(.archive-detail-panel) .partition-stats { grid-column: 1 / -1; justify-content: flex-start; margin-top: .75rem; }
}

/* Vista interna de archivo: composición tipo panel de gestión, sin cambiar la lógica. */
.archive-detail-panel {
  position: relative;
  padding: 1.35rem;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.archive-detail-actions {
  position: absolute;
  top: 1.35rem;
  right: 1.35rem;
  z-index: 2;
}
.archive-detail-title {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  min-height: 150px;
  margin-bottom: 1.15rem;
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(11,44,102,.07);
}
.archive-detail-icon {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--archive-color, var(--blue)) 12%, white);
  color: var(--archive-color, var(--blue));
}
.archive-detail-icon svg { width: 52px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.archive-detail-copy h2 { margin: .15rem 0 0; color: var(--blue-dark); font-size: clamp(1.5rem, 2vw, 2rem); }
.archive-detail-copy p { margin: .25rem 0 .85rem; color: var(--muted); }
.archive-detail-metrics { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: .88rem; }
.archive-detail-metrics span { display: inline-flex; align-items: center; gap: .35rem; }
.archive-detail-metrics span + span { padding-left: 1rem; border-left: 1px solid var(--border); }
.archive-detail-metrics b { color: var(--blue-dark); font-size: 1rem; }
.archive-count { align-self: start; padding-top: .25rem; }
.partition-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; padding-top: 0; }
.partition-card {
  padding: 1.15rem 1.35rem 1.1rem 1.55rem;
  border-radius: 17px;
  box-shadow: 0 8px 22px rgba(11,44,102,.055);
}
.partition-card-head { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: .8rem; }
.partition-card-head strong { font-size: 1.1rem; }
.partition-card-head small { font-size: .86rem; }
.partition-icon { width: 52px; height: 52px; flex-basis: 52px; border-radius: 15px; }
.partition-icon svg { width: 31px; }
.partition-stats { align-items: center; justify-content: flex-end; gap: 1.25rem; margin: 0; font-size: .9rem; }
.partition-stats span { display: inline-flex; align-items: baseline; gap: .32rem; white-space: nowrap; }
.partition-stats b { font-size: 1rem; }
.partition-collections-title { margin: 1.1rem 0 .55rem; color: var(--text); font-size: .88rem; }
.partition-collections { gap: .55rem; }
.partition-collections a { min-height: 3.1rem; padding: .75rem .9rem; border-radius: 11px; background: var(--surface); }
.partition-card-actions { margin: .85rem 0 0; }
.partition-card-actions .btn { border-color: color-mix(in srgb, var(--partition-color, var(--blue)) 55%, white); color: var(--partition-color, var(--blue)); }
.partition-card > .muted-copy { margin: 1rem 0 0; padding: 1.1rem; border: 1px dashed var(--border); border-radius: 12px; text-align: center; }
html[data-theme="dark"] .archive-detail-title { background: var(--surface); }
html[data-theme="dark"] .archive-detail-copy h2,
html[data-theme="dark"] .archive-detail-metrics b { color: var(--text); }
@media (max-width: 800px) {
  .archive-detail-panel { padding: .75rem 0; }
  .archive-detail-title { grid-template-columns: 60px minmax(0, 1fr); padding: 1rem; }
  .archive-detail-icon { width: 60px; height: 60px; border-radius: 14px; }
  .archive-detail-icon svg { width: 36px; }
  .archive-count { display: none; }
  .partition-card-head { grid-template-columns: 46px minmax(0, 1fr); }
  .partition-icon { width: 46px; height: 46px; flex-basis: 46px; }
  .partition-stats { grid-column: 1 / -1; justify-content: flex-start; margin-top: .75rem; }
}

/* Barra superior de escritorio: controles globales fuera del contenido de cada página. */
.desktop-topbar {
  position: sticky;
  z-index: 70;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(14px);
}
.desktop-topbar-spacer { flex: 1 1 auto; min-width: 0; }
.brand-home-link { display: block; color: inherit; text-decoration: none; }
.brand-home-link:focus-visible { border-radius: 10px; outline: 3px solid color-mix(in srgb, var(--blue) 35%, transparent); outline-offset: 4px; }
.desktop-topbar-actions { display: flex; align-items: center; gap: 10px; }
.desktop-topbar .notification-center { position: relative; top: auto; right: auto; display: block; }
.desktop-topbar .notification-button,
.desktop-topbar .theme-toggle { width: 48px; height: 48px; box-shadow: none; }
.global-search-menu { position: relative; flex: 0 1 560px; min-width: 260px; }
.global-search-menu summary { display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--border)); border-radius: 16px; background: color-mix(in srgb, var(--surface) 90%, var(--blue-soft)); color: var(--blue); cursor: pointer; list-style: none; box-shadow: 0 8px 22px rgba(22, 35, 64, .06); transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
.global-search-menu summary::-webkit-details-marker { display: none; }
.global-search-menu summary svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.global-search-menu summary:hover, .global-search-menu summary:focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: none; box-shadow: 0 10px 24px rgba(17, 61, 141, .14); transform: translateY(-1px); }
.global-search-menu form { position: relative; z-index: 1000; width: 100%; padding: 0; }
.global-search-field { display: grid; grid-template-columns: 24px minmax(0, 1fr) 34px 42px; align-items: center; gap: 10px; min-height: 54px; padding: 0 7px 0 17px; border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--border)); border-radius: 999px; background: var(--surface-raised); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.global-search-field > svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.global-search-field input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .9rem; }
.global-search-field input::placeholder { color: var(--muted); opacity: .9; }
.global-search-field button { min-height: 38px; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--red); color: #fff; font-size: .75rem; font-weight: 800; transition: background 160ms ease, transform 160ms ease; }
.global-search-field button:hover { background: var(--red-dark); transform: translateY(-1px); }
.global-search-clear { display: grid; width: 30px; height: 30px; min-height: 30px !important; padding: 0 !important; place-items: center; background: transparent !important; color: var(--muted) !important; }
.global-search-clear:hover { background: var(--blue-soft) !important; color: var(--text) !important; transform: none !important; }
.global-search-clear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.global-search-submit-icon { display: grid; width: 38px; height: 38px; place-items: center; border-left: 1px solid var(--border); color: var(--muted); }
.global-search-submit-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.global-search-filter-toggle:hover, .global-search-filter-toggle[aria-expanded="true"] { color: var(--blue) !important; transform: none !important; }
.global-search-filter-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.global-search-filters { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; align-items: end; gap: 9px; margin-top: 9px; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--surface) 80%, var(--blue-soft)); }
.global-search-filters label { margin: 0 !important; font-size: .7rem !important; }
.global-search-filters select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: .74rem; }
.global-search-apply { min-height: 36px; padding: 7px 13px; border: 0; border-radius: 9px; background: var(--red); color: #fff; font-size: .72rem; font-weight: 800; }
.global-search-menu form small { display: block; margin-top: 7px; color: var(--muted); font-size: .64rem; }
.global-search-suggestions { position: absolute; top: calc(100% + 10px); right: 0; left: 0; display: grid; gap: 3px; max-height: min(440px, 60vh); margin: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 22px 55px rgba(12, 35, 78, .18); padding: 9px 3px 2px; scrollbar-width: thin; }
.global-search-suggestion { display: grid; grid-template-columns: 38px minmax(0, 1fr) 18px; align-items: center; gap: 11px; min-height: 54px; padding: 8px 10px; border-radius: 13px; color: var(--text); text-decoration: none; transition: background 140ms ease, transform 140ms ease; }
.global-search-suggestion:hover, .global-search-suggestion:focus-visible { background: var(--blue-soft); outline: none; transform: translateX(2px); }
.global-search-suggestion-icon { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid color-mix(in srgb, var(--blue) 12%, var(--border)); border-radius: 11px; background: var(--blue-soft); color: var(--blue); }
.global-search-suggestion-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.global-search-suggestion-copy { display: grid; min-width: 0; gap: 2px; }
.global-search-suggestion-copy strong, .global-search-suggestion-copy small, .global-search-suggestion-copy em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-suggestion-copy strong { font-size: .8rem; }
.global-search-suggestion-copy small, .global-search-suggestion-copy em { color: var(--muted); font-size: .68rem; font-style: normal; }
.global-search-suggestion-arrow { color: var(--muted); font-size: 1.5rem; }
.global-search-suggestions-empty { margin: 8px; color: var(--muted); font-size: .75rem; }
.desktop-user-menu-topbar { position: relative; min-width: 58px; }
.desktop-user-menu-topbar summary {
  display: grid;
  grid-template-columns: 36px 18px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.desktop-user-menu-topbar summary::-webkit-details-marker { display: none; }
.desktop-user-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); }
.desktop-user-avatar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.desktop-user-chevron { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transition: transform 160ms ease; }
.desktop-user-menu-topbar[open] .desktop-user-chevron { transform: rotate(180deg); }
.desktop-user-menu-topbar form { position: absolute; z-index: 2; top: calc(100% + 8px); right: 0; width: 232px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.desktop-user-menu-info { display: grid; gap: 3px; padding: 8px 9px 10px; border-bottom: 1px solid var(--border); }
.desktop-user-menu-info > span { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; }
.desktop-user-menu-info strong, .desktop-user-menu-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-user-menu-info strong { font-size: .82rem; }
.desktop-user-menu-info small { color: var(--muted); font-size: .66rem; }
.desktop-user-menu-info small i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--green); }
.desktop-user-menu-options { display: grid; gap: 2px; padding: 7px 0; }
.desktop-user-menu-options a, .desktop-user-menu-options button { display: flex; width: 100%; align-items: center; gap: 9px; min-height: 36px; padding: 7px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: .74rem; text-align: left; text-decoration: none; }
.desktop-user-menu-options svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.desktop-user-menu-options a:hover, .desktop-user-menu-options a:focus-visible { background: var(--blue-soft); color: var(--blue); outline: none; }
.desktop-user-menu-topbar form .desktop-user-menu-options button { width: 100%; min-height: 36px; padding: 7px 9px; border: 0; border-radius: 8px; background: transparent !important; color: var(--text); font-size: .74rem; font-weight: 400; cursor: not-allowed; }
.desktop-user-menu-topbar form .desktop-user-menu-options button:disabled { opacity: .48; }
.desktop-user-menu-divider { height: 1px; margin: 0 0 7px; background: var(--border); }
.about-page-card { display: flex; max-width: 760px; align-items: center; gap: 28px; padding: 32px; }
.about-brand-mark { display: grid; width: 116px; height: 116px; flex: 0 0 116px; place-items: center; border: 1px solid var(--border); border-radius: 24px; background: var(--surface-raised); }
.about-brand-mark img { width: 92px; height: auto; }
.about-page-copy { display: grid; gap: 8px; }
.about-eyebrow { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.about-page-copy h2 { margin: 0; color: var(--text); font-size: 1.45rem; }
.about-page-copy p { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.55; }
.about-page-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; color: var(--muted); font-size: .78rem; }
.about-page-meta span { display: grid; gap: 2px; }
.about-page-meta strong { color: var(--text); font-size: .7rem; text-transform: uppercase; }
@media (max-width: 700px) { .about-page-card { align-items: flex-start; flex-direction: column; padding: 22px; } }
.desktop-user-menu-topbar form button { width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: .76rem; font-weight: 800; cursor: pointer; }
.desktop-user-menu-topbar form button:hover, .desktop-user-menu-topbar form button:focus-visible { background: var(--red); color: #fff; outline: none; }
@media (min-width: 901px) {
  .sidebar > .side-footer { display: none; }
}

/* Mobile profile menu: keep the account actions available beside theme and notifications. */
@media (max-width: 900px) {
  .desktop-topbar { display: none !important; }
  .mobile-header { gap: 10px; }
  .mobile-header-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .mobile-header-actions .theme-toggle,
  .mobile-header-actions .notification-button { width: 40px; height: 40px; border-radius: 11px; box-shadow: none; }
  .mobile-header-actions .notification-center { position: relative; top: auto; right: auto; display: block; }
  .mobile-header-actions .notification-panel { top: 49px; right: 0; }
  .desktop-topbar .desktop-user-menu-topbar {
    display: block;
    min-width: 48px;
  }

  .desktop-user-menu-topbar summary {
    width: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: center;
    border-radius: 13px;
  }

  .desktop-user-menu-topbar summary .desktop-user-chevron {
    display: none;
  }

  .desktop-user-menu-topbar form {
    position: fixed !important;
    z-index: 1000;
    top: 68px !important;
    right: 12px !important;
    bottom: auto !important;
    left: 12px !important;
    width: auto !important;
    max-width: 360px;
    margin-left: auto;
    box-sizing: border-box;
  }

  .desktop-user-menu-info { padding: 10px 12px 12px; }
  .desktop-user-menu-options { padding: 8px 0; gap: 3px; }
  .desktop-user-menu-options a,
  .desktop-user-menu-options button { min-height: 42px; padding: 9px 12px; font-size: .82rem; }

  html[data-theme="dark"] .desktop-user-menu-topbar form {
    background: #202020;
    border-color: #343434;
  }
}

/* Búsqueda contextual del encabezado: independiente del buscador de Inicio. */
.topbar-search-launcher { position: relative; }
.topbar-search-launcher > summary {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--blue);
  cursor: pointer;
  list-style: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.topbar-search-launcher > summary::-webkit-details-marker { display: none; }
.topbar-search-launcher > summary svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.topbar-search-launcher > summary:hover,
.topbar-search-launcher[open] > summary,
.topbar-search-launcher > summary:focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: none; transform: translateY(-1px); }
.topbar-search-panel {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  width: min(430px, calc(100vw - 32px));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(17, 39, 75, .18);
}
.topbar-search-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topbar-search-panel-heading div { display: grid; gap: 3px; }
.topbar-search-panel-heading strong { color: var(--text); font-size: .88rem; }
.topbar-search-panel-heading small { color: var(--muted); font-size: .7rem; }
.topbar-search-panel-heading > span { color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .05em; }
.topbar-search-query { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--background); }
.topbar-search-query svg { width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.topbar-search-query input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .78rem; }
.topbar-search-query input::placeholder { color: var(--muted); }
.topbar-search-results { display: grid; gap: 3px; max-height: 310px; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.topbar-search-result { display: grid; grid-template-columns: 32px minmax(0, 1fr) 16px; align-items: center; gap: 9px; min-height: 48px; padding: 6px 7px; border-radius: 10px; color: var(--text); text-decoration: none; }
.topbar-search-result:hover, .topbar-search-result:focus-visible { background: var(--blue-soft); outline: none; }
.topbar-search-result-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--blue); }
.topbar-search-result-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.topbar-search-result-copy { display: grid; min-width: 0; gap: 2px; }
.topbar-search-result-copy strong, .topbar-search-result-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-search-result-copy strong { font-size: .73rem; }
.topbar-search-result-copy small { color: var(--muted); font-size: .64rem; }
.topbar-search-result-arrow { color: var(--muted); font-size: 1.35rem; line-height: 1; }
.topbar-search-empty { margin: 4px 2px 0; color: var(--muted); font-size: .72rem; }
.topbar-search-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.topbar-search-fields label { display: grid; gap: 5px; min-width: 0; }
.topbar-search-fields span { color: var(--muted); font-size: .67rem; font-weight: 750; }
.topbar-search-fields select { min-width: 0; min-height: 38px; padding: 0 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--background); color: var(--text); font: inherit; font-size: .73rem; }
.topbar-search-panel > button { min-height: 40px; border: 0; border-radius: 10px; background: var(--red); color: #fff; font: inherit; font-size: .76rem; font-weight: 800; cursor: pointer; }
.topbar-search-panel > button:hover, .topbar-search-panel > button:focus-visible { background: var(--red-dark); outline: none; }
html[data-theme="dark"] .topbar-search-launcher > summary { background: #202020; border-color: #343434; color: #c4c4c4; }
html[data-theme="dark"] .topbar-search-launcher > summary:hover,
html[data-theme="dark"] .topbar-search-launcher[open] > summary { background: #292929; border-color: #555; }
html[data-theme="dark"] .topbar-search-panel { background: #202020; border-color: #343434; box-shadow: 0 20px 50px rgba(0,0,0,.42); }
html[data-theme="dark"] .topbar-search-result:hover, html[data-theme="dark"] .topbar-search-result:focus-visible { background: #292929; }

@media (max-width: 900px) {
  .topbar-search-launcher { display: none; }
}

/* Etiquetas documentales */
.document-tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.document-tag-chip { --tag-color: #1e5aa8; display: inline-flex; align-items: center; gap: 6px; min-height: 29px; padding: 4px 10px; border: 1px solid color-mix(in srgb, var(--tag-color) 32%, white); border-radius: 999px; background: color-mix(in srgb, var(--tag-color) 10%, white); color: color-mix(in srgb, var(--tag-color) 88%, #071b3d); font-size: .76rem; font-style: normal; font-weight: 750; line-height: 1.15; }
.document-tag-chip::before { width: 7px; height: 7px; border-radius: 50%; background: var(--tag-color); content: ""; }
.document-tag-chip button { display: grid; width: 18px; height: 18px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: currentColor; font-size: 1rem; line-height: 1; }
.document-tag-chip button:hover { background: color-mix(in srgb, var(--tag-color) 16%, white); }
.detail-tag-list { margin-top: 12px; }
.document-tag-field { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.document-tag-field .section-heading h2 { font-size: 1rem; }
.tag-combobox { position: relative; z-index: 4; }
.tag-combobox:focus-within { z-index: 8; }
.tag-combobox-control { display: grid; grid-template-columns: minmax(0, 1fr) 54px; min-height: 50px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(20, 38, 72, .03); }
.tag-combobox-control:focus-within { border-color: #8ba8d7; box-shadow: 0 0 0 3px rgba(17, 61, 141, .09); }
.tag-selection-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; padding: 9px 12px; }
.tag-selection-placeholder { color: var(--muted); font-size: .82rem; }
.tag-picker-toggle { display: grid; grid-template-columns: auto 18px; align-items: center; justify-content: center; gap: 4px; border: 0; border-left: 1px solid var(--border); border-radius: 0 14px 14px 0; background: #fbfcfe; color: var(--blue-dark); font-size: .72rem; font-weight: 800; }
.tag-picker-toggle svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; transition: transform .16s ease; }
.tag-picker-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.tag-picker-popover { position: absolute; top: calc(100% + 8px); right: 0; left: 0; z-index: 30; padding: 12px; border: 1px solid #d2ddec; border-radius: 15px; background: #fff; box-shadow: 0 20px 48px rgba(21, 38, 70, .16); }
.tag-picker-search { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; background: #f9fbfe; }
.tag-picker-search:focus-within { border-color: #8ba8d7; box-shadow: 0 0 0 3px rgba(17, 61, 141, .08); }
.tag-picker-search svg { width: 18px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; }
.tag-picker-search input { width: 100%; padding: 10px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .82rem; }
.tag-picker-meta { display: flex; justify-content: space-between; gap: 12px; padding: 10px 4px 6px; color: var(--muted); font-size: .68rem; }
.tag-picker-options { display: grid; gap: 3px; max-height: 260px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.tag-picker-option { display: grid; grid-template-columns: 20px 12px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px; border-radius: 10px; cursor: pointer; }
.tag-picker-option:hover { background: #f4f7fc; }
.tag-picker-option:has(input:checked) { background: color-mix(in srgb, var(--tag-color) 7%, white); }
.tag-picker-option input { width: 17px; height: 17px; accent-color: var(--tag-color); }
.tag-color-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--tag-color); }
.tag-picker-option strong, .tag-picker-option small { display: block; }
.tag-picker-option strong { color: var(--text); font-size: .82rem; }
.tag-picker-option small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.tag-picker-option em { color: var(--muted); font-size: .68rem; font-style: normal; font-weight: 750; }
.tag-picker-option.is-inactive { opacity: .65; cursor: default; }
.tag-picker-no-results { margin: 0; padding: 26px 12px; color: var(--muted); font-size: .78rem; text-align: center; }
.tag-selector-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px dashed var(--border); border-radius: 13px; color: var(--muted); font-size: .8rem; }
.tag-selector-empty a { color: var(--blue); font-weight: 750; }

.tag-page-heading { align-items: flex-end; }
.tag-create-button { display: inline-flex; align-items: center; gap: 8px; }
.tag-create-button svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.tag-catalog { padding: 0; overflow: visible; }
.tag-catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--border); }
.tag-catalog-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.05rem; }
.tag-catalog-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.tag-admin-search { display: grid; grid-template-columns: 20px minmax(180px, 280px); align-items: center; gap: 7px; min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: #f9fbfe; }
.tag-admin-search:focus-within { border-color: #8ba8d7; box-shadow: 0 0 0 3px rgba(17, 61, 141, .08); }
.tag-admin-search svg { width: 18px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; }
.tag-admin-search input { width: 100%; padding: 9px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .8rem; }
.tag-admin-table-head, .tag-admin-row { display: grid; grid-template-columns: minmax(170px, .85fr) minmax(260px, 1.5fr) 140px 100px 44px; align-items: center; gap: 18px; }
.tag-admin-table-head { min-height: 42px; padding: 0 24px; border-bottom: 1px solid #e6ebf3; background: #fafbfd; color: #74809a; font-size: .66rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.tag-admin-row { position: relative; min-height: 70px; padding: 12px 24px; border-bottom: 1px solid #e8edf4; background: #fff; }
.tag-admin-row:last-of-type { border-bottom: 0; border-radius: 0 0 18px 18px; }
.tag-admin-row:hover { background: #fbfcff; }
.tag-admin-row.is-inactive { background: #fafafa; }
.tag-admin-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tag-admin-name strong { overflow: hidden; color: var(--blue-dark); font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.tag-admin-swatch { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: var(--tag-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tag-color) 12%, white); }
.tag-admin-row > p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: .77rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.tag-document-count { color: var(--muted); font-size: .72rem; }
.tag-document-count strong { margin-right: 3px; color: var(--text); font-size: .84rem; }
.tag-status { display: inline-flex; align-items: center; gap: 5px; width: fit-content; padding: 4px 8px; border-radius: 999px; background: #eaf7ef; color: #1a7049; font-size: .64rem; font-weight: 800; }
.tag-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.is-inactive .tag-status { background: #eef0f4; color: #657087; }
.tag-row-menu { position: relative; justify-self: end; }
.tag-row-menu > summary { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid transparent; border-radius: 10px; color: #64718b; cursor: pointer; list-style: none; }
.tag-row-menu > summary::-webkit-details-marker { display: none; }
.tag-row-menu > summary:hover, .tag-row-menu[open] > summary { border-color: var(--border); background: #f5f8fc; color: var(--blue-dark); }
.tag-row-menu > summary svg { width: 20px; fill: currentColor; }
.tag-row-menu > div { position: absolute; top: 41px; right: 0; z-index: 12; min-width: 155px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 15px 34px rgba(20, 36, 66, .15); }
.tag-row-menu a, .tag-row-menu button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: .76rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.tag-row-menu a:hover, .tag-row-menu button:hover { background: #f4f7fb; }
.tag-row-menu button.is-danger { color: #b1262e; }
.tag-row-menu svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.tag-row-menu form { margin: 0; }
.tag-admin-no-results { padding: 48px 20px; color: var(--muted); font-size: .82rem; text-align: center; }
.tag-empty-state { padding: 64px 20px; text-align: center; color: var(--muted); }
.tag-empty-state > svg { width: 38px; fill: none; stroke: #7a8ba8; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.tag-empty-state h3 { margin: 12px 0 4px; color: var(--blue-dark); }
.tag-empty-state p { margin: 0; }

.tag-editor-shell { position: fixed; inset: 0; z-index: 120; }
.tag-editor-backdrop { position: absolute; inset: 0; background: rgba(15, 29, 55, .46); backdrop-filter: blur(2px); }
.tag-editor { position: absolute; top: 0; right: 0; display: flex; flex-direction: column; width: min(480px, 100%); height: 100%; padding: 28px; overflow-y: auto; background: #fff; box-shadow: -24px 0 58px rgba(14, 28, 54, .2); animation: tag-editor-in .18s ease-out; }
@keyframes tag-editor-in { from { transform: translateX(24px); opacity: .7; } to { transform: translateX(0); opacity: 1; } }
.tag-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.tag-editor-heading > div > span { color: var(--red); font-size: .68rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.tag-editor-heading h2 { margin: 5px 0 0; color: var(--blue-dark); font-size: 1.35rem; }
.tag-editor-heading p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.tag-editor-close { display: grid; flex: 0 0 auto; width: 40px; height: 40px; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--blue-dark); }
.tag-editor-close:hover { background: #f4f7fb; }
.tag-editor-close svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.tag-editor form { display: grid; gap: 18px; margin-top: 24px; }
.tag-color-field { display: flex; flex-wrap: wrap; gap: 11px; margin: 0; padding: 0; border: 0; }
.tag-color-field legend { width: 100%; margin-bottom: 2px; color: var(--text); font-size: .8rem; font-weight: 800; }
.tag-color-field label { cursor: pointer; }
.tag-color-field input { position: absolute; opacity: 0; pointer-events: none; }
.tag-color-field label span { display: block; width: 36px; height: 36px; border: 4px solid #fff; border-radius: 50%; background: var(--choice-color); box-shadow: 0 0 0 1px #d6deec; }
.tag-color-field input:checked + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--choice-color) 32%, white); }
.tag-live-preview { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid #e7ebf2; border-radius: 12px; background: #f7f9fd; }
.tag-live-preview small { color: var(--muted); font-size: .7rem; }
.tag-live-preview .document-tag-chip { align-self: flex-start; }
.tag-editor .form-actions { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.tag-editor-active { overflow: hidden; }
.mobile-document-tags { display: flex; gap: 5px; margin-top: 6px; overflow: hidden; }
.mobile-document-tags i { --tag-color: #1e5aa8; padding: 3px 6px; border-radius: 999px; background: color-mix(in srgb, var(--tag-color) 12%, white); color: var(--tag-color); font-size: .58rem; font-style: normal; font-weight: 750; white-space: nowrap; }

@media (min-width: 901px) {
  .desktop-home-search form { grid-template-columns: minmax(260px, 1fr) 170px 180px 120px; }
}

@media (max-width: 900px) {
  .tag-page-heading { align-items: flex-start; }
  .tag-create-button { width: 100%; justify-content: center; }
  .tag-catalog-heading { align-items: stretch; flex-direction: column; padding: 18px; }
  .tag-admin-search { grid-template-columns: 20px minmax(0, 1fr); }
  .tag-admin-table-head { display: none; }
  .tag-admin-table { display: grid; gap: 10px; padding: 12px; }
  .tag-admin-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; min-height: 0; padding: 15px; border: 1px solid var(--border); border-radius: 13px; }
  .tag-admin-row:last-of-type { border: 1px solid var(--border); border-radius: 13px; }
  .tag-admin-name { grid-column: 1; grid-row: 1; }
  .tag-admin-row > p { grid-column: 1 / -1; grid-row: 2; }
  .tag-document-count { grid-column: 1; grid-row: 3; min-width: 0; }
  .tag-status-cell { grid-column: 2; grid-row: 3; justify-self: end; }
  .tag-row-menu { grid-column: 2; grid-row: 1; }
  .tag-editor { padding: 22px 18px; }
  .tag-picker-popover { position: fixed; top: auto; right: 12px; bottom: 12px; left: 12px; max-height: min(540px, calc(100vh - 100px)); border-radius: 18px; }
  .tag-picker-options { max-height: min(350px, calc(100vh - 250px)); }
  .mobile-document-row:has(.mobile-document-tags) { grid-template-columns: 42px minmax(0, 1fr) 22px; }
  .mobile-document-tags { grid-column: 2; }
}

/* El atributo HTML hidden siempre debe prevalecer sobre estilos de botones y paneles. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; color: var(--text); background: var(--background); font-family: Inter, "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, .btn { cursor: pointer; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.auth-body { min-height: 100vh; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-transition[hidden] { display: none; }
.login-transition { position: fixed; z-index: 2000; inset: 0; display: grid; place-items: center; background: var(--background); }
.login-transition img { display: block; width: min(420px, 42vw); height: auto; max-height: 42vh; object-fit: contain; }
body.login-transition-active { overflow: hidden; }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid #e2e7ef; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.active-session-warning { display: grid; gap: 14px; margin-bottom: 18px; padding: 16px; border: 1px solid #f0c66a; border-radius: 14px; background: #fff8e8; color: var(--blue-dark); }
.active-session-warning h2 { margin: 0; font-size: 1.05rem; }
.active-session-warning dl { display: grid; gap: 8px; margin: 0; }
.active-session-warning dl div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; }
.active-session-warning dt { color: var(--muted); }
.active-session-warning dd { margin: 0; overflow-wrap: anywhere; font-weight: 750; }
.active-session-warning p { margin: 0; font-size: .85rem; }
.brand-centered { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid #e7ebf1; text-align: center; }
.brand-centered h1 { margin: 0; color: var(--blue-dark); font-size: 1.875rem; line-height: 1.15; letter-spacing: -.02em; }
.brand-centered p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.compact-brand .logo-login { width: 190px; }
.logo-login { width: 230px; max-width: 100%; height: auto; object-fit: contain; }

.form-stack { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--text); font-size: .8125rem; font-weight: 750; }
.input, .select { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 13px; outline: none; background: var(--surface); color: var(--text); }
.input:focus, .select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(17, 61, 141, .12); }
.input:disabled, .select:disabled { background: #f2f4f8; color: #6c7484; cursor: not-allowed; }
.field-error { min-height: 0; color: #ad2228; font-size: .78rem; }
.field-error:empty { display: none; }
.field-help { color: var(--muted); font-size: .76rem; line-height: 1.45; }
.validation-summary-valid { display: none; }

.btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 15px; border: 0; border-radius: 12px; font-size: .9rem; font-weight: 750; line-height: 1; text-decoration: none; transition: 160ms ease; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { border: 1px solid var(--border); background: #fff; color: var(--blue); }
.btn-secondary:hover, .btn-quiet:hover { background: #f6f9ff; }
.btn-quiet { border: 0; background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.secondary-form { margin-top: 10px; }
.password-form-actions { display: grid; grid-template-columns: 1fr 1.45fr; gap: 10px; margin-top: 4px; }
.password-form-actions .btn { width: 100%; }

.alert { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; font-size: .875rem; line-height: 1.45; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { border: 1px solid #f1c9cc; background: var(--red-soft); color: #9b2026; }
.alert-success { border: 1px solid #c6e3ce; background: var(--green-soft); color: var(--green); }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 20px 16px 16px; border-right: 1px solid var(--border); background: var(--surface); }
.mobile-sidebar-only, .sidebar-backdrop { display: none; }
.side-brand { display: flex; min-height: 96px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 5px 6px 18px; text-align: center; }
.side-brand img { width: 178px; max-width: 100%; height: auto; }
.brand-logo-dark { display: none; }
.side-brand strong { color: #7b879d; font-size: .66rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { display: flex; min-height: 43px; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: #56627a; font-size: .83rem; font-weight: 680; text-decoration: none; }
.side-nav a svg { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.75; }
.side-nav a:hover, .side-nav a:focus-visible { background: var(--blue-soft); color: var(--blue); }
.side-nav a.active:not(.nav-primary) { background: #eaf2ff; color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.side-nav .nav-primary { margin: 4px 0 7px; background: var(--red-soft); color: var(--red-dark); }
.side-nav .nav-primary:hover, .side-nav .nav-primary:focus-visible { background: #fbdcdf; color: var(--red-dark); }
.side-nav .nav-primary.active { background: var(--red); color: #fff; }
.side-footer { display: grid; gap: 9px; margin-top: auto; }
.desktop-user-menu { position: relative; }
.desktop-user-menu summary { display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; gap: 9px; min-height: 58px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; background: #f8faff; color: var(--blue-dark); cursor: pointer; list-style: none; }
.desktop-user-menu summary::-webkit-details-marker { display: none; }
.desktop-user-menu summary > span:first-child { display: grid; min-width: 0; gap: 3px; }
.desktop-user-menu summary strong, .desktop-user-menu summary small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-user-menu summary strong { font-size: .75rem; }
.desktop-user-menu summary small { color: var(--muted); font-size: .58rem; }
.desktop-user-menu summary small i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: #2f9d58; }
.desktop-user-menu summary > svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transition: transform 160ms ease; }
.desktop-user-menu[open] summary > svg { transform: rotate(180deg); }
.desktop-user-menu form { position: absolute; right: 0; bottom: calc(100% + 7px); left: 0; padding: 6px; border: 1px solid var(--border); border-radius: 11px; background: #fff; box-shadow: var(--shadow); }
.desktop-user-menu form button { width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: var(--red-soft); color: var(--red-dark); font-size: .72rem; font-weight: 750; }
.session-state { color: var(--green); font-size: .75rem; font-weight: 700; }
.session-state span { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #32a05b; }
.user-box { padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: #f8faff; font-size: .82rem; }
.user-box strong, .user-box small { display: block; }
.user-box small { margin-top: 4px; color: var(--muted); }
.app-content { min-width: 0; }
.main-content { padding: 24px; }
.mobile-header { display: none; }

/* Escritorio: el lateral permanece visible mientras se recorren listados largos. */
@media (min-width: 981px) {
  .app-shell { display: block; min-height: 100vh; }
  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: 250px;
    height: 100dvh;
    max-height: 100dvh;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .app-content { min-height: 100vh; margin-left: 250px; }
}

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; color: var(--blue-dark); font-size: 1.8rem; letter-spacing: -.02em; }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.page-heading-actions { align-items: center; }
.content-panel, .welcome-panel, .phase-note { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.welcome-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px; }
.welcome-copy { display: flex; align-items: center; gap: 15px; }
.welcome-copy h2 { margin: 0 0 5px; color: var(--blue-dark); font-size: 1.25rem; }
.welcome-copy p { margin: 0; color: var(--muted); }
.welcome-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 900; }
.phase-note { margin-top: 16px; padding: 20px 22px; }
.phase-note h2 { margin: 0 0 6px; color: var(--blue-dark); font-size: 1rem; }
.phase-note p { margin: 0; color: var(--muted); line-height: 1.55; }

.dashboard-heading { margin-bottom: 18px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 17px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-decoration: none; transition: 160ms ease; }
.metric:hover, .metric:focus-visible { border-color: #b9cbea; box-shadow: 0 8px 22px rgba(17, 61, 141, .08); transform: translateY(-1px); }
.metric span { color: var(--muted); font-size: .8rem; }
.metric strong { display: block; margin-top: 6px; color: var(--blue); font-size: 1.75rem; }
.search-panel { overflow: visible; margin-bottom: 18px; }
.search-panel-heading { padding: 18px 18px 0; }
.search-panel-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.08rem; }
.search-panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.search-form { display: grid; grid-template-columns: minmax(260px, 1fr) 190px auto auto; align-items: end; gap: 10px; padding: 16px 18px 18px; }
.search-form .field { align-self: start; }
.search-query-field { position: relative; }
.search-input-wrap { position: relative; }
.search-input-wrap svg { position: absolute; top: 50%; left: 13px; width: 19px; height: 19px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search-input-wrap .input { padding-left: 41px; }
.search-submit { gap: 7px; }
.search-form .btn { min-height: 46px; }
.search-submit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search-welcome { display: grid; min-height: 240px; place-items: center; align-content: center; padding: 36px 20px; border: 1px dashed #c7d3e5; border-radius: 16px; background: rgba(255, 255, 255, .55); text-align: center; }
.search-welcome.compact { min-height: 190px; }
.search-welcome-icon { display: grid; width: 54px; height: 54px; margin-bottom: 13px; place-items: center; border-radius: 16px; background: var(--blue-soft); color: var(--blue); }
.search-welcome-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-welcome h2 { margin: 0; color: var(--blue-dark); font-size: 1.05rem; }
.search-welcome p { max-width: 520px; margin: 7px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.recent-section { margin-top: 20px; }
.recent-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 2px 12px; }
.recent-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.08rem; }
.recent-heading p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.results-summary { display: flex; justify-content: space-between; gap: 12px; margin: 16px 2px 10px; color: var(--muted); font-size: .84rem; }
.document-results { display: grid; gap: 12px; }
.document-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 17px; border: 1px solid var(--border); border-radius: 17px; background: linear-gradient(180deg, #fff 0%, #fcfdff 100%); }
.document-result-main { min-width: 0; }
.document-result-topline { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; }
.document-type, .record-status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.document-type { background: var(--blue-soft); color: var(--blue); }
.record-status { background: #f1f3f7; color: #5d6678; }
.record-status.activo { background: var(--green-soft); color: var(--green); }
.record-status.borrador { background: #fff7dd; color: #805e00; }
.record-status.archivado { background: #f0f1f4; color: #50596b; }
.document-result h2 { margin: 0; overflow: hidden; color: var(--blue-dark); font-size: 1.04rem; text-overflow: ellipsis; white-space: nowrap; }
.document-result p { margin: 6px 0 9px; overflow: hidden; color: var(--muted); font-size: .82rem; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .75rem; }
.document-meta strong { color: #44506a; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: .82rem; }
.page-link { display: inline-flex; min-height: 40px; align-items: center; padding: 8px 13px; border: 1px solid var(--border); border-radius: 11px; background: #fff; color: var(--blue); font-weight: 750; text-decoration: none; }
.page-link:hover { background: var(--blue-soft); }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.detail-heading h1 { margin: 0; color: var(--blue-dark); font-size: 1.75rem; letter-spacing: -.02em; }
.detail-heading p { margin: 6px 0 0; color: var(--muted); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 18px; }
.detail-section { padding: 20px; }
.detail-section h2 { margin: 0 0 15px; color: var(--blue-dark); font-size: 1.05rem; }
.detail-data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.detail-data-grid > div { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcff; }
.detail-data-grid dt { color: var(--muted); font-size: .73rem; }
.detail-data-grid dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: .85rem; font-weight: 750; }
.description-list { display: grid; gap: 10px; }
.description-list article { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcff; }
.description-list span { color: var(--muted); font-size: .73rem; font-weight: 750; }
.description-list p { margin: 5px 0 0; font-size: .85rem; line-height: 1.5; }
.detail-subsection { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.detail-subsection > h2 { margin-bottom: 12px; }
.muted-copy { color: var(--muted); font-size: .85rem; }
.detail-footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; padding: 14px 18px; color: var(--muted); font-size: .76rem; }
.detail-actions { display: flex; gap: 9px; }
.version-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: #f1f3f7; color: #5d6678; font-size: .72rem; font-weight: 800; }
.audit-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin-top: 16px; background: var(--border); }
.audit-summary > div { display: grid; gap: 3px; padding: 15px 18px; background: #fff; }
.audit-summary span, .audit-summary small { color: var(--muted); font-size: .73rem; }
.audit-summary strong { color: var(--blue-dark); font-size: .85rem; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 16px; padding: 18px; border-color: #f1c9cc; }
.danger-zone h2 { margin: 0; color: #94262b; font-size: 1rem; }
.danger-zone p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.btn-danger { border: 1px solid #e7aeb2; background: #fff4f4; color: #a6262c; }
.btn-danger:hover { background: #ffe7e8; }

.document-form { padding: 22px; }
.form-section + .form-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.form-section[hidden] { display: none; }
.textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.descriptions-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.descriptions-head .section-heading p { margin-bottom: 0; }
.descriptions-head .btn { flex: 0 0 auto; white-space: nowrap; }
.description-fields { display: grid; gap: 12px; }
.description-item { padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fbfcff; }
.description-item[hidden] { display: none; }
.description-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.description-item-head label { color: var(--text); font-size: .8125rem; font-weight: 750; }
.remove-description { padding: 4px 7px; border: 0; border-radius: 8px; background: transparent; color: #bb2222; font-size: .78rem; font-weight: 700; }
.remove-description:hover { background: var(--red-soft); }
.trash-panel { overflow: hidden; }
.trash-list { display: grid; }
.trash-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 17px 18px; border-bottom: 1px solid var(--border); }
.trash-row:last-child { border-bottom: 0; }
.trash-row h2 { margin: 0; color: var(--blue-dark); font-size: 1rem; }
.trash-row p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; }

.users-panel { overflow: hidden; }
.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 210px auto auto; align-items: end; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fbfcff 0%, #f8faff 100%); }
.field-inline { gap: 5px; }
.user-list { display: grid; }
.user-row { display: grid; grid-template-columns: minmax(240px, 1fr) 110px 90px 180px auto; align-items: center; gap: 16px; padding: 15px 16px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fff 0%, #fcfdff 100%); }
.user-row:last-child { border-bottom: 0; }
.user-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { display: grid; flex: 0 0 40px; height: 40px; place-items: center; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-weight: 850; }
.user-main h2 { margin: 0; overflow: hidden; color: var(--blue-dark); font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.user-main p { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.status-badge.active { background: var(--green-soft); color: var(--green); }
.status-badge.inactive { background: #fff0f0; color: #a62626; }
.user-meta { display: grid; gap: 2px; font-size: .78rem; }
.user-meta strong { color: var(--text); }
.user-meta span { color: var(--muted); }
.backups-panel { padding: 22px; overflow: hidden; }
.backup-import-panel { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr); align-items: end; gap: 18px 28px; margin-bottom: 18px; padding: 22px; }
.backup-import-panel h2, .backup-import-panel p { margin: 0; }
.backup-import-panel > div p, .backup-import-note { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.backup-import-form { display: grid; grid-template-columns: minmax(260px, 1fr) auto; align-items: end; gap: 12px; }
.backup-import-form .field { min-width: 0; }
.backup-import-form .btn { white-space: nowrap; }
.backup-import-note { grid-column: 1 / -1; }
.backups-panel > .section-heading { text-align: center; }
.backup-list { display: grid; gap: 12px; }
.backup-row { display: grid; grid-template-columns: minmax(260px, 1fr) auto 90px auto; align-items: center; gap: 18px; padding: 17px; border: 1px solid var(--border); border-radius: 15px; background: linear-gradient(180deg, #fff 0%, #fcfdff 100%); }
.backup-main { min-width: 0; }
.backup-main h2 { margin: 0; overflow-wrap: anywhere; color: var(--blue-dark); font-size: .95rem; }
.backup-main p { margin: 5px 0 0; color: var(--muted); font-size: .8rem; }
.backup-main small { display: block; margin-top: 5px; color: var(--muted); font-size: .7rem; }
.backup-meta { display: grid; gap: 2px; font-size: .78rem; }
.backup-meta span { color: var(--muted); }
.backup-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.backup-actions form { margin: 0; }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }

.user-form { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.checkbox-field { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--blue); }
.checkbox-field label { font-size: .9rem; }
.checkbox-field .field-help { width: 100%; margin-left: 27px; }
.permissions-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.section-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.08rem; }
.section-heading p { margin: 5px 0 14px; color: var(--muted); font-size: .84rem; }
.permission-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.permission-group { overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: #fff; }
.permission-group-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 15px 16px 13px; border-bottom: 1px solid var(--border); background: #f7f9fd; }
.permission-group-heading h3 { margin: 0; color: var(--blue-dark); font-size: .93rem; }
.permission-group-heading p { margin: 4px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.35; }
.permission-group-heading > span { display: grid; min-width: 27px; height: 27px; place-items: center; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: .72rem; font-weight: 800; }
.permission-group-options { display: grid; gap: 8px; padding: 10px; }
.permission-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcff; }
.permission-option:has(input:checked) { border-color: #b9ceef; background: #f1f6ff; }
.permission-option input { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px; accent-color: var(--blue); }
.permission-option strong, .permission-option small { display: block; }
.permission-option strong { font-size: .84rem; }
.permission-option small { margin-top: 3px; color: var(--muted); font-size: .74rem; line-height: 1.35; }
.permission-option.locked { background: #f3f5f8; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.narrow-panel { max-width: 600px; margin: 10vh auto 0; padding: 30px; text-align: center; }
.narrow-panel h1 { color: var(--blue-dark); }
.narrow-panel p { margin-bottom: 20px; color: var(--muted); }
.status-icon { display: grid; width: 50px; height: 50px; margin: 0 auto 15px; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 1.4rem; font-weight: 900; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  body.sidebar-open { overflow: hidden; }
  .desktop-sidebar-only { display: none !important; }
  .mobile-sidebar-only { display: flex; }
  .sidebar { position: fixed; z-index: 52; top: 0; left: 0; display: grid; width: min(350px, 88vw); height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0; overflow: hidden; padding: 0; border: 0; border-radius: 0 22px 22px 0; box-shadow: 18px 0 48px rgba(11, 44, 102, .2); transform: translateX(-105%); transition: transform 220ms cubic-bezier(.22,.8,.35,1); touch-action: pan-y; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.is-dragging { transition: none; }
  .sidebar-backdrop { position: fixed; z-index: 51; inset: 0; display: block; padding: 0; border: 0; background: rgba(10, 23, 48, .38); backdrop-filter: blur(2px); }
  .mobile-side-brand { position: relative; min-height: 92px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 18px 58px 15px 24px; border-bottom: 1px solid #e5ebf5; }
  .mobile-side-brand img { width: 164px; max-height: 48px; object-fit: contain; object-position: left center; }
  .mobile-side-brand span { color: var(--muted); font-size: .7rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
  .mobile-side-nav { display: block; overflow-x: hidden; overflow-y: auto; padding: 14px 14px 18px; overscroll-behavior: contain; scrollbar-width: thin; }
  .mobile-side-nav > a, .mobile-nav-group-toggle { display: flex; width: 100%; min-height: 48px; align-items: center; gap: 13px; padding: 10px 13px; border: 0; border-radius: 13px; background: transparent; color: #465673; font-size: .91rem; font-weight: 720; text-align: left; text-decoration: none; }
  .mobile-side-nav > a + a { margin-top: 3px; }
  .mobile-side-nav svg, .mobile-side-footer svg { width: 21px; height: 21px; flex: 0 0 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
  .mobile-side-nav > a:hover, .mobile-side-nav > a:focus-visible, .mobile-nav-group-toggle:hover, .mobile-nav-group-toggle:focus-visible { background: var(--blue-soft); color: var(--blue); outline: none; }
  .mobile-side-nav > a.active { background: var(--blue-dark); color: #fff; box-shadow: 0 8px 18px rgba(11, 44, 102, .16); }
  .mobile-side-nav > a.mobile-nav-primary { margin: 5px 0 10px; color: var(--red-dark); }
  .mobile-side-nav > a.mobile-nav-primary:not(.active) { background: var(--red-soft); }
  .mobile-side-nav > a.mobile-nav-primary.active { background: var(--red); color: #fff; }
  .mobile-nav-group { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e6ecf5; }
  .mobile-nav-group-toggle { justify-content: space-between; }
  .mobile-nav-group-title { display: flex; min-width: 0; align-items: center; gap: 13px; }
  .mobile-nav-group-toggle .mobile-nav-chevron { width: 17px; height: 17px; flex-basis: 17px; transition: transform 160ms ease; }
  .mobile-nav-group-toggle[aria-expanded="true"] .mobile-nav-chevron { transform: rotate(180deg); }
  .mobile-nav-submenu { display: grid; gap: 2px; margin: 3px 0 2px 47px; padding-left: 12px; border-left: 1px solid #dbe4f2; }
  .mobile-nav-submenu a { padding: 9px 10px; border-radius: 9px; color: #5b6880; font-size: .82rem; font-weight: 680; text-decoration: none; }
  .mobile-nav-submenu a:hover, .mobile-nav-submenu a:focus-visible { background: var(--blue-soft); color: var(--blue); outline: none; }
  .mobile-nav-submenu a.active { background: #eaf2ff; color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
  .mobile-side-footer { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: 12px; padding: 15px 18px max(15px, env(safe-area-inset-bottom)); border-top: 1px solid #e2e9f3; background: #f8faff; }
  .mobile-user-copy { display: grid; min-width: 0; gap: 3px; }
  .mobile-user-copy strong { overflow: hidden; color: var(--blue-dark); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-user-copy small { overflow: hidden; color: var(--muted); font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-user-copy i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: #2f9d58; }
  .mobile-side-footer form { margin: 0; }
  .mobile-side-footer button { display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--blue); }
  .mobile-side-footer button:hover, .mobile-side-footer button:focus-visible { border-color: #f0bec1; background: var(--red-soft); color: var(--red-dark); outline: none; }
  .mobile-swipe-indicator { position: absolute; top: 50%; right: 7px; width: 4px; height: 42px; border-radius: 10px; background: #dbe3ef; transform: translateY(-50%); pointer-events: none; }
  .mobile-header { position: sticky; z-index: 30; top: 0; display: flex; height: 62px; align-items: center; gap: 13px; padding: 0 18px; border-bottom: 1px solid var(--border); background: #fff; color: var(--blue-dark); font-weight: 800; }
  .menu-button { display: grid; width: 40px; height: 40px; place-content: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
  .menu-button > span:not(.sr-only) { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--blue); }
  .main-content { padding: 22px 18px; }
  .user-row { grid-template-columns: minmax(220px, 1fr) 100px 80px auto; }
  .last-access { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-form { grid-template-columns: minmax(220px, 1fr) 180px auto; }
  .search-form > .btn-secondary { grid-column: 3; }
  .detail-layout { grid-template-columns: 1fr; }
  .descriptions-head { align-items: stretch; flex-direction: column; }
  .descriptions-head .btn { width: 100%; }
}
@media (max-width: 900px) {
  .login-transition { display: none !important; }
}

@media (max-width: 700px) {
  .auth-shell { padding: 14px; }
  .login-card { padding: 26px 22px; }
  .brand-centered h1 { font-size: 1.6rem; }
  .page-heading, .page-heading-actions, .welcome-panel { align-items: stretch; flex-direction: column; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .btn { width: 100%; }
  .user-row { grid-template-columns: 1fr auto; gap: 12px; }
  .user-row > .user-meta { display: none; }
  .user-row > .btn { grid-column: span 2; }
  .form-grid, .permission-groups { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .search-form { grid-template-columns: 1fr; }
  .search-form > .btn-secondary { grid-column: auto; }
  .search-form .btn { width: 100%; }
  .document-result { grid-template-columns: 1fr; }
  .document-result > .btn { width: 100%; }
  .document-result h2, .document-result p { white-space: normal; }
  .recent-heading { align-items: stretch; flex-direction: column; }
  .recent-heading .btn { width: 100%; }
  .results-summary, .detail-heading, .detail-footer, .danger-zone { align-items: stretch; flex-direction: column; }
  .detail-actions { flex-direction: column; }
  .detail-actions .btn, .danger-zone .btn { width: 100%; }
  .detail-data-grid { grid-template-columns: 1fr; }
  .audit-summary { grid-template-columns: 1fr; }
  .trash-row { grid-template-columns: 1fr; }
  .trash-row .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Resumen documental: una fila estable para el total y las seis categorías. */
@media (min-width: 981px) {
  .desktop-home-summary {
    display: grid;
    grid-template-columns: minmax(178px, 1.3fr) repeat(6, minmax(78px, 1fr));
    align-items: stretch;
    gap: 0;
    min-height: 112px;
    margin: 16px 0 20px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 18px;
    background: linear-gradient(135deg, #12346f 0%, #173d80 100%);
    box-shadow: 0 14px 30px rgba(11, 44, 102, .16);
  }

  .desktop-home-summary > a {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-left: 1px solid rgba(220, 233, 255, .22);
    border-radius: 10px;
    color: #f4f7ff;
    text-decoration: none;
    transition: background-color 160ms ease, transform 160ms ease;
  }

  .desktop-home-summary > a:hover,
  .desktop-home-summary > a:focus-visible {
    background: rgba(255, 255, 255, .08);
    transform: translateY(-1px);
  }

  .desktop-home-summary > a span {
    overflow: hidden;
    color: #b9c9e9;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .025em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .desktop-home-summary > a strong {
    color: #fff;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
  }

  .desktop-home-total {
    display: flex;
    position: relative;
    min-width: 0;
    align-items: baseline;
    gap: 8px;
    padding: 12px 22px 12px 14px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .08);
  }

  .desktop-home-total::before {
    width: 4px;
    height: 38px;
    flex: 0 0 4px;
    border-radius: 999px;
    background: #dce9ff;
    content: "";
  }

  .desktop-home-total strong {
    color: #fff;
    font-size: 2.15rem;
    font-weight: 850;
    letter-spacing: -.04em;
    line-height: 1;
  }

  .desktop-home-total span {
    color: #d6e2f8;
    font-size: .94rem;
    font-weight: 750;
  }
}

/* El buscador global se retira del encabezado; se conservan los controles de tema, avisos y cuenta. */
.desktop-topbar .global-search-menu { display: none !important; }

@media (min-width: 981px) and (max-width: 1250px) {
  .desktop-home-summary { grid-template-columns: minmax(150px, 1.2fr) repeat(6, minmax(60px, 1fr)); padding: 9px; }
  .desktop-home-summary > a { padding-right: 11px; padding-left: 11px; }
  .desktop-home-summary > a strong { font-size: 1.35rem; }
  .desktop-home-total { padding-right: 12px; padding-left: 9px; }
}

/* Archivo > Particiones > Expedientes staging navigation */
.archive-breadcrumb { display:flex; align-items:center; gap:.55rem; margin:0 0 1rem; color:var(--muted); font-size:.86rem; }
.archive-breadcrumb a { color:var(--blue); font-weight:750; }
.archive-breadcrumb strong { color:var(--blue-dark); }
.archive-card-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; }
.archive-card { position:relative; display:flex; align-items:center; gap:1rem; min-height:150px; padding:1.25rem; overflow:hidden; border:1px solid var(--border); border-radius:20px; background:var(--surface); box-shadow:0 12px 28px rgba(11,44,102,.07); transition:transform .16s ease, box-shadow .16s ease; }
.archive-card::before,.partition-card::before { position:absolute; inset:0 auto 0 0; width:5px; background:var(--archive-color,var(--blue)); content:""; }
.archive-card:hover { transform:translateY(-2px); box-shadow:0 18px 32px rgba(11,44,102,.13); }
.archive-card-icon,.partition-icon { --archive-folder-base:var(--archive-color,var(--blue)); --archive-folder-front:color-mix(in srgb, var(--archive-folder-base) 72%, white); --archive-folder-dark:color-mix(in srgb, var(--archive-folder-base) 72%, black); display:grid; flex:0 0 54px; width:54px; height:54px; place-items:center; border-radius:16px; background:color-mix(in srgb, var(--archive-folder-base) 12%, white); color:var(--archive-folder-base); }
.archive-card-icon svg,.partition-icon svg { width:28px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.8; }
.archive-card strong,.archive-card small,.archive-card em { display:block; }
.archive-card-main { display:flex; min-width:0; flex:1; align-items:center; gap:2rem; color:inherit; text-decoration:none; }
.archive-card-actions { position:absolute; top:1.35rem; right:1.35rem; z-index:2; }
.archive-card-menu { display:grid; width:2.5rem; height:2.5rem; place-items:center; padding:0; border:0; border-radius:10px; background:transparent; color:var(--blue-dark); cursor:pointer; }
.archive-card-menu:hover,.archive-card-menu:focus-visible { background:var(--blue-soft); outline:none; }
.archive-card-menu svg { width:1.45rem; fill:currentColor; }
.archive-card-menu-panel { position:absolute; top:calc(100% + .35rem); right:0; display:grid; min-width:9rem; padding:.35rem; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 14px 30px rgba(11,44,102,.16); }
.archive-card-menu-panel[hidden] { display:none; }
.archive-card-menu-panel a,.archive-card-menu-panel button { display:block; width:100%; padding:.55rem .7rem; border:0; border-radius:8px; background:transparent; color:var(--text); font:inherit; font-size:.85rem; text-align:left; text-decoration:none; cursor:pointer; }
.archive-card-menu-panel a:hover,.archive-card-menu-panel a:focus-visible,.archive-card-menu-panel button:hover,.archive-card-menu-panel button:focus-visible { background:var(--blue-soft); color:var(--blue); outline:none; }
.archive-card-menu-panel form { margin:0; }
.archive-card-menu-panel form button { color:var(--red); }
.archive-card strong { color:var(--blue-dark); font-size:1.05rem; }
.archive-card small { margin-top:.3rem; color:var(--muted); }
.archive-card em { margin-top:.7rem; color:var(--muted); font-size:.76rem; font-style:normal; }
.archive-card-arrow { width:22px; margin-left:auto; fill:none; stroke:var(--blue); stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }
.archive-detail-panel { padding:1.35rem; }
.archive-detail-title { display:flex; justify-content:space-between; gap:1rem; padding-bottom:1rem; border-bottom:1px solid var(--border); }
.archive-detail-title h2,.archive-detail-title p { margin:0; }.archive-detail-title h2 { color:var(--blue-dark); }.archive-detail-title p { margin-top:.3rem; color:var(--muted); }
.archive-kicker { color:var(--blue); font-size:.68rem; font-weight:850; letter-spacing:.1em; }.archive-count { color:var(--muted); font-weight:750; }
.partition-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; padding-top:1rem; }
.partition-card { position:relative; padding:1rem 1rem 1rem 1.25rem; overflow:hidden; border:1px solid var(--border); border-radius:18px; background:var(--surface); }
.partition-card::before { background:var(--partition-color,var(--blue)); }.partition-card-head { display:flex; align-items:center; gap:.75rem; }.partition-card-head strong,.partition-card-head small { display:block; }.partition-card-head strong { color:var(--blue-dark); }.partition-card-head small { margin-top:.2rem; color:var(--muted); font-size:.76rem; }
.partition-icon { --archive-color:var(--partition-color,var(--blue)); width:44px; height:44px; flex-basis:44px; border-radius:13px; }.partition-icon svg { width:23px; }
.partition-stats { display:flex; gap:1.25rem; margin:1rem 0 .75rem; color:var(--muted); font-size:.76rem; }.partition-stats b { color:var(--blue-dark); font-size:1rem; }
.partition-collections { display:grid; gap:.4rem; }.partition-collections a { display:grid; grid-template-columns:minmax(0,1fr) auto 18px; align-items:center; gap:.5rem; padding:.65rem .7rem; border:1px solid var(--border); border-radius:10px; background:var(--surface-subtle); }.partition-collections span { overflow:hidden; color:var(--blue-dark); font-size:.8rem; font-weight:750; text-overflow:ellipsis; white-space:nowrap; }.partition-collections small { color:var(--muted); font-size:.68rem; }.partition-collections svg { width:18px; fill:none; stroke:var(--blue); stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }.archive-add-partition { margin-top:1rem; }
html[data-theme="dark"] .archive-card,html[data-theme="dark"] .partition-card,html[data-theme="dark"] .archive-detail-panel { background:var(--surface); }.archive-card strong,html[data-theme="dark"] .partition-card-head strong,html[data-theme="dark"] .archive-detail-title h2,html[data-theme="dark"] .archive-breadcrumb strong,html[data-theme="dark"] .partition-stats b { color:var(--text); }.partition-collections a { background:var(--surface-subtle); }
@media (max-width:1000px) { .archive-card-grid,.partition-grid { grid-template-columns:1fr; } }

/* Restauración exacta de la barra superior previa al buscador global. */
.desktop-topbar .global-search-menu,
.desktop-topbar .global-search-menu * {
  display: none !important;
}
.desktop-topbar-actions {
  justify-content: flex-end;
  gap: 10px;
}

/* Restauración del diseño anterior: botón de lupa y formulario desplegable compacto. */
.global-search-menu { flex: none; min-width: 0; }
.global-search-menu summary { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--blue); cursor: pointer; list-style: none; box-shadow: none; }
.global-search-menu summary:hover, .global-search-menu summary:focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: none; transform: none; box-shadow: none; }
.global-search-menu form { position: absolute !important; z-index: 1000; top: calc(100% + 9px) !important; right: 0 !important; width: min(560px, calc(100vw - 32px)) !important; padding: 13px !important; border: 1px solid var(--border) !important; border-radius: 16px !important; background: var(--surface) !important; box-shadow: var(--shadow) !important; }
.global-search-field { grid-template-columns: 19px minmax(0, 1fr) 34px auto; min-height: 42px; padding: 0 6px 0 11px; border-radius: 10px; }
.global-search-field > svg { width: 18px; height: 18px; }
.global-search-field input { font-size: .76rem; }
.global-search-submit-icon { display: none; }
.global-search-filters { display: none !important; }
.global-search-suggestions { position: static; max-height: min(420px, 60vh); margin-top: 10px; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none; padding: 7px 0 0; }
.global-search-suggestion { grid-template-columns: 34px minmax(0, 1fr) 18px; min-height: 0; padding: 8px; }
.global-search-suggestion-icon { width: 32px; height: 32px; }
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu form { position: fixed !important; top: 76px !important; right: 10px !important; left: 10px !important; width: auto !important; max-height: calc(100vh - 92px) !important; padding: 10px !important; border-radius: 16px !important; overflow: hidden; }
  .desktop-topbar .global-search-suggestions { max-height: min(58vh, 460px) !important; overflow-y: scroll !important; }
}

/* Búsqueda general siempre visible y flotante dentro de la barra superior. */
.desktop-topbar .global-search-menu { flex: 0 1 560px; min-width: 260px; }
.desktop-topbar .global-search-menu > form {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  width: 100% !important;
  max-width: none !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.desktop-topbar .global-search-filters { display: none !important; }
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu { flex: 1 1 auto; min-width: 0; }
  .desktop-topbar .global-search-menu > form {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
}

/* La lista de sugerencias debe desplazarse con el dedo en pantallas táctiles. */
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu form {
    overflow: hidden !important;
    overscroll-behavior: contain;
  }
  .desktop-topbar .global-search-suggestions {
    max-height: min(58vh, 460px) !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
  }
}

/* Final mobile overrides for the topbar account menu. */
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu form {
    position: fixed !important;
    z-index: 1000;
    top: 76px !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box;
    max-height: calc(100vh - 92px);
    overflow: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .desktop-topbar .global-search-field { grid-template-columns: 19px minmax(0, 1fr) auto; }
  .desktop-topbar .global-search-field input { font-size: .78rem; }
  .desktop-topbar .global-search-suggestions {
    max-height: min(58vh, 460px);
    overflow-y: scroll;
    touch-action: pan-y;
  }

  .desktop-topbar .desktop-user-menu-topbar { display: none !important; }
  .desktop-topbar .desktop-user-menu-topbar summary {
    width: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: center;
  }
  .desktop-topbar .desktop-user-menu-topbar summary .desktop-user-chevron { display: none; }
  .desktop-topbar .desktop-user-menu-topbar form {
    position: fixed !important;
    z-index: 1000;
    top: 68px !important;
    right: 12px !important;
    bottom: auto !important;
    left: 12px !important;
    width: auto !important;
    max-width: 360px;
    margin-left: auto;
    box-sizing: border-box;
  }
  .desktop-topbar .desktop-user-menu-info { padding: 10px 12px 12px; }
  .desktop-topbar .desktop-user-menu-options { gap: 3px; padding: 8px 0; }
  .desktop-topbar .desktop-user-menu-options a,
  .desktop-topbar .desktop-user-menu-options button { min-height: 42px; padding: 9px 12px; font-size: .82rem; }

  .mobile-side-footer { display: block; padding: 0; }
  .mobile-account-menu { position: relative; }
  .mobile-account-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    padding: 12px 18px;
    color: var(--blue-dark);
    cursor: pointer;
    list-style: none;
  }
  .mobile-account-summary::-webkit-details-marker { display: none; }
  .mobile-account-chevron { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transition: transform 160ms ease; }
  .mobile-account-menu[open] .mobile-account-chevron { transform: rotate(180deg); }
  .mobile-account-menu form { display: grid; gap: 0; padding: 0 12px 12px; }
  .mobile-account-options { display: grid; gap: 3px; padding: 8px 0; border-top: 1px solid var(--border); }
  .mobile-account-options a,
  .mobile-account-options button { display: flex; width: 100%; min-height: 42px; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-size: .82rem; text-align: left; text-decoration: none; }
  .mobile-account-options svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
  .mobile-account-options a:hover, .mobile-account-options a:focus-visible { background: var(--blue-soft); color: var(--blue); outline: none; }
  .mobile-account-options button:disabled { cursor: not-allowed; opacity: .48; }
  .mobile-account-divider { height: 1px; background: var(--border); }
  .mobile-account-logout { display: grid; width: 48px; height: 48px; min-height: 48px; margin-top: 10px; margin-left: auto; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--red-soft); color: var(--red); }
  .mobile-account-logout svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
  .mobile-account-logout:hover, .mobile-account-logout:focus-visible { background: var(--red); color: #fff; outline: none; }
}

/* Los controles ya viven en la barra superior; los encabezados recuperan todo su ancho. */
@media (min-width: 901px) {
  .main-content > .page-heading:first-child,
  .main-content > .detail-heading:first-child,
  .activity-page-heading,
  .receipt-page-heading,
  .catalog-page-heading,
  .tag-page-heading,
  .collection-page-heading {
    padding-right: 0 !important;
  }

  .page-heading-actions > form,
  .page-heading-actions > .btn,
  .detail-heading .detail-actions,
  .catalog-add-button,
  .tag-create-button,
  .receipt-page-heading .receipt-availability {
    margin-right: 0 !important;
  }

  html, body { overflow-x: hidden; }
  .desktop-user-menu-topbar form {
    position: fixed !important;
    z-index: 1000;
    top: 84px !important;
    right: 24px !important;
    bottom: auto !important;
    left: auto !important;
    width: min(232px, calc(100vw - 32px)) !important;
    box-sizing: border-box;
  }
}

/* Nuevo registro: todos los controles internos respetan la superficie carbón. */
html[data-theme="dark"] .upload-box,
html[data-theme="dark"] .description-item,
html[data-theme="dark"] .private-document-option .checkbox-option {
  background: #181818 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .upload-box > strong,
html[data-theme="dark"] .description-item-head label,
html[data-theme="dark"] .private-document-option .checkbox-option strong {
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .upload-box > p,
html[data-theme="dark"] .private-document-option .checkbox-option small {
  color: #a1a1a1 !important;
}
html[data-theme="dark"] .file-input {
  color-scheme: dark;
  background: #141414 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .file-input::file-selector-button {
  background: #292929 !important;
  border: 1px solid #444 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .private-document-option .checkbox-option input { accent-color: #ef4444; }
html[data-theme="dark"] .tag-combobox-control {
  background: #141414 !important;
  border-color: #343434 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .tag-picker-toggle {
  background: #202020 !important;
  border-left-color: #343434 !important;
  color: #e5e5e5 !important;
}
html[data-theme="dark"] .tag-picker-popover {
  background: #181818 !important;
  border-color: #343434 !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, .38) !important;
}
html[data-theme="dark"] .tag-picker-search {
  background: #141414 !important;
  border-color: #343434 !important;
}
html[data-theme="dark"] .tag-picker-option:hover,
html[data-theme="dark"] .tag-picker-option:has(input:checked) { background: #292929 !important; }

/* Detalle del documento: tarjetas de datos y archivos sin superficies blancas. */
@media (min-width: 701px) {
  html[data-theme="dark"] .detail-heading .detail-actions { margin-right: 124px; }
}
html[data-theme="dark"] .detail-data-grid > div,
html[data-theme="dark"] .description-list article,
html[data-theme="dark"] .file-row {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .detail-data-grid dt,
html[data-theme="dark"] .description-list span,
html[data-theme="dark"] .file-row small,
html[data-theme="dark"] .file-kind,
html[data-theme="dark"] .related-file-description {
  color: #a1a1a1 !important;
}
html[data-theme="dark"] .detail-data-grid dd,
html[data-theme="dark"] .description-list p,
html[data-theme="dark"] .file-row strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .payment-receipt-data dt { color: #a1a1a1 !important; }
html[data-theme="dark"] .payment-receipt-data dd { color: #a3a3ff !important; }
html[data-theme="dark"] .desktop-preview-frame,
html[data-theme="dark"] .existing-related-preview { background: #141414 !important; }

/* Editar registro: tarjetas de archivos existentes y opción de quitar archivo. */
html[data-theme="dark"] .current-main-file,
html[data-theme="dark"] .existing-related-card,
html[data-theme="dark"] .related-file-editor {
  background: #181818 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .current-main-file strong,
html[data-theme="dark"] .existing-related-card-heading strong,
html[data-theme="dark"] .related-file-heading strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .current-main-file span,
html[data-theme="dark"] .existing-related-card-heading small { color: #a1a1a1 !important; }
html[data-theme="dark"] .related-remove-option {
  background: #2a1919 !important;
  border-color: #6b3030 !important;
  color: #ff8b8b !important;
}
html[data-theme="dark"] .related-remove-option small { color: #d99a9a !important; }

@media (min-width: 701px) {
  html[data-theme="dark"] .activity-page-heading { padding-right: 124px; }
}

/* Copias de seguridad: filas y controles legibles en la paleta carbón. */
@media (min-width: 701px) {
  html[data-theme="dark"] .page-heading-actions > form { margin-right: 124px; }
  html[data-theme="dark"] .backup-import-panel { margin-right: 0; }
}
html[data-theme="dark"] .backup-row {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .backup-main h2,
html[data-theme="dark"] .backup-meta strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .backup-main p,
html[data-theme="dark"] .backup-main small,
html[data-theme="dark"] .backup-meta span { color: #a1a1a1 !important; }
html[data-theme="dark"] .backup-import-panel .file-input {
  color-scheme: dark;
  background: #141414 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .backup-import-panel .file-input::file-selector-button {
  background: #292929 !important;
  border: 1px solid #444 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .backup-actions .btn-secondary {
  background: #202020 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .backup-actions .btn-secondary:hover,
html[data-theme="dark"] .backup-actions .btn-secondary:focus-visible { background: #292929 !important; }
html[data-theme="dark"] .backup-actions .btn-danger {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #fff !important;
}
html[data-theme="dark"] .backup-row .status-badge.active {
  background: #16301f !important;
  color: #22c55e !important;
}
html[data-theme="dark"] .audit-status.success {
  background: #16301f !important;
  color: #22c55e !important;
}
@media (min-width: 701px) { html[data-theme="dark"] .page-heading-actions > .btn { margin-right: 124px !important; } }
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .active-access-user,
html[data-theme="dark"] .active-access-user-heading,
html[data-theme="dark"] .active-access-card,
html[data-theme="dark"] .permission-group,
html[data-theme="dark"] .permission-group-heading,
html[data-theme="dark"] .permission-option { background: #181818 !important; border-color: #2b2b2b !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .active-access-user-heading span,
html[data-theme="dark"] .active-access-card small,
html[data-theme="dark"] .permission-group-heading p,
html[data-theme="dark"] .permission-option small { color: #a1a1a1 !important; }
html[data-theme="dark"] .active-access-list,
html[data-theme="dark"] .user-list { background: #181818 !important; }
html[data-theme="dark"] .permission-group-heading { background: #141414 !important; }
html[data-theme="dark"] .permission-group-heading h3,
html[data-theme="dark"] .permission-option strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .permission-group-heading > span { background: #292929 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .permission-option:has(input:checked) { background: #292929 !important; border-color: #666 !important; }
html[data-theme="dark"] .permission-option.locked { background: #202020 !important; }
html[data-theme="dark"] .permission-option input { accent-color: #ef4444; }
html[data-theme="dark"] .active-access-user-heading,
html[data-theme="dark"] .permissions-section { border-color: #343434 !important; }
@media (min-width: 701px) {
  html[data-theme="dark"] .page-heading-actions > .btn { margin-right: 124px !important; }
}
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .active-access-user,
html[data-theme="dark"] .active-access-user-heading,
html[data-theme="dark"] .active-access-card,
html[data-theme="dark"] .permission-group,
html[data-theme="dark"] .permission-group-heading,
html[data-theme="dark"] .permission-option {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .active-access-user-heading span,
html[data-theme="dark"] .active-access-card small,
html[data-theme="dark"] .permission-group-heading p,
html[data-theme="dark"] .permission-option small { color: #a1a1a1 !important; }
html[data-theme="dark"] .active-access-list,
html[data-theme="dark"] .user-list { background: #181818 !important; }
html[data-theme="dark"] .permission-group-heading { background: #141414 !important; }
html[data-theme="dark"] .permission-group-heading h3,
html[data-theme="dark"] .permission-option strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .permission-group-heading > span { background: #292929 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .permission-option:has(input:checked) { background: #292929 !important; border-color: #666 !important; }
html[data-theme="dark"] .permission-option.locked { background: #202020 !important; }
html[data-theme="dark"] .permission-option input { accent-color: #ef4444; }
html[data-theme="dark"] .active-access-user-heading,
html[data-theme="dark"] .permissions-section { border-color: #343434 !important; }
html[data-theme="dark"] .tag-admin-swatch,
html[data-theme="dark"] .tag-color-dot { box-shadow: 0 0 0 3px #343434 !important; }

html[data-theme="dark"] .document-tag-chip,
html[data-theme="dark"] .mobile-document-tags i {
  background: #292929 !important;
  border-color: #444 !important;
  color: #e5e5e5 !important;
}
html[data-theme="dark"] .tag-admin-swatch,
html[data-theme="dark"] .tag-color-dot {
  box-shadow: 0 0 0 3px #343434 !important;
}

@media (min-width: 701px) {
  html[data-theme="dark"] .catalog-page-heading .catalog-add-button { margin-right: 124px !important; }
}

@media (min-width: 701px) {
  html[data-theme="dark"] .tag-page-heading { padding-right: 124px; }
  html[data-theme="dark"] .tag-page-heading .tag-create-button { margin-right: 124px !important; }
}
html[data-theme="dark"] .tag-catalog-heading { border-color: #2b2b2b !important; }
html[data-theme="dark"] .tag-admin-table-head,
html[data-theme="dark"] .tag-admin-row { background: #181818 !important; border-color: #2b2b2b !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-admin-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .tag-admin-row:hover { background: #222 !important; }
html[data-theme="dark"] .tag-status { background: #16301f !important; color: #7ee2a8 !important; }
html[data-theme="dark"] .tag-row-menu > summary:hover,
html[data-theme="dark"] .tag-row-menu[open] > summary { background: #292929 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .tag-row-menu > div { background: #202020 !important; border-color: #343434 !important; }
html[data-theme="dark"] .tag-row-menu a:hover,
html[data-theme="dark"] .tag-row-menu button:hover { background: #292929 !important; }
html[data-theme="dark"] .tag-editor-backdrop { background: rgba(0, 0, 0, .72) !important; }
html[data-theme="dark"] .tag-editor { background: #181818 !important; color: #f1f1f1 !important; box-shadow: -24px 0 58px rgba(0, 0, 0, .38); }
html[data-theme="dark"] .tag-editor-heading { border-color: #343434 !important; }
html[data-theme="dark"] .tag-editor-heading h2,
html[data-theme="dark"] .tag-color-field legend { color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-editor-heading p { color: #a1a1a1 !important; }
html[data-theme="dark"] .tag-editor-close { background: #202020 !important; border-color: #343434 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .tag-editor input[type="text"],
html[data-theme="dark"] .tag-editor textarea { background: #141414 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-color-field label span { border-color: #e5e5e5 !important; box-shadow: 0 0 0 1px #444 !important; }
html[data-theme="dark"] .tag-color-field input:checked + span { box-shadow: 0 0 0 3px #666 !important; }
html[data-theme="dark"] .tag-editor .form-actions { border-color: #343434 !important; }
html[data-theme="dark"] .tag-editor .document-tag-chip { background: #292929 !important; border-color: #444 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .document-tag-chip,
html[data-theme="dark"] .mobile-document-tags i {
  background: #292929 !important;
  border-color: #444 !important;
  color: #e5e5e5 !important;
}

@media (min-width: 701px) {
  html[data-theme="dark"] .tag-page-heading { padding-right: 124px; }
  html[data-theme="dark"] .tag-page-heading .tag-create-button { margin-right: 124px !important; }
}
html[data-theme="dark"] .tag-catalog-heading { border-color: #2b2b2b !important; }
html[data-theme="dark"] .tag-admin-table-head,
html[data-theme="dark"] .tag-admin-row { background: #181818 !important; border-color: #2b2b2b !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-admin-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .tag-admin-row:hover { background: #222 !important; }
html[data-theme="dark"] .tag-status { background: #16301f !important; color: #7ee2a8 !important; }
html[data-theme="dark"] .tag-row-menu > summary:hover,
html[data-theme="dark"] .tag-row-menu[open] > summary { background: #292929 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .tag-row-menu > div { background: #202020 !important; border-color: #343434 !important; }
html[data-theme="dark"] .tag-row-menu a:hover,
html[data-theme="dark"] .tag-row-menu button:hover { background: #292929 !important; }
html[data-theme="dark"] .tag-editor-backdrop { background: rgba(0, 0, 0, .72) !important; }
html[data-theme="dark"] .tag-editor { background: #181818 !important; color: #f1f1f1 !important; box-shadow: -24px 0 58px rgba(0, 0, 0, .38); }
html[data-theme="dark"] .tag-editor-heading { border-color: #343434 !important; }
html[data-theme="dark"] .tag-editor-heading h2,
html[data-theme="dark"] .tag-color-field legend { color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-editor-heading p { color: #a1a1a1 !important; }
html[data-theme="dark"] .tag-editor-close { background: #202020 !important; border-color: #343434 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .tag-editor input[type="text"],
html[data-theme="dark"] .tag-editor textarea { background: #141414 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .tag-color-field label span { border-color: #e5e5e5 !important; box-shadow: 0 0 0 1px #444 !important; }
html[data-theme="dark"] .tag-color-field input:checked + span { box-shadow: 0 0 0 3px #666 !important; }
html[data-theme="dark"] .tag-editor .form-actions { border-color: #343434 !important; }
html[data-theme="dark"] .tag-editor .document-tag-chip { background: #292929 !important; border-color: #444 !important; color: #f1f1f1 !important; }

/* Catálogos: botón y modal respetan el área global y la paleta carbón. */
@media (min-width: 701px) { html[data-theme="dark"] .catalog-page-heading { padding-right: 124px; } }
@media (min-width: 701px) { html[data-theme="dark"] .catalog-page-heading .catalog-add-button { margin-right: 124px; } }
html[data-theme="dark"] .catalog-table,
html[data-theme="dark"] .catalog-table-head,
html[data-theme="dark"] .catalog-row { background: #181818 !important; border-color: #2b2b2b !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .catalog-name-cell,
html[data-theme="dark"] .catalog-data-cell strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-data-cell { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-management-dialog { background: #181818 !important; border: 1px solid #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-dialog::backdrop,
html[data-theme="dark"] .catalog-dialog::backdrop { background: rgba(0, 0, 0, .72) !important; }
html[data-theme="dark"] .catalog-management-head { background: #181818 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-management-head h2,
html[data-theme="dark"] .catalog-dialog-head h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-head p,
html[data-theme="dark"] .catalog-dialog-head p { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-dialog-close,
html[data-theme="dark"] .catalog-search-button { background: #202020 !important; border-color: #343434 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .catalog-management-dialog input,
html[data-theme="dark"] .catalog-management-dialog textarea,
html[data-theme="dark"] .catalog-management-dialog select,
html[data-theme="dark"] .catalog-picker .input { background: #141414 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-dialog label,
html[data-theme="dark"] .catalog-management-dialog legend { color: #dedede !important; }
html[data-theme="dark"] .catalog-management-dialog .form-actions { background: #181818 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-suggestions,
html[data-theme="dark"] .catalog-dialog-results { background: #202020 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-result { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-result:hover,
html[data-theme="dark"] .catalog-result:focus { background: #292929 !important; }
@media (min-width: 701px) { html[data-theme="dark"] .catalog-page-heading .catalog-add-button { margin-right: 124px; } }

/* La insignia de correlativos queda fuera del área reservada a luna y campana. */
@media (min-width: 701px) {
  html[data-theme="dark"] .receipt-page-heading .receipt-availability { margin-right: 124px; }
}
html[data-theme="dark"] .receipt-availability { background: #202020 !important; border-color: #343434 !important; color: #d6d6d6 !important; }
html[data-theme="dark"] .receipt-availability i { background: #22c55e !important; }

/* Expedientes: elimina las superficies blancas heredadas en listado y detalle. */
html[data-theme="dark"] .collection-toolbar,
html[data-theme="dark"] .collection-search,
html[data-theme="dark"] .collection-toolbar select,
html[data-theme="dark"] .collection-card,
html[data-theme="dark"] .collection-card dl div,
html[data-theme="dark"] .collection-documents-head label,
html[data-theme="dark"] .collection-inner-search button,
html[data-theme="dark"] .collection-inner-search a,
html[data-theme="dark"] .collection-document-table-head,
html[data-theme="dark"] .collection-document-row,
html[data-theme="dark"] .collection-row-actions a,
html[data-theme="dark"] .collection-row-actions button {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .collection-search input,
html[data-theme="dark"] .collection-documents-head input,
html[data-theme="dark"] .collection-available-search input { background: transparent !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .collection-summary,
html[data-theme="dark"] .collection-detail-hero { background: #151515 !important; border-color: #303030 !important; }
html[data-theme="dark"] .collection-card dl div { background: #202020 !important; }
html[data-theme="dark"] .collection-document-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .collection-document-row { border-top-color: #2b2b2b !important; }
html[data-theme="dark"] .collection-document-row:hover { background: #222 !important; }
html[data-theme="dark"] .collection-document-copy strong,
html[data-theme="dark"] .collection-card h2,
html[data-theme="dark"] .collection-documents-head h2,
html[data-theme="dark"] .collection-detail-side h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .collection-folder,
html[data-theme="dark"] .collection-document-icon { background: #292929 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .collection-card.invoices .collection-folder,
html[data-theme="dark"] .collection-document-icon.type-factura { background: #3a1d1d !important; color: #ff8b8b !important; }
html[data-theme="dark"] .collection-inner-search button,
html[data-theme="dark"] .collection-inner-search a,
html[data-theme="dark"] .collection-row-actions a,
html[data-theme="dark"] .collection-row-actions button { box-shadow: none !important; }
html[data-theme="dark"] .collection-inner-search button { background: #292929 !important; border-color: #444 !important; }
html[data-theme="dark"] .collection-row-actions a { color: #e5e5e5 !important; }
html[data-theme="dark"] .collection-row-actions button { color: #ff8b8b !important; }
html[data-theme="dark"] .collection-add { background: #202020 !important; color: #f1f1f1 !important; border-color: #343434 !important; }
html[data-theme="dark"] .collection-detail-side dl div { border-bottom-color: #2b2b2b !important; }

/* Catálogos: botón y modal respetan el área global y la paleta carbón. */
@media (min-width: 701px) { html[data-theme="dark"] .catalog-page-heading { padding-right: 124px; } }
html[data-theme="dark"] .catalog-table,
html[data-theme="dark"] .catalog-table-head,
html[data-theme="dark"] .catalog-row { background: #181818 !important; border-color: #2b2b2b !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .catalog-name-cell,
html[data-theme="dark"] .catalog-data-cell strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-data-cell { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-management-dialog { background: #181818 !important; border: 1px solid #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-dialog::backdrop,
html[data-theme="dark"] .catalog-dialog::backdrop { background: rgba(0, 0, 0, .72) !important; }
html[data-theme="dark"] .catalog-management-head { background: #181818 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-management-head h2,
html[data-theme="dark"] .catalog-dialog-head h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-head p,
html[data-theme="dark"] .catalog-dialog-head p { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-dialog-close,
html[data-theme="dark"] .catalog-search-button { background: #202020 !important; border-color: #343434 !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .catalog-management-dialog input,
html[data-theme="dark"] .catalog-management-dialog textarea,
html[data-theme="dark"] .catalog-management-dialog select,
html[data-theme="dark"] .catalog-picker .input { background: #141414 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-dialog label,
html[data-theme="dark"] .catalog-management-dialog legend { color: #dedede !important; }
html[data-theme="dark"] .catalog-management-dialog .form-actions { background: #181818 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-suggestions,
html[data-theme="dark"] .catalog-dialog-results { background: #202020 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-result { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-result:hover,
html[data-theme="dark"] .catalog-result:focus { background: #292929 !important; }

/* Catálogos (Empresas, Proveedores y Clientes): botón y modal respetan el área global. */
@media (min-width: 701px) {
  html[data-theme="dark"] .catalog-page-heading { padding-right: 124px; }
  html[data-theme="dark"] .catalog-add-button { margin-right: 0; }
}
html[data-theme="dark"] .catalog-table,
html[data-theme="dark"] .catalog-table-head,
html[data-theme="dark"] .catalog-row {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .catalog-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .catalog-name-cell,
html[data-theme="dark"] .catalog-data-cell strong { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-data-cell { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-management-dialog {
  background: #181818 !important;
  border: 1px solid #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .catalog-management-dialog::backdrop,
html[data-theme="dark"] .catalog-dialog::backdrop { background: rgba(0, 0, 0, .72) !important; }
html[data-theme="dark"] .catalog-management-head {
  background: #181818 !important;
  border-color: #343434 !important;
}
html[data-theme="dark"] .catalog-management-head h2,
html[data-theme="dark"] .catalog-dialog-head h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-management-head p,
html[data-theme="dark"] .catalog-dialog-head p { color: #a1a1a1 !important; }
html[data-theme="dark"] .catalog-dialog-close,
html[data-theme="dark"] .catalog-search-button {
  background: #202020 !important;
  border-color: #343434 !important;
  color: #e5e5e5 !important;
}
html[data-theme="dark"] .catalog-management-dialog input,
html[data-theme="dark"] .catalog-management-dialog textarea,
html[data-theme="dark"] .catalog-management-dialog select,
html[data-theme="dark"] .catalog-picker .input {
  background: #141414 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .catalog-management-dialog label,
html[data-theme="dark"] .catalog-management-dialog legend { color: #dedede !important; }
html[data-theme="dark"] .catalog-management-dialog .form-actions { background: #181818 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-suggestions,
html[data-theme="dark"] .catalog-dialog-results { background: #202020 !important; border-color: #343434 !important; }
html[data-theme="dark"] .catalog-result { color: #f1f1f1 !important; }
html[data-theme="dark"] .catalog-result:hover,
html[data-theme="dark"] .catalog-result:focus { background: #292929 !important; }

/* Expedientes: elimina las superficies blancas heredadas en listado y detalle. */
html[data-theme="dark"] .collection-toolbar,
html[data-theme="dark"] .collection-search,
html[data-theme="dark"] .collection-toolbar select,
html[data-theme="dark"] .collection-card,
html[data-theme="dark"] .collection-card dl div,
html[data-theme="dark"] .collection-documents-head label,
html[data-theme="dark"] .collection-inner-search button,
html[data-theme="dark"] .collection-inner-search a,
html[data-theme="dark"] .collection-document-table-head,
html[data-theme="dark"] .collection-document-row,
html[data-theme="dark"] .collection-row-actions a,
html[data-theme="dark"] .collection-row-actions button {
  background: #181818 !important;
  border-color: #2b2b2b !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .collection-search input,
html[data-theme="dark"] .collection-documents-head input,
html[data-theme="dark"] .collection-available-search input { background: transparent !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .collection-summary,
html[data-theme="dark"] .collection-detail-hero { background: #151515 !important; border-color: #303030 !important; }
html[data-theme="dark"] .collection-card dl div { background: #202020 !important; }
html[data-theme="dark"] .collection-document-table-head { background: #141414 !important; color: #858585 !important; }
html[data-theme="dark"] .collection-document-row { border-top-color: #2b2b2b !important; }
html[data-theme="dark"] .collection-document-row:hover { background: #222 !important; }
html[data-theme="dark"] .collection-document-copy strong,
html[data-theme="dark"] .collection-card h2,
html[data-theme="dark"] .collection-documents-head h2,
html[data-theme="dark"] .collection-detail-side h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .collection-folder,
html[data-theme="dark"] .collection-document-icon { background: #292929 !important; color: #d0d0d0 !important; }
html[data-theme="dark"] .collection-card.invoices .collection-folder,
html[data-theme="dark"] .collection-document-icon.type-factura { background: #3a1d1d !important; color: #ff8b8b !important; }
html[data-theme="dark"] .collection-inner-search button,
html[data-theme="dark"] .collection-inner-search a,
html[data-theme="dark"] .collection-row-actions a,
html[data-theme="dark"] .collection-row-actions button { box-shadow: none !important; }
html[data-theme="dark"] .collection-inner-search button { background: #292929 !important; border-color: #444 !important; }
html[data-theme="dark"] .collection-row-actions a { color: #e5e5e5 !important; }
html[data-theme="dark"] .collection-row-actions button { color: #ff8b8b !important; }
html[data-theme="dark"] .collection-add { background: #202020 !important; color: #f1f1f1 !important; border-color: #343434 !important; }
html[data-theme="dark"] .collection-detail-side dl div { border-bottom-color: #2b2b2b !important; }

/* Recibos: paleta carbón, superficies neutras y espacio para los controles globales. */
@media (min-width: 701px) {
  html[data-theme="dark"] .receipt-page-heading { padding-right: 124px; }
}
html[data-theme="dark"] .receipt-number-preview,
html[data-theme="dark"] .receipt-payment-icon,
html[data-theme="dark"] .receipt-customer-search-button { background: #292929 !important; border-color: #3a3a3a !important; color: #e5e5e5 !important; }
html[data-theme="dark"] .receipt-choice,
html[data-theme="dark"] .receipt-condition label,
html[data-theme="dark"] .receipt-method label,
html[data-theme="dark"] .receipt-payment-toggle,
html[data-theme="dark"] .receipt-payment-fields,
html[data-theme="dark"] .receipt-customer-result,
html[data-theme="dark"] .receipt-customer-manual { background: #202020 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .receipt-choice.is-selected { background: #292929 !important; border-color: #666 !important; box-shadow: 0 0 0 2px rgba(239, 68, 68, .16); }
html[data-theme="dark"] .receipt-choice.is-selected > span { border-color: #ef4444 !important; }
html[data-theme="dark"] .receipt-field-grid label > span,
html[data-theme="dark"] .receipt-condition legend,
html[data-theme="dark"] .receipt-method legend,
html[data-theme="dark"] .receipt-payment-toggle strong { color: #dedede !important; }
html[data-theme="dark"] .receipt-field-grid input,
html[data-theme="dark"] .receipt-field-grid textarea,
html[data-theme="dark"] .receipt-file-field input[type="file"],
html[data-theme="dark"] .receipt-customer-dialog-search input { background: #141414 !important; border-color: #343434 !important; color: #f1f1f1 !important; }
html[data-theme="dark"] .receipt-field-grid input:focus,
html[data-theme="dark"] .receipt-field-grid textarea:focus,
html[data-theme="dark"] .receipt-customer-search-button:focus-visible { border-color: #666 !important; box-shadow: 0 0 0 2px rgba(255, 255, 255, .08) !important; outline: none; }
html[data-theme="dark"] .receipt-payment-toggle i { background: #555 !important; }
html[data-theme="dark"] .receipt-payment-toggle input:checked + i { background: #ef4444 !important; }
html[data-theme="dark"] .receipt-payment-fields { box-shadow: none !important; }

/* La insignia de correlativos queda fuera del área reservada a luna y campana. */
@media (min-width: 701px) {
  html[data-theme="dark"] .receipt-page-heading .receipt-availability {
    margin-right: 124px;
  }
}
html[data-theme="dark"] .receipt-availability {
  background: #202020 !important;
  border-color: #343434 !important;
  color: #d6d6d6 !important;
}
html[data-theme="dark"] .receipt-availability i { background: #22c55e !important; }

/* Estado vacío de búsqueda en modo oscuro. */
html[data-theme="dark"] .search-welcome {
  background: #181818 !important;
  border-color: #343434 !important;
  color: #a1a1a1;
}
html[data-theme="dark"] .search-welcome h2 { color: #f1f1f1 !important; }
html[data-theme="dark"] .search-welcome p { color: #a1a1a1 !important; }

/* Recibos: se elimina el azul heredado y se reserva espacio para los controles globales. */
@media (min-width: 701px) {
  html[data-theme="dark"] .receipt-page-heading { padding-right: 124px; }
}
html[data-theme="dark"] .receipt-number-preview,
html[data-theme="dark"] .receipt-payment-icon,
html[data-theme="dark"] .receipt-customer-search-button {
  background: #292929 !important;
  border-color: #3a3a3a !important;
  color: #e5e5e5 !important;
}
html[data-theme="dark"] .receipt-choice,
html[data-theme="dark"] .receipt-condition label,
html[data-theme="dark"] .receipt-method label,
html[data-theme="dark"] .receipt-payment-toggle,
html[data-theme="dark"] .receipt-payment-fields,
html[data-theme="dark"] .receipt-customer-result,
html[data-theme="dark"] .receipt-customer-manual {
  background: #202020 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .receipt-choice.is-selected {
  background: #292929 !important;
  border-color: #666 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, .16);
}
html[data-theme="dark"] .receipt-choice.is-selected > span {
  border-color: #ef4444 !important;
}
html[data-theme="dark"] .receipt-field-grid label > span,
html[data-theme="dark"] .receipt-condition legend,
html[data-theme="dark"] .receipt-method legend,
html[data-theme="dark"] .receipt-payment-toggle strong {
  color: #dedede !important;
}
html[data-theme="dark"] .receipt-field-grid input,
html[data-theme="dark"] .receipt-field-grid textarea,
html[data-theme="dark"] .receipt-file-field input[type="file"],
html[data-theme="dark"] .receipt-customer-dialog-search input {
  background: #141414 !important;
  border-color: #343434 !important;
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .receipt-field-grid input:focus,
html[data-theme="dark"] .receipt-field-grid textarea:focus,
html[data-theme="dark"] .receipt-customer-search-button:focus-visible {
  border-color: #666 !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .08) !important;
  outline: none;
}
html[data-theme="dark"] .receipt-payment-toggle i { background: #555 !important; }
html[data-theme="dark"] .receipt-payment-toggle input:checked + i { background: #ef4444 !important; }
html[data-theme="dark"] .receipt-payment-fields { box-shadow: none !important; }

/* Corrección final de controles oscuros: flecha compatible con Chromium y menú sin capas claras. */
html[data-theme="dark"] select,
html[data-theme="dark"] .select {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: #141414 !important;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTQgNmw0IDQgNC00IiBmaWxsPSJub25lIiBzdHJva2U9IiNhMWExYTEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIxLjUiLz48L3N2Zz4=") !important;
  background-position: right 13px center !important;
  background-repeat: no-repeat !important;
  background-size: 15px !important;
  border-color: #2b2b2b !important;
  box-shadow: none;
  padding-right: 40px !important;
}
html[data-theme="dark"] select::-ms-expand { display: none; }
html[data-theme="dark"] select option,
html[data-theme="dark"] .select option {
  background: #181818;
  color: #f1f1f1;
}
html[data-theme="dark"] select option:checked,
html[data-theme="dark"] .select option:checked {
  background: #2b2b2b;
  color: #fff;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .side-footer,
html[data-theme="dark"] .side-footer details,
html[data-theme="dark"] .desktop-user-menu {
  background: #141414 !important;
  border-color: #252525 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .side-footer details,
html[data-theme="dark"] .desktop-user-menu {
  border: 0 !important;
  padding: 0 !important;
}
html[data-theme="dark"] .desktop-user-menu summary {
  box-sizing: border-box;
  width: 100%;
  background: #202020 !important;
  border: 1px solid #343434 !important;
  border-radius: 13px;
  box-shadow: none !important;
  outline: none;
}
html[data-theme="dark"] .desktop-user-menu summary:focus,
html[data-theme="dark"] .desktop-user-menu summary:focus-visible {
  border-color: #666 !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .08) !important;
  outline: none;
}

/* Estado vacío de búsqueda: la superficie también debe pertenecer al tema oscuro. */
html[data-theme="dark"] .search-welcome {
  background: #181818 !important;
  border-color: #343434 !important;
  color: #a1a1a1;
}
html[data-theme="dark"] .search-welcome h2 {
  color: #f1f1f1 !important;
}
html[data-theme="dark"] .search-welcome p {
  color: #a1a1a1 !important;
}

/* Controles oscuros: evita la flecha nativa clara y los bordes que sobresalen. */
html[data-theme="dark"] select,
html[data-theme="dark"] .select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #141414;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23a1a1a1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-repeat: no-repeat;
  background-size: 15px;
  border: 1px solid #2b2b2b;
  box-shadow: none;
  color: #f1f1f1;
  padding-right: 40px;
}
html[data-theme="dark"] select::-ms-expand { display: none; }
html[data-theme="dark"] select:focus,
html[data-theme="dark"] .select:focus {
  border-color: #666;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .08);
  outline: none;
}
html[data-theme="dark"] select option,
html[data-theme="dark"] .select option {
  background: #181818;
  color: #f1f1f1;
}
html[data-theme="dark"] select option:checked,
html[data-theme="dark"] .select option:checked {
  background: #2b2b2b;
  color: #fff;
}

/* El pie del lateral conserva el fondo del panel y no deja ver el azul antiguo. */
html[data-theme="dark"] .side-footer,
html[data-theme="dark"] .side-footer details,
html[data-theme="dark"] .desktop-user-menu {
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}
html[data-theme="dark"] .desktop-user-menu summary {
  background: #202020;
  border: 1px solid #343434;
  border-radius: 13px;
  box-shadow: none;
  outline: none;
}
html[data-theme="dark"] .desktop-user-menu summary:focus,
html[data-theme="dark"] .desktop-user-menu summary:focus-visible {
  border-color: #666;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .08);
  outline: none;
}
html[data-theme="dark"] .desktop-user-menu[open] summary {
  background: #242424;
  border-color: #4a4a4a;
}

.document-workspace-form { padding: 0; }
.document-workspace-form > .alert { margin-bottom: 18px; }
.document-workspace-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); align-items: stretch; gap: 18px; }
.file-workspace-panel, .metadata-workspace-panel { padding: 22px; }
.file-workspace-panel { min-height: 100%; }
.workspace-section + .workspace-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.workspace-section > h2 { margin: 0 0 14px; color: var(--blue-dark); font-size: 1.08rem; }
.upload-box { padding: 20px; border: 1px dashed #aabbb0; border-radius: 15px; background: #f8fbff; text-align: center; }
.upload-box > strong { color: var(--blue-dark); font-size: 1rem; }
.upload-box > p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.upload-control { margin-top: 18px; text-align: left; }
.file-input { width: 100%; min-height: 46px; padding: 10px; border: 1px solid var(--border); border-radius: 13px; background: #fff; color: var(--text); font-size: .85rem; }
.current-main-file { display: grid; gap: 4px; margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; text-align: left; }
.current-main-file strong { color: var(--blue-dark); font-size: .82rem; }
.current-main-file span { overflow-wrap: anywhere; color: var(--muted); font-size: .78rem; }
.related-empty { padding: 22px 8px; color: var(--muted); text-align: center; }
.related-empty[hidden] { display: none; }
.related-editors { display: grid; gap: 12px; }
.related-file-editor { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: #fbfcff; }
.related-file-editor .field + .field { margin-top: 11px; }
.related-file-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.related-file-heading strong { color: var(--blue-dark); font-size: .9rem; }
.remove-related { padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: #a6262c; font-size: .78rem; font-weight: 750; }
.remove-related:hover { background: var(--red-soft); }
.add-related-button { width: 100%; margin-top: 12px; }
.add-related-button:disabled { opacity: .62; cursor: not-allowed; }
.principal-preview-section { display: none; }
.principal-preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.principal-preview-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.08rem; }
.principal-preview-heading p { max-width: 480px; margin: 5px 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: .8rem; }
.principal-preview-heading > span { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; background: #eef3fb; color: var(--blue-dark); font-size: .7rem; font-weight: 800; }
.principal-preview-frame { display: grid; min-height: 430px; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: #f4f6fa; }
.principal-preview-image { display: block; max-width: 100%; max-height: 580px; padding: 12px; object-fit: contain; }
.principal-preview-image[hidden], .principal-preview-pdf[hidden], .principal-preview-fallback[hidden] { display: none; }
.principal-preview-pdf { display: grid; width: 100%; min-height: 580px; grid-template-rows: auto minmax(0, 1fr); background: #e8ebf0; }
.pdf-preview-toolbar { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid #cfd6e2; background: #fff; color: var(--blue-dark); font-size: .75rem; }
.pdf-toolbar-spacer { flex: 1 1 auto; }
.pdf-control { min-height: 34px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--blue-dark); font: inherit; font-weight: 800; cursor: pointer; }
.pdf-control:hover:not(:disabled) { border-color: #a9b8d0; background: #f4f7fb; }
.pdf-control:disabled { opacity: .45; cursor: not-allowed; }
.pdf-zoom-control { min-width: 34px; padding-inline: 8px; font-size: 1rem; }
.pdf-preview-canvas-wrap { display: grid; max-height: 680px; min-height: 520px; justify-items: center; align-items: start; overflow: auto; padding: 18px; }
.pdf-preview-canvas-wrap canvas { max-width: none; background: #fff; box-shadow: 0 4px 18px rgba(8, 39, 90, .16); }
.pdf-preview-error { align-self: center; margin: -320px auto 0; padding: 14px 18px; border-radius: 10px; background: #fff; color: #a6262c; font-weight: 750; }
.pdf-preview-error[hidden] { display: none; }
.principal-preview-fallback { display: grid; max-width: 390px; justify-items: center; gap: 9px; padding: 36px; color: var(--blue-dark); text-align: center; }
.principal-preview-fallback strong { max-width: 100%; overflow-wrap: anywhere; }
.principal-preview-fallback p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.workspace-actions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.related-current-section .file-list { margin-top: 4px; }
.section-help { margin: -6px 0 14px; color: var(--muted); font-size: .8rem; }
.existing-related-list { display: grid; gap: 16px; }
.existing-related-card { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 15px; background: #fbfcff; }
.existing-related-card-heading > div { display: grid; gap: 3px; }
.existing-related-card-heading strong { overflow-wrap: anywhere; color: var(--blue-dark); }
.existing-related-card-heading small { color: var(--muted); }
.existing-related-preview { display: grid; min-height: 260px; max-height: 460px; place-items: center; overflow: auto; border: 1px solid var(--border); border-radius: 13px; background: #f1f4f8; }
.existing-related-preview img { display: block; width: auto; height: auto; max-width: 100%; max-height: 440px; object-fit: contain; }
.existing-related-preview iframe { width: 100%; height: 420px; border: 0; background: #fff; }
.related-preview-fallback { padding: 24px; color: var(--muted); text-align: center; }
.existing-related-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: .72rem; }
.related-remove-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid #efc5c7; border-radius: 12px; background: #fff7f7; color: #9b2228; cursor: pointer; }
.related-remove-option input { margin-top: 3px; }
.related-remove-option span { display: grid; gap: 2px; }
.related-remove-option small { color: #88575a; font-weight: 500; }
.current-file, .file-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.current-file div, .file-row div { display: grid; gap: .2rem; min-width: 0; }
.current-file strong, .file-row strong { overflow-wrap: anywhere; color: var(--blue-dark); }
.current-file span, .file-row small, .file-kind { color: var(--muted); }
.file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.file-row .file-actions { display: flex; flex: 0 0 auto; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 8px; }
.file-actions .btn { white-space: nowrap; }
.document-files-section { margin-top: 1.2rem; }
.detail-files-panel { margin-top: 0; }
.files-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.files-section-heading h2 { margin: 0; }
.files-section-heading p { margin: 5px 0 0; }
.bundle-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.bundle-actions .btn { white-space: nowrap; }
.detail-preview { margin-top: 1rem; scroll-margin-top: 18px; }
.detail-preview .principal-preview-section:not([hidden]) { display: block; }
.detail-preview-desktop { display: none; margin-top: 1rem; padding: 22px; }
.desktop-preview-frame { display: grid; min-height: 520px; max-height: 76vh; place-items: center; overflow: auto; border: 1px solid var(--border); border-radius: 15px; background: #f4f6fa; }
.desktop-preview-frame img { display: block; width: auto; height: auto; max-width: 100%; max-height: 76vh; object-fit: contain; }
.desktop-preview-frame iframe { width: 100%; height: min(76vh, 820px); min-height: 620px; border: 0; background: #fff; }
.desktop-preview-frame p { padding: 24px; color: var(--muted); text-align: center; }
.btn-with-icon { gap: 7px; }
.icon-button { width: 44px; min-width: 44px; height: 44px; justify-content: center; padding: 0; }
.action-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.preview-open { overflow: hidden; }
.preview-modal[hidden] { display: none; }
.preview-modal { position: fixed; z-index: 250; inset: 0; display: grid; place-items: center; padding: 2.5vh 2.5vw; }
.preview-modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(5, 20, 47, .78); cursor: default; }
.preview-modal-dialog { position: relative; display: grid; width: min(1500px, 95vw); height: 94vh; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border: 1px solid rgba(255,255,255,.35); border-radius: 18px; background: #fff; box-shadow: 0 28px 80px rgba(0, 14, 40, .45); }
.preview-modal-topbar { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px 10px 20px; border-bottom: 1px solid var(--border); color: var(--blue-dark); }
.preview-modal-actions { display: flex; align-items: center; gap: 9px; }
.preview-modal-close { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--border); border-radius: 11px; background: #fff; color: var(--blue-dark); font-size: 1.7rem; line-height: 1; }
.preview-modal-close:hover { background: #f4f7fb; }
.preview-modal-content { min-height: 0; overflow: hidden; padding: 16px; }
.preview-modal .principal-preview-section:not([hidden]) { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr); }
.preview-modal .principal-preview-frame { min-height: 0; height: auto; overflow: auto; }
.preview-modal .principal-preview-image { width: auto; height: auto; max-width: 100%; max-height: calc(94vh - 160px); padding: 0; object-fit: contain; }
.preview-modal .principal-preview-pdf { min-height: 0; height: 100%; }
.preview-modal .pdf-preview-canvas-wrap { max-height: none; min-height: 0; }
.print-panel[hidden] { display: none; }
.print-panel { position: absolute; z-index: 3; top: 72px; right: 18px; display: grid; width: min(390px, calc(100% - 36px)); gap: 12px; padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 18px 48px rgba(5, 30, 75, .25); color: var(--blue-dark); }
.print-panel h2, .print-panel p { margin: 0; }
.print-panel h2 { font-size: 1.05rem; }
.print-panel > p { color: var(--muted); font-size: .82rem; }
.print-panel label { font-weight: 750; }
.print-status { min-height: 20px; font-size: .8rem; font-weight: 700; }
.print-status.is-error { color: #a6262c; }
.print-status.is-success { color: #16733c; }
.print-panel-actions { display: flex; justify-content: flex-end; gap: 9px; }
.document-files-section h3 { margin: 1.25rem 0 .65rem; color: var(--blue-dark); font-size: 1rem; }
.file-list { display: grid; gap: .7rem; }
.file-kind { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.audit-filters { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .7fr) minmax(190px, .7fr) auto auto; align-items: end; gap: 12px; margin-bottom: 18px; padding: 18px; }
.audit-panel, .history-panel { padding: 22px; }
.audit-list, .history-timeline { display: grid; gap: 10px; }
.audit-row { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(260px, 1.2fr) auto; align-items: center; gap: 18px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.audit-row > div { display: grid; gap: 4px; }
.audit-row small, .history-timeline small { color: var(--muted); }
.audit-status { width: max-content; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 850; }
.audit-status.success { background: #e8f7ee; color: #167340; }
.audit-status.failed { background: #fff0f0; color: #aa262c; }
.audit-error { color: #aa262c; font-size: .78rem; }
.history-timeline article { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 14px; padding: 17px; border-left: 3px solid var(--blue-dark); border-radius: 0 13px 13px 0; background: #f8faff; }
.history-timeline article div { display: grid; gap: 4px; }
.history-timeline p { margin: 0; color: var(--muted); }
.conflict-alert { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.conflict-alert div { display: grid; gap: 4px; }
.share-feedback { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 13px 16px; border: 1px solid #c9d6e8; border-radius: 12px; background: #fff; color: var(--blue-dark); box-shadow: 0 12px 36px rgba(15, 31, 73, .2); font-size: .82rem; font-weight: 750; }
.share-feedback[data-kind="success"] { border-color: #abd7bc; background: #effaf3; color: #166b3d; }
.share-feedback[data-kind="warning"] { border-color: #efd39d; background: #fff9ec; color: #805714; }
.share-feedback[data-kind="error"] { border-color: #efb4b7; background: #fff2f2; color: #9b2228; }
.share-feedback[hidden] { display: none; }

.password-input-wrap { position: relative; width: 100%; }
.password-input-wrap .input { width: 100%; padding-right: 52px; }
.password-peek-button { position: absolute; top: 50%; right: 8px; display: grid; width: 38px; height: 38px; place-items: center; padding: 0; transform: translateY(-50%); border: 0; border-radius: 9px; background: transparent; color: var(--blue-dark); cursor: pointer; touch-action: none; }
.password-peek-button:hover, .password-peek-button:focus-visible { background: #edf3fb; outline: none; }
.password-peek-button:focus-visible { box-shadow: 0 0 0 3px rgba(19, 69, 137, .2); }
.password-peek-button.is-pressed { background: #e5edf8; }
.password-peek-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 1051px) {
  .principal-preview-section:not([hidden]) { display: block; }
  .detail-preview-desktop { display: block; }
}

@media (max-width: 1050px) {
  .document-workspace-grid { grid-template-columns: 1fr; }
  .file-workspace-panel { position: static; }
  .audit-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .backup-import-panel, .backup-import-form { grid-template-columns: 1fr; }
  .backup-import-form .btn { width: 100%; }
  .file-workspace-panel, .metadata-workspace-panel { padding: 18px; }
  .file-row { align-items: stretch; flex-direction: column; }
  .file-row .btn { width: 100%; }
  .file-row .file-actions { width: 100%; flex-direction: row; flex-wrap: nowrap; justify-content: center; }
  .file-row .icon-button { width: 46px; min-width: 46px; height: 46px; }
  .existing-related-fields { grid-template-columns: 1fr; }
  .existing-related-preview { min-height: 220px; max-height: 360px; }
  .existing-related-preview iframe { height: 340px; }
  .files-section-heading { flex-direction: column; }
  .bundle-actions { display: grid; width: 100%; grid-template-columns: 1fr; }
  .bundle-actions .btn { width: 100%; }
  .backup-row { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 15px; }
  .backup-row > .status-badge { grid-column: 2; grid-row: 1; align-self: start; }
  .backup-main { grid-column: 1; grid-row: 1; padding-right: 4px; }
  .backup-meta { grid-column: 1 / -1; display: flex; gap: 8px; }
  .backup-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .backup-actions > a { grid-column: 1 / -1; }
  .backup-actions form, .backup-actions .btn { width: 100%; }
  .principal-preview-heading, .pdf-preview-toolbar { align-items: stretch; flex-wrap: wrap; }
  .principal-preview-heading { flex-direction: column; }
  .principal-preview-heading > span { align-self: flex-start; }
  .pdf-toolbar-spacer { display: none; }
  .pdf-preview-canvas-wrap { min-height: 390px; padding: 10px; }
  .audit-filters, .audit-row { grid-template-columns: 1fr; }
  .audit-row .btn, .conflict-alert .btn { width: 100%; }
  .conflict-alert { align-items: stretch; flex-direction: column; }
  .preview-modal { padding: 0; }
  .preview-modal-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .preview-modal-topbar { min-height: 52px; padding: 7px 10px 7px 14px; }
  .preview-modal-topbar > strong { font-size: .82rem; }
  .preview-modal-actions .btn { min-height: 38px; padding: 8px 10px; }
  .preview-modal-actions .btn span { display: none; }
  .preview-modal-content { padding: 8px; }
  .preview-modal .principal-preview-heading { gap: 4px; margin-bottom: 8px; }
  .preview-modal .principal-preview-heading h2 { font-size: .95rem; }
  .preview-modal .principal-preview-heading p { margin-top: 2px; font-size: .72rem; }
  .preview-modal .principal-preview-heading > span { padding: 3px 7px; }
  .preview-modal .principal-preview-image { max-height: calc(100dvh - 135px); }
  .print-panel { top: 60px; right: 8px; width: calc(100% - 16px); }
}
.invoice-payment-fields {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.invoice-paid-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f7f9fd;
}

.invoice-paid-option input { width: 1.1rem; height: 1.1rem; }
.optional-label { color: var(--muted); font-weight: 400; }
.related-add-actions { display: grid; gap: .75rem; }
.related-file-description { margin: .45rem 0 0; color: var(--muted); font-size: .92rem; }

/* Inicio móvil: búsqueda prioritaria, resumen compacto y actividad reciente. */
@media (min-width: 981px) {
  .desktop-home-heading { display: flex; align-items: flex-start; justify-content: space-between; min-height: 62px; margin-bottom: 18px; padding-right: 56px; }
  .desktop-home-heading h1 { margin: 0; color: var(--blue-dark); font-size: 1.75rem; line-height: 1.1; letter-spacing: -.035em; }
  .desktop-home-heading p { margin: 6px 0 0; color: var(--muted); font-size: .86rem; }

  .desktop-home-search { padding: 18px 20px 20px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(17, 61, 141, .04); }
  .desktop-home-search h2 { margin: 0; color: var(--blue-dark); font-size: 1rem; }
  .desktop-home-search form { display: grid; grid-template-columns: minmax(260px, 1fr) 190px 120px; align-items: center; gap: 11px; margin-top: 13px; }
  .desktop-home-query { display: grid; height: 46px; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
  .desktop-home-query:focus-within { border-color: #829dca; box-shadow: 0 0 0 3px rgba(17, 61, 141, .09); }
  .desktop-home-query svg { width: 19px; height: 19px; fill: none; stroke: #75819a; stroke-linecap: round; stroke-width: 1.8; }
  .desktop-home-query input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .84rem; }
  .desktop-home-search select { height: 46px; padding: 0 13px; border: 1px solid var(--border); border-radius: 12px; outline: 0; background: #fff; color: var(--text); font-size: .82rem; }
  .desktop-home-search form > button { height: 46px; border: 0; border-radius: 12px; background: var(--red); color: #fff; font-size: .82rem; font-weight: 800; }
  .desktop-home-search form > button:hover, .desktop-home-search form > button:focus-visible { background: var(--red-dark); }
  .desktop-home-search > .field-error { display: block; margin-top: 7px; }

  .desktop-home-summary { display: grid; grid-template-columns: 1.45fr repeat(5, minmax(90px, 1fr)); align-items: center; margin: 16px 0; padding: 20px 22px; border-radius: 16px; background: var(--blue-dark); color: #fff; box-shadow: 0 13px 28px rgba(11, 44, 102, .14); }
  .desktop-home-summary > a { display: grid; gap: 5px; padding: 0 20px; border-left: 1px solid rgba(255, 255, 255, .25); color: #fff; text-decoration: none; }
  .desktop-home-summary > a:hover span, .desktop-home-summary > a:focus-visible span { color: #fff; }
  .desktop-home-summary > a span { color: rgba(255, 255, 255, .75); font-size: .69rem; }
  .desktop-home-summary > a strong { font-size: 1.45rem; }
  .desktop-home-total { display: flex; align-items: baseline; gap: 8px; }
  .desktop-home-total strong { font-size: 1.9rem; }
  .desktop-home-total span { font-size: 1.15rem; font-weight: 750; }

  .desktop-home-content { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: start; gap: 16px; }
  .desktop-home-recent, .desktop-home-utilities section { border: 1px solid var(--border); border-radius: 16px; background: #fff; }
  .desktop-home-recent { overflow: hidden; }
  .desktop-home-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; }
  .desktop-home-section-heading h2, .desktop-home-utilities h2 { margin: 0; color: var(--blue-dark); font-size: 1rem; }
  .desktop-home-section-heading > a { color: var(--blue); font-size: .72rem; font-weight: 750; text-decoration: none; }
  .desktop-home-table-head { display: grid; grid-template-columns: minmax(260px, 1fr) 110px 140px 18px; padding: 8px 20px 8px 68px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: #8290a7; font-size: .62rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
  .desktop-home-document-row { display: grid; grid-template-columns: 38px minmax(220px, 1fr) 110px 140px 18px; align-items: center; gap: 11px; padding: 12px 20px; border-bottom: 1px solid #e8edf5; color: var(--text); text-decoration: none; transition: background 150ms ease; }
  .desktop-home-document-row:last-child { border-bottom: 0; }
  .desktop-home-document-row:hover, .desktop-home-document-row:focus-visible { background: #f8fbff; }
  .desktop-home-file-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: #edf4ff; color: var(--blue); }
  .desktop-home-file-icon.type-imagen { background: #eaf7ef; color: #23764a; }
  .desktop-home-file-icon.type-plano { background: #fff4df; color: #a35f08; }
  .desktop-home-file-icon.type-contrato { background: #f2ecfb; color: #6841a5; }
  .desktop-home-file-icon.type-factura { background: #fff0f1; color: #b42331; }
  .desktop-home-file-icon.type-documento { background: #edf4ff; color: var(--blue); }
  .desktop-home-file-icon svg, .desktop-home-row-arrow, .desktop-home-utilities svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
  .desktop-home-file-icon svg { width: 19px; height: 19px; }
  .desktop-home-file-copy { display: grid; min-width: 0; gap: 3px; }
  .desktop-home-file-copy strong, .desktop-home-file-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-home-file-copy strong { color: var(--blue-dark); font-size: .76rem; }
  .desktop-home-file-copy small, .desktop-home-document-row > span:nth-child(3), .desktop-home-document-row time { color: var(--muted); font-size: .64rem; }
  .desktop-home-row-arrow { width: 16px; height: 16px; color: var(--blue); }
  .desktop-home-empty { padding: 54px 20px; text-align: center; }
  .desktop-home-empty h3 { margin: 0; color: var(--blue-dark); }
  .desktop-home-empty p { margin: 7px 0 0; color: var(--muted); }

  .desktop-home-utilities { display: grid; gap: 16px; }
  .desktop-home-utilities section { padding: 18px; }
  .desktop-home-utilities section > a { display: grid; min-height: 54px; grid-template-columns: 35px minmax(0, 1fr) 17px; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
  .desktop-home-utilities section > a:last-child { border-bottom: 0; }
  .desktop-home-utilities section > a > span { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--border); border-radius: 9px; color: var(--blue); }
  .desktop-home-utilities section > a strong { font-size: .75rem; font-weight: 680; }
  .desktop-home-utilities section > a:hover strong, .desktop-home-utilities section > a:focus-visible strong { color: var(--blue); }
  .desktop-home-utilities section > a svg { width: 17px; height: 17px; }
  .desktop-home-utility-arrow { color: var(--blue); }
  .desktop-home-system p { margin: 16px 0 4px; color: #34425c; font-size: .75rem; }
  .desktop-home-system p i { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #28a158; }
  .desktop-home-system small { color: var(--muted); font-size: .64rem; }
}

@media (min-width: 981px) and (max-width: 1250px) {
  .desktop-home-summary { grid-template-columns: 1.3fr repeat(5, minmax(72px, 1fr)); padding-right: 14px; padding-left: 14px; }
  .desktop-home-summary > a { padding: 0 12px; }
  .desktop-home-content { grid-template-columns: minmax(0, 1fr) 240px; }
  .desktop-home-table-head { grid-template-columns: minmax(220px, 1fr) 90px 118px 18px; }
  .desktop-home-document-row { grid-template-columns: 38px minmax(180px, 1fr) 90px 118px 18px; }
}

.mobile-home-only { display: none; }

@media (max-width: 700px) {
  body.mobile-filter-open { overflow: hidden; }
  .desktop-dashboard-only, .desktop-recent-results { display: none !important; }
  .mobile-home-only { display: block; }
  .main-content { padding: 24px 18px 58px; }

  .mobile-home-welcome { margin-bottom: 18px; }
  .mobile-home-welcome h1 { margin: 0; color: var(--blue-dark); font-size: clamp(1.75rem, 8vw, 2.3rem); line-height: 1.06; letter-spacing: -.035em; }
  .mobile-home-welcome p { margin: 8px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.45; }

  .mobile-home-search { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 10px; margin-bottom: 13px; }
  .mobile-home-searchbox { display: grid; height: 56px; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 11px; padding: 0 16px; border: 1px solid #cfd9e8; border-radius: 17px; background: #fff; box-shadow: 0 10px 30px rgba(8, 48, 105, .07); }
  .mobile-home-searchbox:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(17, 61, 141, .1); }
  .mobile-home-searchbox svg { width: 22px; height: 22px; fill: none; stroke: #738099; stroke-width: 2; stroke-linecap: round; }
  .mobile-home-searchbox input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 1rem; }
  .mobile-home-searchbox input::placeholder { color: #7f899b; }
  .mobile-home-filter-button, .mobile-filter-close { display: grid; width: 54px; height: 56px; place-items: center; padding: 0; border: 1px solid #cfd9e8; border-radius: 17px; background: #fff; color: var(--blue-dark); }
  .mobile-home-filter-button svg, .mobile-filter-close svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

  .mobile-home-actions { display: grid; grid-template-columns: 1.15fr .85fr; gap: 10px; margin-bottom: 25px; }
  .mobile-home-action { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; font-size: .88rem; font-weight: 800; text-decoration: none; }
  .mobile-home-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-home-action-primary { border-color: var(--red); background: var(--red); color: #fff; }
  .mobile-home-action-secondary { background: #fff; color: var(--blue-dark); }

  .mobile-summary-section { margin-bottom: 25px; }
  .mobile-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .mobile-section-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.15rem; }
  .mobile-section-heading a { color: var(--blue-dark); font-size: .82rem; font-weight: 800; text-decoration: none; }
  .mobile-summary-card { overflow: hidden; padding: 17px 0 14px; border-radius: 20px; background: var(--blue-dark); box-shadow: 0 14px 30px rgba(8, 48, 105, .14); }
  .mobile-summary-total { display: flex; align-items: baseline; justify-content: space-between; padding: 0 18px 13px; color: #fff; }
  .mobile-summary-total strong { font-size: 1.65rem; letter-spacing: -.03em; }
  .mobile-summary-total span { color: #c7d8f2; font-size: .75rem; }
  .mobile-type-strip { display: flex; gap: 9px; overflow-x: auto; padding: 0 18px 3px; scroll-padding-inline: 18px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .mobile-type-strip::-webkit-scrollbar { display: none; }
  .mobile-type-strip a { flex: 0 0 calc((100% - 18px) / 3); min-width: 0; padding: 10px 12px; border-radius: 13px; background: #fff; color: var(--blue-dark); text-decoration: none; scroll-snap-align: start; }
  .mobile-type-strip span, .mobile-type-strip strong { display: block; }
  .mobile-type-strip span { color: var(--muted); font-size: .72rem; }
  .mobile-type-strip strong { margin-top: 2px; font-size: 1.25rem; }

  .mobile-attention-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) 22px; align-items: center; gap: 12px; margin-bottom: 25px; padding: 14px; border: 1px solid #f0cfd2; border-radius: 17px; background: var(--red-soft); color: inherit; text-decoration: none; }
  .mobile-attention-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: #fff; color: var(--red); }
  .mobile-attention-icon svg, .mobile-attention-arrow { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-attention-card strong, .mobile-attention-card small { display: block; }
  .mobile-attention-card strong { color: #841c25; font-size: .82rem; }
  .mobile-attention-card small { margin-top: 2px; color: #8c5459; font-size: .75rem; line-height: 1.35; }
  .mobile-attention-arrow { color: #a66369; }

  .recent-section { margin-top: 0; }
  .recent-heading { flex-direction: row; align-items: end; margin: 0 0 12px; }
  .recent-heading h2 { font-size: 1.15rem; }
  .recent-heading p, .recent-heading .btn { display: none; }
  .mobile-recent-results { overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: 0 10px 30px rgba(8, 48, 105, .07); }
  .mobile-document-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 22px; align-items: center; gap: 12px; padding: 15px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
  .mobile-document-row:last-child { border-bottom: 0; }
  .mobile-document-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--blue-soft); color: var(--blue-dark); }
  .mobile-document-icon svg, .mobile-document-arrow { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-document-icon.type-imagen { background: #eef7f0; color: #267044; }
  .mobile-document-icon.type-plano { background: #fff6e8; color: #a96409; }
  .mobile-document-icon.type-contrato { background: #f4effc; color: #6841a5; }
  .mobile-document-icon.type-factura { background: #fff0f1; color: #b42331; }
  .mobile-document-row strong, .mobile-document-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-document-row strong { color: var(--text); font-size: .82rem; }
  .mobile-document-row small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
  .mobile-document-arrow { color: #8793a6; }

  .mobile-filter-overlay { position: fixed; z-index: 120; inset: 0; }
  .mobile-filter-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(3, 23, 48, .46); }
  .mobile-filter-panel { position: absolute; right: 0; bottom: 0; left: 0; padding: 22px 20px max(24px, env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: #fff; box-shadow: 0 -18px 50px rgba(3, 23, 48, .18); }
  .mobile-filter-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .mobile-filter-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.35rem; }
  .mobile-filter-close { width: 46px; height: 46px; border-radius: 14px; }
  .mobile-filter-panel .field { margin-bottom: 18px; }
  .mobile-filter-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 10px; }
  .mobile-filter-actions .btn { width: 100%; }
}
/* Catálogos de empresas y proveedores */
.nav-section-label { display:block; margin:1rem .75rem .25rem; color:#72809a; font-size:.72rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.catalog-page-heading > div { min-width:0; }
.catalog-add-button { flex:0 0 auto; }
.catalog-add-button svg,.catalog-button-icon { width:18px; height:18px; flex:0 0 auto; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
.catalog-list-panel { padding:1.5rem; }
.catalog-search { display:flex; align-items:end; gap:.75rem; margin-bottom:1.4rem; }
.catalog-search .field { flex:1; }
.catalog-search .btn { min-height:46px; }
.catalog-empty-state { display:grid; min-height:310px; place-content:center; justify-items:center; gap:.55rem; padding:2.5rem 1.25rem; border:1px dashed #cbd8ea; border-radius:16px; background:#fbfcff; color:var(--muted); text-align:center; }
.catalog-empty-state strong { color:var(--blue-dark); font-size:1.08rem; }
.catalog-empty-state p { max-width:460px; margin:0 0 .75rem; }
.catalog-empty-icon { display:grid; width:58px; height:58px; margin-bottom:.3rem; place-items:center; border-radius:17px; background:#edf3fc; color:var(--blue-dark); }
.catalog-empty-icon svg { width:30px; height:30px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linecap:round; stroke-linejoin:round; }
.catalog-list-summary { display:flex; justify-content:space-between; gap:1rem; margin-bottom:.75rem; color:var(--blue-dark); }
.catalog-list-summary span { color:var(--muted); font-size:.86rem; }
.catalog-table { overflow:hidden; border:1px solid var(--border); border-radius:15px; background:#fff; }
.catalog-table-head,.catalog-row { display:grid; grid-template-columns:minmax(180px,1.4fr) minmax(140px,.9fr) minmax(120px,.8fr) minmax(180px,1.15fr) auto; align-items:center; gap:1rem; }
.catalog-table-head { padding:.75rem 1rem; border-bottom:1px solid var(--border); background:#f5f8fc; color:#69768d; font-size:.74rem; font-weight:800; letter-spacing:.035em; text-transform:uppercase; }
.catalog-row { min-height:78px; padding:1rem; border-bottom:1px solid #e6ebf3; }
.catalog-row:last-child { border-bottom:0; }
.catalog-name-cell { display:flex; min-width:0; align-items:center; gap:.55rem; color:var(--blue-dark); }
.catalog-name-cell strong,.catalog-email-cell span:last-child { overflow-wrap:anywhere; }
.catalog-data-cell { display:grid; min-width:0; gap:.15rem; color:#596880; }
.catalog-data-cell > span:first-child { display:none; color:#7a879b; font-size:.72rem; font-weight:750; text-transform:uppercase; }
.catalog-data-cell strong { color:var(--blue-dark); }
.catalog-row-actions { display:flex; justify-content:flex-end; gap:.5rem; align-items:center; }
.catalog-entry-form { display:grid; gap:1rem; margin-top:1.25rem; }
.catalog-management-dialog { width:min(760px,calc(100vw - 2rem)); max-height:calc(100vh - 2rem); overflow:auto; padding:0; border:0; border-radius:20px; background:#fff; color:var(--blue-dark); box-shadow:0 28px 80px rgba(5,25,55,.36); }
.catalog-management-dialog::backdrop { background:rgba(7,25,52,.62); }
.catalog-management-head { position:sticky; z-index:2; top:0; display:flex; justify-content:space-between; gap:1rem; padding:1.35rem 1.5rem; border-bottom:1px solid var(--border); background:#fff; }
.catalog-management-head h2,.catalog-management-head p { margin:0; }
.catalog-management-head h2 { font-size:1.35rem; }
.catalog-management-head p { margin-top:.3rem; color:var(--muted); }
.catalog-dialog-close { display:grid; width:40px; height:40px; flex:0 0 auto; place-items:center; border:1px solid var(--border); border-radius:12px; background:#fff; color:var(--blue-dark); font-size:1.6rem; line-height:1; cursor:pointer; }
.catalog-management-dialog .catalog-entry-form { margin:0; padding:1.5rem; }
.catalog-picker { position:relative; display:grid; grid-template-columns:minmax(0,1fr) 52px; }
.catalog-picker .input { border-radius:12px 0 0 12px; }
.catalog-search-button { border:1px solid #ccd9eb; border-left:0; border-radius:0 12px 12px 0; background:#fff; color:#0b3b82; cursor:pointer; display:grid; place-items:center; }
.catalog-search-button:hover { background:#f1f6fd; }
.catalog-search-button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2; }
.catalog-suggestions { position:absolute; z-index:30; top:calc(100% + 5px); left:0; right:0; padding:.4rem; border:1px solid #ccd9eb; border-radius:12px; background:#fff; box-shadow:0 14px 35px rgba(14,45,89,.15); max-height:260px; overflow:auto; }
.catalog-result { width:100%; display:grid; gap:.15rem; padding:.75rem; border:0; border-radius:9px; background:transparent; color:#0d326d; text-align:left; cursor:pointer; }
.catalog-result:hover,.catalog-result:focus { background:#eef4fc; }
.catalog-result span,.catalog-result-empty { color:#64718a; font-size:.9rem; }
.catalog-result-empty { padding:.75rem; }
.catalog-result-create { color:#b51f2c; font-weight:800; }
.catalog-dialog { width:min(760px,calc(100vw - 2rem)); max-height:calc(100vh - 2rem); border:0; border-radius:20px; padding:1.4rem; color:#0c2f68; box-shadow:0 25px 70px rgba(5,25,55,.35); }
.catalog-dialog::backdrop { background:rgba(7,25,52,.58); }
.catalog-dialog-head { display:flex; justify-content:space-between; align-items:start; gap:1rem; }
.catalog-dialog-head h2,.catalog-dialog-head p { margin:0 0 .3rem; }
.catalog-dialog-search { display:grid; grid-template-columns:1fr auto; gap:.6rem; margin:1.1rem 0; }
.catalog-dialog-results { display:grid; gap:.35rem; max-height:230px; overflow:auto; border:1px solid #e0e7f1; border-radius:12px; padding:.35rem; margin-bottom:.8rem; }
.catalog-quick-create { margin-top:1rem; padding-top:1rem; border-top:1px solid #dfe7f2; }
.payment-related-fields { margin-top:1rem; padding-top:1rem; border-top:1px solid #dce5f1; }
.payment-receipt-data { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.45rem 1rem; margin:.9rem 0 0; }
.payment-receipt-data div { display:grid; gap:.1rem; }
.payment-receipt-data dt { color:#6b7890; font-size:.78rem; font-weight:700; }
.payment-receipt-data dd { margin:0; color:#12386f; font-weight:700; }
.notification-center { position:fixed; z-index:80; top:1.1rem; right:1.4rem; }
.notification-button { position:relative; width:48px; height:48px; display:grid; place-items:center; border:1px solid #d6e0ee; border-radius:14px; background:#fff; color:#0c3b80; cursor:pointer; box-shadow:0 8px 24px rgba(17,49,91,.08); }
.notification-button:hover { background:#f1f6fd; }
.notification-button svg { width:24px; height:24px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.notification-count { position:absolute; top:-7px; right:-7px; min-width:22px; height:22px; padding:0 5px; display:grid; place-items:center; border:2px solid #fff; border-radius:20px; background:#dd2b34; color:#fff; font-size:.7rem; font-weight:900; }
.notification-panel { position:absolute; top:58px; right:0; width:min(410px,calc(100vw - 2rem)); max-height:min(620px,calc(100vh - 90px)); overflow:auto; border:1px solid #d5dfed; border-radius:18px; background:#fff; box-shadow:0 22px 60px rgba(7,30,66,.22); }
.notification-panel-head { position:sticky; top:0; z-index:1; display:flex; justify-content:space-between; gap:1rem; padding:1rem 1.1rem; border-bottom:1px solid #e4eaf2; background:#fff; }
.notification-panel-head a { color:#b8202d; font-weight:800; font-size:.86rem; }
.notification-panel-empty { margin:0; padding:1.5rem; color:#68758c; text-align:center; }
.notification-panel-list { display:grid; }
.notification-panel-item { display:grid; grid-template-columns:10px 1fr; gap:.75rem; padding:1rem 1.1rem; border-bottom:1px solid #e9edf4; color:#10366f; text-decoration:none; }
.notification-panel-item:hover { background:#f5f8fc; }
.notification-panel-item div { display:grid; gap:.22rem; }
.notification-panel-item span,.notification-panel-item small { color:#65728a; }
.notification-panel-item.is-read { opacity:.68; }
.notification-status-dot { width:9px; height:9px; margin-top:.35rem; border-radius:50%; background:#e4a11b; }
.severity-danger .notification-status-dot { background:#d62631; }
.notifications-history { padding:1.25rem; }
.notification-history-list { display:grid; gap:.75rem; }
.notification-history-item { display:grid; grid-template-columns:12px minmax(0,1fr) auto; align-items:center; gap:1rem; padding:1rem; border:1px solid #dbe3ef; border-radius:15px; color:#10366f; text-decoration:none; background:#fff; }
.notification-history-item:hover { border-color:#9db3d1; background:#f8fafd; }
.notification-history-item > div { display:grid; gap:.25rem; }
.notification-item-top { display:flex; justify-content:space-between; gap:1rem; }
.notification-history-item p,.notification-history-item small { margin:0; color:#65728a; }
.notification-history-item.is-read { opacity:.72; }
.notification-history-item.is-historical { background:#f4f6f9; }
.notification-open-label { color:#b8202d; font-weight:800; white-space:nowrap; }
@media (min-width: 901px) {
  .main-content > .page-heading:first-child,
  .main-content > .detail-heading:first-child { padding-right:64px; }
}

@media (max-width: 900px) {
  .catalog-table-head { display:none; }
  .catalog-row { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
  .catalog-name-cell,.catalog-row-actions { grid-column:1 / -1; }
  .catalog-data-cell > span:first-child { display:block; }
  .catalog-row-actions { justify-content:flex-start; padding-top:.3rem; }
  .notification-history-item { grid-template-columns:10px minmax(0,1fr); }
  .notification-open-label { grid-column:2; }
}

@media (max-width: 560px) {
  .catalog-page-heading { display:grid; }
  .catalog-add-button { width:100%; }
  .catalog-list-panel { padding:1rem; }
  .catalog-search { display:grid; }
  .catalog-search .btn { width:100%; }
  .catalog-empty-state { min-height:280px; padding:2rem 1rem; }
  .catalog-list-summary { display:grid; gap:.15rem; }
  .catalog-row { grid-template-columns:1fr; gap:.8rem; padding:1rem; }
  .catalog-name-cell,.catalog-row-actions { grid-column:auto; }
  .catalog-row-actions { display:grid; grid-template-columns:1fr 1fr; width:100%; }
  .catalog-row-actions .btn,.catalog-row-actions form,.catalog-row-actions form .btn { width:100%; }
  .catalog-management-dialog { width:100%; max-width:none; max-height:none; height:100%; border-radius:0; }
  .catalog-management-head { padding:1rem; }
  .catalog-management-dialog .catalog-entry-form { padding:1rem; }
  .catalog-management-dialog .form-grid { grid-template-columns:1fr; }
  .catalog-management-dialog .span-2 { grid-column:auto; }
  .catalog-management-dialog .form-actions { position:sticky; bottom:-1rem; margin-left:-1rem; margin-right:-1rem; padding:1rem; background:#fff; }
  .catalog-dialog { padding:1rem; }
  .catalog-dialog-search { grid-template-columns:1fr; }
  .payment-receipt-data { grid-template-columns:1fr; }
  .notification-center { top:.65rem; right:.8rem; }
  .notification-button { width:44px; height:44px; box-shadow:none; }
  .notification-panel { top:52px; right:-.15rem; max-height:calc(100vh - 76px); }
  .notification-item-top { display:grid; gap:.2rem; }
}

/* Ajuste final de la búsqueda desplegable: compacta en escritorio y móvil. */
.global-search-field input[type="search"]::-webkit-search-cancel-button,
.global-search-field input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.global-search-menu form {
  width: min(560px, calc(100vw - 32px));
  padding: 10px;
  border-radius: 18px;
}
.global-search-suggestions {
  max-height: 306px !important;
  margin-top: 8px;
  padding-top: 6px;
}
.global-search-suggestion {
  min-height: 46px;
  padding: 6px 9px;
}
.global-search-suggestion-icon {
  width: 32px;
  height: 32px;
}
.global-search-suggestion-copy strong { font-size: .76rem; }
.global-search-suggestion-copy small,
.global-search-suggestion-copy em { font-size: .64rem; }
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu form {
    top: 76px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-height: none !important;
    padding: 9px !important;
    border-radius: 18px;
  }
  .desktop-topbar .global-search-field {
    min-height: 48px;
    grid-template-columns: 22px minmax(0, 1fr) 30px 36px;
  }
  .desktop-topbar .global-search-filters { grid-template-columns: 1fr auto; }
  .desktop-topbar .global-search-filters label { grid-column: 1 / -1; }
  .desktop-topbar .global-search-suggestions {
    max-height: min(306px, 52vh) !important;
  }
}

.access-management-heading { display:flex; justify-content:space-between; align-items:end; gap:1rem; padding:1.15rem 1.25rem .75rem; }
.access-management-heading h2,.access-management-heading p { margin:0; }
.access-management-heading p { margin-top:.25rem; color:#66748a; }
.active-access-list { display:grid; gap:.8rem; padding:0 1.25rem 1.25rem; }
.active-access-user { border:1px solid #dbe4f0; border-radius:16px; background:#f9fbfe; overflow:hidden; }
.active-access-user-heading { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.85rem 1rem; border-bottom:1px solid #e2e9f2; }
.active-access-user-heading > div { display:grid; gap:.1rem; }
.active-access-user-heading span { color:#68758a; font-size:.85rem; }
.active-access-slots { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.75rem; padding:.85rem; }
.active-access-card { display:flex; align-items:center; justify-content:space-between; gap:.8rem; min-width:0; padding:.9rem; border:1px solid #e0e7f1; border-radius:13px; background:#fff; }
.active-access-card > div { min-width:0; display:grid; gap:.2rem; }
.active-access-card strong,.active-access-card small { overflow-wrap:anywhere; }
.active-access-card small { color:#68758a; }
.access-kind { width:max-content; padding:.2rem .55rem; border-radius:999px; color:#0d4b86; background:#eaf3ff; font-size:.72rem; font-weight:900; text-transform:uppercase; letter-spacing:.04em; }
.section-divider { margin:0 1.25rem 1.25rem; border:0; border-top:1px solid #e2e8f1; }
.btn-small { min-height:38px; padding:.55rem .75rem; font-size:.85rem; }
.empty-state.compact { min-height:auto; margin:0 1.25rem 1.25rem; padding:1rem; }

@media (max-width: 760px) {
  .active-access-slots { grid-template-columns:1fr; }
  .active-access-card { align-items:stretch; display:grid; }
  .active-access-card form,.active-access-card .btn { width:100%; }
  .active-access-user-heading { align-items:start; }
}

@media (min-width: 901px) {
  .desktop-home-search form { grid-template-columns:minmax(260px,1fr) 170px 180px 120px; }
}

.private-document-option { margin-top:1rem; }
.private-document-option .checkbox-option { display:flex; align-items:flex-start; gap:.85rem; padding:1rem; border:1px solid #d7e1ef; border-radius:14px; background:#f7faff; cursor:pointer; }
.private-document-option .checkbox-option input { width:20px; height:20px; margin-top:.15rem; accent-color:#123b7a; }
.private-document-option .checkbox-option span { display:grid; gap:.2rem; }
.private-document-option .checkbox-option small { color:#65738d; font-weight:400; }
.record-status.privado { background:#eef0ff; color:#4138a8; }

/* Expedientes documentales */
.collection-page-heading { display:flex; align-items:end; justify-content:space-between; gap:1.25rem; margin-bottom:1rem; }
.collection-page-heading h1,.collection-page-heading p { margin:0; }
.collection-page-heading h1 { color:var(--blue-dark); font-size:2rem; }
.collection-page-heading p { margin-top:.25rem; color:var(--muted); }
.collection-toolbar { display:grid; grid-template-columns:minmax(260px,1fr) 180px 180px 110px; gap:.75rem; padding:1rem; border:1px solid var(--border); border-radius:18px; background:#fff; box-shadow:var(--shadow); }
.collection-toolbar select,.collection-search { min-height:48px; border:1px solid var(--border); border-radius:13px; background:#fff; }
.collection-toolbar select { padding:0 .9rem; color:var(--text); }
.collection-search { display:grid; grid-template-columns:22px 1fr; align-items:center; gap:.5rem; padding:0 .9rem; }
.collection-search svg,.collection-documents-head label svg,.collection-available-search label svg { width:20px; fill:none; stroke:var(--muted); stroke-linecap:round; stroke-width:1.8; }
.collection-search input,.collection-documents-head input,.collection-available-search input { min-width:0; border:0; outline:0; background:transparent; color:var(--text); }
.collection-summary { display:grid; grid-template-columns:repeat(4,1fr); margin:1rem 0; overflow:hidden; border-radius:18px; background:var(--blue-dark); color:#fff; box-shadow:0 14px 30px rgba(11,44,102,.16); }
.collection-summary div { padding:1rem 1.35rem; border-right:1px solid rgba(255,255,255,.16); }
.collection-summary div:last-child { border:0; }
.collection-summary span,.collection-summary strong { display:block; }
.collection-summary span { color:#bdd0f2; font-size:.76rem; }
.collection-summary strong { margin-top:.2rem; font-size:1.45rem; }
.collection-card-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; }
.collection-card { --collection-color:#2367b1; position:relative; display:flex; min-height:255px; padding:1.25rem; flex-direction:column; overflow:hidden; border:1px solid var(--border); border-radius:18px; background:#fff; box-shadow:0 10px 26px rgba(22,35,64,.05); }
.collection-card::before { position:absolute; inset:0 auto 0 0; width:5px; background:var(--collection-color); content:""; }
.collection-card.invoices { --collection-color:#d62c33; }.collection-card.municipal { --collection-color:#15835c; }.collection-card.project { --collection-color:#d77b09; }.collection-card.legal { --collection-color:#7544d7; }
.collection-card-top { display:flex; align-items:center; justify-content:space-between; }
.collection-card-badges,.collection-hero-badges { display:flex; align-items:center; gap:.4rem; }
.collection-private-badge { display:inline-flex; align-items:center; gap:.3rem; padding:.3rem .6rem; border-radius:999px; background:#eef0ff; color:#4338a8; font-size:.68rem; font-weight:800; }
.collection-private-badge svg { width:13px; height:13px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }
.collection-private-badge.light { margin-bottom:.6rem; background:rgba(255,255,255,.16); color:#fff; }
.collection-folder { display:grid; width:46px; height:46px; place-items:center; border-radius:13px; background:color-mix(in srgb,var(--collection-color) 11%,white); color:var(--collection-color); }
.collection-folder svg { width:25px; fill:none; stroke:currentColor; stroke-linejoin:round; stroke-width:1.8; }
.collection-state { padding:.3rem .65rem; border-radius:999px; background:var(--green-soft); color:var(--green); font-size:.7rem; font-weight:800; }
.collection-state.closed { background:#eef1f5; color:#69758a; }
.collection-card h2 { margin:1rem 0 .3rem; color:var(--blue-dark); font-size:1.08rem; }
.collection-card > p { display:-webkit-box; min-height:2.6rem; margin:0; overflow:hidden; color:var(--muted); font-size:.8rem; -webkit-box-orient:vertical; -webkit-line-clamp:2; }
.collection-card dl { display:grid; grid-template-columns:1fr 1fr; gap:.7rem; margin:1rem 0; }
.collection-card dl div { padding:.7rem; border-radius:11px; background:#f6f8fc; }
.collection-card dt { color:var(--muted); font-size:.67rem; }.collection-card dd { margin:.18rem 0 0; color:var(--text); font-size:.83rem; font-weight:800; }
.collection-card > a { display:flex; align-items:center; justify-content:space-between; margin-top:auto; color:var(--blue); font-size:.8rem; font-weight:800; text-decoration:none; }
.collection-card > a svg,.collection-back svg,.collection-row-actions svg { width:19px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }
.collection-empty { min-height:330px; padding:4rem 2rem; text-align:center; }.collection-empty > svg { width:48px; fill:none; stroke:#7890b4; stroke-width:1.5; }.collection-empty h2 { color:var(--blue-dark); }
.collection-modal[hidden] { display:none; }
.partition-card-actions { display:flex; flex-wrap:wrap; gap:.55rem; margin:.9rem 0; }
.partition-card-actions .btn { font-size:.78rem; }
.partition-assignment-list { display:grid; gap:.55rem; max-height:460px; overflow:auto; padding:1.1rem 1.25rem; }
.partition-assignment-option { display:flex; align-items:center; gap:.75rem; padding:.8rem; border:1px solid var(--border); border-radius:12px; cursor:pointer; }
.partition-assignment-option:has(input:checked) { border-color:var(--blue); background:color-mix(in srgb, var(--blue) 8%, transparent); }
.partition-assignment-option input { width:18px; height:18px; accent-color:var(--blue); }
.partition-assignment-option strong,.partition-assignment-option small { display:block; }
.partition-assignment-option small { margin-top:.2rem; color:var(--muted); font-size:.75rem; }
.partition-assignment-option.disabled { cursor:not-allowed; opacity:.62; background:var(--surface-muted); }
.partition-assignment-option.disabled input { cursor:not-allowed; }
.collection-modal { position:fixed; inset:0; z-index:150; display:grid; padding:1.25rem; place-items:center; }
.collection-modal-backdrop { position:absolute; inset:0; display:block; width:100%; border:0; background:rgba(10,27,57,.62); }
.collection-modal-card { position:relative; z-index:1; width:min(560px,100%); max-height:calc(100vh - 2.5rem); overflow:auto; border-radius:20px; background:#fff; box-shadow:0 28px 75px rgba(5,16,36,.3); }
.collection-modal-head { display:flex; align-items:start; justify-content:space-between; gap:1rem; padding:1.25rem; border-bottom:1px solid var(--border); }
.collection-modal-head h2,.collection-modal-head p { margin:0; }.collection-modal-head h2 { color:var(--blue-dark); }.collection-modal-head p { margin-top:.25rem; color:var(--muted); font-size:.8rem; }
.collection-create-form { display:grid; gap:1rem; padding:1.25rem; }.collection-create-form > label { display:grid; gap:.4rem; color:var(--text); font-size:.8rem; font-weight:800; }.collection-create-form > label > span { color:var(--muted); font-weight:400; }.collection-create-form > label:not(.collection-privacy-option) input,.collection-create-form select,.collection-create-form textarea { width:100%; padding:.8rem; border:1px solid var(--border); border-radius:12px; color:var(--text); font:inherit; font-weight:400; }
.collection-color-field { margin:0; padding:0; border:0; }.collection-color-field legend { margin-bottom:.5rem; color:var(--text); font-size:.8rem; font-weight:800; }.collection-color-palette { display:flex; flex-wrap:wrap; gap:.55rem; }.collection-color-palette label { cursor:pointer; }.collection-color-palette input { position:absolute; opacity:0; pointer-events:none; }.collection-color-palette span { display:block; width:30px; height:30px; border:4px solid #fff; border-radius:50%; background:var(--swatch); box-shadow:0 0 0 1px #cbd5e1; }.collection-color-palette input:checked + span { box-shadow:0 0 0 3px color-mix(in srgb,var(--swatch) 35%,white); transform:scale(1.08); }
.collection-privacy-option { display:flex!important; grid-template-columns:none!important; align-items:flex-start; gap:.75rem!important; padding:.9rem; border:1px solid var(--border); border-radius:13px; background:#f8faff; cursor:pointer; }.collection-privacy-option > input { width:18px!important; height:18px; margin-top:.12rem; accent-color:var(--blue-dark); }.collection-privacy-option > span { display:grid; gap:.15rem; }.collection-privacy-option strong { color:var(--blue-dark); }.collection-privacy-option small { color:var(--muted); font-weight:400; line-height:1.4; }
.collection-modal-actions { display:flex; justify-content:flex-end; gap:.65rem; padding-top:.25rem; }
.collection-back { display:inline-flex; align-items:center; gap:.35rem; margin-bottom:.8rem; color:var(--blue); font-size:.8rem; font-weight:800; text-decoration:none; }
.collection-detail-hero { display:flex; align-items:end; justify-content:space-between; gap:1.5rem; padding:1.55rem; border-left:6px solid var(--collection-color,#2367b1); border-radius:20px; background:linear-gradient(120deg,#0b2c66,#164f9e); color:#fff; box-shadow:0 18px 36px rgba(11,44,102,.2); }
.collection-detail-hero h1,.collection-detail-hero p { margin:0; }.collection-detail-hero h1 { font-size:1.8rem; }.collection-detail-hero p { max-width:760px; margin-top:.35rem; color:#cbdaf2; }
.collection-detail-hero dl { display:flex; gap:1.5rem; margin:1.15rem 0 0; }.collection-detail-hero dt { color:#9eb7dd; font-size:.68rem; }.collection-detail-hero dd { margin:.2rem 0 0; font-size:.82rem; font-weight:800; }
.collection-hero-actions { display:flex; gap:.65rem; flex-wrap:wrap; }.collection-hero-actions .btn { white-space:nowrap; }.collection-download { background:var(--red); color:#fff; }.collection-add { background:#fff; color:var(--blue-dark); }
.collection-detail-layout { display:grid; grid-template-columns:minmax(0,1fr) 315px; gap:1rem; margin-top:1rem; }
.collection-documents-panel { padding:0; overflow:hidden; }
.collection-documents-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1.2rem; border-bottom:1px solid var(--border); }
.collection-documents-head h2,.collection-documents-head p { margin:0; }.collection-documents-head h2 { color:var(--blue-dark); font-size:1.05rem; }.collection-documents-head p { margin-top:.2rem; color:var(--muted); font-size:.75rem; }
.collection-documents-head label,.collection-available-search label { display:grid; grid-template-columns:20px minmax(0,1fr); align-items:center; gap:.5rem; min-width:260px; min-height:42px; padding:0 .8rem; border:1px solid var(--border); border-radius:11px; background:#f9fbfe; }
.collection-inner-search { display:flex; align-items:center; gap:.45rem; }.collection-inner-search button,.collection-inner-search a { min-height:42px; padding:0 .85rem; border:1px solid var(--border); border-radius:11px; background:#fff; color:var(--blue-dark); font:inherit; font-size:.72rem; font-weight:800; cursor:pointer; text-decoration:none; display:grid; place-items:center; }.collection-inner-search button { border-color:var(--blue-dark); background:var(--blue-dark); color:#fff; }
.collection-document-table-head,.collection-document-row { display:grid; grid-template-columns:minmax(260px,1fr) 110px 110px 72px; align-items:center; gap:1rem; }
.collection-document-table-head { min-height:38px; padding:0 1.2rem; background:#fafbfd; color:#78849a; font-size:.64rem; font-weight:800; text-transform:uppercase; }
.collection-document-row { min-height:76px; padding:.75rem 1.2rem; border-top:1px solid #e9edf4; }
.collection-document-row:hover { background:#fbfcff; }
.collection-document-copy { display:flex; align-items:center; gap:.75rem; min-width:0; }.collection-document-copy strong,.collection-document-copy small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.collection-document-copy strong { color:var(--blue-dark); font-size:.82rem; }.collection-document-copy small { margin-top:.2rem; color:var(--muted); font-size:.68rem; }
.collection-inline-private { display:inline-flex!important; width:max-content; margin:0 0 0 .35rem!important; padding:.15rem .4rem; border-radius:999px; background:#eef0ff; color:#4338a8!important; font-size:.58rem!important; font-weight:800; vertical-align:middle; }
.collection-document-icon { display:grid; flex:0 0 auto; width:39px; height:39px; place-items:center; border-radius:11px; background:#eaf2ff; color:#1b5bae; }.collection-document-icon.type-factura { background:#fff0f1; color:#cf2f38; }.collection-document-icon.type-imagen { background:#eaf8ef; color:#258253; }.collection-document-icon.type-plano { background:#fff4df; color:#b66a00; }.collection-document-icon svg { width:21px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.8; }
.collection-document-row > span:not(:first-child),.collection-document-row time { color:var(--muted); font-size:.72rem; }
.collection-row-actions { display:flex; justify-content:flex-end; gap:.3rem; }.collection-row-actions a,.collection-row-actions button { display:grid; width:34px; height:34px; padding:0; place-items:center; border:1px solid var(--border); border-radius:9px; background:#fff; color:var(--blue); }.collection-row-actions form { margin:0; }.collection-row-actions button { color:#a9272f; }
.collection-documents-empty { padding:4rem 1rem; text-align:center; }.collection-documents-empty h3,.collection-documents-empty p { margin:0; }.collection-documents-empty h3 { color:var(--blue-dark); }.collection-documents-empty p { margin-top:.3rem; color:var(--muted); }
.collection-detail-side { display:grid; align-content:start; gap:1rem; }.collection-detail-side .content-panel { padding:1.2rem; }.collection-detail-side h2 { margin:0 0 .8rem; color:var(--blue-dark); font-size:1rem; }.collection-detail-side dl { margin:0; }.collection-detail-side dl div { display:flex; justify-content:space-between; gap:1rem; padding:.7rem 0; border-bottom:1px solid #e9edf4; }.collection-detail-side dl div:last-child { border:0; }.collection-detail-side dt { color:var(--muted); font-size:.72rem; }.collection-detail-side dd { margin:0; color:var(--text); font-size:.75rem; font-weight:800; text-align:right; }
.collection-control p { color:var(--muted); font-size:.76rem; }.collection-control .btn { width:100%; }
.collection-add-documents-card { width:min(850px,100%); }.collection-available-search { display:grid; grid-template-columns:minmax(250px,1fr) 160px 90px; gap:.65rem; padding:1rem 1.2rem; border-bottom:1px solid var(--border); }.collection-available-search label { min-width:0; }.collection-available-search select { border:1px solid var(--border); border-radius:11px; padding:0 .7rem; }
.collection-candidate-list { display:grid; max-height:420px; overflow:auto; }.collection-candidate { display:grid; grid-template-columns:22px 40px minmax(0,1fr); align-items:center; gap:.75rem; padding:.85rem 1.2rem; border-bottom:1px solid #e9edf4; cursor:pointer; }.collection-candidate:hover { background:#f7faff; }.collection-candidate input { width:18px; height:18px; accent-color:var(--blue); }.collection-candidate strong,.collection-candidate small { display:block; }.collection-candidate strong { color:var(--blue-dark); font-size:.8rem; }.collection-candidate small { margin-top:.2rem; color:var(--muted); font-size:.68rem; }.collection-add-documents-card .collection-modal-actions { padding:1rem 1.2rem; }.collection-available-empty { padding:3rem 1rem; color:var(--muted); text-align:center; }
.collection-privacy-decision-body { display:grid; grid-template-columns:1fr 1fr; gap:.7rem; padding:1.25rem; }.collection-privacy-decision-body > p { grid-column:1 / -1; margin:0 0 .4rem; color:var(--muted); }.collection-privacy-decision-body form,.collection-privacy-decision-body .btn { width:100%; }

@media (max-width:1000px) { .collection-card-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }.collection-detail-layout { grid-template-columns:1fr; }.collection-detail-side { grid-template-columns:1fr 1fr; } }
@media (max-width:720px) {
  .collection-page-heading { display:grid; }.collection-page-heading h1 { font-size:1.7rem; }.collection-page-heading .btn { width:100%; }
  .collection-toolbar { grid-template-columns:1fr; }.collection-summary { grid-template-columns:1fr 1fr; }.collection-summary div:nth-child(2) { border-right:0; }.collection-summary div:nth-child(-n+2) { border-bottom:1px solid rgba(255,255,255,.16); }
  .collection-card-grid { grid-template-columns:1fr; }.collection-card { min-height:225px; }
  .collection-detail-hero { display:grid; padding:1.2rem; }.collection-detail-hero h1 { font-size:1.45rem; }.collection-detail-hero dl { display:grid; grid-template-columns:1fr 1fr; gap:.8rem; }.collection-hero-actions,.collection-hero-actions .btn { width:100%; }
  .collection-documents-head { display:grid; }.collection-documents-head label { min-width:0; width:100%; }.collection-inner-search { display:grid; grid-template-columns:minmax(0,1fr) auto; width:100%; }.collection-inner-search label { grid-column:1 / -1; }.collection-inner-search button,.collection-inner-search a { min-height:40px; }
  .collection-document-table-head { display:none; }.collection-document-row { grid-template-columns:1fr auto; gap:.7rem; padding:1rem; }.collection-document-row > span:nth-child(2),.collection-document-row > time { grid-column:1; }.collection-row-actions { grid-column:2; grid-row:1 / span 3; flex-direction:column; }
  .collection-detail-side { grid-template-columns:1fr; }.collection-available-search { grid-template-columns:1fr; }.collection-available-search label { min-height:46px; }.collection-available-search select { min-height:46px; }
  .collection-modal { padding:0; }.collection-modal-card { width:100%; max-height:100vh; min-height:100vh; border-radius:0; }.collection-modal-actions { position:sticky; bottom:0; background:#fff; }
  .collection-card-badges { align-items:flex-end; flex-direction:column; }.collection-privacy-decision-body { grid-template-columns:1fr; }.collection-privacy-decision-body > p { grid-column:auto; }
}
.private-archive-heading { margin-bottom:1rem; }
.private-ownership-panel { margin-top:1rem; }
.private-ownership-actions,.private-transfer-form { display:flex; align-items:end; gap:.75rem; flex-wrap:wrap; }
.private-transfer-form { flex:1 1 38rem; }
.private-transfer-form label { flex-basis:100%; font-weight:700; }
.private-transfer-form .select { flex:1 1 20rem; }
@media (max-width:700px) {
  .private-ownership-actions,.private-transfer-form { align-items:stretch; flex-direction:column; }
  .private-transfer-form,.private-transfer-form .select { flex-basis:auto; width:100%; }
}
.receipt-page-heading { align-items: flex-start; }
.receipt-availability { display: inline-flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid #cfe7da; border-radius: 12px; background: #f0faf5; color: #23734d; font-size: .78rem; font-weight: 800; }
.receipt-availability i { width: 8px; height: 8px; border-radius: 50%; background: #2bab69; }
.receipt-workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(350px, .72fr); gap: 22px; align-items: start; }
.receipt-workspace > .validation-summary { grid-column: 1 / -1; }
.receipt-main-panel, .receipt-payment-panel { padding: 28px; }
.receipt-payment-panel { position: sticky; top: 24px; }
.receipt-form-section + .receipt-form-section { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--border); }
.receipt-section-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.receipt-section-heading h2, .receipt-payment-title h2 { margin: 0; font-size: 1.32rem; }
.receipt-section-heading p, .receipt-payment-title p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.receipt-number-preview { align-self: flex-start; padding: 9px 12px; border: 1px solid #d7e4f6; border-radius: 10px; background: #edf4ff; color: var(--blue); font-size: .76rem; letter-spacing: .05em; }
.receipt-series-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.receipt-choice { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 14px 15px; border: 1px solid var(--border); border-radius: 14px; background: #fff; color: var(--blue-dark); text-align: left; }
.receipt-choice > span { width: 21px; height: 21px; flex: 0 0 auto; border: 2px solid #99a8ba; border-radius: 50%; }
.receipt-choice strong, .receipt-choice small { display: block; }
.receipt-choice small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.receipt-choice.is-selected { border-color: #6288bd; background: #edf4fd; box-shadow: 0 0 0 3px rgba(18,59,120,.07); }
.receipt-choice.is-selected > span { border: 6px solid var(--blue); }
.receipt-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.receipt-field-grid label, .receipt-condition, .receipt-method { min-width: 0; }
.receipt-field-grid label > span, .receipt-condition legend, .receipt-method legend { display: block; margin-bottom: 8px; color: #173057; font-size: .82rem; font-weight: 800; }
.receipt-field-grid input, .receipt-field-grid textarea { width: 100%; border: 1px solid var(--border); border-radius: 13px; background: #fbfcfe; color: var(--blue-dark); outline: none; }
.receipt-field-grid input { height: 51px; padding: 0 15px; }
.receipt-field-grid textarea { min-height: 96px; padding: 14px 15px; resize: vertical; }
.receipt-field-grid input:focus, .receipt-field-grid textarea:focus { border-color: #6e93c6; background: #fff; box-shadow: 0 0 0 3px #eaf1fb; }
.receipt-field-grid .wide { grid-column: 1 / -1; }
.receipt-money { position: relative; display: block; }
.receipt-money b { position: absolute; z-index: 1; top: 16px; left: 15px; }
.receipt-money input { padding-left: 36px; }
.receipt-condition, .receipt-method { margin: 0; padding: 0; border: 0; }
.receipt-condition label, .receipt-method label { display: inline-flex; align-items: center; gap: 7px; min-height: 51px; margin-right: 8px; padding: 0 14px; border: 1px solid var(--border); border-radius: 13px; background: #fff; font-weight: 700; }
.receipt-condition input, .receipt-method input { width: auto; height: auto; }
.receipt-payment-title { display: flex; gap: 13px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.receipt-payment-icon { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: #edf4ff; color: var(--blue); font-size: 1.3rem; }
.receipt-payment-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #f7f9fc; cursor: pointer; }
.receipt-payment-toggle strong, .receipt-payment-toggle small { display: block; }
.receipt-payment-toggle small { margin-top: 4px; color: var(--muted); font-size: .73rem; }
.receipt-payment-toggle input { position: absolute; opacity: 0; }
.receipt-payment-toggle i { position: relative; width: 48px; height: 28px; flex: 0 0 auto; border-radius: 99px; background: #bcc7d5; }
.receipt-payment-toggle i::after { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px #8793a6; content: ""; transition: .2s; }
.receipt-payment-toggle input:checked + i { background: var(--blue); }
.receipt-payment-toggle input:checked + i::after { transform: translateX(20px); }
.receipt-payment-fields { margin-top: 15px; padding: 19px; border: 1px solid #ccd9ea; border-radius: 16px; background: #f7faff; }
.receipt-method { margin-bottom: 17px; }
.receipt-file-field small { display: block; margin-top: 7px; color: var(--muted); font-size: .72rem; }
.receipt-file-field input[type=file] { height: auto; padding: 12px; background: #fff; }
.receipt-form-notice { display: flex; gap: 8px; margin-top: 22px; padding: 12px; border: 1px solid #f0dfac; border-radius: 12px; background: #fff9e9; color: #69531b; font-size: .75rem; line-height: 1.45; }
.receipt-form-actions { display: grid; grid-template-columns: 1fr 1.45fr; gap: 10px; margin-top: 15px; }
.nav-receipt { color: #b8242d !important; }
@media (max-width: 1050px) { .receipt-workspace { grid-template-columns: 1fr; } .receipt-payment-panel { position: static; } }
.receipt-later-payment { margin-top: 22px; }
.receipt-later-payment-form { margin-top: 18px; }
.receipt-customer-search { position: relative; display: block; }
.receipt-customer-search input { padding-right: 56px; }
.receipt-customer-search-button { position: absolute; top: 6px; right: 6px; width: 39px; height: 39px; padding: 0; border: 0; border-radius: 10px; background: #edf4ff; color: var(--blue); font-size: 1.45rem; line-height: 1; cursor: pointer; }
.receipt-customer-search-button:hover, .receipt-customer-search-button:focus-visible { background: #dceaff; outline: 2px solid #93b8ee; outline-offset: 1px; }
.receipt-customer-search-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.receipt-customer-modal[hidden] { display: none; }
.receipt-customer-modal { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; }
.receipt-customer-backdrop { position: absolute; inset: 0; background: rgba(10, 26, 54, .42); }
.receipt-customer-dialog { position: relative; width: min(560px, 100%); max-height: min(700px, calc(100vh - 40px)); overflow: auto; padding: 25px; border: 1px solid #d4e0ef; border-radius: 18px; background: #fff; box-shadow: 0 24px 70px rgba(8, 31, 70, .22); }
.receipt-customer-dialog-heading { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; padding-bottom: 17px; border-bottom: 1px solid var(--border); }
.receipt-customer-dialog-heading h2 { margin: 0; color: var(--blue-dark); font-size: 1.3rem; }
.receipt-customer-dialog-heading p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.receipt-customer-dialog .icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--blue-dark); font-size: 1.4rem; cursor: pointer; }
.receipt-customer-dialog-search { display: block; margin: 18px 0 11px; }
.receipt-customer-dialog-search > span { display: block; margin-bottom: 7px; color: #173057; font-size: .82rem; font-weight: 800; }
.receipt-customer-dialog-search input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid var(--border); border-radius: 11px; outline: none; }
.receipt-customer-dialog-search input:focus { border-color: #6e93c6; box-shadow: 0 0 0 3px #eaf1fb; }
.receipt-customer-results-label { margin: 0 0 8px; color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.receipt-customer-results { display: grid; gap: 7px; max-height: 360px; overflow: auto; }
.receipt-customer-result { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px; border: 1px solid #dce5f1; border-radius: 11px; background: #fbfcfe; color: var(--blue-dark); text-align: left; cursor: pointer; }
.receipt-customer-result:hover, .receipt-customer-result:focus-visible { border-color: #6e93c6; background: #f0f6ff; outline: none; }
.receipt-customer-result[hidden] { display: none; }
.receipt-customer-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e6efff; color: var(--blue); font-weight: 800; }
.receipt-customer-result strong, .receipt-customer-result small { display: block; }
.receipt-customer-result small { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.receipt-customer-empty { margin: 10px 0; color: var(--muted); font-size: .86rem; }
.receipt-customer-manual { width: 100%; margin-top: 15px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--blue); font-weight: 700; cursor: pointer; }
.receipt-customer-manual:hover { background: #f1f6ff; }
body.receipt-modal-open { overflow: hidden; }
@media (max-width: 700px) { .receipt-main-panel, .receipt-payment-panel { padding: 19px 17px; } .receipt-series-grid, .receipt-field-grid { grid-template-columns: 1fr; } .receipt-field-grid .wide { grid-column: auto; } .receipt-section-heading { display: block; } .receipt-number-preview { display: inline-block; margin-top: 11px; } .receipt-condition label, .receipt-method label { width: calc(50% - 7px); justify-content: center; margin-right: 3px; } .receipt-form-actions { grid-template-columns: 1fr; } .receipt-availability { display: none; } }

/* Modo oscuro: capa visual, sin cambiar operaciones ni almacenamiento. */
.notification-center { display: flex; align-items: center; gap: 10px; }
.theme-toggle { position: relative; display: flex; width: 48px; height: 48px; align-items: center; justify-content: space-between; padding: 5px 7px; border: 1px solid #d6e0ee; border-radius: 14px; background: #fff; color: #0c3b80; box-shadow: 0 8px 24px rgba(17,49,91,.08); cursor: pointer; transition: .18s ease; }
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: #9eb7dc; background: #f1f6fd; outline: none; }
.theme-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(17,61,141,.18), 0 8px 24px rgba(17,49,91,.08); }
.theme-toggle-icon { position: relative; z-index: 1; display: grid; width: 15px; height: 15px; place-items: center; opacity: .72; }
.theme-toggle-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.theme-toggle-moon svg { fill: currentColor; stroke: none; }
.theme-toggle-thumb { position: absolute; top: 5px; left: 5px; width: 20px; height: 36px; border-radius: 10px; background: #eef4ff; transition: transform .2s ease, background .2s ease; }
html[data-theme="dark"] { color-scheme: dark; --background: #101827; --surface: #182438; --text: #e7edf8; --muted: #aab8cf; --border: #344866; --blue: #8fb8ff; --blue-dark: #c3d8ff; --blue-soft: #1d3152; --red-soft: #3b2028; --green-soft: #18382c; --shadow: 0 16px 42px rgba(0,0,0,.28); }
html[data-theme="dark"] .theme-toggle { border-color: #40577e; background: #1b2942; color: #dce9ff; }
html[data-theme="dark"] .theme-toggle-thumb { transform: translateX(18px); background: #263b61; }
html[data-theme="dark"] .theme-toggle:hover, html[data-theme="dark"] .theme-toggle:focus-visible { background: #243655; }
html[data-theme="dark"] body { background: var(--background); }
html[data-theme="dark"] .sidebar, html[data-theme="dark"] .mobile-header { background: #121d2e; }
html[data-theme="dark"] .side-nav a, html[data-theme="dark"] .mobile-side-nav a, html[data-theme="dark"] .mobile-nav-group-toggle { color: #b9c7dc; }
html[data-theme="dark"] .side-nav a:hover, html[data-theme="dark"] .mobile-side-nav a:hover, html[data-theme="dark"] .mobile-nav-group-toggle:hover { background: #1c2d48; color: #edf4ff; }
html[data-theme="dark"] .side-nav a.active, html[data-theme="dark"] .mobile-side-nav a.active { background: #203b67; color: #e8f1ff; }
html[data-theme="dark"] .side-nav .nav-primary, html[data-theme="dark"] .mobile-side-nav .mobile-nav-primary { background: #3b2028; color: #ffb7bd; }
html[data-theme="dark"] .side-footer details, html[data-theme="dark"] .mobile-side-footer { background: #16243a; border-color: var(--border); }
html[data-theme="dark"] .content-panel, html[data-theme="dark"] .welcome-panel, html[data-theme="dark"] .phase-note, html[data-theme="dark"] .metric, html[data-theme="dark"] .card, html[data-theme="dark"] .panel, html[data-theme="dark"] .login-card { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
html[data-theme="dark"] .input, html[data-theme="dark"] .select, html[data-theme="dark"] .file-input, html[data-theme="dark"] textarea, html[data-theme="dark"] input, html[data-theme="dark"] select { background: #121e31; border-color: #3a5070; color: var(--text); }
html[data-theme="dark"] .input::placeholder, html[data-theme="dark"] textarea::placeholder, html[data-theme="dark"] input::placeholder { color: #8090aa; }
html[data-theme="dark"] .notification-button { border-color: #40577e; background: #1b2942; color: #dce9ff; box-shadow: 0 8px 24px rgba(0,0,0,.24); }
html[data-theme="dark"] .notification-button:hover { background: #243655; }
html[data-theme="dark"] .notification-count { border-color: #1b2942; }
html[data-theme="dark"] .notification-panel, html[data-theme="dark"] .notification-panel-head, html[data-theme="dark"] .notification-history-item { background: #182438; border-color: #344866; }
html[data-theme="dark"] .notification-panel-item { color: #dce9ff; border-color: #2d405d; }
html[data-theme="dark"] .notification-panel-item:hover, html[data-theme="dark"] .notification-history-item:hover { background: #213451; }
html[data-theme="dark"] .notification-panel-item span, html[data-theme="dark"] .notification-panel-item small, html[data-theme="dark"] .notification-panel-empty, html[data-theme="dark"] .notification-history-item p, html[data-theme="dark"] .notification-history-item small { color: #aab8cf; }
html[data-theme="dark"] .desktop-home-query, html[data-theme="dark"] .desktop-home-search, html[data-theme="dark"] .mobile-home-searchbox, html[data-theme="dark"] .tag-picker-search, html[data-theme="dark"] .tag-admin-search { background: #121e31; border-color: #3a5070; }
html[data-theme="dark"] .tag-picker-popover, html[data-theme="dark"] .tag-row-menu > div, html[data-theme="dark"] .tag-editor, html[data-theme="dark"] .receipt-customer-dialog { background: #182438; border-color: #344866; box-shadow: var(--shadow); }
html[data-theme="dark"] .tag-picker-option:hover, html[data-theme="dark"] .tag-row-menu a:hover, html[data-theme="dark"] .tag-row-menu button:hover, html[data-theme="dark"] .receipt-customer-result:hover { background: #213451; }
html[data-theme="dark"] .tag-live-preview, html[data-theme="dark"] .tag-admin-table-head, html[data-theme="dark"] .receipt-payment-fields { background: #121e31; border-color: #344866; }
html[data-theme="dark"] .tag-admin-row { background: #182438; border-color: #2d405d; }
html[data-theme="dark"] .tag-admin-row:hover { background: #1e2e48; }
html[data-theme="dark"] .receipt-choice, html[data-theme="dark"] .receipt-condition label, html[data-theme="dark"] .receipt-method label, html[data-theme="dark"] .receipt-payment-toggle, html[data-theme="dark"] .receipt-customer-result, html[data-theme="dark"] .receipt-customer-manual { background: #182438; border-color: #344866; color: var(--text); }
html[data-theme="dark"] .receipt-choice.is-selected { background: #203b67; }
html[data-theme="dark"] .receipt-field-grid input, html[data-theme="dark"] .receipt-field-grid textarea, html[data-theme="dark"] .receipt-file-field input[type=file], html[data-theme="dark"] .receipt-customer-dialog-search input { background: #121e31; border-color: #3a5070; color: var(--text); }
html[data-theme="dark"] .sidebar-backdrop { background: rgba(3,9,20,.62); }

/* Botón de tema: alterna un único icono sin modificar la disposición existente. */
.theme-toggle {
  display: inline-grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid #d6e0ee;
  border-radius: 14px;
  background: #fff;
  color: #123b7a;
  box-shadow: 0 8px 24px rgba(17,49,91,.08);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: #9eb7dc; background: #f1f6fd; outline: none; }
.theme-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(17,61,141,.18); }
.theme-toggle-icon { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; }
.theme-toggle-icon[hidden] { display: none !important; }
.theme-toggle-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.theme-toggle-moon svg { fill: currentColor; stroke: none; }
.theme-toggle-thumb { display: none; }

/* Paleta de referencia: azul marino, superficies azul pizarra y acento rosa. */
html[data-theme="dark"] {
  --background: #0b1326;
  --surface: #1d2a40;
  --text: #e1e8ff;
  --muted: #aebbd4;
  --border: #2d3d59;
  --blue: #b7d0ff;
  --blue-dark: #e1e8ff;
  --blue-soft: #273551;
  --red-soft: #3d1d2a;
  --green-soft: #15392f;
  --green: #54d6a1;
  --shadow: 0 16px 42px rgba(0,0,0,.28);
}
html[data-theme="dark"] body { background: var(--background); color: var(--text); }
html[data-theme="dark"] .theme-toggle { border-color: #2d3d59; background: #121b30; color: #d8e5ff; box-shadow: none; }
html[data-theme="dark"] .theme-toggle:hover, html[data-theme="dark"] .theme-toggle:focus-visible { border-color: #708fca; background: #1b2942; }
html[data-theme="dark"] .sidebar, html[data-theme="dark"] .mobile-header { background: #121b30; border-color: #293752; }
html[data-theme="dark"] .side-nav a, html[data-theme="dark"] .mobile-side-nav a, html[data-theme="dark"] .mobile-nav-group-toggle { color: #c8d4ee; }
html[data-theme="dark"] .side-nav a:hover, html[data-theme="dark"] .mobile-side-nav a:hover, html[data-theme="dark"] .mobile-nav-group-toggle:hover { background: #202e48; color: #f0f4ff; }
html[data-theme="dark"] .side-nav a.active, html[data-theme="dark"] .mobile-side-nav a.active { background: #273551; color: #d7e5ff; }
html[data-theme="dark"] .side-nav .nav-primary, html[data-theme="dark"] .mobile-side-nav .mobile-nav-primary { background: #351c2c; color: #ff5b83; }
html[data-theme="dark"] .content-panel, html[data-theme="dark"] .welcome-panel, html[data-theme="dark"] .phase-note, html[data-theme="dark"] .metric, html[data-theme="dark"] .card, html[data-theme="dark"] .panel, html[data-theme="dark"] .login-card { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea, html[data-theme="dark"] .input, html[data-theme="dark"] .select, html[data-theme="dark"] .file-input { background: #0f172b; border-color: #30415f; color: var(--text); }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #8291ad; }
html[data-theme="dark"] .notification-button { border-color: #2d3d59; background: #121b30; color: #d8e5ff; box-shadow: none; }
html[data-theme="dark"] .notification-button:hover { background: #1b2942; }
html[data-theme="dark"] .notification-panel, html[data-theme="dark"] .notification-panel-head, html[data-theme="dark"] .notification-history-item, html[data-theme="dark"] .receipt-customer-dialog { background: #1d2a40; border-color: var(--border); }
html[data-theme="dark"] .notification-panel-item:hover, html[data-theme="dark"] .notification-history-item:hover, html[data-theme="dark"] .receipt-customer-result:hover { background: #273551; }
html[data-theme="dark"] .btn-primary, html[data-theme="dark"] .btn-danger, html[data-theme="dark"] button[type="submit"].btn-primary { background: #ed1f55; border-color: #ed1f55; color: #fff; }

/* Ajustes finales del tema oscuro: conservar la estructura y mejorar contraste. */
html[data-theme="dark"] .desktop-home-search,
html[data-theme="dark"] .desktop-home-recent,
html[data-theme="dark"] .desktop-home-utilities section { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .desktop-home-summary { background: #172e55; color: #f0f5ff; }
html[data-theme="dark"] .desktop-home-summary > a { color: #f0f5ff; border-color: rgba(220,233,255,.2); }
html[data-theme="dark"] .desktop-home-summary > a span { color: #b8c9e8; }
html[data-theme="dark"] .desktop-home-document-row { border-color: #2b3d5a; }
html[data-theme="dark"] .desktop-home-document-row:hover,
html[data-theme="dark"] .desktop-home-document-row:focus-visible { background: #223452; }
html[data-theme="dark"] .desktop-home-table-head { border-color: #2b3d5a; color: #aebbd4; }
html[data-theme="dark"] .desktop-home-system p { color: #d5e0f5; }
html[data-theme="dark"] .mobile-summary-card { background: #172e55; }

/* El botón muestra un solo icono: sol en modo claro y luna en modo oscuro. */
.theme-toggle-icon[hidden] { display: none !important; }
html[data-theme="light"] .theme-toggle-moon,
html:not([data-theme]) .theme-toggle-moon { display: none; }
html[data-theme="dark"] .theme-toggle-sun { display: none; }
html[data-theme="dark"] .theme-toggle-moon { display: inline-flex; }

/* Estado final del control de tema: botón único, sin apariencia de switch,
   con contraste suficiente para distinguir el icono activo en ambos temas. */
.theme-toggle {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 14px;
}

.theme-toggle .theme-toggle-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
}

.theme-toggle .theme-toggle-icon[hidden] { display: none !important; }
.theme-toggle .theme-toggle-icon svg { width: 24px; height: 24px; }

html[data-theme="light"] .theme-toggle {
  color: #1d4f96;
  background: #ffffff;
  border-color: #b6c9e8;
}

html[data-theme="light"] .theme-toggle-sun svg { stroke: #1d4f96; }

html[data-theme="dark"] .theme-toggle {
  color: #ffe49a;
  background: #172b4c;
  border-color: #6f8fca;
}

html[data-theme="dark"] .theme-toggle-moon svg {
  fill: #ffe49a;
  stroke: none;
}

/* Contraste de controles y documentos sobre superficies oscuras. */
.theme-toggle .theme-toggle-sun,
.theme-toggle .theme-toggle-moon { display: none !important; }
html[data-theme="light"] .theme-toggle .theme-toggle-sun,
html:not([data-theme]) .theme-toggle .theme-toggle-sun,
html[data-theme="dark"] .theme-toggle .theme-toggle-moon { display: inline-flex !important; }
html[data-theme="dark"] .desktop-user-menu summary,
html[data-theme="dark"] .mobile-side-footer { background: #172b4c; border-color: #34496d; color: #e1e8ff; }
html[data-theme="dark"] .desktop-user-menu summary small,
html[data-theme="dark"] .mobile-user-copy small { color: #aebbd4; }
html[data-theme="dark"] .desktop-user-menu form { background: #172238; border-color: #34496d; }
html[data-theme="dark"] .desktop-user-menu form button { background: #4b2632; color: #ffb6c1; }
html[data-theme="dark"] .mobile-side-footer button { background: #172b4c; border-color: #34496d; color: #b7d0ff; }

html[data-theme="dark"] .desktop-home-file-icon,
html[data-theme="dark"] .mobile-document-icon,
html[data-theme="dark"] .collection-document-icon { background: #253754; color: #b7d0ff; }
html[data-theme="dark"] .desktop-home-file-icon.type-imagen,
html[data-theme="dark"] .mobile-document-icon.type-imagen,
html[data-theme="dark"] .collection-document-icon.type-imagen { background: #193b34; color: #75dfad; }
html[data-theme="dark"] .desktop-home-file-icon.type-plano,
html[data-theme="dark"] .mobile-document-icon.type-plano,
html[data-theme="dark"] .collection-document-icon.type-plano { background: #4b3b20; color: #ffd080; }
html[data-theme="dark"] .desktop-home-file-icon.type-contrato,
html[data-theme="dark"] .mobile-document-icon.type-contrato { background: #3d3153; color: #d2b6ff; }
html[data-theme="dark"] .desktop-home-file-icon.type-factura,
html[data-theme="dark"] .mobile-document-icon.type-factura,
html[data-theme="dark"] .collection-document-icon.type-factura { background: #4b2632; color: #ffb6c1; }

/* El botón usa un único SVG renderizado por theme.js; nunca queda sin icono. */
.theme-toggle-glyph { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; }
.theme-toggle-glyph svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
html[data-theme="dark"] .theme-toggle-glyph svg { fill: #ffe49a; stroke: none; }

/* La cabecera reserva espacio para los dos controles globales: tema y notificaciones. */
@media (min-width: 701px) {
  .page-heading,
  .collection-page-heading,
  .desktop-home-heading { padding-right: 124px; }
  .page-heading-actions,
  .collection-page-heading > .btn,
  .desktop-home-heading > .btn { min-width: 0; }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .page-heading,
  .collection-page-heading,
  .desktop-home-heading { padding-right: 112px; }
}

/* Acciones de formularios: mantener Cancelar fuera del bloque fijo de cabecera. */
@media (min-width: 701px) {
  .page-heading-actions > .btn { margin-right: 108px; }
}

@media (max-width: 700px) {
  .page-heading-actions > .btn { margin-right: 0; }
}

/* Paleta oscura inspirada en la referencia: carbón, índigo y rojo Primor. */
html[data-theme="dark"] {
  color-scheme: dark;
  --background: #08090b;
  --surface: #111216;
  --surface-raised: #17181e;
  --surface-soft: #0d0e12;
  --text: #f1f1f5;
  --muted: #9296aa;
  --border: #292b35;
  --blue: #9a96ff;
  --blue-dark: #f1f1f5;
  --blue-soft: #1b1a2d;
  --red: #ed1f55;
  --red-dark: #c91847;
  --red-soft: #351522;
  --green: #69d6a5;
  --green-soft: #122b25;
  --shadow: 0 20px 50px rgba(0, 0, 0, .38);
}

html[data-theme="dark"] body { background: var(--background); color: var(--text); }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .mobile-header { background: #0d0e12; border-color: #202129; }
html[data-theme="dark"] .side-brand strong,
html[data-theme="dark"] .nav-section-label { color: #777b90; }
html[data-theme="dark"] .side-nav a,
html[data-theme="dark"] .mobile-side-nav a,
html[data-theme="dark"] .mobile-nav-group-toggle { color: #b7b8c8; }
html[data-theme="dark"] .side-nav a:hover,
html[data-theme="dark"] .mobile-side-nav a:hover,
html[data-theme="dark"] .mobile-nav-group-toggle:hover { background: #191a22; color: #fff; }
html[data-theme="dark"] .side-nav a.active,
html[data-theme="dark"] .mobile-side-nav a.active { background: #1a1a2d; color: #b4b0ff; box-shadow: inset 3px 0 0 #706bff; }
html[data-theme="dark"] .side-nav .nav-primary,
html[data-theme="dark"] .mobile-side-nav .mobile-nav-primary { background: var(--red-soft); color: #ff8eab; }

html[data-theme="dark"] .content-panel,
html[data-theme="dark"] .welcome-panel,
html[data-theme="dark"] .phase-note,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .desktop-home-search,
html[data-theme="dark"] .desktop-home-recent,
html[data-theme="dark"] .desktop-home-utilities section,
html[data-theme="dark"] .collection-toolbar,
html[data-theme="dark"] .collection-card,
html[data-theme="dark"] .tag-catalog { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .input,
html[data-theme="dark"] .select,
html[data-theme="dark"] .file-input,
html[data-theme="dark"] .desktop-home-query,
html[data-theme="dark"] .tag-picker-search,
html[data-theme="dark"] .tag-admin-search { background: var(--surface-soft); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #6f7388; }
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-quiet,
html[data-theme="dark"] .mobile-home-filter-button,
html[data-theme="dark"] .filter-bar .btn-secondary { background: var(--surface-raised); border-color: var(--border); color: #c2c0ff; }
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-quiet:hover { background: #20202b; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] button[type="submit"].btn-primary { background: var(--red); border-color: var(--red); color: #fff; }

html[data-theme="dark"] .page-heading h1,
html[data-theme="dark"] .page-heading h2,
html[data-theme="dark"] .page-heading h3,
html[data-theme="dark"] .section-heading h2,
html[data-theme="dark"] .desktop-home-section-heading h2,
html[data-theme="dark"] .collection-page-heading h1,
html[data-theme="dark"] .tag-catalog-heading h2 { color: var(--text); }
html[data-theme="dark"] .page-heading p,
html[data-theme="dark"] .collection-page-heading p,
html[data-theme="dark"] .section-heading p { color: var(--muted); }

html[data-theme="dark"] .desktop-home-summary,
html[data-theme="dark"] .collection-summary,
html[data-theme="dark"] .collection-detail-hero { background: #11111a; border-color: #2f2e55; }
html[data-theme="dark"] .desktop-home-summary > a { border-color: #2b2b3e; }
html[data-theme="dark"] .desktop-home-summary > a:hover,
html[data-theme="dark"] .desktop-home-summary > a:focus-visible { background: #1a1a29; }
html[data-theme="dark"] .desktop-home-summary > a span { color: #9d9bbd; }
html[data-theme="dark"] .desktop-home-total { background: #19182b; }

html[data-theme="dark"] .desktop-home-document-row,
html[data-theme="dark"] .document-result,
html[data-theme="dark"] .tag-admin-row,
html[data-theme="dark"] .audit-row,
html[data-theme="dark"] .user-row { background: var(--surface); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .desktop-home-document-row:hover,
html[data-theme="dark"] .desktop-home-document-row:focus-visible,
html[data-theme="dark"] .tag-admin-row:hover { background: #191a22; }
html[data-theme="dark"] .desktop-home-table-head,
html[data-theme="dark"] .tag-admin-table-head { background: var(--surface-soft); border-color: var(--border); color: #85899d; }
html[data-theme="dark"] .desktop-user-menu summary,
html[data-theme="dark"] .mobile-side-footer { background: var(--surface-raised); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .desktop-user-menu form { background: var(--surface-raised); border-color: var(--border); }
html[data-theme="dark"] .desktop-user-menu form button { background: var(--red-soft); color: #ff9ab2; }

html[data-theme="dark"] .notification-button,
html[data-theme="dark"] .theme-toggle { background: #11111a; border-color: #373568; color: #b4b0ff; box-shadow: 0 10px 28px rgba(0, 0, 0, .3); }
html[data-theme="dark"] .notification-button:hover,
html[data-theme="dark"] .theme-toggle:hover { background: #1a1930; border-color: #706bff; }
html[data-theme="dark"] .notification-panel,
html[data-theme="dark"] .notification-panel-head,
html[data-theme="dark"] .notification-history-item { background: var(--surface-raised); border-color: var(--border); }
html[data-theme="dark"] .notification-panel-item:hover,
html[data-theme="dark"] .notification-history-item:hover { background: #20202b; }

html[data-theme="dark"] .desktop-home-file-icon,
html[data-theme="dark"] .mobile-document-icon,
html[data-theme="dark"] .collection-document-icon { background: #1a1a2d; color: #aaa6ff; }
html[data-theme="dark"] .desktop-home-file-icon.type-factura,
html[data-theme="dark"] .mobile-document-icon.type-factura,
html[data-theme="dark"] .collection-document-icon.type-factura { background: #351522; color: #ff8eab; }

/* Ajuste final: paleta neutra tipo interfaz de trabajo, con rojo Primor. */
html[data-theme="dark"] {
  --background: #101010;
  --surface: #181818;
  --surface-raised: #202020;
  --surface-soft: #141414;
  --text: #f1f1f1;
  --muted: #a1a1a1;
  --border: #2b2b2b;
  --blue: #a3a3ff;
  --blue-dark: #f1f1f1;
  --blue-soft: #252535;
  --red: #ef4444;
  --red-dark: #dc2626;
  --red-soft: #3a1d1d;
  --green: #22c55e;
  --green-soft: #16301f;
  --shadow: 0 18px 45px rgba(0, 0, 0, .38);
}

html[data-theme="dark"] body { background: #101010; color: #f1f1f1; }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .mobile-header { background: #141414; border-color: #252525; }
html[data-theme="dark"] .side-nav a,
html[data-theme="dark"] .mobile-side-nav a,
html[data-theme="dark"] .mobile-nav-group-toggle { color: #b5b5b5; }
html[data-theme="dark"] .side-nav a:hover,
html[data-theme="dark"] .mobile-side-nav a:hover,
html[data-theme="dark"] .mobile-nav-group-toggle:hover { background: #222; color: #fff; }
html[data-theme="dark"] .side-nav a.active,
html[data-theme="dark"] .mobile-side-nav a.active { background: #292929; color: #fff; box-shadow: inset 3px 0 0 #ef4444; }
html[data-theme="dark"] .side-nav .nav-primary,
html[data-theme="dark"] .mobile-side-nav .mobile-nav-primary { background: #3a1d1d; color: #ff8b8b; }

html[data-theme="dark"] .content-panel,
html[data-theme="dark"] .welcome-panel,
html[data-theme="dark"] .phase-note,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .desktop-home-search,
html[data-theme="dark"] .desktop-home-recent,
html[data-theme="dark"] .desktop-home-utilities section,
html[data-theme="dark"] .collection-toolbar,
html[data-theme="dark"] .collection-card,
html[data-theme="dark"] .tag-catalog { background: #181818; border-color: #2b2b2b; box-shadow: var(--shadow); }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .input,
html[data-theme="dark"] .select,
html[data-theme="dark"] .file-input,
html[data-theme="dark"] .desktop-home-query,
html[data-theme="dark"] .tag-picker-search,
html[data-theme="dark"] .tag-admin-search { background: #141414; border-color: #303030; color: #f1f1f1; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #777; }
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-quiet,
html[data-theme="dark"] .mobile-home-filter-button { background: #202020; border-color: #343434; color: #e5e5e5; }
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-quiet:hover { background: #292929; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] button[type="submit"].btn-primary { background: #ef4444; border-color: #ef4444; color: #fff; }
html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn-danger:hover { background: #dc2626; }

html[data-theme="dark"] .desktop-home-summary,
html[data-theme="dark"] .collection-summary,
html[data-theme="dark"] .collection-detail-hero { background: #151515; border-color: #303030; }
html[data-theme="dark"] .desktop-home-total { background: #202020; }
html[data-theme="dark"] .desktop-home-summary > a { border-color: #303030; }
html[data-theme="dark"] .desktop-home-summary > a:hover,
html[data-theme="dark"] .desktop-home-summary > a:focus-visible { background: #242424; }
html[data-theme="dark"] .desktop-home-summary > a span { color: #a1a1a1; }

html[data-theme="dark"] .desktop-home-document-row,
html[data-theme="dark"] .document-result,
html[data-theme="dark"] .tag-admin-row,
html[data-theme="dark"] .audit-row,
html[data-theme="dark"] .user-row { background: #181818; border-color: #2b2b2b; color: #f1f1f1; }
html[data-theme="dark"] .desktop-home-document-row:hover,
html[data-theme="dark"] .desktop-home-document-row:focus-visible,
html[data-theme="dark"] .tag-admin-row:hover { background: #222; }
html[data-theme="dark"] .desktop-home-table-head,
html[data-theme="dark"] .tag-admin-table-head { background: #141414; border-color: #2b2b2b; color: #858585; }

html[data-theme="dark"] .desktop-user-menu summary,
html[data-theme="dark"] .mobile-side-footer,
html[data-theme="dark"] .desktop-user-menu form { background: #202020; border-color: #343434; color: #f1f1f1; }
html[data-theme="dark"] .desktop-user-menu form button { background: #3a1d1d; color: #ff8b8b; }
html[data-theme="dark"] .notification-button,
html[data-theme="dark"] .theme-toggle { background: #181818; border-color: #363636; color: #e5e5e5; box-shadow: 0 10px 28px rgba(0, 0, 0, .32); }
html[data-theme="dark"] .notification-button:hover,
html[data-theme="dark"] .theme-toggle:hover { background: #242424; border-color: #666; }
html[data-theme="dark"] .notification-panel,
html[data-theme="dark"] .notification-panel-head,
html[data-theme="dark"] .notification-history-item { background: #202020; border-color: #343434; }
html[data-theme="dark"] .notification-panel-item:hover,
html[data-theme="dark"] .notification-history-item:hover { background: #292929; }

html[data-theme="dark"] .desktop-home-file-icon,
html[data-theme="dark"] .mobile-document-icon,
html[data-theme="dark"] .collection-document-icon { background: #292929; color: #c4c4c4; }
html[data-theme="dark"] .desktop-home-file-icon.type-factura,
html[data-theme="dark"] .mobile-document-icon.type-factura,
html[data-theme="dark"] .collection-document-icon.type-factura { background: #3a1d1d; color: #ff8b8b; }

/* Logo especial para el modo oscuro. El logo claro se conserva en modo claro. */
html[data-theme="dark"] .side-brand .brand-logo-light,
html[data-theme="dark"] .mobile-side-brand .brand-logo-light { display: none; }
html[data-theme="dark"] .side-brand .brand-logo-dark,
html[data-theme="dark"] .mobile-side-brand .brand-logo-dark {
  display: block;
  object-fit: cover;
  object-position: center 52%;
  mix-blend-mode: screen;
}
html[data-theme="dark"] .side-brand .brand-logo-dark {
  width: 178px;
  height: 86px;
  border-radius: 0;
}
html[data-theme="dark"] .mobile-side-brand .brand-logo-dark {
  width: 164px;
  height: 48px;
  border-radius: 0;
}

/* Override final: búsqueda general visible en la barra superior, sin filtros ni panel fijo. */
.desktop-topbar .global-search-menu { flex: 0 1 560px; min-width: 260px; }
.desktop-topbar .global-search-menu > form {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.desktop-topbar .global-search-filters { display: none !important; }
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu { flex: 1 1 auto; min-width: 0; }
  .desktop-topbar .global-search-menu > form { width: 100% !important; }
}

/* Buscador de escritorio: campo a la izquierda y resultados en un panel separado. */
@media (min-width: 901px) {
  .desktop-topbar-spacer { display: none; }
  .desktop-topbar-actions {
    width: 100%;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 10px;
  }
  .desktop-topbar .global-search-menu {
    display: block !important;
    flex: 0 1 560px;
    min-width: 280px;
    margin-right: auto;
    position: relative;
  }
  .desktop-topbar .global-search-menu > summary { display: none !important; }
  .desktop-topbar .global-search-menu > form {
    display: block !important;
    position: relative !important;
    inset: auto !important;
    width: min(560px, calc(100vw - 32px)) !important;
    max-width: 560px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .desktop-topbar .global-search-field {
    grid-template-columns: 22px minmax(0, 1fr) 30px;
    min-height: 48px;
    padding: 0 8px 0 14px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 8px 22px rgba(22, 35, 64, .08);
  }
  .desktop-topbar .global-search-submit-icon { display: none !important; }
  .desktop-topbar .global-search-suggestions {
    display: grid !important;
    position: absolute !important;
    top: calc(100% + 10px) !important;
    right: auto !important;
    bottom: auto !important;
    left: 0 !important;
    width: min(560px, calc(100vw - 32px)) !important;
    max-height: min(420px, 60vh) !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow-y: auto !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    background: var(--surface) !important;
    box-shadow: 0 22px 55px rgba(12, 35, 78, .18) !important;
  }
}

@media (max-width: 900px) {
  .desktop-topbar .global-search-menu { display: none !important; }
  .desktop-topbar-spacer { display: block; }
  .desktop-topbar-actions { width: auto; justify-content: flex-end; }
}

/* Corrección final del buscador: tamaño controlado y estados hidden respetados. */
@media (min-width: 901px) {
  .desktop-topbar .global-search-field input {
    display: block !important;
    width: 100%;
    min-width: 0;
    font-size: .9rem !important;
  }
  .desktop-topbar .global-search-field > svg {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
  }
  .desktop-topbar .global-search-suggestions[hidden] { display: none !important; }
}

.global-search-page-form { display: grid; gap: 8px; }
.global-search-page-form > label { color: var(--text); font-size: .78rem; font-weight: 750; }
.global-search-page-field {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(150px, 180px) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 8px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.global-search-page-field > svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.global-search-page-field input,
.global-search-page-field select {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .84rem;
}
.global-search-page-field input { padding: 0 10px; border-color: transparent; outline: 0; }
.global-search-page-field input:focus { border-color: var(--blue); }
.global-search-page-field select { padding: 0 9px; }
.global-search-page-field button { min-height: 38px; padding: 8px 17px; border: 0; border-radius: 9px; background: var(--red); color: #fff; font-size: .78rem; font-weight: 800; }
.global-search-list { display: grid; gap: 8px; }
.global-search-item { min-height: 72px; }
@media (max-width: 700px) {
  .global-search-page-field { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .global-search-page-field select { grid-column: 2; }
  .global-search-page-field button { grid-column: 3; grid-row: 1; }
}

/* Filas de resultados de /buscar: evitar que los SVG ocupen el panel completo. */
.global-search-results-panel { overflow: hidden; }
.global-search-result-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 12px; }
.global-search-result-heading h2 { margin: 0; color: var(--text); font-size: 1.15rem; }
.global-search-result-heading > span { color: var(--muted); font-size: .78rem; }
.global-search-list { display: grid; gap: 8px; }
.global-search-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(88px, auto) 20px;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.global-search-item:hover, .global-search-item:focus-visible { border-color: color-mix(in srgb, var(--blue) 35%, var(--border)); background: var(--blue-soft); outline: none; }
.global-search-item-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 11px; background: var(--blue-soft); color: var(--blue); }
.global-search-item-icon svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.global-search-item-copy { display: grid; min-width: 0; gap: 3px; }
.global-search-item-copy strong, .global-search-item-copy small, .global-search-item-copy em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-item-copy strong { font-size: .82rem; }
.global-search-item-copy small, .global-search-item-copy em { color: var(--muted); font-size: .7rem; font-style: normal; }
.global-search-item-date { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.global-search-item-arrow { display: block; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
@media (max-width: 700px) {
  .global-search-item { grid-template-columns: 38px minmax(0, 1fr) 18px; min-height: 64px; }
  .global-search-item-date { display: none; }
  .global-search-item-icon { width: 36px; height: 36px; }
}

/* Restauración del buscador anterior: botón de lupa y cuadro desplegable acotado. */
.desktop-topbar .global-search-menu {
  display: block !important;
  flex: 0 0 auto !important;
  min-width: 0 !important;
  margin-right: 0 !important;
}
.desktop-topbar .global-search-menu > summary {
  display: grid !important;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--blue);
  cursor: pointer;
  list-style: none;
}
.desktop-topbar .global-search-menu > summary::-webkit-details-marker { display: none; }
.desktop-topbar .global-search-menu > summary svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.desktop-topbar .global-search-menu > form {
  position: absolute !important;
  z-index: 1000;
  top: calc(100% + 9px) !important;
  right: 0 !important;
  left: auto !important;
  width: min(560px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
  padding: 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  background: var(--surface) !important;
  box-shadow: var(--shadow) !important;
}
.desktop-topbar .global-search-field {
  grid-template-columns: 22px minmax(0, 1fr) 30px !important;
  min-height: 46px;
  padding: 0 7px 0 11px;
  border-radius: 12px;
}
.desktop-topbar .global-search-field > svg { display: block !important; width: 20px !important; height: 20px !important; }
.desktop-topbar .global-search-field input { display: block !important; width: 100%; font-size: .84rem !important; }
.desktop-topbar .global-search-submit-icon { display: none !important; }
.desktop-topbar .global-search-suggestions { position: static !important; width: auto !important; max-height: min(420px, 58vh) !important; margin-top: 8px !important; padding: 7px 0 0 !important; border: 0 !important; border-top: 1px solid var(--border) !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; }
.desktop-topbar .global-search-suggestions[hidden] { display: none !important; }
@media (max-width: 900px) {
  .desktop-topbar .global-search-menu { display: block !important; }
  .desktop-topbar .global-search-menu > form { position: fixed !important; top: 76px !important; right: 10px !important; left: 10px !important; width: auto !important; max-width: none !important; max-height: calc(100dvh - 92px) !important; overflow: hidden !important; }
  .desktop-topbar .global-search-suggestions { max-height: calc(100dvh - 165px) !important; overflow-y: auto !important; }
}

/* Restaurar la barra superior sin buscador: solo tema, notificaciones y usuario. */
.desktop-topbar-spacer { display: block !important; flex: 1 1 auto !important; }
.desktop-topbar-actions { width: auto !important; flex: 0 0 auto !important; justify-content: flex-end !important; }

/* Rehabilitar los elementos internos ocultados por la restauración anterior. */
@media (min-width: 901px) {
  .desktop-topbar .global-search-menu > form,
  .desktop-topbar .global-search-menu .global-search-field,
  .desktop-topbar .global-search-menu .global-search-field > svg,
  .desktop-topbar .global-search-menu .global-search-field input,
  .desktop-topbar .global-search-menu .global-search-clear {
    display: grid !important;
  }
  .desktop-topbar .global-search-menu .global-search-field input {
    display: block !important;
  }
  .desktop-topbar .global-search-menu .global-search-clear[hidden] {
    display: none !important;
  }
}

/* Override final del resumen documental: siete columnas reales en una sola fila. */
@media (min-width: 981px) {
  .desktop-home-summary {
    grid-template-columns: minmax(178px, 1.3fr) repeat(6, minmax(78px, 1fr));
    align-items: stretch;
    gap: 0;
    min-height: 112px;
    margin: 16px 0 20px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 18px;
    background: linear-gradient(135deg, #12346f 0%, #173d80 100%);
    box-shadow: 0 14px 30px rgba(11, 44, 102, .16);
  }
  .desktop-home-summary > a {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-left: 1px solid rgba(220, 233, 255, .22);
    border-radius: 10px;
    transition: background-color 160ms ease, transform 160ms ease;
  }
  .desktop-home-summary > a:hover,
  .desktop-home-summary > a:focus-visible { background: rgba(255, 255, 255, .08); transform: translateY(-1px); }
  .desktop-home-summary > a span { overflow: hidden; color: #b9c9e9; font-size: .68rem; font-weight: 700; letter-spacing: .025em; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-home-summary > a strong { color: #fff; font-size: 1.55rem; font-weight: 800; line-height: 1; }
  .desktop-home-total { display: flex; position: relative; min-width: 0; align-items: baseline; gap: 8px; padding: 12px 22px 12px 14px; border-radius: 11px; background: rgba(255, 255, 255, .08); }
  .desktop-home-total::before { width: 4px; height: 38px; flex: 0 0 4px; border-radius: 999px; background: #dce9ff; content: ""; }
  .desktop-home-total strong { color: #fff; font-size: 2.15rem; font-weight: 850; letter-spacing: -.04em; line-height: 1; }
  .desktop-home-total span { color: #d6e2f8; font-size: .94rem; font-weight: 750; }
}

@media (min-width: 981px) and (max-width: 1250px) {
  .desktop-home-summary { grid-template-columns: minmax(150px, 1.2fr) repeat(6, minmax(60px, 1fr)); padding: 9px; }
  .desktop-home-summary > a { padding-right: 11px; padding-left: 11px; }
  .desktop-home-summary > a strong { font-size: 1.35rem; }
  .desktop-home-total { padding-right: 12px; padding-left: 9px; }
}
 .document-location-chip {
    display: inline-flex;
    align-items: center;
    max-width: min(100%, 52rem);
    padding: .38rem .72rem;
    border: 1px solid #cbd9ef;
    border-radius: 999px;
    background: #eef4ff;
    color: #17447f;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.25;
}

html[data-theme="dark"] .document-location-chip {
    border-color: #414b67;
    background: #20263a;
    color: #dbe5ff;
}

.partition-new-collection {
    width: 100%;
    justify-content: center;
    margin: .8rem 0;
}

/* Archivos: capa visual nueva, aislada de la lógica y de los handlers. */
.archive-tabs { display:flex; align-items:stretch; gap:1.1rem; margin:1.45rem 0 2rem; padding:0 0 .1rem; border-bottom:1px solid var(--border); }
.archive-tab { display:inline-flex; align-items:center; gap:.8rem; min-height:4rem; padding:.8rem 1.25rem; color:var(--muted); font-size:1rem; text-decoration:none; }
.archive-tab svg { width:1.55rem; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.8; }
.archive-tab-active { border-bottom:4px solid var(--blue); border-radius:14px 14px 0 0; background:var(--surface); color:var(--blue); font-weight:800; box-shadow:0 8px 18px rgba(11,44,102,.06); }
.archive-card-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:1.5rem; max-width:none; }
.archive-card { min-height:300px; padding:2.4rem 2.2rem; gap:2rem; border-radius:22px; box-shadow:0 14px 30px rgba(11,44,102,.08); }
.archive-card::before { width:7px; }
.archive-card-content { display:flex; min-width:0; flex:1; flex-direction:column; justify-content:center; }
.archive-card strong { display:block; overflow:hidden; color:var(--blue-dark); font-size:1.45rem; line-height:1.2; text-overflow:ellipsis; white-space:nowrap; text-decoration:none; }
.archive-card small { display:block; overflow:hidden; margin-top:.7rem; color:var(--muted); font-size:1rem; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; }
.archive-card-icon { flex-basis:108px; width:108px; height:108px; border-radius:26px; }
.archive-card-icon svg { width:58px; }
.archive-card-actions { top:1.4rem; right:1.4rem; }
.archive-card-metrics { display:flex; gap:2rem; margin-top:1.6rem; padding-top:1rem; border-top:1px solid var(--border); color:var(--blue); }
.archive-card-metrics > span { display:grid; grid-template-columns:24px auto; grid-template-rows:auto auto; column-gap:.6rem; min-width:0; }
.archive-card-metrics > span + span { padding-left:2rem; border-left:1px solid var(--border); }
.archive-card-metrics svg { grid-row:1 / span 2; width:24px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.7; }
.archive-card-metrics b { font-size:1.2rem; line-height:1; }
.archive-card-metrics small { grid-column:2; margin:0; color:var(--muted); font-size:.82rem; white-space:nowrap; }
html[data-theme="dark"] .archive-tab-active { background:var(--surface); }
html[data-theme="dark"] .archive-card strong { color:var(--text); }
@media (max-width:900px) {
  .archive-tabs { margin-top:1rem; margin-bottom:1.2rem; gap:.25rem; }
  .archive-tab { min-height:3.25rem; padding:.65rem .8rem; font-size:.86rem; }
  .archive-card-grid { grid-template-columns:1fr; gap:1rem; }
  .archive-card { min-height:190px; padding:1.35rem; gap:1rem; }
  .archive-card-main { gap:1rem; }
  .archive-card-actions { top:.7rem; right:.7rem; }
  .archive-card-icon { flex-basis:72px; width:72px; height:72px; border-radius:18px; }
  .archive-card-icon svg { width:40px; }
  .archive-card strong { font-size:1.08rem; }
  .archive-card small { margin-top:.4rem; font-size:.84rem; }
  .archive-card-metrics { gap:1rem; margin-top:1rem; padding-top:.7rem; }
  .archive-card-metrics > span + span { padding-left:1rem; }
}

/* Ajuste visual de la vista interna del archivo, aplicado al final para prevalecer sobre estilos base. */
body:has(.archive-detail-panel) .archive-detail-panel { position:relative; padding:1.35rem; border:0; background:transparent; box-shadow:none; }
body:has(.archive-detail-panel) .archive-detail-actions { position:absolute; top:1.35rem; right:1.35rem; z-index:2; }
body:has(.archive-detail-panel) .archive-detail-title { display:grid; grid-template-columns:86px minmax(0,1fr) auto; align-items:center; gap:1.25rem; min-height:150px; margin-bottom:1.15rem; padding:1.35rem 1.5rem; border:1px solid var(--border); border-radius:18px; background:var(--surface); box-shadow:0 10px 26px rgba(11,44,102,.07); }
body:has(.archive-detail-panel) .archive-detail-icon { display:grid; width:86px; height:86px; place-items:center; border-radius:18px; background:color-mix(in srgb,var(--archive-color,var(--blue)) 12%,white); color:var(--archive-color,var(--blue)); }
body:has(.archive-detail-panel) .archive-detail-icon svg { width:52px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.65; }
body:has(.archive-detail-panel) .archive-detail-copy h2 { margin:.15rem 0 0; color:var(--blue-dark); font-size:clamp(1.5rem,2vw,2rem); }
body:has(.archive-detail-panel) .archive-detail-copy p { margin:.25rem 0 .85rem; color:var(--muted); }
body:has(.archive-detail-panel) .archive-detail-metrics { display:flex; flex-wrap:wrap; gap:1rem; color:var(--muted); font-size:.88rem; }
body:has(.archive-detail-panel) .archive-detail-metrics span { display:inline-flex; align-items:center; gap:.35rem; }
body:has(.archive-detail-panel) .archive-detail-metrics span + span { padding-left:1rem; border-left:1px solid var(--border); }
body:has(.archive-detail-panel) .archive-detail-metrics b { color:var(--blue-dark); font-size:1rem; }
body:has(.archive-detail-panel) .partition-grid { grid-template-columns:1fr; gap:1rem; padding-top:0; }
body:has(.archive-detail-panel) .partition-card { padding:1.15rem 1.35rem 1.1rem 1.55rem; border-radius:17px; box-shadow:0 8px 22px rgba(11,44,102,.055); }
body:has(.archive-detail-panel) .partition-card-head { display:grid; grid-template-columns:52px minmax(0,1fr) auto; align-items:center; gap:.8rem; }
body:has(.archive-detail-panel) .partition-card-head strong { font-size:1.1rem; }
body:has(.archive-detail-panel) .partition-card-head small { font-size:.86rem; }
body:has(.archive-detail-panel) .partition-icon { width:52px; height:52px; flex-basis:52px; border-radius:15px; }
body:has(.archive-detail-panel) .partition-icon svg { width:31px; }
body:has(.archive-detail-panel) .partition-stats { align-items:center; justify-content:flex-end; gap:1.25rem; margin:0; font-size:.9rem; }
body:has(.archive-detail-panel) .partition-stats span { display:inline-flex; align-items:baseline; gap:.32rem; white-space:nowrap; }
body:has(.archive-detail-panel) .partition-collections-title { margin:1.1rem 0 .55rem; color:var(--text); font-size:.88rem; }
body:has(.archive-detail-panel) .partition-collections { gap:.55rem; }
body:has(.archive-detail-panel) .partition-collections a { min-height:3.1rem; padding:.75rem .9rem; border-radius:11px; background:var(--surface); }
body:has(.archive-detail-panel) .partition-card-actions { margin:.85rem 0 0; }
body:has(.archive-detail-panel) .partition-card-actions .btn { border-color:color-mix(in srgb,var(--partition-color,var(--blue)) 55%,white); color:var(--partition-color,var(--blue)); }
body:has(.archive-detail-panel) .partition-card > .muted-copy { margin:1rem 0 0; padding:1.1rem; border:1px dashed var(--border); border-radius:12px; text-align:center; }
body:has(.archive-detail-panel) .partition-card-menu-wrap { position:absolute; top:1rem; right:1rem; z-index:3; }
body:has(.archive-detail-panel) .partition-card-menu { display:grid; width:2.4rem; height:2.4rem; place-items:center; padding:0; border:0; border-radius:10px; background:transparent; color:var(--partition-color,var(--blue)); cursor:pointer; }
body:has(.archive-detail-panel) .partition-card-menu:hover,
body:has(.archive-detail-panel) .partition-card-menu:focus-visible { background:color-mix(in srgb,var(--partition-color,var(--blue)) 10%,var(--surface)); outline:none; }
body:has(.archive-detail-panel) .partition-card-menu svg { width:1.35rem; fill:currentColor; }
body:has(.archive-detail-panel) .partition-card-menu-panel { position:absolute; top:calc(100% + .3rem); right:0; display:grid; min-width:9.5rem; padding:.35rem; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 14px 30px rgba(11,44,102,.16); }
body:has(.archive-detail-panel) .partition-card-menu-panel[hidden] { display:none; }
body:has(.archive-detail-panel) .partition-card-menu-panel a,
body:has(.archive-detail-panel) .partition-card-menu-panel button { display:block; width:100%; padding:.55rem .7rem; border:0; border-radius:8px; background:transparent; color:var(--text); font:inherit; font-size:.85rem; text-align:left; text-decoration:none; cursor:pointer; }
body:has(.archive-detail-panel) .partition-card-menu-panel button:hover,
body:has(.archive-detail-panel) .partition-card-menu-panel button:focus-visible { background:var(--blue-soft); color:var(--blue); outline:none; }
body:has(.archive-detail-panel) .partition-card-menu-panel form { margin:0; }
body:has(.archive-detail-panel) .partition-card-menu-panel form button { color:var(--red); }
body:has(.archive-detail-panel) .partition-card-menu-panel form button:hover,
body:has(.archive-detail-panel) .partition-card-menu-panel form button:focus-visible { background:var(--red-soft); color:var(--red); }
@media (max-width:800px) {
  body:has(.archive-detail-panel) .archive-detail-panel { padding:.75rem 0; }
  body:has(.archive-detail-panel) .archive-detail-title { grid-template-columns:60px minmax(0,1fr); padding:1rem; }
  body:has(.archive-detail-panel) .archive-detail-icon { width:60px; height:60px; border-radius:14px; }
  body:has(.archive-detail-panel) .archive-detail-icon svg { width:36px; }
  body:has(.archive-detail-panel) .archive-count { display:none; }
  body:has(.archive-detail-panel) .partition-card-menu-wrap { top:.75rem; right:.75rem; }
  body:has(.archive-detail-panel) .partition-card-head { grid-template-columns:46px minmax(0,1fr); }
  body:has(.archive-detail-panel) .partition-icon { width:46px; height:46px; flex-basis:46px; }
  body:has(.archive-detail-panel) .partition-stats { grid-column:1/-1; justify-content:flex-start; margin-top:.75rem; }
}

/* Vista interna de Archivo: composición basada en el panel de referencia. */
.archive-reference-detail { display:grid; gap:1.35rem; padding:1.35rem 0 2rem; }
.archive-reference-summary,
.archive-reference-partition { position:relative; border:1px solid var(--border); border-radius:16px; background:var(--surface); box-shadow:0 12px 28px rgba(11,44,102,.08); }
.archive-reference-summary { display:grid; grid-template-columns:112px minmax(0,1fr) auto; align-items:center; gap:1.35rem; padding:1.45rem; }
.archive-reference-summary-icon,
.archive-reference-partition-icon { display:grid; place-items:center; flex:0 0 auto; border-radius:20px; color:var(--archive-color,var(--blue)); background:color-mix(in srgb,var(--archive-color,var(--blue)) 12%,white); }
.archive-reference-summary-icon { width:110px; height:110px; }
.archive-reference-summary-icon svg { width:59px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-summary-icon .archive-folder-logo { --archive-folder-base:var(--archive-color,var(--blue)); --archive-folder-back:color-mix(in srgb,var(--archive-folder-base) 88%,black); --archive-folder-dark:color-mix(in srgb,var(--archive-folder-base) 78%,black); --archive-folder-light:color-mix(in srgb,var(--archive-folder-base) 82%,white); --archive-folder-tab:color-mix(in srgb,var(--archive-folder-base) 62%,white); --archive-folder-tab-light:color-mix(in srgb,var(--archive-folder-base) 54%,white); --archive-folder-tab-soft:color-mix(in srgb,var(--archive-folder-base) 40%,white); --archive-folder-tab-soft-light:color-mix(in srgb,var(--archive-folder-base) 34%,white); width:59px; height:59px; stroke:none; }
.archive-reference-summary-copy h2 { margin:.12rem 0 .35rem; color:var(--text); font-size:2rem; line-height:1.15; }
.archive-reference-summary-copy p,
.archive-reference-partition-copy p { margin:0; color:var(--muted); }
.archive-reference-kicker { display:block; color:var(--archive-color,var(--blue)); font-size:.72rem; font-weight:800; letter-spacing:.12em; }
.archive-reference-metrics { display:flex; align-items:center; flex-wrap:wrap; gap:.75rem 0; margin-top:1rem; color:var(--muted); }
.archive-reference-metrics span { display:inline-flex; align-items:center; gap:.45rem; padding:0 1rem; font-size:.95rem; }
.archive-reference-metrics span:first-child { padding-left:0; }
.archive-reference-metrics span + span { border-left:1px solid var(--border); }
.archive-reference-metrics svg { width:1.2rem; height:1.2rem; stroke:var(--archive-color,var(--blue)); fill:none; stroke-width:1.8; }
.archive-reference-edit { display:inline-flex; align-items:center; justify-content:center; gap:.55rem; min-height:3.25rem; padding:.7rem 1.1rem; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--archive-color,var(--blue)); font:inherit; font-weight:750; cursor:pointer; white-space:nowrap; }
.archive-reference-edit:hover,.archive-reference-edit:focus-visible { border-color:var(--archive-color,var(--blue)); background:color-mix(in srgb,var(--archive-color,var(--blue)) 8%,var(--surface)); outline:none; }
.archive-reference-edit svg { width:1.25rem; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-partitions { display:grid; gap:1.25rem; }
.archive-reference-partition { min-height:13rem; padding:1.2rem 1.8rem 1.25rem; overflow:visible; }
.archive-reference-partition::before { position:absolute; inset:0 auto 0 0; width:6px; border-radius:16px 0 0 16px; background:var(--partition-color,var(--blue)); content:""; }
.archive-reference-partition-head { display:grid; grid-template-columns:66px minmax(0,1fr) auto; align-items:center; gap:1.1rem; padding-right:2.4rem; }
.archive-reference-partition-icon { width:66px; height:66px; border-radius:14px; color:var(--partition-color,var(--blue)); background:color-mix(in srgb,var(--partition-color,var(--blue)) 11%,white); }
.archive-reference-partition-icon svg { width:35px; stroke:currentColor; fill:none; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-partition-copy h3 { margin:0 0 .3rem; color:var(--text); font-size:1.12rem; }
.archive-reference-partition-stats { display:flex; align-items:center; gap:2rem; color:var(--muted); white-space:nowrap; }
.archive-reference-partition-stats span { display:inline-flex; align-items:center; gap:.42rem; }
.archive-reference-partition-stats svg { width:1.2rem; height:1.2rem; fill:none; stroke:var(--partition-color,var(--blue)); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-partition-stats b { color:var(--text); }
.archive-reference-partition-menu-wrap { position:absolute; top:1.25rem; right:1.25rem; z-index:3; }
.archive-reference-partition-menu { display:grid; width:2rem; height:2rem; padding:0; border:0; border-radius:8px; place-items:center; background:transparent; color:var(--text); cursor:pointer; }
.archive-reference-partition-menu:hover,.archive-reference-partition-menu:focus-visible { background:color-mix(in srgb,var(--partition-color,var(--blue)) 10%,var(--surface)); outline:none; }
.archive-reference-partition-menu svg { width:1.35rem; fill:currentColor; }
.archive-reference-partition-menu-panel { position:absolute; top:calc(100% + .3rem); right:0; display:grid; min-width:9.5rem; padding:.35rem; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 14px 30px rgba(11,44,102,.16); }
.archive-reference-partition-menu-panel[hidden] { display:none; }
.archive-reference-partition-menu-panel button { display:block; width:100%; padding:.55rem .7rem; border:0; border-radius:8px; background:transparent; color:var(--text); font:inherit; font-size:.85rem; text-align:left; cursor:pointer; }
.archive-reference-partition-menu-panel button:hover,.archive-reference-partition-menu-panel button:focus-visible { background:var(--blue-soft); color:var(--blue); outline:none; }
.archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link { display:block; width:100%; padding:.55rem .7rem; border-radius:8px; color:var(--text); font:inherit; font-size:.85rem; text-align:left; text-decoration:none; cursor:pointer; }
.archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link:hover,.archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link:focus-visible { background:var(--blue-soft); color:var(--blue); outline:none; }
.archive-reference-partition-menu-panel form { margin:0; }.archive-reference-partition-menu-panel form button { color:var(--red); }.archive-reference-partition-menu-panel form button:hover,.archive-reference-partition-menu-panel form button:focus-visible { background:var(--red-soft); color:var(--red); }
.archive-reference-collections-title { margin:1.15rem 0 .6rem; color:var(--text); font-size:1rem; }
.archive-reference-collections { display:grid; gap:.6rem; }
.archive-reference-collections a { display:grid; grid-template-columns:2rem minmax(0,1fr) auto 1.25rem; align-items:center; gap:.75rem; min-height:3.6rem; padding:.65rem .9rem; border:1px solid var(--border); border-radius:10px; color:var(--text); text-decoration:none; }
.archive-reference-collections a:hover,.archive-reference-collections a:focus-visible { border-color:var(--partition-color,var(--blue)); background:color-mix(in srgb,var(--partition-color,var(--blue)) 5%,var(--surface)); outline:none; }
.archive-reference-collection-icon { width:1.7rem; height:1.7rem; stroke:#e5a11c; fill:#fff4d6; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-collections strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.archive-reference-collections small { color:var(--muted); white-space:nowrap; }.archive-reference-collection-arrow { width:1.1rem; stroke:var(--text); fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-manage { display:inline-flex; align-items:center; gap:.5rem; margin-top:1rem; padding:.7rem 1rem; border:1px solid color-mix(in srgb,var(--partition-color,var(--blue)) 55%,var(--border)); border-radius:9px; background:var(--surface); color:var(--partition-color,var(--blue)); font:inherit; font-weight:750; cursor:pointer; }.archive-reference-manage svg { width:1.15rem; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.archive-reference-empty { display:flex; align-items:center; justify-content:center; gap:1.15rem; min-height:9.5rem; margin-top:1rem; padding:1.2rem; border:1px dashed var(--border); border-radius:10px; }.archive-reference-empty > span { display:grid; width:3.5rem; height:3.5rem; place-items:center; border-radius:50%; color:var(--muted); background:var(--surface-muted); }.archive-reference-empty > span svg { width:2rem; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }.archive-reference-empty h4 { margin:0 0 .25rem; color:var(--text); }.archive-reference-empty p { margin:0 0 .9rem; color:var(--muted); }.archive-reference-create-collection { display:inline-flex; align-items:center; gap:.45rem; padding:.7rem 1rem; border-radius:8px; background:var(--blue); color:#fff; font-weight:750; text-decoration:none; }.archive-reference-create-collection svg { width:1.1rem; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
@media (max-width:800px) { .archive-reference-detail { gap:1rem; padding:.75rem 0 1.5rem; }.archive-reference-summary { grid-template-columns:66px minmax(0,1fr); gap:1rem; padding:1rem; }.archive-reference-summary-icon { width:66px; height:66px; border-radius:14px; }.archive-reference-summary-icon svg { width:36px; }.archive-reference-summary-icon .archive-folder-logo { width:36px; height:36px; }.archive-reference-summary-copy h2 { font-size:1.35rem; }.archive-reference-summary-copy p { font-size:.9rem; }.archive-reference-metrics { grid-column:1/-1; }.archive-reference-metrics span { padding:0 .65rem; font-size:.82rem; }.archive-reference-edit { grid-column:1/-1; width:100%; }.archive-reference-partition { padding:1rem; }.archive-reference-partition-head { grid-template-columns:50px minmax(0,1fr); gap:.8rem; padding-right:2rem; }.archive-reference-partition-icon { width:50px; height:50px; }.archive-reference-partition-icon svg { width:28px; }.archive-reference-partition-icon .open-folder-logo { width:28px; height:28px; }.archive-reference-partition-copy h3 { font-size:1rem; }.archive-reference-partition-copy p { font-size:.86rem; }.archive-reference-partition-stats { grid-column:1/-1; gap:1.1rem; font-size:.86rem; }.archive-reference-partition-menu-wrap { top:.85rem; right:.75rem; }.archive-reference-collections a { grid-template-columns:1.7rem minmax(0,1fr) 1rem; gap:.55rem; }.archive-reference-collections small { grid-column:2; }.archive-reference-collection-arrow { grid-column:3; grid-row:1/3; }.archive-reference-empty { align-items:flex-start; justify-content:flex-start; }.archive-reference-empty p { font-size:.88rem; } }

/* Icono estándar de carpetas abiertas: conserva el color elegido por archivo o expediente. */
.archive-reference-partition-icon .open-folder-logo,
.collection-folder .open-folder-logo { --folder-base:var(--partition-color,var(--collection-color,var(--blue))); --folder-back:color-mix(in srgb,var(--folder-base) 82%,black); --folder-front:color-mix(in srgb,var(--folder-base) 70%,white); width:35px; height:35px; stroke:none; }
.collection-folder .open-folder-logo { width:29px; height:29px; }
.archive-reference-collection-icon.open-folder-logo { --folder-base:var(--collection-color,var(--blue)); --folder-back:color-mix(in srgb,var(--folder-base) 82%,black); --folder-front:color-mix(in srgb,var(--folder-base) 70%,white); width:1.7rem; height:1.7rem; stroke:none; fill:none; }

/* Archivos: superficies y tipografía legibles en modo oscuro, incluidos menús y modales. */
html[data-theme="dark"] .archive-reference-summary,
html[data-theme="dark"] .archive-reference-partition { background:#151515 !important; border-color:#303030 !important; box-shadow:0 12px 28px rgba(0,0,0,.24); }
html[data-theme="dark"] .archive-card,
html[data-theme="dark"] .partition-card,
html[data-theme="dark"] .archive-detail-panel { background:#151515 !important; border-color:#303030 !important; box-shadow:0 12px 28px rgba(0,0,0,.24); }
html[data-theme="dark"] .archive-card strong,
html[data-theme="dark"] .partition-card-head strong,
html[data-theme="dark"] .archive-detail-title h2 { color:#f1f1f1 !important; }
html[data-theme="dark"] .archive-card small,
html[data-theme="dark"] .archive-card em,
html[data-theme="dark"] .partition-card-head small,
html[data-theme="dark"] .partition-stats,
html[data-theme="dark"] .archive-detail-title p,
html[data-theme="dark"] .archive-count { color:#a1a1a1 !important; }
html[data-theme="dark"] .archive-card-icon,
html[data-theme="dark"] .partition-icon { background:#292929 !important; }
html[data-theme="dark"] .archive-reference-summary-copy h2,
html[data-theme="dark"] .archive-reference-partition-copy h3,
html[data-theme="dark"] .archive-reference-partition-stats b,
html[data-theme="dark"] .archive-reference-collections-title,
html[data-theme="dark"] .archive-reference-collections strong,
html[data-theme="dark"] .archive-reference-empty h4 { color:#f1f1f1 !important; }
html[data-theme="dark"] .archive-reference-summary-copy p,
html[data-theme="dark"] .archive-reference-partition-copy p,
html[data-theme="dark"] .archive-reference-metrics,
html[data-theme="dark"] .archive-reference-partition-stats,
html[data-theme="dark"] .archive-reference-collections small,
html[data-theme="dark"] .archive-reference-empty p { color:#a1a1a1 !important; }
html[data-theme="dark"] .archive-reference-edit,
html[data-theme="dark"] .archive-reference-collections a,
html[data-theme="dark"] .archive-reference-empty { background:#181818 !important; border-color:#343434 !important; color:#e5e5e5 !important; }
html[data-theme="dark"] .archive-reference-collections a:hover,
html[data-theme="dark"] .archive-reference-collections a:focus-visible { background:#222 !important; }
html[data-theme="dark"] .archive-reference-partition-menu-panel { background:#202020 !important; border-color:#3a3a3a !important; box-shadow:0 14px 30px rgba(0,0,0,.42); }
html[data-theme="dark"] .archive-reference-partition-menu-panel button,
html[data-theme="dark"] .archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link { color:#e5e5e5 !important; }
html[data-theme="dark"] .archive-reference-partition-menu-panel button:hover,
html[data-theme="dark"] .archive-reference-partition-menu-panel button:focus-visible,
html[data-theme="dark"] .archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link:hover,
html[data-theme="dark"] .archive-reference-partition-menu-panel > a.archive-reference-partition-menu-link:focus-visible { background:#2b2b2b !important; color:#fff !important; }
html[data-theme="dark"] .collection-modal-card { background:#181818 !important; border:1px solid #343434; box-shadow:0 28px 75px rgba(0,0,0,.55); }
html[data-theme="dark"] .collection-modal-head { background:#181818 !important; border-color:#343434 !important; }
html[data-theme="dark"] .collection-modal-head h2 { color:#f1f1f1 !important; }
html[data-theme="dark"] .collection-modal-head p { color:#a1a1a1 !important; }
html[data-theme="dark"] .collection-modal-backdrop { background:rgba(0,0,0,.74) !important; }
html[data-theme="dark"] .partition-assignment-option { background:#202020 !important; border-color:#3a3a3a !important; color:#f1f1f1 !important; }
html[data-theme="dark"] .partition-assignment-option:has(input:checked) { background:#292929 !important; border-color:#8f8cff !important; }
html[data-theme="dark"] .partition-assignment-option strong { color:#f1f1f1 !important; }
html[data-theme="dark"] .partition-assignment-option small { color:#a1a1a1 !important; }
html[data-theme="dark"] .partition-assignment-option.disabled { background:#171717 !important; opacity:.68; }
html[data-theme="dark"] .collection-modal-actions { background:#181818 !important; }
html[data-theme="dark"] .collection-modal-actions .btn-secondary { background:#292929 !important; border-color:#444 !important; color:#f1f1f1 !important; }
html[data-theme="dark"] .preview-modal-close { background:#202020 !important; border-color:#444 !important; color:#e5e5e5 !important; }
/* Notification preferences and per-item actions */
.notification-history-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .75rem 1rem; align-items: start; }
.notification-item-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .35rem; }
.notification-item-actions form { margin: 0; }
.notification-item-actions button, .notification-open-label { border: 1px solid var(--border-color, #d7dfef); border-radius: .45rem; background: transparent; color: var(--text-secondary, #31527e); cursor: pointer; font: inherit; font-size: .82rem; padding: .35rem .6rem; text-decoration: none; }
.notification-item-actions button:hover, .notification-open-label:hover { border-color: var(--primary-color, #1e5aa8); color: var(--primary-color, #1e5aa8); }
.notification-preferences-form { display: grid; gap: 1rem; max-width: 760px; }
.notification-preference-toggle { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem; border: 1px solid var(--border-color, #d7dfef); border-radius: .75rem; }
.notification-preference-toggle input { accent-color: var(--primary-color, #1e5aa8); margin-top: .2rem; }
.notification-preference-toggle span { display: grid; gap: .25rem; }
.notification-preference-toggle small { color: var(--text-secondary, #58739a); }
.notification-preference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.notification-preference-grid label { display: grid; gap: .4rem; color: var(--text-secondary, #58739a); }
.notification-preference-grid input { border: 1px solid var(--border-color, #d7dfef); border-radius: .5rem; background: var(--surface, #fff); color: inherit; padding: .65rem .75rem; }
@media (max-width: 700px) { .notification-preference-grid { grid-template-columns: 1fr; } .notification-item-actions { grid-column: 1 / -1; } }

/* Notification settings - expanded professional layout */
.notification-settings-heading { display:flex; align-items:center; justify-content:space-between; gap:1.5rem; }
.notification-settings-title-row { display:flex; align-items:center; gap:1rem; }
.notification-settings-icon { display:grid; place-items:center; width:3.25rem; height:3.25rem; border-radius:1rem; background:var(--blue-soft); color:var(--blue); }
.notification-settings-icon svg { width:1.6rem; height:1.6rem; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.page-eyebrow,.section-kicker { display:block; color:var(--blue); font-size:.72rem; font-weight:800; letter-spacing:.13em; text-transform:uppercase; }
.notification-settings-heading h1 { margin:.22rem 0 .3rem; }
.notification-settings-heading p { max-width:48rem; margin:0; }
.notification-settings-status { display:inline-flex; align-items:center; gap:.45rem; border:1px solid var(--border); border-radius:999px; color:var(--muted); font-size:.78rem; padding:.55rem .8rem; white-space:nowrap; }
.notification-settings-status i { width:.45rem; height:.45rem; border-radius:50%; background:var(--green); }
.notification-settings-alert { margin:0 0 1rem; }
.notification-settings-layout { display:grid; grid-template-columns:minmax(0,1.65fr) minmax(18rem,.75fr); gap:1.25rem; align-items:start; }
.notification-settings-card { padding:0; overflow:hidden; }
.notification-settings-card-header { display:flex; justify-content:space-between; gap:1rem; padding:1.5rem 1.6rem 1.3rem; border-bottom:1px solid var(--border); }
.notification-settings-card-header h2 { margin:.35rem 0 .25rem; font-size:1.35rem; }
.notification-settings-card-header p { margin:0; color:var(--muted); font-size:.9rem; }
.notification-settings-card-mark { color:var(--border); font-size:2.2rem; font-weight:800; line-height:1; }
.notification-preferences-form { display:grid; gap:0; }
.notification-settings-section { padding:1.45rem 1.6rem; border-bottom:1px solid var(--border); }
.notification-settings-section-last { border-bottom:0; }
.notification-settings-section-heading { display:flex; gap:.75rem; align-items:flex-start; margin-bottom:1rem; }
.notification-settings-section-heading h3 { margin:0 0 .22rem; font-size:1rem; }
.notification-settings-section-heading p { margin:0; color:var(--muted); font-size:.84rem; }
.notification-settings-section-icon { display:grid; place-items:center; flex:0 0 2rem; width:2rem; height:2rem; border-radius:.65rem; background:var(--blue-soft); color:var(--blue); }
.notification-settings-section-icon svg { width:1.05rem; height:1.05rem; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.notification-preference-toggle { position:relative; display:flex; align-items:flex-start; gap:.8rem; padding:1rem; border:1px solid var(--border); border-radius:.8rem; background:color-mix(in srgb,var(--surface) 92%,var(--blue-soft)); }
.notification-preference-toggle input,.notification-type-card input { accent-color:var(--blue); flex:0 0 auto; width:1.05rem; height:1.05rem; margin:.15rem 0 0; }
.notification-preference-toggle span { display:grid; gap:.25rem; }
.notification-preference-toggle strong { font-size:.95rem; }
.notification-preference-toggle small,.notification-type-card small { color:var(--muted); line-height:1.45; }
.notification-preference-toggle em { margin-left:auto; border-radius:999px; color:var(--green); background:var(--green-soft); font-size:.7rem; font-style:normal; font-weight:800; padding:.3rem .55rem; }
.notification-type-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.75rem; }
.notification-type-card { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:.7rem; padding:.9rem; border:1px solid var(--border); border-radius:.8rem; cursor:pointer; }
.notification-type-card:has(input:checked) { border-color:color-mix(in srgb,var(--blue) 45%,var(--border)); box-shadow:0 0 0 2px color-mix(in srgb,var(--blue) 10%,transparent); }
.notification-type-card-icon { display:grid; place-items:center; width:2.25rem; height:2.25rem; border-radius:.65rem; }
.notification-type-card-icon-invoice { color:var(--red); background:var(--red-soft); }
.notification-type-card-icon-contract { color:var(--blue); background:var(--blue-soft); }
.notification-type-card-icon svg { width:1.2rem; height:1.2rem; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.notification-type-card-copy { display:grid; gap:.2rem; }
.notification-number-field { display:grid; gap:.4rem; color:var(--text); font-weight:700; }
.notification-number-field > div { display:flex; align-items:center; border:1px solid var(--border); border-radius:.65rem; background:var(--surface); overflow:hidden; }
.notification-number-field input { min-width:0; width:100%; border:0; outline:0; background:transparent; color:inherit; font:inherit; padding:.72rem .8rem; }
.notification-number-field b { color:var(--muted); font-size:.75rem; font-weight:600; padding-right:.8rem; white-space:nowrap; }
.notification-number-field small { color:var(--muted); font-size:.75rem; font-weight:400; }
.notification-settings-form-footer { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1.2rem 1.6rem; background:color-mix(in srgb,var(--surface) 85%,var(--blue-soft)); }
.notification-settings-form-footer > span { color:var(--muted); font-size:.78rem; }
.notification-settings-form-footer button { display:inline-flex; align-items:center; gap:.5rem; }
.notification-settings-form-footer button svg { width:1.1rem; height:1.1rem; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.notification-settings-aside { display:grid; gap:1.25rem; }
.notification-info-card { padding:1.35rem; border:1px solid var(--border); border-radius:1rem; background:var(--surface); box-shadow:var(--shadow); }
.notification-info-card-highlight { color:var(--text); background:linear-gradient(145deg,var(--blue) 0%,var(--blue-dark) 100%); border-color:transparent; }
.notification-info-card-highlight .section-kicker,.notification-info-card-highlight p,.notification-info-card-highlight small { color:color-mix(in srgb,#fff 72%,transparent); }
.notification-info-card h2 { margin:.4rem 0 .55rem; font-size:1.3rem; }
.notification-info-card p { margin:0; color:var(--muted); font-size:.86rem; line-height:1.55; }
.notification-flow-list { display:grid; gap:0; margin:1.25rem 0 0; padding:0; list-style:none; }
.notification-flow-list li { display:flex; gap:.75rem; align-items:flex-start; padding:.8rem 0; border-top:1px solid color-mix(in srgb,#fff 16%,transparent); }
.notification-flow-list b { color:color-mix(in srgb,#fff 55%,transparent); font-size:.72rem; letter-spacing:.08em; }
.notification-flow-list span { display:grid; gap:.15rem; }
.notification-flow-list strong { color:#fff; font-size:.85rem; }
.notification-info-card-heading { display:flex; align-items:center; gap:.65rem; margin-bottom:.8rem; }
.notification-info-card-heading h3 { margin:0; font-size:1rem; }
.notification-settings-secondary-link { display:flex; justify-content:space-between; gap:1rem; margin-top:1rem; padding-top:1rem; border-top:1px solid var(--border); color:var(--blue); font-size:.85rem; font-weight:700; text-decoration:none; }
.notification-preference-stack { display:grid; gap:.65rem; }
.notification-preference-stack .notification-preference-toggle:has(input:disabled) { opacity:.62; cursor:not-allowed; }
.notification-preference-toggle em.notification-status-pending { color:var(--muted); background:var(--surface-muted, #eef2f7); }
.notification-email-help { margin:.75rem 0 0; }
@media (max-width:900px) { .notification-settings-layout { grid-template-columns:1fr; } .notification-settings-aside { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:650px) { .notification-settings-heading,.notification-settings-title-row { align-items:flex-start; flex-direction:column; } .notification-settings-status { margin-left:4.25rem; } .notification-type-grid,.notification-settings-aside { grid-template-columns:1fr; } .notification-settings-card-header,.notification-settings-section,.notification-settings-form-footer { padding-left:1rem; padding-right:1rem; } .notification-settings-form-footer { align-items:stretch; flex-direction:column; } .notification-settings-form-footer button { justify-content:center; } }

/* Independent rules for each notification type. */
.notification-type-grid-independent { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; }
.notification-type-card-expanded { display:block; cursor:default; }
.notification-type-card-title { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:.7rem; }
.notification-type-card-title > span:nth-child(2) { display:grid; gap:.2rem; }
.notification-type-card-title > input { accent-color:var(--blue); width:1.05rem; height:1.05rem; }
.notification-type-card-fields { display:grid; gap:.65rem; margin-top:1rem; padding-top:1rem; border-top:1px solid var(--border); }
.notification-type-card-fields .notification-preference-toggle { padding:.7rem; border-radius:.65rem; }
.notification-type-card-fields .notification-preference-toggle strong { font-size:.84rem; }
.notification-type-card-fields .notification-preference-toggle small { font-size:.74rem; }
@media (max-width:900px) { .notification-type-grid-independent { grid-template-columns:1fr; } }

/* New alert inbox */
.notification-inbox-heading { display:flex; justify-content:space-between; align-items:end; gap:1rem; }
.notification-inbox-heading h1 { margin:.25rem 0 .35rem; }
.notification-inbox-heading p { margin:0; }
.notification-inbox-summary { display:grid; grid-template-columns:repeat(4,1fr); gap:.8rem; margin-bottom:1rem; }
.notification-inbox-summary > div { display:flex; align-items:center; gap:.75rem; padding:1rem; border:1px solid var(--border); border-radius:.85rem; background:var(--surface); }
.notification-inbox-summary > a { display:flex; align-items:center; gap:.75rem; padding:1rem; border:1px solid var(--border); border-radius:.85rem; background:var(--surface); color:inherit; text-decoration:none; }
.notification-summary-card-hidden { color:var(--purple, #6b5bd2) !important; }
.notification-summary-card { color:inherit; }
.notification-summary-card:hover,.notification-summary-card.is-selected { border-color:var(--blue); background:var(--blue-soft); }
.notification-summary-card-hidden .notification-summary-icon { color:var(--purple, #6b5bd2); background:var(--purple-soft, #f1efff); }
.notification-summary-card-hidden:hover,.notification-summary-card-hidden.is-selected { border-color:var(--purple, #6b5bd2); background:var(--purple-soft, #f1efff); }
.notification-inbox-summary > div > span:last-child { display:grid; gap:.18rem; }
.notification-inbox-summary > a > span:last-child { display:grid; gap:.18rem; }
.notification-inbox-summary small { color:var(--muted); font-size:.78rem; }
.notification-inbox-summary strong { color:var(--text); font-size:1.35rem; line-height:1; }
.notification-summary-icon { display:grid; place-items:center; width:2.4rem; height:2.4rem; border-radius:.7rem; }
.notification-summary-icon svg { width:1.2rem; height:1.2rem; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.notification-summary-icon-blue { color:var(--blue); background:var(--blue-soft); }.notification-summary-icon-red { color:var(--red); background:var(--red-soft); }.notification-summary-icon-green { color:var(--green); background:var(--green-soft); }
.notification-inbox-panel { padding:0; overflow:hidden; }
.notification-inbox-panel-header { display:flex; align-items:center; justify-content:space-between; padding:1.25rem 1.4rem; border-bottom:1px solid var(--border); }
.notification-configure-button { display:inline-flex; align-items:center; justify-content:center; gap:.55rem; min-width:12rem; }
.notification-configure-button img { width:1.35rem; height:1.35rem; object-fit:contain; filter: invert(27%) sepia(47%) saturate(1182%) hue-rotate(178deg) brightness(83%) contrast(91%); }
.email-routing-section,.email-template-section,.email-manual-section { display:grid; gap:1rem; }
.email-recipient-list,.email-recipient-add,.email-template-grid,.email-manual-form { display:grid; gap:.75rem; }
.email-recipient-row { display:grid; grid-template-columns:minmax(12rem,1fr) auto auto auto; gap:.8rem; align-items:center; padding:.8rem 1rem; border:1px solid var(--border); border-radius:12px; }
.email-recipient-row div { display:grid; gap:.25rem; }.email-recipient-row small input { width:100%; padding:.35rem .5rem; border:1px solid var(--border); border-radius:8px; }
.email-recipient-row label,.email-recipient-add label { display:flex; align-items:center; gap:.35rem; white-space:nowrap; font-size:.85rem; }.email-recipient-row input[type=checkbox],.email-recipient-add input[type=checkbox] { width:18px; height:18px; accent-color:var(--blue); }
.email-recipient-add { grid-template-columns:1fr 1fr auto auto auto; align-items:center; }.email-recipient-add > input,.email-template-card input,.email-template-card textarea,.email-manual-form input,.email-manual-form select,.email-manual-form textarea { width:100%; padding:.75rem; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); }.email-template-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }.email-template-card { display:grid; gap:.65rem; padding:1rem; border:1px solid var(--border); border-radius:14px; }.email-template-card label,.email-manual-form label { display:grid; gap:.35rem; color:var(--muted); font-size:.85rem; }.email-template-card textarea,.email-manual-form textarea { min-height:150px; resize:vertical; }.email-template-card small { color:var(--muted); line-height:1.5; }.email-manual-form { max-width:700px; }.email-manual-section { border-top:1px solid var(--border); padding:1.5rem; }
.email-recipient-manager { display:grid; gap:1rem; width:100%; }
.email-recipient-empty { display:grid; gap:.35rem; padding:1.25rem; border:1px dashed var(--border); border-radius:1rem; background:color-mix(in srgb,var(--blue-soft) 45%,var(--surface)); color:var(--muted); }
.email-recipient-empty strong,.email-recipient-add-title strong { color:var(--text); }
.email-recipient-list { gap:0; overflow:hidden; border:1px solid var(--border); border-radius:1rem; }
.email-recipient-table-heading { display:grid; grid-template-columns:minmax(16rem,1.4fr) minmax(15rem,1fr) 7rem 7rem; gap:1rem; padding:.75rem 1rem; background:var(--blue-soft); color:var(--muted); font-size:.78rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.email-recipient-row { display:grid; grid-template-columns:minmax(16rem,1.4fr) minmax(15rem,1fr) 7rem 7rem; gap:1rem; align-items:center; padding:1rem; border:0; border-top:1px solid var(--border); border-radius:0; }
.email-recipient-identity { display:grid; gap:.45rem; min-width:0; }
.email-recipient-identity strong { overflow:hidden; color:var(--text); text-overflow:ellipsis; }
.email-recipient-identity input { width:100%; padding:.55rem .65rem; border:1px solid var(--border); border-radius:.55rem; background:var(--surface); color:var(--text); }
.email-recipient-types { display:flex; flex-wrap:wrap; gap:.75rem; align-items:center; }
.email-recipient-types label,.email-recipient-active { display:flex; align-items:center; gap:.4rem; color:var(--text); font-size:.86rem; white-space:nowrap; }
.email-recipient-delete { justify-self:start; white-space:nowrap; }
.email-recipient-list > .btn { justify-self:start; margin:0 1rem 1rem; }
.email-recipient-add { padding:1rem; border:1px solid var(--border); border-radius:1rem; background:var(--surface); }
.email-recipient-add-title { display:grid; gap:.25rem; margin-bottom:.75rem; }
.email-recipient-add-title span { color:var(--muted); font-size:.85rem; }
.email-recipient-add-fields { display:grid; grid-template-columns:minmax(14rem,1fr) minmax(12rem,1fr) auto auto; gap:.75rem; align-items:center; }
.email-recipient-add-fields > input { width:100%; padding:.75rem; border:1px solid var(--border); border-radius:.7rem; background:var(--surface); color:var(--text); }
html[data-theme="dark"] .email-recipient-empty,html[data-theme="dark"] .email-recipient-table-heading { background:#182a45; }
html[data-theme="dark"] .email-recipient-identity input,html[data-theme="dark"] .email-recipient-add-fields > input { background:#121e31; border-color:#3a5070; color:var(--text); }
@media (max-width:900px) { .email-recipient-table-heading { display:none; }.email-recipient-row { grid-template-columns:1fr; gap:.75rem; }.email-recipient-active,.email-recipient-delete { justify-self:start; }.email-recipient-add-fields { grid-template-columns:1fr; }.email-recipient-add-fields .email-recipient-types { padding:.25rem 0; } }
html[data-theme="dark"] .email-recipient-row small input,html[data-theme="dark"] .email-recipient-add > input,html[data-theme="dark"] .email-template-card input,html[data-theme="dark"] .email-template-card textarea,html[data-theme="dark"] .email-manual-form input,html[data-theme="dark"] .email-manual-form select,html[data-theme="dark"] .email-manual-form textarea { background:#121e31; border-color:#3a5070; color:var(--text); }
@media (max-width:900px) { .email-recipient-row,.email-recipient-add,.email-template-grid { grid-template-columns:1fr; } .email-recipient-row label,.email-recipient-add label { justify-self:start; } }
.email-template-stack { display:grid; gap:1.5rem; width:100%; max-width:none; }
.email-settings-layout { grid-template-columns:minmax(0,1fr); }
.email-settings-layout .notification-settings-card { width:100%; }
.email-channel-status { display:flex; flex-wrap:wrap; gap:.75rem; align-items:center; }
.email-channel-status > span { color:var(--muted); font-size:.85rem; }
.email-channel-status .status-good { color:var(--green); font-weight:700; }
.email-channel-status .status-warning { color:#b86a00; font-weight:700; }
.email-smtp-form { display:grid; gap:1rem; padding:1rem; border:1px solid var(--border); border-radius:1rem; background:color-mix(in srgb,var(--blue-soft) 28%,var(--surface)); }
.email-smtp-heading { position:relative; z-index:5; align-items:center; }
.email-smtp-edit { position:relative; z-index:6; margin-left:auto; min-width:12rem; pointer-events:auto; }
.email-smtp-form { position:relative; z-index:1; }
.email-smtp-fields { min-width:0; margin:0; padding:1.2rem; border:1px solid var(--border); border-radius:1rem; background:color-mix(in srgb,var(--blue-soft) 35%,var(--surface)); }
.email-smtp-fields:disabled { opacity:.78; }
.email-smtp-fields:disabled input,.email-smtp-fields:disabled select { cursor:not-allowed; }
.email-smtp-fields:disabled .email-smtp-actions { opacity:.65; }
.email-smtp-fields:disabled .email-smtp-actions button { cursor:not-allowed; }
.email-smtp-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.85rem; }
.email-smtp-grid label { display:grid; gap:.35rem; color:var(--text); font-size:.82rem; font-weight:700; }
.email-smtp-grid small { color:var(--muted); font-weight:400; }
.email-smtp-grid input,.email-smtp-grid select { width:100%; min-height:2.55rem; padding:.7rem .75rem; border:1px solid var(--border); border-radius:.65rem; background:var(--surface); color:var(--text); font:inherit; font-weight:400; }
.email-smtp-enabled { display:flex; align-items:center; gap:.45rem; color:var(--text); font-size:.86rem; font-weight:700; }
.email-smtp-enabled input { width:18px; height:18px; accent-color:var(--blue); }
.email-smtp-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:.65rem; }
.email-smtp-actions .btn { min-width:11rem; }
.form-help { margin:0; color:var(--muted); font-size:.8rem; }
html[data-theme="dark"] .email-smtp-form,html[data-theme="dark"] .email-smtp-grid input,html[data-theme="dark"] .email-smtp-grid select,html[data-theme="dark"] .email-smtp-fields { background:#182a45; border-color:#3a5070; }
@media (max-width:900px) { .email-smtp-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:650px) { .email-smtp-grid { grid-template-columns:1fr; } .email-smtp-actions { flex-direction:column; } .email-smtp-actions .btn { width:100%; } }
.email-template-editor { display:grid; gap:1rem; padding:1.35rem; border:1px solid var(--border); border-radius:1rem; background:var(--surface); box-shadow:0 8px 22px rgba(18,52,95,.05); }
.email-template-editor-invoice { border-top:4px solid #e02b38; }
.email-template-editor-contract { border-top:4px solid #2865b5; }
.email-template-editor-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; padding-bottom:.85rem; border-bottom:1px solid var(--border); }
.email-template-editor-heading h4 { margin:.18rem 0 .25rem; font-size:1.35rem; color:var(--text); }
.email-template-editor-heading p { margin:0; color:var(--muted); font-size:.9rem; }
.email-template-type-badge { flex:0 0 auto; padding:.38rem .7rem; border-radius:999px; background:var(--blue-soft); color:var(--blue); font-size:.78rem; font-weight:700; }
.email-template-editor label { display:grid; gap:.42rem; color:var(--text); font-weight:700; font-size:.88rem; }
.email-template-editor input,.email-template-editor textarea { width:100%; padding:.8rem .9rem; border:1px solid var(--border); border-radius:.7rem; background:var(--surface); color:var(--text); font:inherit; font-weight:400; }
.email-template-editor-frame { border:1px solid var(--border); border-radius:.7rem; background:var(--surface); overflow:hidden; }
.email-template-composer { min-height:18rem; padding:1rem 1.1rem; background:var(--surface); color:var(--text); font:inherit; font-weight:400; line-height:1.6; white-space:pre-wrap; overflow:auto; }
.email-template-composer p { margin:.35rem 0; }
.email-template-composer ul { margin:.5rem 0; padding-left:1.35rem; }
.email-template-toolbar { display:flex; gap:.4rem; padding:.55rem .65rem; border-top:1px solid var(--border); background:var(--blue-soft); }
.email-template-toolbar button { min-width:2rem; padding:.3rem .55rem; border:1px solid var(--border); border-radius:.4rem; background:var(--surface); color:var(--text); cursor:pointer; }
.email-template-toolbar button:hover { border-color:var(--blue); color:var(--blue); }
.email-template-editor-frame:focus-within { outline:2px solid color-mix(in srgb,var(--blue) 30%,transparent); border-color:var(--blue); }
.email-template-drop-target { background:color-mix(in srgb,var(--blue-soft) 55%,var(--surface)); outline:2px dashed var(--blue); outline-offset:-4px; }
.email-variable-token { display:inline-block; margin:0 .12rem; padding:.12rem .38rem; border:1px solid color-mix(in srgb,var(--blue) 35%,var(--border)); border-radius:.35rem; background:var(--blue-soft); color:var(--blue); font-size:.88em; font-weight:700; line-height:1.35; user-select:none; }
.email-template-editor input:focus,.email-template-editor textarea:focus { outline:2px solid color-mix(in srgb,var(--blue) 30%,transparent); border-color:var(--blue); }
.email-template-editor textarea { min-height:16rem; resize:vertical; line-height:1.6; }
.email-template-variables { display:grid; gap:.55rem; padding:.8rem .9rem; border-radius:.7rem; background:var(--blue-soft); color:var(--muted); font-size:.8rem; }
.email-template-variables strong { color:var(--text); }
.email-template-variables span { display:flex; flex-wrap:wrap; gap:.45rem; }
.email-template-variables code,.email-variable-chip { padding:.25rem .45rem; border-radius:.35rem; background:var(--surface); color:var(--blue); font-size:.78rem; }
.email-variable-chip { border:1px solid var(--border); cursor:grab; font:inherit; font-size:.78rem; font-weight:700; }
.email-variable-chip:active { cursor:grabbing; }
.email-variable-chip-dragging { opacity:.55; }
.email-variable-chip:hover { border-color:var(--blue); background:var(--blue-soft); }
.email-template-variables small { color:var(--muted); font-size:.78rem; }
.email-template-preview { display:grid; gap:.55rem; margin-top:.1rem; padding:1rem; border:1px dashed var(--border); border-radius:.7rem; background:var(--surface); }
.email-template-preview[hidden] { display:none; }
.email-template-preview [data-preview-subject] { color:var(--text); font-size:1rem; }
.email-template-preview [data-preview-body] { color:var(--muted); line-height:1.6; }
.email-template-actions { display:flex; align-items:center; justify-content:space-between; gap:1rem; color:var(--muted); font-size:.82rem; }
.mail-template-list { display:grid; gap:1.5rem; width:100%; }
.mail-template-card { display:grid; gap:1rem; width:100%; padding:1.5rem; border:1px solid var(--border); border-radius:1rem; background:var(--surface); box-shadow:0 8px 22px rgba(18,52,95,.05); }
.mail-template-card-invoice { border-top:4px solid #e02b38; }
.mail-template-card-contract { border-top:4px solid #2865b5; }
.mail-template-card-manual { max-width:none; border-top:4px solid var(--blue); }
.mail-template-card-manual .mail-manual-fields { display:grid; gap:1rem; grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
.mail-template-card-manual .mail-field > select { width:100%; min-height:2.8rem; padding:.8rem .9rem; border:1px solid var(--border); border-radius:.7rem; background:var(--surface); color:var(--text); font:inherit; font-weight:400; }
.mail-template-card-manual .mail-field > select:focus,.mail-template-card-manual .mail-field > input:focus { outline:2px solid color-mix(in srgb,var(--blue) 28%,transparent); outline-offset:1px; border-color:var(--blue); }
.mail-template-card > header { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; padding-bottom:1rem; border-bottom:1px solid var(--border); }
.mail-template-card > header h4 { margin:.2rem 0 .25rem; color:var(--text); font-size:1.4rem; }
.mail-template-card > header p { margin:0; color:var(--muted); }
.mail-field { display:grid; gap:.45rem; color:var(--text); font-size:.88rem; font-weight:700; }
.mail-field > input:not([type="hidden"]) { width:100%; padding:.8rem .9rem; border:1px solid var(--border); border-radius:.7rem; background:var(--surface); color:var(--text); font:inherit; font-weight:400; }
.mail-editor-shell { overflow:hidden; border:1px solid var(--border); border-radius:.75rem; background:var(--surface); }
.mail-editor { min-height:20rem; padding:1.1rem 1.2rem; color:var(--text); background:var(--surface); font:inherit; font-weight:400; line-height:1.65; outline:0; white-space:pre-wrap; }
.mail-editor p { margin:.35rem 0; }
.mail-editor ul { margin:.5rem 0; padding-left:1.4rem; }
.mail-editor-active { box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--blue) 28%,transparent); }
.mail-editor-drop-target { background:color-mix(in srgb,var(--blue-soft) 55%,var(--surface)); outline:2px dashed var(--blue); outline-offset:-5px; }
.mail-toolbar { display:flex; align-items:center; gap:.4rem; padding:.6rem .7rem; border-top:1px solid var(--border); background:var(--blue-soft); }
.mail-toolbar button { min-width:2.1rem; padding:.35rem .6rem; border:1px solid var(--border); border-radius:.45rem; background:var(--surface); color:var(--text); cursor:pointer; font:inherit; }
.mail-toolbar select { width:10rem; min-width:10rem; min-height:2.1rem; padding:.35rem .55rem; border:1px solid var(--border); border-radius:.45rem; background:var(--surface); color:var(--text); cursor:pointer; font:inherit; }
.mail-toolbar-divider { width:1px; align-self:stretch; margin:.1rem .15rem; background:var(--border); }
.mail-toolbar button:hover,.mail-toolbar button:focus-visible { border-color:var(--blue); color:var(--blue); outline:0; }
.mail-toolbar select:hover,.mail-toolbar select:focus-visible { border-color:var(--blue); color:var(--blue); outline:0; }
.mail-toolbar button[aria-pressed="true"],.mail-toolbar button.mail-toolbar-active { background:var(--blue); border-color:var(--blue); color:#fff; box-shadow:0 0 0 2px color-mix(in srgb,var(--blue) 18%,transparent); }
.mail-toolbar button[aria-pressed="true"]:hover,.mail-toolbar button[aria-pressed="true"]:focus-visible { background:color-mix(in srgb,var(--blue) 86%,#000); border-color:color-mix(in srgb,var(--blue) 86%,#000); color:#fff; }
.mail-toolbar button[data-mail-preview] { margin-left:auto; padding-inline:.8rem; font-weight:700; }
.mail-token { display:inline-block; margin:0 .14rem; padding:.12rem .42rem; border:1px solid color-mix(in srgb,var(--blue) 35%,var(--border)); border-radius:.4rem; background:var(--blue-soft); color:var(--blue); font-size:.9em; font-weight:700; line-height:1.35; user-select:none; }
.mail-variable-palette { display:grid; gap:.55rem; padding:.9rem 1rem; border-radius:.75rem; background:var(--blue-soft); color:var(--muted); font-size:.82rem; }
.mail-variable-palette strong { color:var(--text); }
.mail-variable-palette > div { display:flex; flex-wrap:wrap; gap:.5rem; }
.mail-variable-palette button { padding:.35rem .55rem; border:1px solid var(--border); border-radius:.45rem; background:var(--surface); color:var(--blue); cursor:grab; font:inherit; font-size:.8rem; font-weight:700; }
.mail-variable-palette button:hover { border-color:var(--blue); }
.mail-variable-palette button:active,.mail-variable-dragging { cursor:grabbing; opacity:.55; }
.mail-variable-palette small { line-height:1.5; }
.mail-template-header-actions { display:flex; align-items:center; justify-content:flex-end; gap:.75rem; flex-wrap:wrap; }
.mail-template-header-actions .btn-link { white-space:nowrap; }
.mail-preview { display:grid; gap:.55rem; padding:1rem; border:1px dashed var(--border); border-radius:.75rem; background:var(--surface); }
.mail-preview[hidden] { display:none; }
.mail-preview [data-mail-preview-subject] { color:var(--text); }
.mail-preview [data-mail-preview-body] { color:var(--muted); line-height:1.65; }
.mail-preview-message { gap:.85rem; padding:1.2rem 1.35rem; border-style:solid; background:var(--surface); box-shadow:0 6px 18px rgba(18,52,95,.04); }
.mail-preview-header { display:flex; align-items:baseline; justify-content:space-between; gap:1rem; padding-bottom:.7rem; border-bottom:1px solid var(--border); }
.mail-preview-header .mail-preview-label { color:var(--muted); font-size:.82rem; }
.mail-preview-message [data-mail-preview-subject] { font-size:1.1rem; }
.mail-preview-message [data-mail-preview-body] { min-height:4rem; padding:.4rem 0; color:var(--text); }
.mail-preview-message [data-mail-preview-body] p { margin:.35rem 0; }
.mail-preview-message [data-mail-preview-body] ul,.mail-preview-message [data-mail-preview-body] ol { margin:.5rem 0; padding-left:1.5rem; }
.mail-manual-actions { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding-top:.25rem; color:var(--muted); font-size:.84rem; }
.mail-manual-actions .btn { min-width:12rem; }
html[data-theme="dark"] .mail-editor,html[data-theme="dark"] .mail-field > input:not([type="hidden"]) { background:#121e31; border-color:#3a5070; color:var(--text); }
html[data-theme="dark"] .mail-toolbar,html[data-theme="dark"] .mail-template-card-manual .mail-field > select { background:#182a45; }
@media (max-width:650px) { .mail-template-card { padding:1rem; } .mail-template-card > header { flex-direction:column; }.mail-toolbar { flex-wrap:wrap; }.mail-toolbar button[data-mail-preview] { margin-left:0; }.mail-template-card-manual .mail-manual-fields { grid-template-columns:1fr; }.mail-preview-header,.mail-manual-actions { align-items:stretch; flex-direction:column; }.mail-manual-actions .btn { width:100%; } }
html[data-theme="dark"] .email-template-editor input,html[data-theme="dark"] .email-template-editor textarea { background:#121e31; border-color:#3a5070; color:var(--text); }
html[data-theme="dark"] .email-template-composer { background:#121e31; border-color:#3a5070; color:var(--text); }
html[data-theme="dark"] .email-template-toolbar { background:#182a45; }
html[data-theme="dark"] .email-template-variables code { background:#182a45; }
@media (max-width:650px) { .email-template-editor { padding:1rem; } .email-template-editor-heading,.email-template-actions { align-items:stretch; flex-direction:column; } .email-template-type-badge { align-self:flex-start; } .email-template-actions .btn { width:100%; justify-content:center; } }
.notification-inbox-panel-header h2 { margin:.3rem 0 0; font-size:1.2rem; }
.notification-inbox-count { color:var(--muted); font-size:.8rem; }
.notification-inbox-item { padding:1.1rem 1.4rem; border:0; border-bottom:1px solid var(--border); border-radius:0; }
.notification-inbox-item:last-child { border-bottom:0; }
.notification-inbox-item-body { min-width:0; }
.notification-inbox-item-body h3 { margin:.35rem 0 .25rem; color:var(--text); font-size:1rem; }
.notification-inbox-item-body p { margin:0 0 .55rem; color:var(--muted); }
.notification-state-badge { border-radius:999px; font-size:.68rem; font-weight:800; padding:.25rem .5rem; text-transform:capitalize; }
.state-pendiente { color:var(--blue); background:var(--blue-soft); }.state-leida { color:var(--green); background:var(--green-soft); }.state-pospuesta { color:#8b5b00; background:#fff5d6; }
.notification-inbox-meta { display:flex; flex-wrap:wrap; gap:.65rem; color:var(--muted); font-size:.73rem; }.notification-inbox-meta span + span { padding-left:.65rem; border-left:1px solid var(--border); }
@media (max-width:900px) { .notification-inbox-summary { grid-template-columns:repeat(2,1fr); } }
@media (max-width:700px) { .notification-inbox-heading { align-items:stretch; flex-direction:column; }.notification-inbox-summary { grid-template-columns:1fr; }.notification-inbox-panel-header,.notification-inbox-item { padding-left:1rem; padding-right:1rem; } }

/* Notification actions live in a reserved corner column so they never cover alert content. */
.notification-inbox-panel { overflow:visible; }
.notification-inbox-item { position:relative; grid-template-columns:auto minmax(0,1fr) auto; column-gap:1rem; align-items:start; }
.notification-inbox-item:has(.notification-item-menu-toggle[aria-expanded="true"]) { z-index:40; }
.notification-item-menu { grid-column:3; grid-row:1; position:relative; align-self:start; }
.notification-item-menu-toggle { display:grid; place-items:center; width:2.25rem; height:2.25rem; margin:-.2rem -.25rem 0 0; border:1px solid transparent; border-radius:.55rem; background:transparent; color:var(--muted); cursor:pointer; }
.notification-item-menu-toggle:hover,.notification-item-menu-toggle:focus-visible { border-color:var(--border); background:var(--blue-soft); color:var(--blue); outline:none; }
.notification-item-menu-toggle svg { width:1.25rem; height:1.25rem; fill:currentColor; }
.notification-item-menu-popover { position:absolute; z-index:1000; top:calc(100% + .35rem); right:0; display:grid; min-width:12rem; padding:.35rem; border:1px solid var(--border); border-radius:.7rem; background:var(--surface); box-shadow:0 .8rem 2rem rgba(16,54,111,.16); }
.notification-item-menu-popover[hidden] { display:none; }
.notification-item-menu-popover a,.notification-item-menu-popover button { display:block; width:100%; padding:.65rem .75rem; border:0; border-radius:.45rem; background:transparent; color:var(--text); cursor:pointer; font:inherit; font-size:.84rem; text-align:left; text-decoration:none; }
.notification-item-menu-popover a:hover,.notification-item-menu-popover a:focus-visible,.notification-item-menu-popover button:hover,.notification-item-menu-popover button:focus-visible { background:var(--blue-soft); color:var(--blue); outline:none; }
.notification-item-menu-popover form { margin:0; }
html[data-theme="dark"] .notification-item-menu-toggle:hover,html[data-theme="dark"] .notification-item-menu-toggle:focus-visible,html[data-theme="dark"] .notification-item-menu-popover a:hover,html[data-theme="dark"] .notification-item-menu-popover a:focus-visible,html[data-theme="dark"] .notification-item-menu-popover button:hover,html[data-theme="dark"] .notification-item-menu-popover button:focus-visible { background:#273551; }
@media (max-width:700px) { .notification-inbox-item { grid-template-columns:auto minmax(0,1fr) auto; } }
