:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1e212b;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --sidebar: #1e212b;
  --sidebar-text: #fafafa;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: #2a2e3a;
  --sidebar-active: #343848;
  --sidebar-border: #3a3f4d;
  --sidebar-width: 320px;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.25);
  --input-bg: #eef2ff;
  --ok: #166534;
  --ok-bg: #edf3ec;
  --err: #9f2f2d;
  --err-bg: #fdebec;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(30, 33, 43, 0.05);
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 0% -10%, rgba(30, 33, 43, 0.04), transparent 55%),
    linear-gradient(180deg, #eef1f7 0%, var(--bg) 40%, #f8fafc 100%);
}

body {
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

/* Los botones usan display:flex/inline-flex y anulan el atributo HTML hidden. */
[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid #15171f;
  min-width: 0;
  max-height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.15rem 0.2rem 0.35rem;
  min-width: 0;
  flex-shrink: 0;
}

.brand-logo-plate {
  width: 100%;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
  border-radius: 6px;
  line-height: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.brand-copy {
  min-width: 0;
}

.brand-kicker {
  margin-bottom: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.brand-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--sidebar-text);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  min-width: 0;
}

.sidebar-section#folder-section {
  flex: 1 1 auto;
}

.sidebar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-right: 0.2rem;
}

.sidebar-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  padding: 0 0.45rem;
}

.sidebar-search {
  display: block;
  padding: 0 0.15rem 0.35rem;
}

.sidebar-search input {
  width: 100%;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background: #15171f;
  color: var(--sidebar-text);
  padding: 0.55rem 0.7rem;
  font-size: 0.86rem;
}

.sidebar-search input::placeholder {
  color: var(--sidebar-muted);
}

.sidebar-search input:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn-icon {
  appearance: none;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 180ms ease, transform 150ms ease;
}

.btn-icon:hover {
  background: var(--sidebar-hover);
}

.btn-new-folder {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text);
  padding: 0.28rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 180ms ease, border-color 180ms ease, transform 150ms ease;
}

.btn-new-folder:hover:not(:disabled) {
  background: var(--sidebar-hover);
  border-color: #525a6b;
}

.btn-new-folder:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-new-folder-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.btn-trash {
  appearance: none;
  margin-top: 0.55rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 180ms ease, transform 150ms ease;
}

.btn-trash:hover {
  background: var(--sidebar-hover);
}

.btn-trash:active {
  transform: scale(0.98);
}

.trash-count {
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  background: var(--sidebar-active);
  color: var(--sidebar-text);
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trash-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 50vh;
  overflow: auto;
}

.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.trash-item strong {
  display: block;
  font-size: 0.92rem;
}

.trash-item span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.trash-item .trash-deleted-by {
  color: var(--text);
  font-size: 0.82rem;
  margin-top: 0.35rem;
}

.trash-item .trash-deleted-by em {
  font-style: normal;
  font-weight: 600;
}

.trash-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-ghost.danger-text {
  color: var(--err);
}

.btn-ghost.danger-text:hover:not(:disabled) {
  background: var(--err-bg);
}


.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 34vh;
  overflow: auto;
}

/* Visible exactamente ~3 proyectos; el resto con scroll */
.nav-list-projects {
  max-height: calc((0.65rem * 2 + 1.15em + 0.1rem + 0.95em) * 3 + 0.2rem * 2);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: #525a6b transparent;
}

.nav-list-projects::-webkit-scrollbar {
  width: 6px;
}

.nav-list-projects::-webkit-scrollbar-thumb {
  background: #525a6b;
  border-radius: 6px;
}

.nav-list-projects::-webkit-scrollbar-track {
  background: transparent;
}

.nav-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem;
  align-items: stretch;
  min-width: 0;
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--border);
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 180ms ease, transform 150ms ease, opacity 180ms ease;
  min-width: 0;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--sidebar-hover);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-item strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-actions {
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0;
  max-width: 7.5rem;
  flex-shrink: 0;
}

.nav-row:hover .nav-actions,
.nav-row:focus-within .nav-actions {
  display: flex;
}

.nav-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-action:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-action.danger:hover {
  color: #fecaca;
}

.main {
  padding: 1.35rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem 1.25rem;
  padding-bottom: 0.15rem;
  min-width: 0;
}

.header-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem 0.65rem;
  flex: 0 1 auto;
  max-width: 100%;
  padding-top: 0.2rem; /* alinea ópticamente con el título */
}

.header-action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

/* Separador sutil solo cuando carpeta + proyecto están visibles */
.header-action-group:not([hidden]) + .header-action-group:not([hidden]) {
  padding-left: 0.7rem;
  margin-left: 0.1rem;
  border-left: 1px solid var(--border);
}

