/* ══════════════════════════════════════════════════════════════════════
   StickerFlow — styles.css
   Tema: Industrial-craft · Colores cálidos + acentos vibrantes
   Fuentes: Calibri (títulos) + DM Sans (cuerpo)
══════════════════════════════════════════════════════════════════════ */

/* ── TOKENS ──────────────────────────────────────────────────────────── */
:root {
  /* Paleta base */
  --bg:          #D9D9D9;
  --bg-card:     #ffffff;
  --bg-sidebar:  #0b1020;
  --surface:     #e8eef5;
  --border:      #d0dbe8;

  /* Texto */
  --text:        #1c2336;
  --text-muted:  #5a6a82;
  --text-light:  #9aabbf;

  /* Acento principal — azul Peterpack */
  --accent:      #408FC8;
  --accent-dark: #2f72a3;
  --accent-soft: #e0eff9;

  /* Estados */
  --pending-bg:   #fff8e1;
  --pending-fg:   #b45309;
  --pending-dot:  #f59e0b;

  --process-bg:   #ede9fe;
  --process-fg:   #5b21b6;
  --process-dot:  #7c3aed;

  --invoiced-bg:  #d1fae5;
  --invoiced-fg:  #065f46;
  --invoiced-dot: #10b981;

  --delivered-bg: #dbeafe;
  --delivered-fg: #1e40af;
  --delivered-dot:#3b82f6;

  /* Nuevos estados del flujo */
  --revision-dot: #f97316;
  --fabricar-dot: #7c3aed;
  --entregar-dot: #0ea5e9;
  --entregar-bg:  #e0f2fe;
  --entregar-fg:  #075985;

  /* Misc */
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.15);
  --transition:  0.18s ease;

  /* Layout */
  --sidebar-w:   230px;
  --topbar-h:    62px;
}

/* ── MODO OSCURO ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #1a1a1a;
  --bg-card:     #222222;
  --bg-sidebar:  #0b1020;
  --surface:     #1e2d44;
  --border:      #2a3d58;

  --text:        #dce8f5;
  --text-muted:  #7a9ab8;
  --text-light:  #3f5470;

  --accent:      #4fa3df;
  --accent-dark: #3585c0;
  --accent-soft: #12293f;

  --pending-bg:   #2a1f00;
  --pending-fg:   #f6c548;

  --process-bg:   #1e1535;
  --process-fg:   #a78bfa;

  --invoiced-bg:  #022a1a;
  --invoiced-fg:  #34d399;

  --delivered-bg: #0c1e40;
  --delivered-fg: #60a5fa;

  --entregar-bg:  #062030;
  --entregar-fg:  #38bdf8;

  --shadow:      0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

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

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1,h2,h3,h4 { font-family: 'Calibri', sans-serif; }

a { color: inherit; text-decoration: none; }

button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .75rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,93,47,.14);
}
input[readonly] { opacity: .65; cursor: not-allowed; }
textarea { resize: vertical; }

/* ── UTILIDADES ──────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.active   { display: block !important; }

/* ── BOTONES ─────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--accent); color: #fff;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 600; font-size: .875rem;
  transition: background var(--transition), transform .1s;
}
.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:active { transform: scale(.97); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface); color: var(--text);
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 600; font-size: .875rem;
  border: 1.5px solid var(--border);
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--text-muted);
  padding: .5rem .85rem;
  border-radius: var(--radius);
  font-size: .875rem;
  transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--surface); color: var(--text); }

.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ══════════════════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar);
  position: relative; overflow: hidden;
}

.login-deco {
  position: absolute;
  border-radius: 50%;
  opacity: .08;
  background: var(--accent);
}
.login-deco--1 { width: 500px; height: 500px; top: -200px; right: -150px; }
.login-deco--2 { width: 300px; height: 300px; bottom: -100px; left: -80px; }

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.25rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
}

.login-brand {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.75rem;
}

.sidebar-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.login-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}
.login-logo-dark  { display: none; }
.login-logo-light { display: block; }

[data-theme="dark"] .login-logo-light { display: none; }
[data-theme="dark"] .login-logo-dark  { display: block; }

.login-page-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: .85rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.login-page-footer .footer-tagline,
.login-page-footer .footer-copy { color: rgba(255,255,255,.45); }
.login-page-footer .footer-email { color: var(--accent); }
.brand-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.brand-name {
  font-family: 'Calibri', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}

.login-title {
  font-size: 1.9rem; font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  margin-bottom: .4rem;
}
.login-sub {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1.75rem;
}

.login-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: .6rem .85rem;
  font-size: .85rem;
  margin-bottom: .85rem;
}

.login-footer {
  text-align: center;
  font-size: .8rem;
  color: var(--text-light);
  margin-top: 1rem;
}

.login-form { display: flex; flex-direction: column; gap: .85rem; }


/* ══════════════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: #f0ece4;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex; align-items: center; gap: .5rem;
  padding: 1.25rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-header .brand-name { color: #f0ece4; }
.sidebar-close { display: none; margin-left: auto; color: #b5afa6; }

.sidebar-nav {
  flex: 1;
  padding: .75rem .65rem;
  display: flex; flex-direction: column; gap: .25rem;
}

.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .85rem;
  border-radius: 8px;
  color: #b5afa6;
  font-size: .875rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #f0ece4; }
.nav-item.active {
  background: var(--accent);
  color: #fff;
}
.nav-item i { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.15rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: .4rem;
}
.user-email {
  font-size: .75rem;
  color: var(--text-light);
  word-break: break-all;
}

/* ── CONTENIDO ────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
}

#btn-open-sidebar { display: none; }

.page-title {
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: -.02em;
  flex: 1;
}

.topbar-actions {
  display: flex; align-items: center; gap: .65rem;
}

.search-wrap {
  position: relative;
}
.search-icon {
  position: absolute; left: .65rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  width: 15px; height: 15px;
  pointer-events: none;
}
.search-input {
  width: 220px;
  padding-left: 2.1rem;
  background: var(--surface);
  border-color: transparent;
  font-size: .85rem;
}
.search-input:focus { background: var(--bg-card); border-color: var(--accent); }

/* ── TOAST ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-sidebar);
  color: #f0ece4;
  padding: .65rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  white-space: nowrap;
  animation: toast-in .25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── VISTAS ──────────────────────────────────────────────────────────── */
