:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --panel: #fffdfa;
  --panel-2: #f1f3ef;
  --text: #1f2522;
  --muted: #68736d;
  --line: #dfe3dc;
  --primary: #7d3f5f;
  --primary-2: #2f6f67;
  --accent: #c69a46;
  --ok: #2f7d59;
  --warn: #b56a19;
  --danger: #b84545;
  --info: #315f78;
  --shadow: 0 18px 44px rgba(31, 37, 34, .1);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --panel: #18201d;
  --panel-2: #202a26;
  --text: #f7faf6;
  --muted: #b6c0ba;
  --line: #314039;
  --primary: #d895b9;
  --primary-2: #84d2c5;
  --accent: #e7c46f;
  --ok: #78d29d;
  --warn: #f2b56b;
  --danger: #ef8585;
  --info: #95c9df;
  --shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    linear-gradient(112deg, transparent 0 72%, rgba(47, 111, 103, .05) 72% 74.5%, transparent 74.5% 100%),
    linear-gradient(180deg, rgba(255, 253, 250, .62), rgba(247, 244, 239, .88)),
    var(--bg);
}

.zebra-motion-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .42;
}

.app-shell,
.login-screen,
.modal,
.toast,
.app-version-badge {
  position: relative;
  z-index: 1;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 249, .82);
  backdrop-filter: blur(18px);
}
[data-theme="dark"] .sidebar { background: rgba(31, 26, 23, .78); }
.brand, .mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, #fff, #fff2f7);
  box-shadow: 0 14px 30px rgba(224, 70, 144, .22);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 2px;
}
.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.nav {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}
.nav-item, .bottom-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 16px;
  padding: 13px 14px;
  font-weight: 750;
  transition: .18s ease;
}
.nav-item span { margin-right: 10px; }
.nav-item:hover, .bottom-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active, .bottom-item.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(155, 92, 69, .16), rgba(215, 167, 111, .18));
  box-shadow: inset 0 0 0 1px rgba(155, 92, 69, .15);
}
.sidebar-figure-card {
  margin-top: auto;
  display: grid;
  place-items: end center;
  padding: 8px 6px 18px;
}
.sidebar-figure-card img {
  width: min(100%, 220px);
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 30px rgba(88, 57, 39, .12));
}
.main {
  min-width: 0;
  padding: 24px 26px 34px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: -24px -26px 20px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 247, 242, .78);
  backdrop-filter: blur(18px);
}
[data-theme="dark"] .topbar { background: rgba(19, 16, 14, .78); }
.mobile-brand { display: none; }
.global-search {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 10px 35px rgba(88, 57, 39, .05);
}
.global-search span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.global-search input {
  width: 100%;
  min-width: 80px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.mobile-settings-shortcut { display: none; }
.view { outline: none; }
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 6px;
  font-size: 40px;
  line-height: .98;
  letter-spacing: 0;
}
.subtitle, .muted {
  color: var(--muted);
  line-height: 1.5;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: rgba(255, 253, 249, .9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .card { background: rgba(31, 26, 23, .92); }
.card.flat { box-shadow: none; }
.card-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.card-title h2, .card-title h3 { margin: 0; }
.metric {
  min-height: 132px;
  display: grid;
  align-content: space-between;
  position: relative;
  overflow: hidden;
}
.metric::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -42px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: rgba(215, 167, 111, .18);
}
.metric strong {
  font-size: 42px;
  letter-spacing: 0;
  line-height: 1;
}
.metric span { color: var(--muted); font-weight: 750; }
.metric small { color: var(--muted); }
.actions-row, .filters-row, .form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}
button, .button {
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}
.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 14px 28px rgba(155, 92, 69, .25);
}
.ghost { background: transparent; }
.danger {
  border-color: transparent;
  background: var(--danger);
  color: white;
}
.success {
  border-color: transparent;
  background: var(--ok);
  color: white;
}
.icon-button {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 22px;
}
.input, input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  padding: 12px 13px;
  outline: 0;
}
textarea { min-height: 96px; resize: vertical; }
label.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.field span { color: var(--muted); }
.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}
.inline-field input { width: auto; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
th, td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(215, 167, 111, .07); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill.ok { color: var(--ok); background: rgba(47, 125, 89, .12); border-color: rgba(47, 125, 89, .2); }
.pill.warn { color: var(--warn); background: rgba(181, 106, 25, .12); border-color: rgba(181, 106, 25, .2); }
.pill.danger { color: var(--danger); background: rgba(184, 69, 69, .12); border-color: rgba(184, 69, 69, .2); }
.pill.info { color: var(--info); background: rgba(75, 112, 143, .12); border-color: rgba(75, 112, 143, .2); }
.list {
  display: grid;
  gap: 10px;
}
.list-item {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
}
.list-item strong { letter-spacing: 0; }
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); font-weight: 850; }
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.2);
}
.modal {
  width: min(920px, calc(100vw - 22px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}
.small-modal { width: min(520px, calc(100vw - 22px)); }
.modal::backdrop { background: rgba(25, 15, 8, .42); backdrop-filter: blur(4px); }
.modal-card {
  max-height: min(88vh, 960px);
  overflow: auto;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0,0,0,.28);
  padding: 18px;
}
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; letter-spacing: 0; }
.modal-body { display: grid; gap: 14px; }
.repeat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product-lines, .material-lines { display: grid; gap: 10px; }
.line-card {
  display: grid;
  grid-template-columns: 1.6fr .7fr .8fr .8fr 42px;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
}
.material-line-card { grid-template-columns: 1.5fr .7fr 42px; }
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.thumb {
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
  aspect-ratio: 1/1;
  display: grid;
  place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}
