:root {
  --blue: #df7218;
  --blue-dark: #a9470b;
  --pale: #fff0e2;
  --text: #263640;
  --border: #efd4bd;
  --page-bg: #fff;
  --surface: #fff;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    16px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--page-bg);
}
header {
  position: fixed;
  z-index: 10;
  inset: 0 0 auto;
  min-height: 64px;
  background: var(--surface);
  border-bottom: 3px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5%;
}
.brand {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--blue-dark);
  text-decoration: none;
}
.brand small {
  font-size: 0.7rem;
}
nav {
  display: flex;
  gap: 8px;
}
nav a {
  color: var(--blue-dark);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 6px;
}
nav a:hover {
  background: var(--pale);
}
.container {
  width: 95%;
  max-width: none;
  margin: 0 auto;
  padding: 96px 0 50px;
}
h1,
h2 {
  color: var(--blue-dark);
  margin-top: 0;
}
.panel {
  border: 1px solid var(--border);
  border-top: 4px solid var(--blue);
  border-radius: 8px;
  padding: 24px;
  margin: 0 0 24px;
  background: var(--surface);
  box-shadow: 0 5px 20px #a9470b0d;
}
.narrow {
  max-width: 600px;
}
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title h1 {
  margin: 0;
}
form label {
  display: block;
  font-weight: 650;
  margin: 0 0 15px;
}
label span {
  font-weight: 400;
  color: #6b7d86;
  font-size: 0.85rem;
}
input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid #d9bca7;
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  color: inherit;
  background: var(--surface);
}
input:focus,
textarea:focus,
select:focus {
  outline: 3px solid #ffdfbf;
  border-color: var(--blue);
}
input:disabled {
  background: #f2f7f9;
}
textarea {
  min-height: 130px;
  resize: vertical;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 30px;
}
.check-label input {
  width: auto;
  margin: 0;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.grid-form > div,
.grid-form > h3,
.grid-form > .wide {
  grid-column: 1/-1;
}
.grid-form h3 {
  color: var(--blue-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 7px;
  margin: 10px 0 15px;
}
.empty {
  text-align: center;
  color: #71838b;
  padding: 30px;
}
td small {
  color: #71838b;
}
button,
.button {
  display: inline-block;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button:hover,
.button:hover {
  background: var(--blue-dark);
}
.secondary {
  background: #71838b;
}
.alert {
  border: 1px solid #8bd7a8;
  background: #effcf4;
  color: #176b38;
  border-radius: 6px;
  padding: 12px 15px;
  margin-bottom: 20px;
}
.alert.error {
  border-color: #f1a8a8;
  background: #fff3f3;
  color: #9b2525;
}
.table-wrap {
  padding: 0;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
th,
td {
  text-align: left;
  padding: 14px;
  border-bottom: 1px solid #f0dfd0;
}
th {
  color: var(--blue-dark);
  background: var(--pale);
}
.actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.actions a {
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 650;
}
.actions a:hover {
  color: var(--blue);
  text-decoration: underline;
}
.actions .link {
  color: var(--blue-dark);
  text-decoration: none;
}
.actions .link:hover {
  color: var(--blue);
}
.actions .link.danger {
  color: #b84a5a;
}
.actions .link.danger:hover {
  color: #8f2f40;
}
.actions form {
  display: inline;
}
.link {
  background: none !important;
  color: var(--blue-dark);
  padding: 0;
  font-weight: 600;
}
.link.danger {
  color: #c43d3d;
}
.welcome {
  text-align: center;
  padding: 100px 20px;
}
.welcome p:first-child {
  color: var(--blue-dark);
  font-weight: 700;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--page-bg);
  padding: 20px;
}
.login-card {
  width: min(400px, 100%);
  border: 1px solid var(--border);
  border-top: 5px solid var(--blue);
  border-radius: 10px;
  padding: 34px;
  box-shadow: 0 12px 45px #a9470b19;
}
.login-card h1 {
  text-align: center;
  margin-bottom: 28px;
}
.login-card button {
  width: 100%;
  margin-top: 5px;
}
@media (max-width: 650px) {
  header {
    padding: 0 14px;
  }
  .brand {
    font-size: 1.2rem;
  }
  nav {
    gap: 0;
  }
  nav a {
    padding: 10px 8px;
  }
  .container {
    padding: 88px 14px 35px;
  }
  .grid-form {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 18px;
  }
  .page-title {
    align-items: flex-start;
  }
  .actions {
    display: block;
  }
  .actions form {
    margin-left: 10px;
  }
}
.wizard-progress {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.wizard-progress span {
  flex: 1;
  padding: 9px;
  text-align: center;
  background: #eef5f8;
  border-radius: 6px;
  color: #71838b;
}
.wizard-progress span.active {
  background: var(--pale);
  color: var(--blue-dark);
  font-weight: 700;
}
.wizard-step {
  display: none;
}
.wizard-step.active {
  display: block;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.choice-card {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px !important;
  margin: 0 !important;
}
.choice-card input {
  width: auto;
  display: inline;
  margin: 0 8px 0 0;
}
.choice-card small {
  display: block;
  margin-left: 25px;
  color: #71838b;
}
.item-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.budget-line {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 15px;
  margin-bottom: 14px;
}
.budget-line .wide,
.budget-line .remove-line {
  grid-column: 1/-1;
}
.budget-line .remove-line {
  justify-self: start;
}
.budget-wizard #budget-review {
  margin-bottom: 18px;
}
.budget-doc-wrap {
  background: #eef3f5;
  padding: 20px;
}
@media (max-width: 650px) {
  .choice-grid,
  .budget-line {
    grid-template-columns: 1fr;
  }
  .wizard-progress {
    font-size: 0.8rem;
  }
  .budget-doc {
    padding: 15px !important;
  }
}
.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--pale);
  color: var(--blue-dark);
  font-weight: 700;
  white-space: nowrap;
}
.status-aceptado {
  background: #eaf8ef;
  color: #247345;
}
.status-procesado {
  background: #edf0f2;
  color: #53636b;
}
.state-form {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-top: 12px;
}
.state-form select {
  width: auto;
  min-width: 180px;
  margin: 0;
}
.state-help {
  display: inline-block;
  position: relative;
  margin-left: 7px;
  vertical-align: middle;
}
.state-help summary {
  list-style: none;
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 800;
}
.state-help summary::-webkit-details-marker {
  display: none;
}
.state-help > div {
  position: absolute;
  z-index: 20;
  right: 0;
  width: min(390px, 80vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 8px 25px #0002;
  padding: 10px 14px;
}
.state-help ul {
  margin: 0;
  padding-left: 18px;
}
.state-help li {
  margin: 6px 0;
}
.state-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 245px;
}
.state-form.compact {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.state-form.compact select {
  min-width: 125px;
  width: auto;
  margin: 0;
  padding: 7px 8px;
}
.state-form.compact button {
  padding: 7px 10px;
  font-size: 0.88rem;
}
.state-control .state-help {
  margin-left: 0;
}
.invoice-origin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.invoice-origin {
  text-decoration: none;
  color: inherit;
}
.invoice-origin:hover {
  border-color: var(--blue);
  box-shadow: 0 8px 28px #a9470b22;
}
.invoice-client-toggle {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
}
.invoice-client-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.invoice-client-toggle input {
  width: auto;
  margin: 0;
}
.invoice-totals {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding: 14px;
  margin: 0 0 20px;
  background: var(--pale);
  border-radius: 7px;
}
.muted {
  color: #71838b;
}
@media (max-width: 650px) {
  .invoice-origin-grid {
    grid-template-columns: 1fr;
  }
  .invoice-client-toggle,
  .invoice-totals {
    display: block;
  }
  .invoice-totals b {
    display: block;
    margin: 5px 0;
  }
}
.theme-night {
  --page-bg: #252a2e;
  --surface: #343b40;
  --text: #fff;
  --border: #58666d;
  --pale: #414b52;
}
.theme-night input:disabled {
  background: #475158;
}
.appearance-custom-fields[hidden] {
  display: none;
}

header {
  position: sticky;
  flex-wrap: wrap;
  padding: 12px 2.5%;
  gap: 12px;
}
nav {
  flex-wrap: wrap;
  align-items: center;
}
nav form {
  margin: 0;
}
nav button {
  background: none;
  color: var(--blue-dark);
  padding: 10px 14px;
  font-weight: 400;
}
.container {
  padding-top: 28px;
}
nav a[aria-current="page"] {
  background: var(--pale);
  font-weight: 700;
}
.demo-banner {
  padding: 10px 16px;
  background: var(--pale);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 22px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 20px;
}
.dashboard-grid a {
  color: inherit;
  text-decoration: none;
}
.dashboard-grid strong {
  font-size: 2rem;
  display: block;
}
.login-card {
  background: var(--surface);
}
.theme-night {
  --blue: #f59a4a;
  --blue-dark: #ffb574;
  --pale: #493729;
}
.theme-night .state-help > div {
  background: var(--surface);
}
[hidden] {
  display: none !important;
}
.budget-doc {
  color: #111;
}
.budget-doc h1 {
  color: #a9470b;
  font-size: 22px;
}
.budget-doc table {
  color: #111;
}
.budget-doc th {
  color: #a9470b;
}
.budget-doc .grand {
  color: #111;
}
nav a,
nav button {
  min-height: 44px;
}
@media (max-width: 650px) {
  header {
    position: static;
  }
  .container {
    width: 100%;
    padding: 20px 12px;
  }
  .panel.table-wrap {
    padding: 0;
  }
  nav {
    gap: 2px;
  }
  nav a,
  nav button {
    padding: 9px;
  }
  .page-title {
    gap: 12px;
    flex-wrap: wrap;
  }
  .budget-doc-wrap {
    padding: 4px;
    overflow-x: auto;
  }
  .wizard-progress {
    gap: 4px;
  }
  .state-control {
    min-width: 210px;
  }
}

.theme-night button,
.theme-night .button {
  color: #24180c;
}
.theme-night nav button,
.theme-night .link {
  color: var(--blue-dark);
}
.theme-night .secondary {
  color: #fff;
}

/* Caja rápida: catálogo y pedido, con lectura cómoda también en móvil. */
.caja-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.caja-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.caja-grid > *,
.caja-heading > * {
  min-width: 0;
}
.caja-catalogo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow: auto;
  margin: 16px 0;
}
.caja-producto button {
  width: 100%;
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  overflow-wrap: anywhere;
}
.caja-linea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  background: var(--pale);
}
.caja-check {
  display: flex;
  align-items: center;
  gap: 10px;
}
.caja-check input {
  width: auto;
}
.caja-ticket {
  max-width: 800px;
  margin: auto auto 24px;
}
.caja-ticket-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.caja-ticket-line small {
  display: block;
}
.caja-pedido {
  overflow-wrap: anywhere;
}
details > summary {
  cursor: pointer;
  padding: 10px 0;
  color: var(--blue-dark);
  font-weight: 600;
}
[hidden] {
  display: none !important;
}
@media (max-width: 900px) {
  .caja-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media print {
  header,
  .demo-banner,
  .caja-heading,
  .no-print,
  .alert:not(.caja-ticket .alert) {
    display: none !important;
  }
  body,
  .caja-ticket {
    color: #000 !important;
    background: #fff !important;
  }
  .container {
    padding: 0;
    width: 100%;
  }
  .caja-ticket {
    border: 0;
    max-width: none;
  }
}

.caja-historial a { color: var(--blue-dark); }
.theme-night .caja-pedido .muted { color: #cbd5db; }
.caja-pedido .actions { display: flex; flex-wrap: wrap; gap: 8px; }