.view {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}
.view.active { display: block; }


/* ══════════════════════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  display: flex; flex-direction: column; gap: .3rem;
}
.stat-pending  { border-color: var(--pending-dot); }
.stat-process  { border-color: var(--process-dot); }
.stat-invoiced { border-color: var(--invoiced-dot); }
.stat-delivered{ border-color: var(--delivered-dot); }
.stat-revision { border-color: var(--revision-dot); }
.stat-fabricar { border-color: var(--fabricar-dot); }
.stat-entregar { border-color: var(--entregar-dot); }

.stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-num   { font-family: 'Calibri', sans-serif; font-size: 2rem; font-weight: 800; line-height: 1; }

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.section-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.section-title {
  font-size: .95rem; font-weight: 700;
  margin-bottom: .85rem;
  letter-spacing: -.01em;
}

/* Mini lista pedidos recientes */
.order-list-mini { display: flex; flex-direction: column; gap: .5rem; }

.mini-order-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  transition: background var(--transition);
}
.mini-order-item:hover { background: var(--surface); }

.mini-order-name { flex: 1; font-size: .875rem; font-weight: 500; }
.mini-order-client { font-size: .8rem; color: var(--text-muted); }

/* Totales por cliente */
.client-totals { display: flex; flex-direction: column; gap: .5rem; }

.client-total-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .65rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: .875rem;
}
.client-total-name { font-weight: 500; }
.client-total-amount { font-weight: 700; color: var(--accent); }


/* ══════════════════════════════════════════════════════════════════════
   BADGES DE ESTADO
══════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-pendiente  { background: var(--pending-bg);  color: var(--pending-fg); }
.badge-proceso    { background: var(--process-bg);  color: var(--process-fg); }
.badge-facturado  { background: var(--invoiced-bg); color: var(--invoiced-fg); }
.badge-entregado  { background: var(--delivered-bg); color: var(--delivered-fg); }

/* Nuevos estados */
.badge-revision  { background: var(--pending-bg);  color: var(--pending-fg); }
.badge-fabricar  { background: var(--process-bg);  color: var(--process-fg); }
.badge-entregar  { background: var(--entregar-bg); color: var(--entregar-fg); }


