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

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-body);
  font-size: 13px;
  line-height: 1.5;
}

/* ── SHELL ── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
}

/* Header */
.sidebar-header {
  padding: 14px 14px 12px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* Logo siempre visible — nunca se oculta */
.bold-logo {
  flex-shrink: 0;
  overflow: visible;
  transition: opacity 0.2s;
}

/* Al colapsar: logo centrado encima, toggle debajo centrado */
.sidebar.collapsed .sidebar-header {
  padding: 14px 8px 12px;
}

.sidebar.collapsed .logo-row {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 0;
}

/* Escala el logo a 48px de ancho cuando colapsado */
.sidebar.collapsed .bold-logo {
  width: 40px;
  height: auto;
}

.toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-btn:hover { background: #F3F4F6; }

/* User block */
.user-block { margin-bottom: 12px; overflow: hidden; white-space: nowrap; }
.sidebar.collapsed .user-block { display: none; }
.user-name { font-size: 13px; font-weight: 600; color: var(--navy); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Branch selector */
.branch-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  margin-bottom: 12px;
  cursor: default;
  overflow: hidden;
}

.sidebar.collapsed .branch-selector { display: none; }

.branch-name {
  font-size: 12px;
  color: var(--text-body);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nueva venta button */
.btn-nueva-venta {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .btn-nueva-venta { padding: 9px; }
.sidebar.collapsed .btn-nueva-venta .btn-label { display: none; }

/* ── NAV ── */
.nav {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-single {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-body);
  white-space: nowrap;
  cursor: default;
  flex-shrink: 0;
}

.nav-single:hover { background: var(--bg-subtle); }
.nav-single.active { color: var(--red); background: #FEF2F2; font-weight: 500; }

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.nav-section-header:hover { background: var(--bg-subtle); }
.nav-section-header.open { color: var(--red); }

.sidebar.collapsed .nav-section-header,
.sidebar.collapsed .nav-single {
  justify-content: center;
  padding: 9px;
}

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-label { margin-left: 8px; }
.sidebar.collapsed .nav-label { display: none; }

.nav-chev {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.nav-section-header.open .nav-chev { transform: rotate(180deg); }
.sidebar.collapsed .nav-chev { display: none; }

/* Sub-menu */
.nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.2s ease;
  flex-shrink: 0;
}

.nav-sub.open { max-height: 300px; }
.sidebar.collapsed .nav-sub { display: none; }

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 32px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: default;
  white-space: nowrap;
}

.nav-sub-item:hover { background: var(--bg-subtle); color: var(--text-body); }

.nav-sub-item.active {
  color: var(--red);
  font-weight: 500;
  background: #FEF2F2;
}

.nav-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.nav-divider {
  height: 0.5px;
  background: var(--border);
  margin: 4px 0;
}

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-app { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.topbar-app strong { color: var(--navy); font-weight: 600; }

.topbar-help {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: default;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

/* Content area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg-page);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-back {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--navy);
}
