:root {
  --bg-main: #0f1115;
  --bg-card: #181b22;
  --bg-elevated: #1f242d;
  --bg-input: #12151b;
  --border-color: #2a2f3a;
  --border-strong: #3a4150;
  --text-main: #e8eaed;
  --text-muted: #9aa0ac;
  --accent: #FFD700;
  --accent-text: #111318;
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --orange: #f59e0b;
  --orange-soft: rgba(245, 158, 11, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --nav-height: 64px;
  --header-height: 56px;
  --touch-min: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: clip;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  padding: 0;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========================================== */
/* UTILIDADES Y BOTONES                       */
/* ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background-color: #f0c800;
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background-color: #262c37;
}

.btn-danger {
  background-color: var(--red-soft);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.24);
}

.btn-success {
  background-color: var(--green-soft);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  border-color: var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-sm {
  min-height: var(--touch-min);
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.input,
.select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 12px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 15px;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.field-error {
  font-size: 12px;
  color: #fca5a5;
  min-height: 16px;
}

/* ========================================== */
/* LOGIN                                      */
/* ========================================== */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: radial-gradient(circle at top, #181c24 0%, var(--bg-main) 65%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-brand-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.pin-input {
  letter-spacing: 0.35em;
  font-weight: 700;
  font-size: 18px;
  text-align: center;
}

/* ========================================== */
/* SHELL PRINCIPAL (MOBILE FIRST + DESKTOP)   */
/* ========================================== */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background-color: rgba(24, 27, 34, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar-brand span {
  color: var(--accent);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-username {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}

.role-badge-admin {
  border-color: rgba(255, 215, 0, 0.45);
  color: var(--accent);
}

.desktop-sidebar {
  display: none;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 12px calc(var(--nav-height) + env(safe-area-inset-bottom) + 84px);
}

/* Barra inferior fija en movil */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background-color: rgba(24, 27, 34, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}

.nav-item {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item.active {
  color: var(--accent);
}

@media (min-width: 900px) {
  .app-shell {
    flex-direction: row;
  }

  .topbar {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .desktop-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    width: 236px;
    flex-shrink: 0;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    gap: 16px;
  }

  .sidebar-brand {
    padding: 6px 10px 14px;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-brand-main {
    font-size: 17px;
    font-weight: 800;
  }

  .sidebar-brand-sub {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-top: 2px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .sidebar-item {
    min-height: var(--touch-min);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
  }

  .sidebar-item svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
  }

  .sidebar-item:hover {
    background-color: var(--bg-elevated);
    color: var(--text-main);
  }

  .sidebar-item.active {
    background-color: rgba(255, 215, 0, 0.12);
    color: var(--accent);
  }

  .sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: 12px 10px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main-content {
    padding: 20px 24px 96px;
  }
}

/* ========================================== */
/* CABECERAS DE SECCION Y TARJETAS            */
/* ========================================== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.view-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.empty-state {
  background-color: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.empty-state-desc {
  margin: 0;
  font-size: 13px;
}

/* ========================================== */
/* INVENTARIO                                 */
/* ========================================== */
.inv-toolbar {
  position: sticky;
  top: var(--header-height);
  z-index: 20;
  background-color: var(--bg-main);
  padding: 6px 0 10px;
  margin-bottom: 8px;
}

@media (min-width: 900px) {
  .inv-toolbar {
    top: 0;
    padding-top: 8px;
  }
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.search-box .input {
  padding-right: 48px;
}

.search-clear-btn {
  position: absolute;
  right: 2px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.chip {
  min-height: var(--touch-min);
  padding: 0 14px;
  border-radius: 999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chip.active {
  background-color: rgba(255, 215, 0, 0.14);
  border-color: rgba(255, 215, 0, 0.55);
  color: var(--accent);
}

.inv-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 2px 10px;
}

.inv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-card.is-dirty {
  border-color: rgba(255, 215, 0, 0.55);
}

.inv-card.is-deleted {
  border-color: rgba(239, 68, 68, 0.55);
  opacity: 0.65;
}

.inv-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.inv-name-wrap {
  min-width: 0;
  flex: 1;
}

.inv-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
}

.inv-cat {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}

.inv-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.ubic-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background-color: var(--blue-soft);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ubic-badge.empty {
  background-color: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-muted);
  font-weight: 500;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-tag-edited {
  background-color: rgba(255, 215, 0, 0.14);
  color: var(--accent);
}

.status-tag-new {
  background-color: var(--green-soft);
  color: #86efac;
}

.status-tag-deleted {
  background-color: var(--red-soft);
  color: #fca5a5;
}

.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.stock-ok {
  background-color: var(--green-soft);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.stock-low {
  background-color: var(--orange-soft);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.stock-zero {
  background-color: var(--red-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.inv-card-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.inv-prices {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.inv-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.inv-cost {
  font-size: 12px;
  color: var(--text-muted);
}

.inv-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.stepper-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
}

/* Barra flotante de cambios pendientes */
.batch-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px);
  z-index: 35;
  background-color: var(--bg-elevated);
  border: 1px solid rgba(255, 215, 0, 0.55);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (min-width: 900px) {
  .batch-bar {
    left: 260px;
    right: 24px;
    bottom: 18px;
    max-width: 820px;
    margin: 0 auto;
  }
}

.batch-summary {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================== */
/* MENU MAS Y USUARIOS                        */
/* ========================================== */
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-row {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-row-title {
  font-size: 15px;
  font-weight: 700;
}

.menu-row-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* ========================================== */
/* TOASTS Y MODALES CONTROLADOS               */
/* ========================================== */
.toast-container {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast-success {
  border-left-color: var(--green);
}

.toast-error {
  border-left-color: var(--red);
}

.toast-warning {
  border-left-color: var(--orange);
}

.toast-close {
  min-width: 32px;
  min-height: 32px;
  color: var(--text-muted);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background-color: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-panel {
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.modal-body-text {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.loading-box {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.load-more-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