.chat-card {
  display: grid;
  min-height: 620px;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
  max-height: 560px;
}
.bubble {
  width: fit-content;
  max-width: 90%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  line-height: 1.45;
}
.bubble.user { align-self: flex-end; background: rgba(155, 92, 69, .12); }
.bubble.ai { align-self: flex-start; }
.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.suggestion {
  border-radius: 16px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.4;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120px);
  z-index: 99;
  max-width: min(520px, calc(100vw - 24px));
  padding: 13px 16px;
  border-radius: 999px;
  color: #fff;
  background: #231a14;
  box-shadow: 0 16px 50px rgba(0,0,0,.3);
  opacity: 0;
  transition: .24s ease;
  font-weight: 800;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.bottom-nav { display: none; }
.print-area { display: none; }

@media (max-width: 1050px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 14px 14px 92px; }
  .topbar {
    margin: -14px -14px 14px;
    padding: 12px 14px;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .mobile-brand { display: flex; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .mobile-settings-shortcut { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
  .view-header { display: grid; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 12;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 7px;
    border-radius: 22px;
    background: rgba(255, 253, 249, .88);
    border: 1px solid var(--line);
    box-shadow: 0 16px 50px rgba(0,0,0,.16);
    backdrop-filter: blur(16px);
  }
  [data-theme="dark"] .bottom-nav { background: rgba(31, 26, 23, .88); }
  .bottom-item {
    text-align: center;
    min-height: 44px;
    padding: 7px 6px;
    font-size: 12px;
  }
  .line-card, .material-line-card { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .repeat-grid { grid-template-columns: 1fr; }
  .modal-card { border-radius: 22px; padding: 14px; }
  .chat-card { min-height: 520px; }
}

@media print {
  body { background: #fff; color: #111; }
  .app-shell, .modal, .toast { display: none !important; }
  .print-area { display: block; padding: 20px; font-family: Arial, sans-serif; }
  .print-area h1 { font-size: 24px; letter-spacing: 0; line-height: 1.2; margin-bottom: 8px; }
  .print-area h2 { font-size: 18px; margin-bottom: 12px; }
  .print-area p { font-size: 12px; line-height: 1.45; }
  .print-area table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 11px; }
  .print-area th, .print-area td { border: 1px solid #d7d7d7; padding: 8px; text-align: left; vertical-align: top; }
  .print-area th { background: #f3f3f3; font-weight: 800; }
}


/* Mobile-first order form clarity */
.form-section {
  display: grid;
  gap: 14px;
}
.important-section {
  border-color: rgba(155, 92, 69, .24);
  background: linear-gradient(180deg, rgba(255, 253, 249, .98), rgba(246, 239, 231, .5));
}
[data-theme="dark"] .important-section {
  background: linear-gradient(180deg, rgba(31, 26, 23, .98), rgba(42, 35, 31, .58));
}
.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 2px;
}
.section-heading > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading h3 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}
.section-heading p,
.section-help,
.small-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.section-help,
.small-text { font-size: 14px; }
.section-heading.with-action {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.step-badge {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-size: 13px;
  font-weight: 950;
}
.form-grid { gap: 14px; }
.product-lines,
.material-lines { gap: 12px; }
.line-card,
.material-line-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(246, 239, 231, .72);
}
[data-theme="dark"] .line-card,
[data-theme="dark"] .material-line-card { background: rgba(42, 35, 31, .9); }
.line-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.line-card-head strong {
  font-size: 15px;
  letter-spacing: 0;
}
.line-remove {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--danger);
  background: rgba(184, 69, 69, .08);
  border-color: rgba(184, 69, 69, .2);
}
.line-fields {
  display: grid;
  gap: 10px;
}
.product-line-fields {
  grid-template-columns: minmax(180px, 1.5fr) minmax(90px, .55fr) minmax(130px, .8fr) minmax(130px, .8fr);
}
.material-line-fields {
  grid-template-columns: minmax(220px, 1fr) minmax(120px, .45fr);
}
.line-fields .wide { grid-column: span 2; }
.stock-check {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.28);
}
.file-field input { padding: 10px; }
.small-empty { padding: 18px; }
.modal-actions {
  position: sticky;
  bottom: -18px;
  z-index: 3;
  margin: 0 -18px -18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 760px) {
  .modal {
    width: min(100vw - 8px, 560px);
  }
  .modal-card {
    max-height: min(92vh, 980px);
    border-radius: 20px;
    padding: 12px;
  }
  .modal-head {
    padding-bottom: 10px;
    margin-bottom: 10px;
  }
  .modal-head h2 {
    font-size: 28px;
    letter-spacing: 0;
  }
  .modal-body { gap: 12px; }
  .card.form-section,
  .card.flat.form-section {
    padding: 14px;
    border-radius: 20px;
  }
  .section-heading.with-action {
    grid-template-columns: 1fr;
  }
  .section-heading.with-action button {
    width: 100%;
    justify-content: center;
  }
  .section-heading h3 { font-size: 20px; }
  .section-heading p,
  .section-help,
  .small-text { font-size: 13px; }
  label.field {
    gap: 6px;
    font-size: 12px;
  }
  .field span {
    color: var(--text);
    font-weight: 900;
  }
  input, select, textarea {
    min-height: 48px;
    border-radius: 14px;
    padding: 12px;
    font-size: 16px;
  }
  textarea { min-height: 112px; }
  .line-card,
  .material-line-card {
    padding: 12px;
    border-radius: 18px;
  }
  .line-card-head strong { font-size: 16px; }
  .line-remove {
    min-height: 38px;
    padding: 8px 12px;
  }
  .product-line-fields,
  .material-line-fields {
    grid-template-columns: 1fr;
  }
  .line-fields .wide { grid-column: auto; }
  .form-actions.modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    bottom: -12px;
    margin: 0 -12px -12px;
    padding: 12px;
  }
  .form-actions.modal-actions button {
    width: 100%;
    min-height: 50px;
    font-size: 16px;
  }
}

