:root {
  --c-primary: #8AA6A1;
  --c-primary-hover: #7a9691;
  --c-dark: #2d4a47;
  --c-darker: #1f3634;
  --c-mid: #627371;
  --paper: #f7f4ee;
  --paper-edge: #e8e0d2;
  --innar-radius: 12px;
  --innar-radius-lg: 16px;
  --innar-border: #e2e8e7;
  --innar-text: #0f172a;
  --innar-text-muted: #64748b;
  --innar-focus-ring: 0 0 0 3px rgba(138, 166, 161, 0.35);
  --innar-page-bg: linear-gradient(145deg, #f6f8f7 0%, #eef2f1 50%, #e8eeec 100%);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f1;
  color: #1f2937;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

/* ── Splash ─────────────────────────────────────────────────────────────── */
#splashScreen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--c-dark) 0%, var(--c-mid) 55%, var(--c-primary) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splashScreen.hidden-splash {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-logo {
  height: 72px;
  width: auto;
  max-width: min(420px, 86vw);
  object-fit: contain;
  margin-bottom: 24px;
  mix-blend-mode: screen;
  animation: splashLogoFade 1s ease-in-out infinite;
}
@keyframes splashLogoFade { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.splash-text { color: #fff; font-size: 16px; font-weight: 500; margin-bottom: 24px; letter-spacing: 0.5px; }
.splash-spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: splashSpin 1.2s linear infinite;
}
@keyframes splashSpin { to { transform: rotate(360deg); } }

/* ── Login: archivo ─────────────────────────────────────────────────────── */
.view-login {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(320px, 0.95fr);
}

.login-brand {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at -10% 110%, rgba(138,166,161,0.28), transparent 55%),
    linear-gradient(160deg, #1f3634 0%, #2d4a47 48%, #3d5f5b 100%);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-logo {
  height: auto;
  width: min(360px, 100%);
  max-height: 88px;
  object-fit: contain;
  object-position: left center;
  align-self: flex-start;
  margin-bottom: 32px;
  mix-blend-mode: screen;
}

.login-brand h1 {
  margin: 0;
  font-size: clamp(1.85rem, 3vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.12;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background:
    linear-gradient(180deg, rgba(247,244,238,0.92), rgba(238,242,241,0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(45,74,71,0.04) 28px);
}

.paper-card {
  position: relative;
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--paper-edge);
  border-radius: 4px 18px 18px 18px;
  padding: 36px 32px 28px;
  box-shadow:
    0 1px 0 #fff inset,
    0 18px 50px rgba(31, 54, 52, 0.12);
}

.paper-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 8px;
  background: repeating-linear-gradient(90deg, #d7e3e0 0 10px, transparent 10px 18px);
}

.paper-stamp {
  display: inline-block;
  margin-bottom: 14px;
  padding: 4px 10px;
  border: 1.5px solid #b45309;
  color: #b45309;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}

.paper-card h2 {
  margin: 0 0 8px;
  color: var(--c-darker);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.panel-lead {
  margin: 0 0 22px;
  color: var(--innar-text-muted);
  font-size: 0.95rem;
}

.local-hint {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  color: #065f46;
  font-size: 0.85rem;
}

.login-form .form-group { margin-bottom: 16px; }

.login-form label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #374151;
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: #1f2937;
}

.login-form input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: var(--innar-focus-ring);
}

#loginCodigo {
  letter-spacing: 0.28em;
  font-weight: 800;
  text-transform: uppercase;
  font-family: Consolas, "Courier New", monospace;
  text-align: center;
  font-size: 1.2rem;
}

.field-hint {
  margin: 8px 0 0;
  color: var(--innar-text-muted);
  font-size: 0.8rem;
}

.dev-code {
  margin-bottom: 14px;
  padding: 12px;
  background: #fffbeb;
  border: 1px dashed #d97706;
  border-radius: 10px;
  text-align: center;
}

.dev-code span {
  display: block;
  font-size: 0.75rem;
  color: #92400e;
  margin-bottom: 6px;
}

.dev-code strong {
  letter-spacing: 0.28em;
  font-size: 1.35rem;
  color: var(--c-darker);
  font-family: Consolas, "Courier New", monospace;
}

.login-error {
  margin: 0 0 12px;
  padding: 10px;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  font-size: 0.9rem;
}

.btn-login {
  width: 100%;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  background: linear-gradient(135deg, var(--c-dark) 0%, var(--c-darker) 100%);
  color: #fff;
  border: 0;
  border-radius: var(--innar-radius);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(45, 74, 71, 0.35);
}

.btn-login:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--c-darker) 0%, #152a28 100%);
}

.btn-login:disabled { opacity: 0.7; cursor: wait; }