.header-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.page-title {
  font-size: clamp(1.25rem, 1.7vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0.25rem 0 0;
}

.folder-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  opacity: 0.78;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem;
  min-width: 0;
  max-width: 100%;
}

.panel h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  min-width: 0;
}

.panel > p {
  color: var(--muted);
  max-width: 40rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  min-width: 0;
}

.count-pill {
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 150ms ease, opacity 180ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--sidebar);
  color: #fff;
  box-shadow: 0 1px 2px rgba(30, 33, 43, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--sidebar-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
}

.btn-danger {
  background: var(--surface);
  color: var(--err);
  border-color: #f0c7c6;
}

.btn-danger:hover:not(:disabled) {
  background: var(--err-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
  padding-inline: 0.55rem;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
}

.btn-block {
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-full {
  grid-column: 1 / -1;
}

.field span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.78;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="file"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  padding: 0.7rem 0.8rem;
  color: var(--text);
}

.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field input[type="file"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: default;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-hint,
.empty-docs {
  color: var(--muted);
  font-size: 0.86rem;
}

.form-error {
  color: var(--err);
  background: var(--err-bg);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  font-size: 0.86rem;
}

.toast {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.toast.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.toast.err {
  background: var(--err-bg);
  color: var(--err);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 100%;
  min-width: 0;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  table-layout: fixed;
}

.docs-table th,
.docs-table td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.docs-table th:nth-child(1),
.docs-table td:nth-child(1) {
  width: 18%;
}

.docs-table th:nth-child(2),
.docs-table td:nth-child(2) {
  width: 14%;
}

.docs-table th:nth-child(3),
.docs-table td:nth-child(3) {
  width: 18%;
}

.docs-table th:nth-child(4),
.docs-table td:nth-child(4) {
  width: 16%;
}

.docs-table th:nth-child(5),
.docs-table td:nth-child(5) {
  width: 7%;
  white-space: nowrap;
}

.docs-table th:nth-child(6),
.docs-table td:nth-child(6) {
  width: 5.25rem;
}

.docs-table th:nth-child(7),
.docs-table td:nth-child(7) {
  width: 24%;
  white-space: nowrap;
}

.docs-table .col-edited {
  display: none;
}

.docs-table.shows-edits .col-edited {
  display: table-cell;
}

.docs-table:not(.shows-edits) th:nth-child(1),
.docs-table:not(.shows-edits) td:nth-child(1) {
  width: 22%;
}

.docs-table:not(.shows-edits) th:nth-child(3),
.docs-table:not(.shows-edits) td:nth-child(3) {
  width: 22%;
}

.docs-table:not(.shows-edits) th:nth-child(7),
.docs-table:not(.shows-edits) td:nth-child(7) {
  width: 28%;
}

.audit-name,
.audit-time,
.audit-empty {
  display: block;
}

.audit-name {
  font-weight: 600;
  line-height: 1.3;
}

.audit-time,
.audit-empty {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}

.audit-empty {
  margin-top: 0;
}

.docs-table td:nth-child(1),
.docs-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 600;
}

.docs-table tbody tr:last-child td {
  border-bottom: 0;
}

.docs-table tbody tr:hover td {
  background: var(--bg);
}

.doc-preview-btn {
  display: inline-flex;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  line-height: 0;
  cursor: pointer;
}

.doc-preview-btn:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

.doc-preview-btn:disabled {
  cursor: default;
  padding: 0.35rem 0.4rem;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--muted);
}

.doc-preview {
  display: block;
  width: 46px;
  height: 62px;
  object-fit: cover;
  object-position: top center;
  border-radius: 3px;
}

.preview-dialog {
  width: min(1180px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.25rem);
}

.preview-dialog .dialog-body {
  max-height: calc(100vh - 1.25rem);
}

.preview-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.preview-pages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
}

.preview-page {
  margin: 0;
}

.preview-page figcaption {
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview-image {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.docs-table td.row-actions {
  display: table-cell;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  padding-right: 1rem;
}

.docs-table .row-actions .btn {
  display: inline-flex;
  width: auto;
  margin-left: 0.85rem;
  padding: 0.15rem 0.15rem;
  font-size: 0.84rem;
  line-height: 1.3;
  vertical-align: middle;
}

.docs-table .row-actions .btn:first-child {
  margin-left: 0;
}

.panel-head-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
  min-width: 0;
  flex: 1 1 auto;
}

.empty-docs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.empty-docs[hidden],
.table-wrap[hidden],
#trash-empty[hidden] {
  display: none !important;
}

.panel-head-right:has(.empty-docs:not([hidden])) #btn-upload-more {
  display: none !important;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.78;
}