/* ══════════════════════════════════════════════════════════════════════
   KANBAN
══════════════════════════════════════════════════════════════════════ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  align-items: start;
  height: calc(100vh - var(--topbar-h) - 3rem);
  overflow-x: auto;
}

.kanban-col {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .75rem;
  min-width: 220px;
  box-shadow: var(--shadow);
}

.kanban-col-header {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  padding: .35rem .4rem .75rem;
}

.kanban-pending   .col-dot { background: var(--pending-dot); }
.kanban-process   .col-dot { background: var(--process-dot); }
.kanban-invoiced  .col-dot { background: var(--invoiced-dot); }
.kanban-delivered .col-dot { background: var(--delivered-dot); }
.kanban-revision  .col-dot { background: var(--revision-dot); }
.kanban-fabricar  .col-dot { background: var(--fabricar-dot); }
.kanban-entregar  .col-dot { background: var(--entregar-dot); }

.col-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.col-count {
  margin-left: auto;
  background: rgba(0,0,0,.08);
  color: var(--text-muted);
  border-radius: 99px;
  padding: .1rem .5rem;
  font-size: .75rem;
}

.kanban-cards { display: flex; flex-direction: column; gap: .6rem; }

.kanban-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: .85rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border-top: 3px solid transparent;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.kanban-pending   .kanban-card { border-color: var(--pending-dot); }
.kanban-process   .kanban-card { border-color: var(--process-dot); }
.kanban-invoiced  .kanban-card { border-color: var(--invoiced-dot); }
.kanban-delivered .kanban-card { border-color: var(--delivered-dot); }
.kanban-revision  .kanban-card { border-color: var(--revision-dot); }
.kanban-fabricar  .kanban-card { border-color: var(--fabricar-dot); }
.kanban-entregar  .kanban-card { border-color: var(--entregar-dot); }

.k-card-title  { font-size: .875rem; font-weight: 600; margin-bottom: .25rem; }
.k-card-client { font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; }
.k-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; }
.k-card-total  { font-size: .85rem; font-weight: 700; }
.k-card-qty    { font-size: .78rem; color: var(--text-muted); }

.k-card-actions {
  display: flex; gap: .25rem;
  margin-top: .65rem;
}
.k-card-actions select {
  font-size: .75rem;
  padding: .25rem .4rem;
  border-radius: 6px;
  flex: 1;
}


/* ══════════════════════════════════════════════════════════════════════
   TABLA DE PEDIDOS
══════════════════════════════════════════════════════════════════════ */
.view-toolbar {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}

.select-sm {
  width: auto;
  font-size: .85rem;
  padding: .45rem .7rem;
}

.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
}

/* ── Facturación: bloques separados ─────────────────────────────────────── */
.facturar-block {
  margin-bottom: 1.5rem;
}

.facturar-block-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .6rem .9rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}

.facturar-block-header:hover { background: var(--border); }

.facturar-block-header[aria-expanded="true"] {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.facturar-block-header svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.facturar-block-header.pending {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  color: var(--accent-dark);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: default;
}

.facturar-block-header.pending:hover { background: var(--accent-soft); }

.facturar-count-badge {
  margin-left: auto;
  background: rgba(0,0,0,.08);
  color: inherit;
  font-size: .73rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 99px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.data-table thead tr {
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
}
.data-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr.tr-clickable { cursor: pointer; }
.data-table tbody tr.tr-clickable:hover { background: var(--surface); }

.td-actions {
  display: flex; gap: .25rem;
  justify-content: flex-end;
}
.td-actions .btn-icon { width: 30px; height: 30px; }

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
  font-size: .9rem;
}


/* ══════════════════════════════════════════════════════════════════════
   CLIENTES
══════════════════════════════════════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.client-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .35rem;
}
.client-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: .25rem;
}
.client-card-name { font-size: 1rem; font-weight: 700; }
.client-card-company { font-size: .85rem; color: var(--text-muted); }
.client-card-phone { font-size: .82rem; color: var(--text-muted); }
.client-card-notes { font-size: .82rem; color: var(--text-light); font-style: italic; margin-top: .25rem; }
.client-card-total {
  margin-top: .65rem;
  padding-top: .65rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-muted);
  display: flex; justify-content: space-between;
}
.client-card-total strong { color: var(--accent); }

.client-card-actions { display: flex; gap: .25rem; }


/* ══════════════════════════════════════════════════════════════════════
   MODALES
══════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity:0 } to { opacity:1 } }

.modal-backdrop.active { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 680px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in .22s ease;
}
.modal--sm { max-width: 460px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.05rem; font-weight: 700;
  letter-spacing: -.02em;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: .65rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}


/* ── FORMULARIOS ─────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}
.span-2 { grid-column: span 2; }

.field-group { display: flex; flex-direction: column; gap: .3rem; }
.field-group label {
  font-size: .8rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}

.input-row { display: flex; gap: .4rem; }
.unit-select { width: 65px; flex-shrink: 0; }

.input-readonly { background: var(--surface); }


/* ── SIDEBAR OVERLAY MÓVIL ───────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 190;
}


/* ── DETALLE MODAL ───────────────────────────────────────────────────── */
.detail-body { display: flex; flex-direction: column; gap: .65rem; }

.detail-row {
  display: flex; gap: .5rem;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .55rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; color: var(--text-muted); min-width: 140px; }
.detail-value { flex: 1; }

/* Código de pedido / cliente — discreto, esquina pequeña */
.cod-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: .06rem .28rem;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: middle;
}
.cod-badge-lg {
  font-size: .72rem;
  padding: .1rem .38rem;
}

