/* Mi Bodega Admin: base compartida y Dashboard V1. Sin dependencias visuales. */
:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --surface: #fff;
  --ink: #262c29;
  --muted: #626b66;
  --line: #e2e6df;
  --accent: #876318;
  --accent-light: #f7ecd0;
  --green: #286747;
  --green-light: #eff6f0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', sans-serif; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(.95); }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #926a16; outline-offset: 4px; }
input { width: 100%; min-height: 46px; border: 1px solid #a7b0a8; border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.2; letter-spacing: -.8px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; line-height: 1.4; }
h3 { font-size: 15px; font-weight: 600; }
.shell { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.panel { margin: 24px; width: 100%; max-width: 460px; padding: 40px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid #b88b35; border-radius: 14px; box-shadow: 0 12px 40px #27362808; }
.panel h1 { font-size: 24px; letter-spacing: -.4px; margin-bottom: 8px; }
.subtitle { color: var(--accent); font-size: 14px; font-weight: 600; margin-bottom: 24px; }
.description { color: var(--muted); margin: 18px 0 24px; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
#login-btn, #access-logout-btn { width: 100%; }
#access-logout-btn { margin-top: 20px; }
.status { display: inline-block; border-radius: 6px; padding: 7px 10px; background: #f7f0e2; color: #765511; margin-bottom: 12px; font-size: 14px; }
.status.error, .form-msg { color: #8f3229; background: #fff1ef; border: 1px solid #edd2cd; }
.form-msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.admin-layout { width: 100%; min-height: 100dvh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 30px 18px 22px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; margin: 0 8px 44px; font-size: 15px; font-weight: 750; letter-spacing: .2px; line-height: 1.4; }
.brand-mark { width: 38px; height: 40px; display: grid; place-items: center; background: #b88b35; color: #fff; border-radius: 10px; font-size: 26px; font-weight: 700; }
.brand div > span { display: block; font-size: 9px; font-weight: 550; letter-spacing: 2px; color: var(--muted); margin-top: 3px; }
.nav-label { font-size: 9px; font-weight: 700; letter-spacing: 1.3px; color: var(--muted); margin: 0 14px 14px; }
.navigation { display: grid; gap: 5px; }
.navigation button { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; border-radius: 8px; padding: 11px 14px; background: transparent; color: #535d55; font-size: 14px; font-weight: 550; }
.navigation button[aria-current='page'] { color: #705213; background: var(--accent-light); }
.navigation button:hover { background: #f4f5ef; filter: none; }
.navigation small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); }
.nav-icon { font-size: 21px; width: 20px; text-align: center; line-height: 1; }
.sidebar-note { margin: auto 10px 0; padding-top: 38px; font-size: 11px; font-weight: 600; color: #455347; }
.sidebar-note p { margin: 6px 0 0; font-size: 10px; color: var(--muted); font-weight: 400; }
.small-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 8px; }
.workspace { min-width: 0; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 80px; padding: 14px 36px; background: #ffffffb3; border-bottom: 1px solid var(--line); }
.breadcrumb { font-size: 12px; color: var(--muted); }
.breadcrumb > span { margin: 0 12px; color: #b7beb8; }
.breadcrumb strong { color: var(--ink); font-weight: 550; }
.header-actions { display: flex; gap: 18px; align-items: center; }
.admin-badge { font-size: 12px; color: #526055; }
.button-secondary { border-color: #d6dcd3; background: #fff; color: #475147; font-size: 12px; padding: 9px 14px; }
.workspace-content { padding: 32px 36px 20px; max-width: 1440px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: 1.5px; font-weight: 700; margin-bottom: 9px; }
.page-heading h1 { margin-bottom: 9px; }
.page-heading p:last-child { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.environment-badge { font-size: 11px; padding: 5px 10px; border: 1px solid #d8dfd5; background: #fff; border-radius: 6px; }
.overview-banner { display: flex; justify-content: space-between; gap: 20px; align-items: center; background: var(--green-light); border: 1px solid #d9e6d9; border-radius: 10px; padding: 18px 20px; margin-bottom: 28px; }
.overview-banner strong { color: #345940; font-size: 13px; font-weight: 650; }
.overview-banner p { color: #556a57; font-size: 12px; margin: 4px 0 0 19px; }
.overview-banner button { flex-shrink: 0; }
.overview-banner[data-state='error'] { background: #fff4ed; border-color: #ecd8ca; }
.overview-banner[data-state='error'] strong, .overview-banner[data-state='error'] p { color: #88452c; }
.overview-banner[data-state='error'] .small-dot { background: #a65333; }
.overview-banner[data-state='loading'] .small-dot { background: #877535; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > span { font-size: 11px; color: var(--muted); }
.subtle-tag { display: inline-block; padding: 3px 8px; background: #f0f2ed; border: 1px solid #e3e7df; border-radius: 5px; color: #60695e; font-size: 10px; white-space: nowrap; }
.section-description { margin-bottom: 16px; font-size: 12px; color: var(--muted); max-width: 750px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card { background: #fff; border: 1px solid var(--line); padding: 18px 18px 16px; border-radius: 10px; }
.metric-heading { display: flex; justify-content: space-between; gap: 8px; min-height: 42px; }
.metric-heading h3 { font-size: 12px; color: #535e55; margin: 0; line-height: 1.5; font-weight: 550; }
.metric-heading > span { color: #93835d; font-size: 18px; }
.metric-value { font-size: 32px; line-height: 1; color: #7c847b; margin: 10px 0 15px; font-weight: 450; }
.metric-note { font-size: 10px; margin: 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; }
.dashboard-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-heading h2 { margin: 0; }
.outline-icon { color: #8d9c8c; }
.system-list { margin: 0; font-size: 12px; }
.system-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid #eff1ec; }
.system-list dt { color: var(--muted); }
.system-list dd { margin: 0; text-align: right; font-weight: 550; }
.health-ok { color: var(--green); }
.health-error { color: #9b3529; }
.checked-at { font-size: 10px; color: var(--muted); margin: 14px 0 0; }
.empty-state { text-align: center; padding: 9px 16px 14px; max-width: 365px; margin: 0 auto; }
.empty-symbol { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #f3f4ee; color: #87907f; font-size: 25px; margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 7px; font-size: 13px; }
.empty-state p { color: var(--muted); font-size: 12px; margin-bottom: 0; }
.quick-section { margin-top: 26px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.quick-link { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; color: #4a564b; background: transparent; border: 1px solid #dce1d7; text-align: left; font-size: 12px; font-weight: 550; }
.quick-link small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 400; }
.dashboard-footer { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 14px; color: #6b7469; font-size: 9px; letter-spacing: 1px; display: flex; justify-content: space-between; gap: 12px; }
.dashboard-footer span { letter-spacing: 0; }
.dashboard-error { margin: -12px 0 22px; padding: 12px; border-radius: 8px; border: 1px solid #efd6cd; background: #fff2ec; color: #8e3b2c; font-size: 13px; }
.placeholder-view { max-width: 640px; padding: 60px 0; }
.placeholder-view > p:not(.eyebrow) { color: var(--muted); }
.placeholder-note { font-size: 13px; margin: 24px 0; }
.skip-link { position: absolute; left: 245px; top: -100px; padding: 10px; background: #fff; color: var(--ink); z-index: 2; }
.skip-link:focus { top: 8px; }
@media (min-width: 1600px) { .workspace-content { padding-top: 44px; } .metrics-grid { gap: 20px; } }
@media (max-width: 1100px) {
  .admin-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .workspace-header { padding: 14px 24px; }
  .workspace-content { padding: 26px 24px 20px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand { margin-left: 0; font-size: 13px; }
}
@media (max-width: 760px) {
  .admin-layout { display: block; }
  .sidebar { border-right: 0; padding: 18px 18px 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 0 18px; }
  .nav-label, .sidebar-note { display: none; }
  .navigation { display: flex; overflow-x: auto; gap: 6px; padding: 0 0 12px; }
  .navigation button { width: auto; flex-shrink: 0; padding: 8px 12px; gap: 7px; font-size: 12px; }
  .navigation small { font-size: 9px; }
  .nav-icon { font-size: 16px; }
  .workspace-header { min-height: 64px; padding: 10px 18px; }
  .breadcrumb { display: none; }
  .header-actions { justify-content: space-between; width: 100%; }
  .workspace-content { padding: 26px 18px 18px; }
  .page-heading { align-items: flex-start; gap: 8px; }
  .page-heading h1 { font-size: 29px; }
  .page-heading p:last-child { font-size: 12px; }
  .environment-badge { font-size: 10px; margin-top: 23px; }
  .overview-banner { padding: 16px; flex-direction: column; align-items: flex-start; gap: 14px; }
  .overview-banner p { margin-left: 0; }
  .overview-banner button { width: 100%; }
  .section-heading { align-items: flex-start; flex-wrap: wrap; }
  .metrics-grid { gap: 10px; }
  .metric-card { padding: 15px 12px; }
  .metric-heading { min-height: 54px; }
  .detail-grid { grid-template-columns: 1fr; gap: 16px; }
  .dashboard-card { padding: 20px; }
  .quick-grid { gap: 8px; }
  .quick-link { padding: 12px 10px; }
  .dashboard-footer { flex-direction: column; gap: 5px; }
  .skip-link { left: 18px; }
  .panel { padding: 28px 24px; margin: 18px; }
}

/* ===== NEGOCIOS VIEW ===== */
.businesses-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.toolbar-filters select {
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid #a7b0a8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}
.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}
.search-wrapper input {
  padding-right: 42px;
}
.search-wrapper button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.search-wrapper button:hover { color: var(--ink); }

.businesses-table-container {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}
.businesses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.businesses-table th,
.businesses-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.businesses-table thead th {
  background: #fafbf6;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}
.businesses-table tbody tr:hover {
  background: #fbfcf7;
}
.businesses-table tbody tr:last-child td {
  border-bottom: none;
}
.uid-cell {
  font-size: 11px;
  background: #f3f4ee;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-activa { background: var(--green-light); color: var(--green); }
.status-prueba { background: #fff7e0; color: #876318; }
.status-inactiva { background: #fceaea; color: #9b3529; }
.status-vinculada { background: #e8f4fd; color: #1e6ab0; }
.status-sin-tienda { background: #f0f2ed; color: #60695e; }
.status-loading { background: #f0f2ed; color: #60695e; }
.status-error { background: #fceaea; color: #9b3529; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}
.pagination-controls .button-secondary {
  min-width: 110px;
}
.page-info {
  font-size: 13px;
  color: var(--muted);
  min-width: 120px;
  text-align: center;
}

/* Detail Modal */
.detail-modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 680px;
  width: 92%;
  box-shadow: 0 24px 60px #2736281a;
}
.detail-modal::backdrop {
  background: #00000080;
}
.modal-content {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fafbf6;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: #eff1ec; color: var(--ink); }
.modal-body {
  padding: 22px;
  max-height: 70vh;
  overflow-y: auto;
}
.detail-section {
  margin-bottom: 24px;
}
.detail-section:last-child { margin-bottom: 0; }
.detail-section h3 {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.detail-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 16px;
  font-size: 13px;
}
.detail-grid dt {
  color: var(--muted);
  font-weight: 500;
}
.detail-grid dd {
  margin: 0;
  color: var(--ink);
}
.detail-grid code {
  font-size: 11px;
  background: #f3f4ee;
  padding: 2px 6px;
  border-radius: 4px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.detail-table th,
.detail-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.detail-table thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  background: #fafbf6;
  font-weight: 600;
}
.detail-table code {
  font-size: 10px;
}

.error-state {
  padding: 20px;
  text-align: center;
  color: #8e3b2c;
  background: #fff2ec;
  border: 1px solid #efd6cd;
  border-radius: 8px;
}

.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;
}

/* ===== LICENCIAS VIEW ===== */
.license-open { background: transparent; color: inherit; padding: 4px; }
.license-open:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.notes-display { overflow-wrap: anywhere; }
.status-vencida { background: #fceaea; color: #9b3529; }
.status-desconocida { background: #f0f2ed; color: #60695e; }
.status-legacy { background: #fff7e0; color: #876318; }

.notes-display {
  white-space: pre-wrap;
  font-family: inherit;
  background: #fafbf6;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  min-height: 40px;
}
.notes-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
}

/* ===== ALTA DE LICENCIA (Nueva licencia) ===== */
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #a7b0a8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 92px; resize: vertical; }
.field-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-actions .button-secondary { min-width: 110px; }
.modal-actions button:last-child:not(.button-secondary) { min-width: 170px; }