.pdf-replace {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.pdf-slot {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  background: var(--surface-soft);
}

.pdf-slot-new {
  background: var(--surface);
  border-style: dashed;
  border-color: var(--muted);
}

.pdf-slot-label {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.pdf-slot-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.pdf-slot-note {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.pdf-slot-pending {
  margin-top: 0.55rem;
  font-weight: 500;
  color: var(--muted);
}

.pdf-slot-pending.is-ready {
  color: var(--ok);
  font-weight: 600;
}

.pdf-slot-new .btn {
  margin-top: 0.15rem;
}

.pdf-replace[hidden] {
  display: none !important;
}

#doc-file-field.is-upload #doc-file {
  display: block;
  margin-top: 0.35rem;
}

#doc-file-field.is-edit #doc-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
  box-shadow: 0 12px 40px rgba(30, 33, 43, 0.12);
}

.dialog-wide {
  width: min(560px, calc(100vw - 2rem));
}

.dialog.preview-dialog {
  width: min(1320px, calc(100vw - 2rem));
  max-height: calc(100vh - 1.25rem);
}

.dialog-full {
  position: fixed;
  inset: 1rem 1rem 1rem calc(var(--sidebar-width) + 1rem);
  width: auto;
  max-width: none;
  max-height: none;
  height: auto;
  margin: 0;
  border-radius: 10px;
}

.dialog-full::backdrop {
  background: linear-gradient(
    to right,
    transparent 0,
    transparent var(--sidebar-width),
    rgba(30, 33, 43, 0.35) var(--sidebar-width)
  );
}

.dialog-full .dialog-body {
  height: 100%;
  max-height: none;
  overflow: auto;
}

.dialog-full .users-table-wrap {
  flex: 1;
  max-height: none;
  min-height: 12rem;
}

.dialog-body .form-grid {
  margin-top: 0;
}

.dialog::backdrop {
  background: rgba(30, 33, 43, 0.35);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  padding: 1.25rem;
}

.dialog-body header p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

.confirm-subject {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  gap: 0.7rem;
}

.confirm-subject-row {
  display: grid;
  gap: 0.15rem;
}

.confirm-subject-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.confirm-subject-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

#empty-state,
#no-folders-state {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
  max-width: 34rem;
}