/* Stock artesanal: tarjetas claras para descripción, color, diseño y unidades */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.stock-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}
.stock-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.stock-card-head strong {
  display: block;
  font-size: 20px;
  letter-spacing: 0;
  line-height: 1.1;
}
.stock-card-head span:not(.pill) {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}
.stock-health {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.stock-health span {
  display: block;
  min-width: 4px;
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.stock-health.ok span { background: linear-gradient(90deg, var(--ok), #4aa982); }
.stock-health.warn span { background: linear-gradient(90deg, var(--warn), var(--accent)); }
.stock-health.danger span { background: linear-gradient(90deg, var(--danger), #de7676); }
.stock-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.stock-meta div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-2);
}
.stock-meta span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.stock-meta strong {
  display: block;
  overflow-wrap: anywhere;
}
.stock-stepper {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: stretch;
  gap: 8px;
}
.stock-step-button {
  min-height: 46px;
  padding: 0;
  border-radius: 14px;
  font-size: 22px;
  line-height: 1;
}
.stock-step-count {
  min-height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.stock-step-count strong {
  font-size: 22px;
  line-height: 1;
}
.stock-step-count span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.stock-actions button {
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .stock-grid { grid-template-columns: 1fr; }
  .stock-card { padding: 14px; border-radius: 18px; }
  .stock-card-head {
    display: grid;
    gap: 10px;
  }
  .stock-card-head .pill { width: fit-content; }
  .stock-meta { grid-template-columns: 1fr; }
  .stock-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .stock-actions button {
    width: 100%;
    min-height: 48px;
  }
  .stock-stepper {
    grid-template-columns: 54px minmax(0, 1fr) 54px;
  }
  .stock-step-button,
  .stock-step-count {
    min-height: 50px;
  }
}

@media (max-width: 900px) {
  .command-strip {
    grid-template-columns: 1fr;
  }
  .command-card {
    grid-template-columns: 1fr;
  }
  .command-card button {
    grid-column: 1;
    grid-row: auto;
    width: fit-content;
  }
}

/* v1.4 — formulario de stock obligatorio y estado de IA más claro */
.stock-form-card .section-heading {
  margin-bottom: 14px;
}
.stock-required-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.stock-main-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
}
.stock-main-field span {
  color: var(--text);
  font-size: 14px;
  font-weight: 950;
}
.ia-settings-card .card-title {
  align-items: flex-start;
}
.ia-settings-grid {
  gap: 12px;
}
.ia-toggle {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
}
.ai-apply-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(215, 167, 111, .10);
}
.ai-apply-box button {
  width: 100%;
  min-height: 48px;
}

@media (max-width: 760px) {
  .stock-required-grid {
    grid-template-columns: 1fr;
  }
  .stock-main-field {
    padding: 12px;
  }
  .stock-main-field span {
    display: block;
    margin-bottom: 2px;
    font-size: 15px;
  }
  .stock-form-card .section-heading p {
    font-size: 14px;
  }
  .ia-settings-card .card-title {
    display: grid;
  }
}

/* Selector de materiales desde stock dentro del pedido */
.stock-picker-fields {
  grid-template-columns: minmax(220px, 1.5fr) minmax(120px, .5fr);
  align-items: stretch;
}
.stock-picker-fields .selected-stock-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,.42);
  color: var(--muted);
  font-size: 13px;
}
.stock-picker-fields .selected-stock-card strong {
  color: var(--text);
  font-size: 14px;
}
.stock-picker-fields .selected-stock-card .stock-available {
  font-weight: 900;
  color: var(--primary);
}
[data-theme="dark"] .stock-picker-fields .selected-stock-card {
  background: rgba(255,255,255,.04);
}
@media (max-width: 760px) {
  .stock-picker-fields {
    grid-template-columns: 1fr;
  }
  .stock-picker-fields .selected-stock-card {
    padding: 12px;
    font-size: 13px;
  }
}

/* Pedido simplificado: formulario rápido y legible en móvil */
.order-quick-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr);
  gap: 14px;
}
.compact-heading { gap: 4px; }
.compact-heading h3 { font-size: 19px; }
.compact-heading p { font-size: 13px; }
.quick-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, .8fr);
  gap: 12px;
}
.compact-lines { gap: 10px; }
.compact-item-line,
.compact-material-line {
  padding: 12px;
  gap: 10px;
  border-radius: 18px;
}
.compact-line-head {
  padding-bottom: 8px;
}
.compact-product-fields {
  grid-template-columns: minmax(0, 1fr) 110px;
}
.compact-stock-fields {
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: end;
}
.product-extra-fields {
  margin-top: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.line-details,
.optional-order-card details {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
}
.line-details summary,
.optional-order-card summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 950;
  color: var(--text);
}
.line-details summary::-webkit-details-marker,
.optional-order-card summary::-webkit-details-marker { display: none; }
.line-details summary::after,
.optional-order-card summary::after {
  content: 'Abrir';
  float: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.line-details[open] summary::after,
.optional-order-card details[open] summary::after { content: 'Cerrar'; }
.line-details[open],
.optional-order-card details[open] { padding-bottom: 12px; }
.line-details[open] .product-extra-fields,
.optional-order-card details[open] .details-grid,
.optional-order-card details[open] .field,
.optional-order-card details[open] .muted,
.optional-order-card details[open] .attachments-grid {
  margin-left: 12px;
  margin-right: 12px;
}
.compact-stock-preview {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,.34);
  font-size: 13px;
  color: var(--muted);
}
.compact-stock-preview strong { color: var(--text); }
.compact-stock-preview .stock-available { color: var(--primary); font-weight: 950; }
.compact-stock-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.compact-stock-check span { display: grid; gap: 2px; }
.compact-stock-check small { color: var(--muted); line-height: 1.35; }
.full-btn { width: 100%; justify-content: center; }
.warn-box { border-color: rgba(184, 69, 69, .24); }
[data-theme="dark"] .line-details,
[data-theme="dark"] .optional-order-card details,
[data-theme="dark"] .compact-stock-preview {
  background: rgba(255,255,255,.04);
}

