/* ============================================================
   GÜERO BARBACOA — Admin Dashboard CSS
   Dark mode premium, optimitzat per tablets/desktop de cuina
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Variables ── */
:root {
  --bg-base:        #0d0d0d;
  --bg-surface:     #161616;
  --bg-elevated:    #1e1e1e;
  --bg-card:        #222222;
  --bg-card-hover:  #2a2a2a;

  --border:         rgba(255,255,255,0.07);
  --border-active:  rgba(255,255,255,0.15);

  --text-primary:   #f5f5f5;
  --text-secondary: #a0a0a0;
  --text-muted:     #5a5a5a;

  --accent-red:     #e53935;
  --accent-red-dim: rgba(229,57,53,0.15);
  --accent-red-glow:rgba(229,57,53,0.3);

  --status-recibido:   #ff9800;
  --status-preparando: #2196f3;
  --status-listo:      #4caf50;
  --status-entregado:  #5a5a5a;

  --status-recibido-bg:   rgba(255,152,0,0.1);
  --status-preparando-bg: rgba(33,150,243,0.1);
  --status-listo-bg:      rgba(76,175,80,0.1);
  --status-entregado-bg:  rgba(90,90,90,0.1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 24px rgba(229,57,53,0.15);
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ─────────────────────────────────────────────
   VIEW SYSTEM
   ───────────────────────────────────────────── */
.view {
  display: none;
  min-height: 100vh;
}
.view.active {
  display: flex;
  flex-direction: column;
}

/* ─────────────────────────────────────────────
   LOGIN VIEW
   ───────────────────────────────────────────── */
#view-login {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, rgba(229,57,53,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(229,57,53,0.05) 0%, transparent 50%),
              var(--bg-base);
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 400px;
  margin: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent-red);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  font-style: italic;
}

.login-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 1.25rem;
}

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

.form-group input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px var(--accent-red-dim);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  width: 100%;
  background: var(--accent-red);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.875rem 1.5rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px var(--accent-red-glow);
}

