:root {
    /* Colores de Radzen */
    --rz-primary: #E2001A !important;
    --rz-sidebar-toggle-hover-background-color: transparent !important;
    --rz-layout-body-padding: 0px !important;
    --rz-switch-checked-circle-background-color: var(--rz-primary) !important;
    /* Colores personalizados */
    --color-primary: #E2001A;
    --color-primary-dark: #B00015;
    --color-primary-light: #FEF0F1;
    --color-accent: #C9935A;
    --color-success: #2E9E5A;
    --color-warning: #E09B30;
    --color-danger: #CC3333;
    --color-bg: #F5F6FA;
    --color-bg-hover: #FAFBFF;
    --color-surface: #FFFFFF;
    --color-text: #1A1D2B;
    --color-text-secondary: #6B7186;
    --color-border: #E0E3ED;
    --radius-input: 6px;
    --radius-btn: 8px;
    --radius-card: 12px;
    --radius-chip: 20px;
    --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-dropdown: 0 4px 24px rgba(0,0,0,0.12);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.10);
    --topbar-height: 56px;
    --bottomnav-height: 56px;
    --page-top-spacing: 12px;
}

* { box-sizing: border-box; }

html, body {
    overscroll-behavior-y: contain;
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.875rem;
    line-height: 1.4;
}

#app {
    width: 100%; height: 100%;
}

/* ─────────── Espacio uniforme entre header y primer contenido de página ─────────── */
.page-content {
    padding-top: var(--page-top-spacing);
}

.app-shell {
    width: 100%; min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column;
}

.app-screen {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.app-screen::-webkit-scrollbar { width: 3px; }
.app-screen::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 4px; }

/* Scrollbars discretas */
.sga-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.sga-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
.sga-scroll::-webkit-scrollbar-track { background: transparent; }

/* ─────────── Botones ─────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 20px;
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-btn);
  font-weight: 600; font-size: 1rem;
  cursor: pointer; user-select: none;
  transition: background 150ms, border-color 150ms;
  width: 100%;
  min-height: 52px;
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: 13px 20px;
  font-weight: 600; font-size: 1rem;
  cursor: pointer; user-select: none;
  transition: background 150ms, color 150ms;
  min-height: 52px;
}
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: 13px 20px;
  font-weight: 600; font-size: 1rem;
  cursor: pointer;
  min-height: 52px;
}
.btn-danger:hover { background: rgba(204,51,51,0.08); }

.btn-icon {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--color-border); border-radius: var(--radius-btn);
  color: var(--color-text-secondary); cursor: pointer;
  transition: background 150ms, color 150ms;
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-primary); }
.btn-icon.active { background: var(--color-primary-light); color: var(--color-primary); border-color: transparent; }

/* ─────────── Inputs ─────────── */
.input, .select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  transition: border-color 150ms, box-shadow 150ms;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,90,142,0.15);
}
.input::placeholder { color: var(--color-text-secondary); }

.label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.input-scan {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 10px 12px;
}
.input-scan .bi { color: var(--color-primary); font-size: 18px; }
.input-scan input {
  flex: 1; min-width: 0; border: none; outline: none; font-size: 1.05rem;
  background: transparent; color: var(--color-text);
  padding: 4px 0; font-weight: 500;
}
.input-scan input::placeholder { font-size: 0.95rem; opacity: 0.7; }

/* ─────────── Card ─────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 14px;
}
.card.clickable { cursor: pointer; transition: border-color 150ms, box-shadow 150ms; }
.card.clickable:hover { border-color: var(--color-primary); box-shadow: var(--shadow-hover); }
.card--disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

/* ─────────── Badges ─────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-chip);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}
.badge--success { background: rgba(46,158,90,0.12); color: #1F7A42; }
.badge--warning { background: rgba(224,155,48,0.15); color: #B5781D; }
.badge--danger  { background: rgba(204,51,51,0.12); color: var(--color-danger); }
.badge--neutral { background: var(--color-bg); color: var(--color-text-secondary); }
.badge--primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge--accent  { background: rgba(201,147,90,0.14); color: #8C6233; }

.row-state { position: relative; padding-left: 10px; }
.row-state::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 8px; border-radius: 4px;
}
.row-state--red::before    { background: var(--color-danger); }
.row-state--orange::before { background: var(--color-warning); }
.row-state--green::before  { background: var(--color-success); }
.row-state--neutral::before{ background: var(--color-border); }

/* ─────────── Topbar ─────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  position: sticky; top: 0; z-index: 10;
}
.topbar__title {
  flex: 1; min-width: 0;
  font-size: 1rem; font-weight: 700; color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__sub {
  font-size: 0.7rem; color: var(--color-text-secondary); font-weight: 400;
  text-transform: none; letter-spacing: 0; margin-top: 1px;
}

/* ─────────── Bottom nav ─────────── */
.bottom-nav {
  height: var(--bottomnav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex; align-items: stretch;
  position: sticky; bottom: 0; z-index: 10;
}
.bottom-nav button {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--color-text-secondary); cursor: pointer;
  font-size: 0.65rem; font-weight: 500;
  padding: 0;
}
.bottom-nav button .bi { font-size: 20px; }
.bottom-nav button.active { color: var(--color-primary); }