@media (max-width: 860px) {
  .order-quick-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .quick-grid,
  .compact-product-fields,
  .compact-stock-fields,
  .product-extra-fields {
    grid-template-columns: 1fr;
  }
  .order-main-card,
  .stock-order-card,
  .optional-order-card {
    padding: 12px !important;
  }
  .compact-heading h3 { font-size: 18px; }
  .compact-heading p { font-size: 12.5px; }
  .compact-item-line,
  .compact-material-line {
    padding: 10px;
    border-radius: 16px;
  }
  .compact-line-head {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .line-remove {
    min-height: 34px;
    padding: 7px 10px;
  }
  .compact-stock-preview {
    font-size: 12.5px;
    padding: 10px;
  }
  .line-details summary,
  .optional-order-card summary {
    padding: 11px 12px;
  }
}

/* Corrección real: pedido simple, un solo flujo y avisos visibles dentro del formulario */
.order-simple-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.main-stock-picker {
  border-width: 2px;
  border-color: rgba(139, 75, 52, .24);
}
.compact-material-line,
.compact-item-line,
.line-card.material-line-card {
  display: grid;
  grid-template-columns: 1fr !important;
  gap: 10px;
}
.compact-stock-fields {
  grid-template-columns: minmax(0, 1fr) 150px;
}
.form-notice {
  position: sticky;
  top: 62px;
  z-index: 5;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(184, 69, 69, .28);
  background: #fff2ee;
  color: #7f2a1d;
  font-weight: 900;
  box-shadow: 0 12px 34px rgba(61, 38, 25, .12);
}
.form-notice.success {
  border-color: rgba(45, 135, 92, .28);
  background: #edf9f2;
  color: #1d6b46;
}
.form-notice[hidden] { display: none !important; }
.stock-line-details { margin-top: 2px; }
.selected-stock-card.compact-stock-preview {
  background: rgba(255,255,255,.62);
}
[data-theme="dark"] .form-notice {
  background: rgba(127, 42, 29, .28);
  color: #ffd7cd;
}
[data-theme="dark"] .form-notice.success {
  background: rgba(29, 107, 70, .28);
  color: #c7f7dc;
}

@media (max-width: 760px) {
  .modal {
    width: calc(100vw - 6px);
  }
  .modal-card {
    max-height: 94vh;
    padding: 10px;
  }
  .compact-stock-fields {
    grid-template-columns: 1fr;
  }
  .form-notice {
    top: 56px;
    font-size: 14px;
  }
}

/* Urgencia manual en pedidos */
.urgent-order-toggle {
  grid-column: 1 / -1;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(184, 69, 69, .22);
  border-radius: 16px;
  background: rgba(184, 69, 69, .07);
}
.urgent-order-toggle input { margin-top: 3px; }
.urgent-order-toggle span { display: grid; gap: 3px; }
.urgent-order-toggle small { color: var(--muted); line-height: 1.35; }
.pill.muted-pill { color: var(--muted); background: var(--panel-2); border-color: var(--line); }

.inline-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.inline-badges .pill {
  line-height: 1.2;
}

.next-action {
  display: inline-flex;
  align-items: center;
  max-width: 160px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(125, 63, 95, .12), rgba(47, 111, 103, .12));
  border: 1px solid rgba(47, 111, 103, .18);
  font-size: 12px;
  font-weight: 950;
  line-height: 1.15;
  white-space: normal;
}