.btn-primary:hover {
  background: #ef5350;
  box-shadow: 0 6px 20px var(--accent-red-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  color: var(--accent-red);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* ─────────────────────────────────────────────
   DASHBOARD SHELL (app shell quan s'ha fet login)
   ───────────────────────────────────────────── */
#view-dashboard {
  flex-direction: row;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-logo {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-logo .brand {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--accent-red);
  text-transform: uppercase;
  font-style: italic;
  letter-spacing: -0.02em;
}

.sidebar-logo .subbrand {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.nav-btn .nav-icon {
  font-size: 1.2rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--accent-red-dim);
  color: var(--accent-red);
  border: 1px solid rgba(229,57,53,0.2);
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  display: none;
}

.nav-badge.visible { display: flex; }

.sidebar-footer {
  padding: 1rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-red-dim);
  border: 1px solid var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--accent-red);
  font-weight: 700;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* ── Main content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
}

.panel {
  display: none;
  flex: 1;
  flex-direction: column;
}
.panel.active { display: flex; }

/* ── Panel header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.panel-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ─────────────────────────────────────────────
   COCINA PANEL
   ───────────────────────────────────────────── */
.cocina-body {
  flex: 1;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Stat pills al header de Cocina */
.cocina-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.875rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.stat-pill.recibido   { background: var(--status-recibido-bg);   color: var(--status-recibido);   border-color: rgba(255,152,0,0.2); }
.stat-pill.preparando { background: var(--status-preparando-bg); color: var(--status-preparando); border-color: rgba(33,150,243,0.2); }
.stat-pill.listo      { background: var(--status-listo-bg);      color: var(--status-listo);      border-color: rgba(76,175,80,0.2); }

/* Columnes de Kanban */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  flex: 1;
}

.kanban-col {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 400px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.recibido   { background: var(--status-recibido); box-shadow: 0 0 6px var(--status-recibido); }
.status-dot.preparando { background: var(--status-preparando); box-shadow: 0 0 6px var(--status-preparando); }
.status-dot.listo      { background: var(--status-listo); box-shadow: 0 0 6px var(--status-listo); }

.kanban-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Estat buit */
.empty-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.5rem;
}
.empty-col .empty-icon { font-size: 2rem; opacity: 0.5; }
.empty-col p { font-size: 0.78rem; }

/* ── Order Card ── */
.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.order-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

/* Color de barra esquerra per estat */
.order-card.recibido   { border-left-color: var(--status-recibido); }
.order-card.preparando { border-left-color: var(--status-preparando); }
.order-card.listo      { border-left-color: var(--status-listo); }

/* Animació entrada nou pedido */
@keyframes slideInCard {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}
.order-card.new-order {
  animation: slideInCard 0.35s cubic-bezier(0.4,0,0.2,1) forwards;
}

@keyframes flashNew {
  0%   { background: rgba(229,57,53,0.15); }
  100% { background: var(--bg-card); }
}
.order-card.flash {
  animation: flashNew 1.5s ease-out forwards;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}

.card-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-code {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.badge-type {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

.badge-urgent {
  background: rgba(229,57,53,0.2);
  color: var(--accent-red);
  border: 1px solid rgba(229,57,53,0.3);
  animation: pulse-urgent 1.5s ease-in-out infinite;
}

@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.card-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Items dins la targeta */
.card-items {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.875rem;
}

.card-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.card-item-qty {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.7rem;
  min-width: 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-item-info { flex: 1; }

.card-item-name {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

.card-item-opts {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.3;
  font-style: italic;
}

/* Accions de la targeta */
.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-action {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.btn-action:active { transform: scale(0.96); }

.btn-preparando {
  background: rgba(33,150,243,0.15);
  color: var(--status-preparando);
  border: 1px solid rgba(33,150,243,0.25);
}
.btn-preparando:hover {
  background: rgba(33,150,243,0.25);
}

.btn-listo {
  background: rgba(76,175,80,0.15);
  color: var(--status-listo);
  border: 1px solid rgba(76,175,80,0.25);
}
.btn-listo:hover {
  background: rgba(76,175,80,0.25);
}

.btn-entregado {
  background: rgba(90,90,90,0.15);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-entregado:hover {
  background: rgba(90,90,90,0.25);
  color: var(--text-primary);
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Botons secundaris (retrocés + eliminar) */
.card-secondary-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.btn-secondary {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}
.btn-secondary:active { transform: scale(0.95); }

.btn-back {
  color: var(--text-muted);
  flex: 1;
}
.btn-back:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-active);
}

.btn-delete {
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  flex-shrink: 0;
}
.btn-delete:hover {
  background: rgba(229,57,53,0.12);
  border-color: rgba(229,57,53,0.3);
  color: var(--accent-red);
}

/* ── Botó d'Historial ── */
.btn-historial {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-historial:hover {
  border-color: var(--border-active);
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────
   MODAL HISTORIAL
   ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  transform: translateY(10px);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-close:hover {
  background: var(--accent-red-dim);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.modal-filter {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-filter input[type="date"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  color-scheme: dark;
}
.modal-filter input[type="date"]:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 2px var(--accent-red-dim);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Targeta historial (versió compacta) */
.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.history-card-info { flex: 1; min-width: 0; }

.history-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.history-card-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-card-items {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.5;
}

.history-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-reactivar {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(76,175,80,0.25);
  background: rgba(76,175,80,0.1);
  color: var(--status-listo);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-reactivar:hover {
  background: rgba(76,175,80,0.2);
}

/* ─────────────────────────────────────────────
   REPORTES PANEL
   ───────────────────────────────────────────── */
.reportes-body {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Filtres de temps */
.filter-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.3rem;
  width: fit-content;
}

.filter-tab {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.filter-tab:hover { color: var(--text-primary); }

.filter-tab.active {
  background: var(--accent-red);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-red-glow);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-card.accent .kpi-value { color: var(--accent-red); }
.kpi-card.green .kpi-value  { color: var(--status-listo); }
.kpi-card.blue .kpi-value   { color: var(--status-preparando); }

/* Gràfics */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
}

/* Taula de pedidos recents */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover { color: var(--text-secondary); }

td {
  padding: 0.875rem 1rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.recibido   { background: var(--status-recibido-bg);   color: var(--status-recibido); }
.status-badge.preparando { background: var(--status-preparando-bg); color: var(--status-preparando); }
.status-badge.listo      { background: var(--status-listo-bg);      color: var(--status-listo); }
.status-badge.entregado  { background: var(--status-entregado-bg);  color: var(--status-entregado); }

/* Top plats (bar chart simple) */
.top-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

.top-item-rank {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 18px;
  text-align: right;
}

.top-item-bar-wrap {
  flex: 1;
  height: 28px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.top-item-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-red), #ef5350);
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
}

.top-item-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.top-item-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Distribució per tipus (donut-like simple) */
.type-split {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.type-split-bar {
  height: 10px;
  border-radius: 5px;
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
}

.type-split-bar .bar-recoger {
  background: var(--accent-red);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.type-split-bar .bar-mesa {
  background: var(--status-preparando);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

.type-legend {
  display: flex;
  gap: 1.25rem;
}

.type-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   TOAST
   ───────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  min-width: 240px;
  animation: toastIn 0.3s cubic-bezier(0.4,0,0.2,1) forwards;
  pointer-events: auto;
}

.toast.success { border-left: 3px solid var(--status-listo); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--status-preparando); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast.hiding {
  animation: toastOut 0.25s ease forwards;
}

/* ─────────────────────────────────────────────
   LOADING SPINNER
   ───────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .charts-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .kanban-board { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .panel-header { padding: 1rem 1.25rem; }
  .cocina-body, .reportes-body { padding: 1rem 1.25rem; }
}

/* Mobile top bar (hidden on desktop) */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-nav {
  display: flex;
  gap: 0.5rem;
}

.mobile-nav .nav-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.78rem;
}

/* ── Realtime indicator ── */
.realtime-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-listo);
  box-shadow: 0 0 6px var(--status-listo);
  animation: pulse-rt 2s ease-in-out infinite;
}

@keyframes pulse-rt {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.realtime-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--status-listo);
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
