:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f4f6f8;
  --border: #dfe5ea;
  --muted: #6b7680;
  --primary: #1261a0;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.access-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef3f7 0%, #f8fafb 100%);
}

.login-card {
  width: min(100%, 430px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 18px 50px rgba(28, 45, 63, .10);
}
.login-brand { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
h1, h2 { margin: 0; }
.login-card h1 { font-size: 30px; }
.login-copy { color: var(--muted); margin: 8px 0 24px; line-height: 1.5; }
.login-hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 18px; }

.access-form { display: grid; gap: 16px; }
.access-form label, .form-grid label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; color: #34404b; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd7de;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  color: #17202a;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #6ca4cf; box-shadow: 0 0 0 3px rgba(18,97,160,.10); }

.primary-button, .secondary-button {
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-button { background: var(--primary); color: white; }
.secondary-button { background: white; color: #263442; border-color: #cfd7de; }
.primary-button:disabled { opacity: .55; cursor: default; }
.form-error { margin: 0; padding: 10px 12px; background: #fff0ef; color: var(--danger); border: 1px solid #f2c7c2; border-radius: 10px; font-size: 13px; }
.hidden { display: none !important; }

.admin-body { min-height: 100vh; background: #f4f6f8; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px 24px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand-link { font-size: 20px; font-weight: 800; color: #17202a; text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.admin-page { max-width: 1450px; margin: 0 auto; padding: 30px 28px 60px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
.page-header h1 { font-size: 31px; }
.page-header p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); max-width: 760px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stats-grid article { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; display: grid; gap: 2px; }
.stats-grid strong { font-size: 28px; }
.stats-grid span { color: var(--muted); font-size: 13px; }
.people-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); gap: 18px; }
.panel { background: white; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 19px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.catalog-list { display: grid; }
.catalog-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; width: 100%; border: 0; border-bottom: 1px solid #edf0f2; background: white; text-align: left; padding: 14px 18px; color: inherit; }
.catalog-row:hover { background: #f8fafb; }
.catalog-row.inactive { opacity: .58; }
.catalog-main { display: grid; gap: 3px; min-width: 0; }
.catalog-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-side { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.soft-badge { font-size: 11px; padding: 4px 7px; border-radius: 999px; background: #edf3f7; color: #52616e; white-space: nowrap; }
.soft-badge.alert { background: #fff1e7; color: #a64b00; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
.info-panel { margin-top: 18px; background: #eef6fb; border: 1px solid #cadfed; border-radius: 14px; padding: 16px 18px; }
.info-panel p { margin: 5px 0 0; color: #4e6374; line-height: 1.45; }

.access-dialog { width: min(680px, calc(100vw - 28px)); border: 1px solid var(--border); border-radius: 16px; padding: 0; box-shadow: 0 24px 70px rgba(0,0,0,.20); }
.access-dialog::backdrop { background: rgba(22,31,39,.38); }
.wide-dialog { width: min(900px, calc(100vw - 28px)); }
.access-dialog form { padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.icon-button { border: 0; background: transparent; font-size: 27px; color: #63717d; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.full-width { grid-column: 1 / -1; }
.toggle-label { display: flex !important; grid-template-columns: auto 1fr !important; align-items: center; justify-content: flex-start; }
.toggle-label input { width: auto; }
.field-title { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.permission-groups { display: grid; gap: 14px; }
.permission-group { border: 1px solid #e1e7eb; border-radius: 12px; padding: 12px; }
.permission-group h3 { margin: 0 0 8px; font-size: 13px; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 12px; }
.permission-option { display: flex !important; grid-template-columns: none !important; flex-direction: row; align-items: flex-start; gap: 8px !important; font-weight: 500 !important; }
.permission-option input { width: auto; margin-top: 2px; }
.permission-option > span { display: grid; gap: 2px; }
.user-permission-entry { display: grid; gap: 3px; padding: 3px 0; }
.user-permission-origin { color: var(--muted); font-weight: 450; font-size: 11px; line-height: 1.35; }
.user-permission-denied { color: #9a2424 !important; }
.user-permission-clear { justify-self: start; padding: 2px 0; color: #174b72; font-size: 11px; text-align: left; background: transparent; border: 0; text-decoration: underline; }
.user-permission-entry input:disabled { cursor: not-allowed; opacity: .65; }
.field-help { margin: -2px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.user-permission-groups { padding-right: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.password-actions { margin-top: 16px; padding: 12px; border-radius: 12px; border: 1px solid #e0e6ea; background: #f8fafb; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.password-actions > div { display: grid; gap: 3px; }
.password-actions span { color: var(--muted); font-size: 12px; }

@media (max-width: 850px) {
  .people-grid, .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .form-grid, .permission-grid { grid-template-columns: 1fr; }
  .topbar-user span { display: none; }
}


.mobile-access-body{
  min-height:100dvh;
  place-items:center;
  padding:
    max(24px,env(safe-area-inset-top))
    max(20px,env(safe-area-inset-right))
    max(24px,env(safe-area-inset-bottom))
    max(20px,env(safe-area-inset-left));
  background:#eef3f2;
  --primary:#176f5a;
  --muted:#66756f;
  --border:#d7e2de;
}
.mobile-access-body .login-card{
  width:min(100%,430px);
  border-color:#d7e2de;
  border-radius:24px;
  padding:30px 26px;
  box-shadow:0 18px 50px rgba(25,64,54,.10);
}
.mobile-access-body .login-brand{
  color:#153f36;
  margin-bottom:22px;
}
.mobile-access-body .eyebrow{
  color:#176f5a;
}
.mobile-access-body input{
  min-height:52px;
  border-radius:14px;
  font-size:16px;
}
.mobile-access-body input:focus{
  border-color:#67a997;
  box-shadow:0 0 0 3px rgba(23,111,90,.10);
}
.mobile-access-body .primary-button{
  min-height:52px;
  border-radius:14px;
  font-size:16px;
}
@media(max-width:520px){
  .mobile-access-body{
    place-items:stretch;
    align-content:center;
  }
  .mobile-access-body .login-card{
    width:100%;
    padding:26px 22px;
  }
}


.compact-status-info{
  margin-top:14px;
  padding:12px 14px;
}
.compact-status-info strong{
  color:#2e4b5d;
  font-size:13px;
}
.compact-status-info p{
  font-size:12px;
}
#userStatusDialog .field-help{
  margin:0;
}

/* La clave se compone en el DOM únicamente durante la impresión. */
#temporaryPasswordPrintSheet { display: none; }

@page {
  size: A4 portrait;
  margin: 18mm;
}
@media print {
  html, body, body.admin-body {
    background: #fff !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.admin-body > :not(#temporaryPasswordPrintSheet) {
    display: none !important;
  }
  #temporaryPasswordPrintSheet {
    display: block !important;
    width: 100%;
    max-width: 155mm;
    margin: 10mm auto 0;
    padding: 12mm;
    border: 1px solid #8f8f8f;
    border-radius: 0;
    color: #111;
    background: #fff;
    box-shadow: none;
    font: 12pt/1.5 Arial, Helvetica, sans-serif;
    break-inside: avoid;
  }
  .temporary-print-brand {
    margin: 0 0 2mm;
    font-size: 13pt;
    font-weight: 800;
  }
  .temporary-print-title {
    margin: 0 0 4mm;
    font-size: 19pt;
    line-height: 1.25;
    font-weight: 750;
  }
  .temporary-print-intro {
    margin: 0 0 9mm;
    font-size: 10pt;
  }
  .temporary-print-field {
    margin: 0 0 5mm;
    padding: 3mm 4mm;
    border: 1px solid #999;
    break-inside: avoid;
  }
  .temporary-print-label {
    display: block;
    font-size: 10pt;
  }
  .temporary-print-value {
    display: block;
    margin-top: 1mm;
    font-size: 19pt;
    line-height: 1.3;
    font-weight: 750;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .temporary-print-expiry {
    margin: 6mm 0 0;
    font-size: 10pt;
  }
  .temporary-print-warning {
    margin: 9mm 0 0;
    padding-top: 4mm;
    border-top: 1px solid #999;
    font-size: 10pt;
    font-weight: 650;
  }
}