.command-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.command-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, .88);
  box-shadow: 0 14px 34px rgba(31, 37, 34, .08);
}

[data-theme="dark"] .command-card {
  background: rgba(24, 32, 29, .9);
}

.command-card.hot {
  border-color: rgba(184, 69, 69, .28);
  background: linear-gradient(135deg, rgba(184, 69, 69, .1), rgba(255, 253, 250, .88));
}

.command-card.warn {
  border-color: rgba(181, 106, 25, .28);
  background: linear-gradient(135deg, rgba(198, 154, 70, .13), rgba(255, 253, 250, .88));
}

[data-theme="dark"] .command-card.hot,
[data-theme="dark"] .command-card.warn {
  background: linear-gradient(135deg, rgba(184, 69, 69, .14), rgba(24, 32, 29, .92));
}

.command-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.command-card strong,
.command-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.command-card strong {
  grid-column: 1;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.command-card small {
  grid-column: 1;
  color: var(--muted);
  line-height: 1.35;
}

.command-card button {
  grid-column: 2;
  grid-row: 1 / span 3;
  min-height: 38px;
  align-self: center;
}

.ai-nudge-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 82;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 10px 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 103, .22);
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .24), transparent 46%),
    linear-gradient(135deg, rgba(125, 63, 95, .16), rgba(47, 111, 103, .14)),
    var(--panel);
  box-shadow: 0 18px 44px rgba(31, 37, 34, .16);
  backdrop-filter: blur(16px);
}

.ai-nudge-button[hidden] {
  display: none !important;
}

.ai-nudge-button span {
  font-size: 13px;
  font-weight: 950;
}

.ai-nudge-button strong {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--ok);
  font-size: 13px;
  line-height: 1;
}

.ai-nudge-button.has-alerts strong {
  background: var(--danger);
}

.ai-proactive-panel {
  display: grid;
  gap: 14px;
}

.ai-proactive-head {
  display: grid;
  gap: 8px;
}

.ai-suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.ai-suggestion-grid.compact {
  grid-template-columns: 1fr;
}

.ai-suggestion-card {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.ai-suggestion-card strong {
  line-height: 1.15;
}

.ai-suggestion-card small {
  color: var(--muted);
  line-height: 1.35;
}

.ai-suggestion-card.danger {
  border-color: rgba(184, 69, 69, .26);
  background: linear-gradient(135deg, rgba(184, 69, 69, .09), transparent 60%), var(--panel);
}

.ai-suggestion-card.warn {
  border-color: rgba(181, 106, 25, .26);
  background: linear-gradient(135deg, rgba(198, 154, 70, .1), transparent 60%), var(--panel);
}

.ai-suggestion-card.info {
  border-color: rgba(49, 95, 120, .24);
  background: linear-gradient(135deg, rgba(47, 111, 103, .1), transparent 60%), var(--panel);
}

.ai-suggestion-card.calm {
  border-style: dashed;
}

.ai-suggestion-card button {
  justify-self: start;
  min-height: 38px;
}


/* Versión visible de la web */
.app-version-badge {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 80;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 75, 52, .16);
  background: rgba(255, 252, 248, .82);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(61, 38, 25, .08);
  pointer-events: none;
}
[data-theme="dark"] .app-version-badge {
  background: rgba(38, 27, 22, .78);
  border-color: rgba(255, 255, 255, .10);
  color: rgba(255, 244, 232, .72);
}
@media (max-width: 820px) {
  .app-version-badge {
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    font-size: 10.5px;
    padding: 6px 9px;
  }
  .ai-nudge-button {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 118px);
  }
  .ai-nudge-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Acceso seguro */
.app-shell.locked {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(125, 63, 95, .12), transparent 46%),
    linear-gradient(315deg, rgba(47, 111, 103, .12), transparent 50%),
    rgba(251, 247, 242, .94);
  backdrop-filter: blur(18px);
}
.login-screen[hidden] { display: none !important; }
.login-card {
  width: min(100%, 440px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}
.login-brand strong { display: block; }
.login-brand span { display: block; color: var(--muted); font-size: 13px; }
.login-card h1 { margin-bottom: 0; }
.login-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}
.full-button { width: 100%; justify-content: center; }
.user-create-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}
.user-row {
  position: relative;
  padding-right: 110px;
}
.small-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 8px 10px;
  border-radius: 12px;
}