.btn-ghost {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: transparent;
  border: 0;
  color: var(--c-dark);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Home ───────────────────────────────────────────────────────────────── */
.view-home {
  min-height: 100vh;
  background: var(--innar-page-bg);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 28px;
  min-height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--innar-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-brand strong {
  display: block;
  color: var(--c-dark);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.header-brand span {
  color: var(--innar-text-muted);
  font-size: 0.78rem;
}

.menu-logo {
  height: 52px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  background: #111;
  padding: 6px 10px;
  border-radius: 10px;
}

.menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-user > span {
  color: #374151;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 12px;
  background: #f8faf9;
  color: #3d534f;
  border: 1px solid #d7e0de;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-logout svg {
  flex-shrink: 0;
}

.btn-logout:hover {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
  box-shadow: 0 6px 16px rgba(159, 18, 57, 0.08);
}

.btn-logout:focus-visible {
  outline: none;
  box-shadow: var(--innar-focus-ring);
}

.home-content {
  padding: 36px 28px 56px;
  max-width: 1100px;
  margin: 0 auto;
}

.home-intro h2 {
  margin: 0 0 8px;
  color: var(--c-dark);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.home-intro p {
  margin: 0 0 28px;
  color: var(--innar-text-muted);
  max-width: 640px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.module-card {
  background: #fff;
  border: 1px solid var(--innar-border);
  border-radius: 16px;
  padding: 20px 18px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  min-height: 180px;
}

.module-card-btn {
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  width: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card-btn:hover {
  transform: translateY(-2px);
  border-color: var(--c-primary);
  box-shadow: 0 12px 28px rgba(45, 74, 71, 0.12);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border: 1px solid #d7e0de;
  background: #f8faf9;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--c-dark);
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn-back svg {
  flex-shrink: 0;
}

.btn-back:hover {
  background: var(--c-dark);
  border-color: var(--c-dark);
  color: #fff;
  transform: translateX(-2px);
  box-shadow: 0 8px 18px rgba(45, 74, 71, 0.22);
}

.btn-back:focus-visible {
  outline: none;
  box-shadow: var(--innar-focus-ring);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #3d5f5b 0%, var(--c-dark) 55%, var(--c-darker) 100%);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(45, 74, 71, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-action svg {
  flex-shrink: 0;
}

.btn-action:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(45, 74, 71, 0.34);
}

.btn-action:active {
  transform: translateY(0);
}

.btn-action:focus-visible {
  outline: none;
  box-shadow: var(--innar-focus-ring), 0 8px 20px rgba(45, 74, 71, 0.28);
}

.hv-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hv-toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 999px;
  font-size: 1rem;
  font-family: inherit;
}

.hv-toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: var(--innar-focus-ring);
}

.hv-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 28px 22px;
  padding-top: 12px;
}

.hv-folder {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.hv-folder-body {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f7f0e4 0%, #e6d4b8 100%);
  border-radius: 0 14px 14px 14px;
  min-height: 176px;
  padding: 22px 16px 14px;
  box-shadow: 0 10px 24px rgba(45, 74, 71, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hv-folder-body::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 0;
  width: 42%;
  height: 18px;
  background: #d9c7a8;
  border-radius: 10px 12px 0 0;
}

.hv-folder:hover .hv-folder-body {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(45, 74, 71, 0.18);
}

.hv-folder-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--c-dark);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.hv-folder-name,
.hv-folder-role,
.hv-folder-count {
  display: block;
}

.hv-folder-name {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--c-darker);
  line-height: 1.25;
}

.hv-folder-role {
  margin: 0 0 12px;
  font-size: 0.8rem;
  color: #6b6256;
}

.hv-folder-count {
  margin-top: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c-dark);
}

.hv-empty {
  margin: 28px 0 0;
  text-align: center;
  color: var(--innar-text-muted);
}

.hv-folder-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hv-docs {
  display: grid;
  gap: 10px;
}

.hv-doc {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--innar-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.hv-doc-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
}

.hv-doc-info {
  flex: 1;
  min-width: 0;
}

.hv-doc-info strong {
  display: block;
  color: var(--c-darker);
}

.hv-doc-info span {
  color: var(--innar-text-muted);
  font-size: 0.82rem;
}

.hv-doc button {
  border: 2px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: var(--c-dark);
}

.hv-dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(420px, 94vw);
  box-shadow: 0 18px 50px rgba(31, 54, 52, 0.2);
}

.hv-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }

.hv-dialog form { padding: 28px 24px; }

.hv-dialog h3 {
  margin: 0 0 16px;
  color: var(--c-darker);
  font-size: 1.2rem;
}

.module-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #e8f0ef;
  color: var(--c-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.module-card h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  color: var(--c-darker);
}

.module-card p {
  margin: 0;
  color: var(--innar-text-muted);
  font-size: 0.88rem;
}

.module-card em {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b45309;
}

@media (max-width: 900px) {
  .view-login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px 48px; min-height: auto; }
  .login-panel { padding: 20px 16px 40px; }
}

@media (max-width: 640px) {
  .paper-card { padding: 28px 18px 22px; }
  .menu-header { padding: 10px 14px; }
  .menu-user > span { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .home-content { padding: 24px 16px 40px; }
}