.changelog-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  padding: .28rem .5rem;
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: .2rem;
}
.changelog-action { font-weight: 600; color: var(--text); }
.changelog-meta   { color: var(--text-muted); font-size: .73rem; white-space: nowrap; }


/* ══════════════════════════════════════════════════════════════════════
   UPLOAD DE IMAGEN
══════════════════════════════════════════════════════════════════════ */
.upload-area {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  overflow: hidden;
  min-height: 130px;
  display: flex; align-items: center; justify-content: center;
}
.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.upload-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 1.5rem;
  pointer-events: none;
  color: var(--text-muted);
  text-align: center;
}
.upload-placeholder i  { width: 28px; height: 28px; color: var(--text-light); }
.upload-placeholder span { font-size: .875rem; font-weight: 500; }
.upload-placeholder small { font-size: .75rem; color: var(--text-light); }

.upload-preview {
  max-height: 220px;
  object-fit: contain;
  border-radius: 6px;
  padding: .5rem;
  pointer-events: none;
}

.upload-progress-label {
  font-size: .8rem; color: var(--text-muted);
  margin-bottom: .35rem;
}
.upload-progress-bar {
  height: 6px;
  background: var(--surface);
  border-radius: 99px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .2s ease;
}


/* ══════════════════════════════════════════════════════════════════════
   MODAL LINK RESULTADO
══════════════════════════════════════════════════════════════════════ */
.link-result-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: .75rem;
}
.link-result-sub {
  font-size: .875rem; color: var(--text-muted);
  text-align: center; line-height: 1.6;
  margin-bottom: 1.1rem;
}
.link-result-box {
  display: flex; gap: .5rem; align-items: center;
  margin-bottom: .65rem;
}
.link-result-input {
  flex: 1;
  font-size: .82rem;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: text;
}
.link-result-expiry {
  text-align: center;
  font-size: .78rem;
  color: var(--text-light);
}