#empty-state[hidden],
#no-folders-state[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 280px;
  }

  .main {
    padding: 1.15rem 1.15rem 1.75rem;
  }

  .page-title {
    font-size: clamp(1.15rem, 2vw, 1.4rem);
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #15171f;
    max-height: none;
    overflow: visible;
  }

  .dialog-full {
    inset: 1rem;
  }

  .dialog-full::backdrop {
    background: rgba(30, 33, 43, 0.35);
  }

  .nav-list {
    max-height: 180px;
  }

  .nav-list-projects {
    max-height: calc((0.65rem * 2 + 1.15em + 0.1rem + 0.95em) * 3 + 0.2rem * 2);
  }

  .main {
    padding: 1.25rem;
  }

  .main-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
    padding-top: 0.35rem;
  }

  .header-action-group:not([hidden]) + .header-action-group:not([hidden]) {
    padding-left: 0;
    margin-left: 0;
    border-left: none;
  }

  .header-meta {
    text-align: left;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .docs-table {
    table-layout: auto;
  }

  .docs-table th:nth-child(1),
  .docs-table td:nth-child(1),
  .docs-table th:nth-child(2),
  .docs-table td:nth-child(2),
  .docs-table th:nth-child(3),
  .docs-table td:nth-child(3),
  .docs-table th:nth-child(4),
  .docs-table td:nth-child(4),
  .docs-table th:nth-child(5),
  .docs-table td:nth-child(5),
  .docs-table th:nth-child(6),
  .docs-table td:nth-child(6),
  .docs-table th:nth-child(7),
  .docs-table td:nth-child(7) {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ─── Login (split institucional) ───────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0;
  background: var(--surface);
}

.login-screen[hidden] {
  display: none !important;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: var(--sidebar);
  color: var(--sidebar-text);
}

.login-panel-inner {
  width: min(100%, 28rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.15rem;
}

.login-logo-plate {
  width: 100%;
  max-width: 22rem;
  padding: 0.85rem 1rem;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.login-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.login-panel-title {
  margin-top: 0.35rem;
  font-size: clamp(1.45rem, 2.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #ffffff;
}

.login-panel-rule {
  display: block;
  width: 3.25rem;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.login-panel-lead {
  max-width: 24rem;
  color: var(--sidebar-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.75rem 1.5rem;
  background: var(--surface);
  position: relative;
}

.login-form {
  width: min(100%, 24rem);
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.login-form-header {
  margin-bottom: 0.35rem;
}

.login-form-title {
  font-size: clamp(1.55rem, 2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-form-subtitle {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-field .login-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0 0.85rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-field .login-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-input-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  color: var(--muted);
}

.login-field .login-input-wrap input[type="email"],
.login-field .login-input-wrap input[type="password"] {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.85rem 0;
  color: var(--text);
  outline: none;
  box-shadow: none;
  border-radius: 0;
}

.login-field .login-input-wrap input[type="email"]:focus,
.login-field .login-input-wrap input[type="password"]:focus {
  outline: none;
  box-shadow: none;
}

.login-field > span:first-child {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  opacity: 1;
}

.login-field .login-input-wrap {
  opacity: 1;
}

.btn-login {
  margin-top: 0.35rem;
  padding: 0.9rem 1.1rem;
  background: var(--sidebar);
  border-color: var(--sidebar);
  font-weight: 600;
  border-radius: 8px;
}

.btn-login:hover:not(:disabled) {
  background: #2a2e3a;
  border-color: #2a2e3a;
}

.login-footer {
  position: absolute;
  bottom: 1.25rem;
  left: 1rem;
  right: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
}

@media (max-width: 900px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 2rem 1.5rem 1.75rem;
    min-height: auto;
  }

  .login-panel-inner {
    gap: 0.9rem;
  }

  .login-panel-title {
    font-size: 1.35rem;
  }

  .login-panel-lead {
    font-size: 0.88rem;
  }

  .login-form-panel {
    padding: 2rem 1.35rem 4rem;
    justify-content: flex-start;
  }

  .login-footer {
    position: static;
    margin-top: 2rem;
  }
}

/* Compat: clases antiguas del login (por si quedan referencias) */
.login-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.login-brand {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.login-lead {
  color: var(--muted);
  font-size: 0.92rem;
}

.app-shell[hidden] {
  display: none !important;
}

.btn-on-dark {
  background: transparent;
  color: var(--sidebar-text);
  border-color: var(--sidebar-border);
}

.btn-on-dark:hover {
  background: var(--sidebar-hover);
}

.btn-sidebar-cta {
  background: var(--sidebar-text);
  color: var(--sidebar);
  border-color: var(--sidebar-text);
  box-shadow: none;
}

.btn-sidebar-cta:hover:not(:disabled) {
  background: var(--border);
  color: var(--sidebar);
}

.btn-sidebar-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.75rem;
}

.sidebar-user {
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-active);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.sidebar-user-info strong {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info span {
  font-size: 0.75rem;
  color: var(--sidebar-muted);
}

.btn-logout {
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.btn-logout:hover {
  background: var(--sidebar-hover);
}

.user-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.users-dialog {
  position: fixed;
  inset: unset;
  top: 50%;
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  transform: translate(-50%, -50%);
  width: min(880px, calc(100vw - var(--sidebar-width) - 2rem));
  max-height: min(90vh, 740px);
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(30, 33, 43, 0.18);
}

.users-dialog::backdrop {
  background: rgba(30, 33, 43, 0.4);
}

.users-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.25rem 1.35rem 1.35rem;
  max-height: min(90vh, 740px);
  overflow: auto;
}

.users-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.users-dialog-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.users-dialog-header p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.users-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1rem;
}

.users-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.users-list-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  flex: 1;
}

.users-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.users-list-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
}

.users-list-count {
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(48vh, 360px);
  overflow: auto;
  padding-right: 0.15rem;
}

.users-list-empty {
  margin: 0;
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  min-width: 0;
}

.user-row:hover {
  background: var(--surface-soft);
}

.user-row-info {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.user-row-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex-wrap: wrap;
}

.user-row-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.user-row-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.user-row-email {
  font-size: 0.84rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(100%, 22rem);
}

.user-row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.btn-user-action {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

@media (max-width: 900px) {
  .users-dialog {
    left: 50%;
    width: min(880px, calc(100vw - 1.25rem));
    max-height: min(92vh, 760px);
  }

  .users-dialog-body {
    max-height: min(92vh, 760px);
  }
}

@media (max-width: 720px) {
  .user-row {
    flex-direction: column;
    align-items: stretch;
  }

  .user-row-actions {
    justify-content: flex-start;
  }

  .user-row-email {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .users-form-grid {
    grid-template-columns: 1fr;
  }

  .users-dialog-header {
    flex-direction: column;
    align-items: stretch;
  }
}

.role-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.user-row .role-badge {
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
}

.user-row .status-pill {
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--ok-bg);
}

.user-row .status-pill.is-inactive {
  background: var(--err-bg);
}

.status-pill.is-active {
  color: var(--ok);
}

.status-pill.is-inactive {
  color: var(--err);
}

.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  background: var(--input-bg);
  color: var(--text);
}

.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