@media (max-width: 760px) {
  .user-create-box { grid-template-columns: 1fr; }
  .user-row { padding-right: 0; }
  .small-button { position: static; transform: none; margin-top: 8px; }
  .login-card { padding: 20px; border-radius: 24px; }
}

.server-ai-status {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--muted);
  line-height: 1.35;
}
.server-ai-status strong { color: var(--text); }
.server-ai-status span { font-size: 13px; }
.server-ai-status.ok { border-color: rgba(47, 125, 89, .35); background: rgba(47, 125, 89, .08); }
.server-ai-status.warn { border-color: rgba(181, 106, 25, .32); background: rgba(181, 106, 25, .08); }

/* v2.9 premium UI layer: tactil, sobria y mas actual */
:root {
  --bg: #f8f4ef;
  --panel: #fffefa;
  --panel-2: #f1ece5;
  --text: #241f1b;
  --muted: #71685f;
  --line: #e4d9ce;
  --primary: #9d4f75;
  --primary-2: #7a3f32;
  --accent: #c3914d;
  --ok: #24745f;
  --warn: #a96516;
  --danger: #b33f4a;
  --info: #376f86;
  --shadow: 0 18px 46px rgba(43, 31, 24, .10);
  --shadow-soft: 0 10px 26px rgba(43, 31, 24, .08);
  --ring: 0 0 0 4px rgba(157, 79, 117, .16);
  --ease-premium: cubic-bezier(.2, .8, .2, 1);
}

[data-theme="dark"] {
  --bg: #12110f;
  --panel: #1d1a17;
  --panel-2: #28231f;
  --text: #fbf4ec;
  --muted: #bdb0a5;
  --line: #3d352f;
  --primary: #e385ad;
  --primary-2: #d49a73;
  --accent: #e3b864;
  --ok: #75c7a9;
  --warn: #edb466;
  --danger: #ef7c86;
  --info: #8fc4dc;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, .24);
  --ring: 0 0 0 4px rgba(227, 133, 173, .18);
}

* { letter-spacing: 0 !important; }

html {
  scroll-behavior: smooth;
}

body {
  background:
    linear-gradient(135deg, rgba(157, 79, 117, .10), transparent 34rem),
    linear-gradient(225deg, rgba(55, 111, 134, .10), transparent 30rem),
    linear-gradient(180deg, rgba(195, 145, 77, .10), transparent 36rem),
    var(--bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 40px;
  line-height: 1.04;
}

h2 { line-height: 1.16; }

@media (max-width: 760px) {
  h1 { font-size: 32px; }
}

.sidebar,
.topbar,
.bottom-nav,
.modal-card,
.login-card {
  backdrop-filter: blur(20px) saturate(1.12);
  -webkit-backdrop-filter: blur(20px) saturate(1.12);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 254, 250, .92), rgba(255, 254, 250, .76)),
    var(--panel);
}

[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, rgba(29, 26, 23, .94), rgba(29, 26, 23, .76)),
    var(--panel);
}

.brand-mark {
  border-radius: 18px;
  box-shadow:
    0 14px 34px rgba(157, 79, 117, .20),
    inset 0 0 0 1px rgba(255, 255, 255, .68);
  transform: translateZ(0);
}

.brand strong,
.mobile-brand strong {
  font-weight: 950;
}

.nav-item,
.bottom-item,
button,
.button,
.list-item,
.card,
.stock-card,
.metric,
.input,
input,
select,
textarea {
  transition:
    transform .18s var(--ease-premium),
    box-shadow .18s var(--ease-premium),
    border-color .18s var(--ease-premium),
    background .18s var(--ease-premium),
    color .18s var(--ease-premium),
    opacity .18s var(--ease-premium);
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

button:active,
.button:active,
.nav-item:active,
.bottom-item:active {
  transform: translateY(0) scale(.98);
}

button:focus-visible,
.button:focus-visible,
input:focus,
select:focus,
textarea:focus,
summary:focus-visible {
  border-color: rgba(157, 79, 117, .48);
  box-shadow: var(--ring);
}

.primary {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .16), transparent 45%),
    linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 34px rgba(122, 63, 50, .22);
}

.primary:hover {
  box-shadow: 0 18px 40px rgba(122, 63, 50, .28);
}

.ghost:hover {
  background: rgba(157, 79, 117, .08);
  border-color: rgba(157, 79, 117, .20);
}

.nav-item,
.bottom-item {
  position: relative;
  overflow: hidden;
}

.nav-item::before,
.bottom-item::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0;
  transform: scaleY(.4);
  transition: .2s var(--ease-premium);
}

.bottom-item::before {
  inset: auto 22% 4px;
  width: auto;
  height: 3px;
  transform: scaleX(.4);
}

.nav-item.active::before,
.bottom-item.active::before {
  opacity: 1;
  transform: scale(1);
}