/* ─────────── Listados ─────────── */
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 150ms;
}
.list-row:hover { background: var(--color-bg-hover); }
.list-row:last-child { border-bottom: none; }

.list-row__main { flex: 1; min-width: 0; }
.list-row__title {
  font-size: 0.9rem; font-weight: 600; color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-row__meta {
  font-size: 0.75rem; color: var(--color-text-secondary);
  margin-top: 2px;
  word-break: break-word;
}
.list-row__right { flex-shrink: 0; text-align: right; }

/* ─────────── Tiles del menú principal ─────────── */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}
.menu-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px 14px;
  min-height: 110px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms, transform 150ms;
}
.menu-tile:hover { border-color: var(--color-primary); box-shadow: var(--shadow-hover); }
.menu-tile:active { transform: scale(0.98); }
.menu-tile--disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}
.menu-tile__icon {
  width: 36px; height: 36px; border-radius: var(--radius-btn);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.menu-tile__title {
  font-size: 0.95rem; font-weight: 700; color: var(--color-text); margin-top: 14px;
}
.menu-tile__sub {
  font-size: 0.72rem; color: var(--color-text-secondary); margin-top: 2px;
}

/* ─────────── Toolbars de iconos ─────────── */
.icon-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.icon-toolbar .btn-icon { width: 36px; height: 36px; }
.icon-toolbar .spacer { flex: 1; }
.icon-toolbar__search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border: 1px solid var(--color-border);
  border-radius: var(--radius-input); background: var(--color-bg);
}
.icon-toolbar__search input {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  font-size: 0.8rem; color: var(--color-text);
}
.icon-toolbar__search .bi { color: var(--color-text-secondary); }

/* ─────────── Toasts ─────────── */
.toast {
  position: absolute; bottom: 72px; left: 16px; right: 16px;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-dropdown);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem; z-index: 50;
  animation: toast-in 180ms ease-out;
}
.toast--success { border-left: 4px solid var(--color-success); }
.toast--error { border-left: 4px solid var(--color-danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.qr-card__code {
  font-family: monospace; font-size: 0.75rem; color: var(--color-text-secondary);
  margin-top: 10px;
}

/* ─────────── Flash feedback ─────────── */
.flash-ok {
  background: rgba(46,158,90,0.12) !important;
  border: 2px solid var(--color-success) !important;
}
.flash-err {
  background: rgba(204,51,51,0.10) !important;
  border: 2px solid var(--color-danger) !important;
}

/* ─────────── Stepper cantidad ─────────── */
.rz-numeric .rz-spinner-up-button,
.rz-numeric .rz-spinner-down-button {
  font-size: 1.4rem !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
}
.rz-numeric input {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  min-height: 44px !important;
}

/* ─────────── Misc ─────────── */
.divider { height: 1px; background: var(--color-border); margin: 12px 0; }
.muted { color: var(--color-text-secondary); }
.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; }

.progress-bar {
  height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden;
}
.progress-bar__fill { height: 100%; background: var(--color-primary); transition: width 300ms; }

.kv {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 6px 0;
}
.kv__k { font-size: 0.72rem; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.kv__v { font-size: 0.9rem; font-weight: 600; color: var(--color-text); text-align: right; word-break: break-word; }

.section-header {
  padding: 16px 16px 8px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ─────────── Swipeable row ─────────── */
.swipe-row {
  position: relative;
  overflow: hidden;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.swipe-row__content {
  position: relative; z-index: 2;
  background: var(--color-surface);
  padding: 12px 14px;
  transition: transform 200ms ease;
  display: flex; align-items: center; gap: 10px;
}
.swipe-row__actions {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: flex; align-items: center;
  z-index: 1;
}
.swipe-row__action {
  height: 100%;
  padding: 0 18px;
  border: none; color: #fff; font-weight: 600; font-size: 0.8rem;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.swipe-row__action--primary { background: var(--color-primary); }
.swipe-row__action--warning { background: var(--color-warning); }
.swipe-row__action--danger  { background: var(--color-danger); }
.swipe-row__action--success { background: var(--color-success); }

/* ─────────── Tabla packing ─────────── */
.packing-table {
  font-size: 0.8rem;
  width: 100%;
}
.packing-table th {
  text-align: left; font-size: 0.68rem; font-weight: 700;
  color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.packing-table td {
  padding: 10px; border-bottom: 1px solid var(--color-border);
  font-size: 0.82rem;
}

/* Blazor error UI */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ha ocurrido un error."
}

@media (max-width: 480px) {
    body { padding: 0; }
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(-100%); }
}