/* ══════════════════════════════════════════════════════════════════════
   PRIORIDAD POR ANTIGÜEDAD
══════════════════════════════════════════════════════════════════════ */
.age-badge {
  display: inline-flex; align-items: center;
  padding: .12rem .45rem;
  border-radius: 99px;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.age-badge.prio-green   { background: #d1fae5; color: #065f46; }
.age-badge.prio-yellow  { background: #fef3c7; color: #92400e; }
.age-badge.prio-red     { background: #fee2e2; color: #991b1b; }
.age-badge.prio-neutral { background: #f1f5f9; color: #64748b; }

/* Borde izquierdo en tabla según prioridad */
tr.priority-green  td:first-child { box-shadow: inset 4px 0 0 #10b981; }
tr.priority-yellow td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
tr.priority-red    td:first-child { box-shadow: inset 4px 0 0 #ef4444; }

/* Toggle facturado en kanban (columna Pend. Entregar) */
/* Tarjeta kanban bloqueada (sin cliente asignado) */
.kanban-card.locked {
  border: 1.5px dashed #f97316;
  opacity: .92;
}
.btn-assign-client {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  width: 100%; padding: .32rem .6rem;
  border-radius: 6px; font-size: .75rem; font-weight: 700;
  background: #fff7ed; color: #c2410c;
  border: 1.5px solid #fdba74; cursor: pointer;
  margin-top: .45rem;
}
.btn-assign-client:hover { background: #ffedd5; }

.k-facturado-toggle {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22rem .6rem;
  border-radius: 6px;
  font-size: .75rem; font-weight: 600;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  margin-top: .45rem;
  width: 100%;
  justify-content: center;
}
.k-facturado-toggle:hover { background: var(--invoiced-bg); color: var(--invoiced-fg); border-color: var(--invoiced-dot); }
.k-facturado-toggle.done  { background: var(--invoiced-bg); color: var(--invoiced-fg); border-color: var(--invoiced-dot); }


/* ══════════════════════════════════════════════════════════════════════
   TAMAÑOS Y VARIACIONES (form dinámico)
══════════════════════════════════════════════════════════════════════ */
.items-container { display: flex; flex-direction: column; gap: .6rem; }

.size-group {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.size-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .35rem .65rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: .72rem; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .05em; text-transform: uppercase;
}
.size-group-body {
  padding: .65rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.size-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 68px 1fr;
  gap: .4rem;
}
.mini-field { display: flex; flex-direction: column; gap: .18rem; }
.mini-field label {
  font-size: .67rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.mini-field input,
.mini-field select {
  font-size: .82rem; padding: .3rem .45rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text); width: 100%;
}
.mini-field input:focus,
.mini-field select:focus {
  outline: none; border-color: var(--accent);
}
.variation-header-row {
  display: grid;
  grid-template-columns: 1fr 88px 72px 28px;
  gap: .35rem;
  font-size: .67rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 0 0 .1rem;
}
.variation-list { display: flex; flex-direction: column; gap: .3rem; }
.variation-row {
  display: grid;
  grid-template-columns: 1fr 88px 72px 28px;
  gap: .35rem; align-items: center;
}
.variation-row input {
  font-size: .82rem; padding: .28rem .42rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text); width: 100%;
}
.variation-row input:focus { outline: none; border-color: var(--accent); }
.var-subtotal {
  font-size: .72rem; color: var(--text-muted);
  text-align: right; white-space: nowrap;
}
@media (max-width: 600px) {
  .size-fields { grid-template-columns: 1fr 1fr; }
  .variation-row,
  .variation-header-row { grid-template-columns: 1fr 72px 62px 28px; }
}

/* ══════════════════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════════════════ */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  margin-top: auto;
}

.app-footer-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.footer-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.footer-logo-dark  { display: none; }
.footer-logo-light { display: block; }

[data-theme="dark"] .footer-logo-light { display: none; }
[data-theme="dark"] .footer-logo-dark  { display: block; }

.footer-center {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  flex: 1;
}

.footer-tagline {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.footer-copy {
  font-size: .7rem;
  color: var(--text-light);
}

.footer-email {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.footer-email:hover { opacity: .75; }

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(2, 1fr); height: auto; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  /* Sidebar deslizable */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: flex; }

  .main-content { margin-left: 0; }
  #btn-open-sidebar { display: flex; }

  .topbar { padding: 0 1rem; }
  .search-input { width: 150px; }
  .page-title { font-size: 1rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .stat-num { font-size: 1.6rem; }

  .kanban-board { grid-template-columns: 1fr; }

  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }

  .view { padding: 1rem; }

  .topbar-actions .btn-primary span:not(.spinner) { display: none; }

  .data-table th:nth-child(4),
  .data-table td:nth-child(4),
  .data-table th:nth-child(5),
  .data-table td:nth-child(5),
  .data-table th:nth-child(9),
  .data-table td:nth-child(9) { display: none; }
}

@media (max-width: 480px) {
  .login-card { padding: 1.75rem 1.25rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .search-wrap { display: none; }

  .app-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: .65rem;
  }
  .footer-center {
    gap: .25rem;
  }
  .footer-tagline { font-size: .8rem; line-height: 1.4; }
  .footer-copy    { font-size: .75rem; line-height: 1.4; }
  .footer-email   { font-size: .8rem; }
}