.nav-item:hover,
.bottom-item:hover {
  transform: translateY(-1px);
}

.nav-item.active,
.bottom-item.active {
  background:
    linear-gradient(135deg, rgba(157, 79, 117, .16), rgba(55, 111, 134, .10)),
    var(--panel);
  border: 1px solid rgba(157, 79, 117, .18);
}

.topbar {
  background: rgba(248, 244, 239, .78);
}

[data-theme="dark"] .topbar {
  background: rgba(18, 17, 15, .78);
}

.global-search {
  min-height: 48px;
  border-color: rgba(157, 79, 117, .14);
  box-shadow: var(--shadow-soft);
}

.global-search:focus-within {
  border-color: rgba(157, 79, 117, .45);
  box-shadow: var(--ring), var(--shadow-soft);
}

.view {
  animation: premium-view-in .28s var(--ease-premium) both;
}

@keyframes premium-view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card,
.stock-card {
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .66), rgba(255, 255, 255, .18)),
    var(--panel);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .card,
[data-theme="dark"] .stock-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent),
    var(--panel);
}

.card:hover,
.stock-card:hover {
  border-color: rgba(157, 79, 117, .20);
}

.metric {
  isolation: isolate;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(112deg, transparent 0 76%, rgba(255, 255, 255, .22) 76% 78.5%, transparent 78.5% 100%),
    linear-gradient(135deg, rgba(157, 79, 117, .10), transparent 48%),
    linear-gradient(315deg, rgba(55, 111, 134, .10), transparent 52%);
  opacity: .92;
}

.metric::after {
  background: linear-gradient(135deg, rgba(198, 154, 70, .24), rgba(47, 111, 103, .08));
}

.metric strong {
  font-size: 40px;
  font-weight: 950;
}

