:root {
  --navy: #0f1c3f; --navy-2: #16265c; --gold: #d9a441; --gold-light: #f2c766;
  --red: #c0392b; --green: #1e7a46; --bg: #f4f6fb; --white: #fff;
  --text: #1a1f2e; --muted: #6b7280; --border: #e3e6ef; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }
h1,h2,h3,h4 { font-family: 'Poppins','Inter',sans-serif; margin: 0 0 .4em; }
button { font-family: inherit; }
a { color: inherit; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy), var(--navy-2)); }
.login-card { background: var(--white); border-radius: var(--radius); padding: 40px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-logo { height: 52px; width: auto; margin: 0 auto 18px; display: block; }
.login-card h1 { font-size: 1.3rem; color: var(--navy); text-align: center; }
.login-links { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; text-align: center; }
.link-btn { background: none; border: none; padding: 0; font-size: .82rem; color: var(--muted); cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--navy); text-decoration: underline; }
.back-home-link { display: block; text-align: left; margin-bottom: 18px; }
.password-reveal { margin-top: 16px; padding: 14px; border-radius: 8px; background: #fafbfe; border: 1.5px solid var(--gold); text-align: center; }
.password-reveal .valor { font-family: 'Poppins',sans-serif; font-size: 1.3rem; font-weight: 700; color: var(--navy); letter-spacing: .04em; margin: 6px 0; }
.password-reveal .cuenta { font-size: .76rem; color: var(--muted); }
.login-card p { color: var(--muted); font-size: .85rem; margin-bottom: 24px; text-align: center; }

/* Layout */
/* El tamaño de la pagina queda fijo al alto de la ventana: solo el contenido
   de cada pestaña (.main) hace scroll vertical, y dentro de el cada tabla
   ancha (.table-wrap) hace su propio scroll horizontal — asi el sidebar (y
   el boton de cerrar sesion) siempre estan visibles sin tener que bajar. */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 230px; background: var(--navy); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar .brand { padding: 20px 18px; font-weight: 700; font-size: .95rem; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.sidebar .brand .brand-mark { width: 100%; height: auto; background: #fff; border-radius: 8px; padding: 10px 12px; box-sizing: border-box; display: block; }
.sidebar .brand small { display: block; font-weight: 400; color: var(--gold-light); font-size: .68rem; }
.sidebar nav { flex: 1; padding: 10px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px;
  border-radius: 8px; border: none; background: none; color: rgba(255,255,255,.75); cursor: pointer; font-size: .87rem; margin-bottom: 2px;
}
.sidebar nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav button.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.sidebar .userbox { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: .8rem; color: rgba(255,255,255,.7); text-align: center; }
.sidebar .userbox .userbox-logo { height: 36px; width: auto; max-width: 100%; background: #fff; border-radius: 7px; padding: 5px; box-sizing: content-box; margin: 0 auto 10px; display: block; object-fit: contain; }
.sidebar .userbox .userbox-logo.userbox-logo-dark { background: #000; }
.sidebar .userbox #userName { font-weight: 600; color: #fff; }
.sidebar .userbox .userbox-access { font-size: .72rem; color: rgba(255,255,255,.55); margin-top: 3px; }
.sidebar .userbox button { margin-top: 10px; background: rgba(255,255,255,.08); color: #fff; border: none; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: .78rem; }

.main { flex: 1; padding: 28px 34px; overflow-y: auto; overflow-x: hidden; max-width: 100%; }
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.main-header h1 { font-size: 1.4rem; color: var(--navy); }

/* Stat cards */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stats-row-6 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); }
.stat-card .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--navy); font-family: 'Poppins',sans-serif; margin-top: 4px; }
.stat-card .sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stat-card .detalle-link { display: inline-block; margin-top: 8px; font-size: .78rem; font-weight: 600; color: var(--gold); cursor: pointer; }
.stat-card .detalle-link:hover { text-decoration: underline; }

.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.chart-box { background: #fafbfe; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.chart-box h3 { font-size: .85rem; color: var(--navy); margin-bottom: 10px; }
.chart-wrap { position: relative; height: 200px; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

/* Panel/box */
.panel { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); padding: 22px; margin-bottom: 20px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-title h2 { font-size: 1.05rem; color: var(--navy); }
.panel-title-plain { margin: 4px 0 14px; }
.panel-title-plain h2 { font-size: 1.05rem; color: var(--navy); }
.panel-title-plain .hint { margin-top: 2px; }
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col-grid { grid-template-columns: 1fr; } }

/* Barras horizontales (panel de control financiero) */
.panel-bar-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid #f1f2f5; font-size: .85rem; }
.panel-bar-row:last-child { border-bottom: none; }
.panel-bar-label { width: 130px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; color: var(--navy); font-weight: 600; }
.panel-bar-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.panel-bar-track { flex: 1; height: 10px; background: #eef0f4; border-radius: 6px; overflow: hidden; }
.panel-bar-fill { height: 100%; background: var(--gold); border-radius: 6px; }
.panel-bar-value { width: 100px; flex-shrink: 0; text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfe; }
.table-wrap { overflow-x: auto; }

/* Tabla del Directorio (admin): tiene muchas columnas con texto largo
   (productos/servicios, contacto), asi que se le fija un ancho por columna
   (colgroup) y se deja crecer mas alla del contenedor en vez de comprimirse
   — .table-wrap ya trae overflow-x:auto, asi que el usuario navega la tabla
   con una barra de desplazamiento horizontal cuando no cabe. */
.dir-admin-table { width: max-content; min-width: 100%; table-layout: fixed; }
.dir-admin-table td { overflow-wrap: break-word; }
.dir-admin-social { display: flex; gap: 6px; flex-wrap: wrap; }
.dir-admin-social-icon {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--navy); flex-shrink: 0; transition: background .2s ease, color .2s ease;
}
.dir-admin-social-icon svg { width: 14px; height: 14px; }
.dir-admin-social-icon:hover { background: var(--gold); color: var(--navy-deep); }
.dir-admin-paginador { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.dir-admin-paginador button:disabled { opacity: .4; cursor: not-allowed; }

/* Badges/status */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.pill-green { background: #e5f6ec; color: var(--green); }
.pill-gold { background: rgba(217,164,65,.15); color: #92660c; }
.pill-gray { background: #eef0f5; color: var(--muted); }
.pill-red { background: #fdeceb; color: var(--red); }
.pill-blue { background: #eaf1ff; color: #1f3a7a; }
.pill-navy { background: rgba(15,28,63,.12); color: var(--navy); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1.5px solid transparent; font-weight: 600; font-size: .83rem; cursor: pointer; background: var(--navy); color: #fff; }
.btn:hover { opacity: .92; }
.btn-sm { padding: 6px 11px; font-size: .78rem; }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: var(--navy); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 7px; font-family: inherit; font-size: .87rem;
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,28,63,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; padding: 26px; }
.modal-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title button { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }

/* Stand map */
.stand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.stand-cell {
  aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; cursor: pointer; border: 1.5px solid transparent; color: #fff;
}
.stand-cell.disponible { background: #cfd6e4; color: var(--navy); }
.stand-cell.apartado { background: var(--gold-light); color: #6b4b04; }
.stand-cell.vendido { background: var(--green); }
.stand-cell.cortesia { background: #2f6fce; }
.stand-cell.confirmada { background: var(--navy); }
.stand-cell small { font-weight: 400; opacity: .85; font-size: .62rem; }
.legend { display: flex; gap: 16px; margin: 10px 0 18px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Agenda grid */
.agenda-grid { overflow-x: auto; }
.agenda-table { border-collapse: collapse; font-size: .74rem; min-width: 900px; }
.agenda-table th, .agenda-table td { border: 1px solid var(--border); padding: 4px; text-align: center; }
.agenda-slot { min-width: 78px; height: 40px; cursor: pointer; border-radius: 4px; }
.agenda-slot.libre { background: #fafbfe; }
.agenda-slot.ocupado { background: rgba(217,164,65,.18); font-size: .66rem; padding: 2px; }
.agenda-slot:hover { outline: 2px solid var(--gold); }

.semaforo { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.semaforo.alto { background: #1e7a46; }
.semaforo.medio { background: var(--gold); }
.semaforo.bajo { background: #c7cbd6; }

.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.file-drop-sm { border: 1.5px dashed var(--border); border-radius: 7px; padding: 12px; text-align: center; font-size: .78rem; color: var(--muted); cursor: pointer; }
.file-drop-sm.has-file { border-color: var(--gold); color: var(--navy); }

.logo-upload-zone {
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; min-height: 46px;
  transition: border-color .2s ease, background .2s ease;
}
.logo-upload-zone:hover { border-color: var(--gold); }
.logo-upload-zone.has-file { border-color: var(--green); border-style: solid; background: #f3faf5; }
.logo-upload-zone.is-loading { border-color: var(--gold); background: #fffaf0; cursor: wait; }
.logo-upload-content { display: flex; align-items: center; justify-content: center; width: 100%; }
.logo-upload-hint { font-size: .78rem; color: var(--muted); }
.logo-upload-info { display: flex; flex-direction: column; text-align: left; }
.logo-upload-info small { color: var(--muted); font-size: .72rem; }
.logo-upload-status { font-size: .8rem; font-weight: 700; color: var(--green); }
.logo-preview-thumb {
  width: 42px; height: 42px; object-fit: contain; border-radius: 6px;
  background: var(--white); border: 1px solid var(--border); padding: 3px; margin-right: 10px; flex-shrink: 0;
}
.logo-upload-spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; margin-right: 8px; animation: logo-spin .7s linear infinite;
}
@keyframes logo-spin { to { transform: rotate(360deg); } }

.file-dropzone {
  border: 1.5px dashed var(--border); border-radius: 9px; padding: 18px 12px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.file-dropzone:hover { border-color: var(--gold); }
.file-dropzone.is-dragover { border-color: var(--gold); background: rgba(217,164,65,.08); color: var(--navy); }
.file-dropzone.is-loading { border-color: var(--gold); background: #fffaf0; cursor: wait; }
.file-dropzone.has-file { border-color: var(--green); border-style: solid; }
.file-dropzone-hint { font-size: .82rem; display: flex; align-items: center; justify-content: center; gap: 6px; }
.file-dropzone-link { color: var(--gold); font-weight: 600; text-decoration: underline; }
.file-dropzone-error { color: var(--red); font-size: .78rem; margin-top: 6px; min-height: 1em; }
.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fafbfe; border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font-size: .8rem; color: var(--navy);
}
.file-item.file-item-ok { background: #f3faf5; border-color: var(--green); }
.file-item-name { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-name small { color: var(--muted); font-weight: 400; }
.file-item-status { color: var(--green); font-weight: 700; flex-shrink: 0; }
.file-item-thumb { width: 26px; height: 26px; object-fit: contain; border-radius: 4px; background: var(--white); border: 1px solid var(--border); padding: 2px; flex-shrink: 0; }
.file-item-doc-icon { width: 26px; height: 26px; border-radius: 4px; background: var(--white); border: 1px solid var(--border); color: var(--red); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-item-doc-icon svg { width: 16px; height: 16px; }

/* Progress bar (pagos) */
.progress-bar { position: relative; height: 10px; border-radius: 999px; background: #e9ecf5; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 999px; transition: width .25s ease; }
.progress-bar-fill.tone-gray { background: #c3c8d6; }
.progress-bar-fill.tone-gold { background: var(--gold); }
.progress-bar-fill.tone-green { background: var(--green); }
.progress-bar-fill.tone-red { background: var(--red); }
.progress-labels { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); margin-top: 6px; }
.progress-labels strong { color: var(--navy); }
.pago-item { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; padding: 6px 0; border-bottom: 1px solid #eee; }
.pago-item-info { display: flex; flex-direction: column; }
.pago-item-info small { color: var(--muted); font-size: .72rem; }

.alert { padding: 14px 16px; border-radius: 9px; font-size: .88rem; }
.alert-success { background: #e5f6ec; color: #1e7a46; border: 1px solid #b8e6c9; }
.alert-error { background: #fdeceb; color: #a8362a; border: 1px solid #f4c3bd; }
.alert-info { background: #eaf1ff; color: #1f3a7a; border: 1px solid #c8dafd; }

/* QR scan row highlight */
.row-highlight { animation: row-pulse-ok 1.5s ease-in-out 2; }
.row-highlight-warn { animation: row-pulse-warn 1.5s ease-in-out 2; }
@keyframes row-pulse-ok { 0%, 100% { background: transparent; } 50% { background: rgba(30,122,70,.18); } }
@keyframes row-pulse-warn { 0%, 100% { background: transparent; } 50% { background: rgba(192,57,43,.18); } }

@media (max-width: 900px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  /* En movil el sidebar se apila arriba del contenido en vez de ser una
     columna fija, asi que se vuelve al scroll normal de la pagina completa. */
  .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; overflow-y: visible; }
  .main { overflow-y: visible; }
}