.pill {
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.table-wrap {
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

tbody tr {
  transition: background .16s var(--ease-premium);
}

tr:hover td {
  background: rgba(157, 79, 117, .06);
}

.list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(157, 79, 117, .22);
  box-shadow: var(--shadow-soft);
}

.modal[open] .modal-card {
  animation: premium-modal-in .22s var(--ease-premium) both;
}

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

.toast.show {
  animation: premium-toast-pop .26s var(--ease-premium) both;
}

@keyframes premium-toast-pop {
  0% { opacity: 0; transform: translateX(-50%) translateY(22px) scale(.98); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.login-screen {
  background:
    linear-gradient(112deg, transparent 0 18%, rgba(43, 31, 24, .06) 18% 20.5%, transparent 20.5% 36%),
    linear-gradient(78deg, transparent 0 69%, rgba(157, 79, 117, .08) 69% 71.5%, transparent 71.5% 100%),
    linear-gradient(135deg, rgba(157, 79, 117, .18), transparent 34rem),
    linear-gradient(225deg, rgba(55, 111, 134, .14), transparent 30rem),
    rgba(248, 244, 239, .92);
}

.login-card {
  border-radius: 24px;
  box-shadow:
    0 30px 90px rgba(43, 31, 24, .16),
    inset 0 1px 0 rgba(255, 255, 255, .62);
  animation: premium-login-in .34s var(--ease-premium) both;
}

@keyframes premium-login-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card h1 {
  font-size: 40px;
  line-height: 1.02;
}

.bottom-nav {
  box-shadow:
    0 18px 54px rgba(43, 31, 24, .18),
    inset 0 1px 0 rgba(255, 255, 255, .62);
}

.app-version-badge {
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

@media (max-width: 760px) {
  .top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-actions button {
    min-height: 44px;
    padding: 9px 8px;
    border-radius: 14px;
  }

  .card,
  .stock-card,
  .table-wrap,
  .list-item {
    border-radius: 16px;
  }

  .login-card h1 {
    font-size: 31px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

/* Para pedir: lista de compra desde stock bajo mínimo */
.shortage-summary-grid {
  margin-bottom: 16px;
}

.shortage-metric::before {
  background:
    linear-gradient(135deg, rgba(179, 63, 74, .13), transparent 52%),
    linear-gradient(315deg, rgba(195, 145, 77, .12), transparent 56%);
}

.shortage-panel {
  margin-top: 16px;
}

.shortage-card {
  border-color: rgba(179, 63, 74, .22);
}

.shortage-card:hover {
  border-color: rgba(179, 63, 74, .34);
}

/* Premium AAA operations layer v2.9.16 */
:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --text: #172033;
  --muted: #637083;
  --line: #d8e0ea;
  --primary: #0f6b63;
  --primary-2: #155ea8;
  --accent: #c2553b;
  --ok: #247653;
  --warn: #a45d17;
  --danger: #b73535;
  --info: #276a9f;
  --shadow: 0 14px 34px rgba(23, 32, 51, .08);
  --shadow-soft: 0 10px 26px rgba(23, 32, 51, .07);
  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg: #10151b;
  --panel: #171f28;
  --panel-2: #202a35;
  --text: #f4f7fb;
  --muted: #b2becb;
  --line: #334150;
  --primary: #59c3b7;
  --primary-2: #7db7f0;
  --accent: #e1886f;
  --ok: #79d5a0;
  --warn: #f0b66e;
  --danger: #f08383;
  --info: #95c9ef;
  --shadow: 0 20px 48px rgba(0, 0, 0, .32);
  --shadow-soft: 0 14px 30px rgba(0, 0, 0, .24);
}

html,
body,
button,
input,
select,
textarea {
  letter-spacing: 0;
}

body {
  background: var(--bg);
}

.zebra-motion-canvas {
  opacity: .10;
  mix-blend-mode: multiply;
}

[data-theme="dark"] .zebra-motion-canvas {
  opacity: .08;
  mix-blend-mode: screen;
}

.sidebar,
.topbar,
.bottom-nav,
.modal-card,
.login-card {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-color: var(--line);
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] .topbar,
[data-theme="dark"] .bottom-nav,
[data-theme="dark"] .modal-card,
[data-theme="dark"] .login-card {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
}

.brand-mark,
.card,
.stock-card,
.table-wrap,
.list-item,
.modal-card,
.login-card,
.line-card,
.material-line-card,
.command-card,
.ai-suggestion-card,
.selected-stock-card,
.optional-order-card details,
.compact-stock-preview {
  border-radius: var(--radius) !important;
}

button,
input,
select,
textarea {
  border-radius: var(--radius-sm);
}

.card,
.stock-card,
.table-wrap,
.list-item,
.modal-card,
.login-card {
  box-shadow: var(--shadow-soft);
}

.card:hover,
.stock-card:hover,
.list-item:hover {
  border-color: color-mix(in srgb, var(--primary) 24%, var(--line));
  box-shadow: var(--shadow);
}

.metric::before,
.metric::after {
  opacity: .42;
}

tr:hover td {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.login-screen {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 84%, white), var(--bg));
}

.login-card h1 {
  font-size: 34px;
  line-height: 1.08;
}

.modal-card {
  max-height: calc(100dvh - 24px);
}

.app-version-badge {
  border-radius: 999px;
}

.desktop-table {
  display: block;
}

.mobile-list {
  display: none;
}

.mobile-record {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.mobile-record-head,
.mobile-record-status,
.mobile-record-next,
.mobile-record-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.mobile-record-head {
  justify-content: space-between;
}

.mobile-record-head strong {
  display: block;
  line-height: 1.18;
}

.mobile-record-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-record-status {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.mobile-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-record-grid div {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}

.mobile-record-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mobile-record-grid strong,
.mobile-record-products,
.mobile-record-next span,
.mobile-record-alert {
  overflow-wrap: anywhere;
}

.mobile-record-products {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
}

.mobile-record-next {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.mobile-record-alert {
  display: block;
  margin-top: 4px;
  color: var(--danger);
  font-style: normal;
  font-weight: 850;
}

.mobile-record-actions {
  flex-wrap: wrap;
}

.mobile-record-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    overflow: hidden;
  }

  .main {
    height: calc(100dvh - 72px - env(safe-area-inset-bottom));
    overflow-y: auto;
    padding-bottom: 18px;
    overscroll-behavior: contain;
  }

  .desktop-table {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 10px;
  }

  .top-actions button {
    border-radius: var(--radius-sm);
  }

  .bottom-nav {
    bottom: calc(8px + env(safe-area-inset-bottom));
    border-radius: var(--radius) !important;
    box-shadow: 0 12px 34px rgba(23, 32, 51, .16);
  }

  .bottom-item {
    min-height: 40px;
    padding: 6px 4px;
  }

  .card,
  .stock-card,
  .table-wrap,
  .list-item {
    border-radius: var(--radius) !important;
  }

  .login-card h1 {
    font-size: 28px;
  }

  .mobile-record-head {
    align-items: flex-start;
  }

  .mobile-record-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-record-actions button:first-child {
    grid-column: span 2;
  }

  .app-version-badge {
    display: none;
  }
}

@media (max-width: 420px) {
  .mobile-record-grid,
  .mobile-record-actions {
    grid-template-columns: 1fr;
  }

  .mobile-record-actions button:first-child {
    grid-column: auto;
  }
}

/* Modal containment: keep long forms inside the viewport without horizontal scroll. */
.modal,
.modal-card,
.modal-body,
.form-section,
.line-card,
.material-line-card,
.stock-picker-fields,
.compact-stock-preview,
.selected-stock-card {
  max-width: 100%;
  min-width: 0;
}

.modal-card,
.modal-body {
  overflow-x: hidden;
}

@media (max-width: 760px) {
  .modal {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px);
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
  }

  .modal-head h2 {
    font-size: 26px;
    line-height: 1.06;
  }

  .form-actions.modal-actions {
    margin: 0;
    padding: 12px 0 0;
  }
}

.negative-units {
  color: var(--danger);
}

@media (max-width: 760px) {
  .shortage-summary-grid {
    margin-bottom: 12px;
  }

  .shortage-card .stock-card-head {
    gap: 8px;
  }

  .shortage-card .pill {
    justify-self: start;
  }
}
