:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --primary: #b45309;
  --primary-hover: #92400e;
  --secondary: #d97706;
  --accent: #059669;
  --text: #451a03;
  --muted: #78716c;
  --border: #e7e0d6;
  --danger: #b91c1c;
  --ok: #047857;
  --warn: #b45309;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(69, 26, 3, 0.08);
  --font: "Figtree", "Segoe UI", sans-serif;
  --max: 1200px;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fde68a55, transparent 60%),
    radial-gradient(900px 400px at 100% 0%, #bbf7d055, transparent 55%),
    var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; }

h1, h2, h3 { margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1rem; color: var(--muted); }

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); border-color: transparent; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.9rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
.form-control:focus {
  outline: 2px solid #fdba74;
  border-color: var(--secondary);
}
.field-validation-error, .text-danger, .validation-summary-errors {
  color: var(--danger);
  font-size: 0.9rem;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.data th, table.data td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.data th {
  background: var(--surface-2);
  font-weight: 650;
}
table.data tr:hover td { background: #fffaf3; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
}
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.alert-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 650;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.badge-ok { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.badge-warn { background: #fff7ed; border-color: #fed7aa; color: var(--warn); }
.badge-muted { color: var(--muted); }

/* Landing */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.brand span { color: var(--primary); }
.nav-links { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: center;
  min-height: calc(100vh - 100px);
  padding: 2rem 0 3rem;
}
.hero-copy h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  margin-bottom: 0.75rem;
}
.hero-visual {
  min-height: 320px;
  border-radius: 12px;
  background:
    linear-gradient(160deg, #f59e0bcc, #b45309cc),
    repeating-linear-gradient(45deg, #ffffff22 0 12px, transparent 12px 24px);
  border: 1px solid #f6d7a8;
  display: grid;
  place-items: end start;
  padding: 1.5rem;
  color: #fffaf3;
  font-weight: 700;
  font-size: 1.25rem;
}
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* App shell */
.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: #2c2118;
  color: #f5f0e8;
  padding: 1.25rem 1rem;
  border-right: 1px solid #3d2f23;
}
.sidebar .brand { color: #fff; margin-bottom: 1.5rem; display: block; }
.sidebar .brand span { color: #fbbf24; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar a {
  color: #e7e0d6;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
}
.sidebar a:hover, .sidebar a.active {
  background: #3d2f23;
  color: #fff;
}
.main { padding: 1.5rem; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat strong { display: block; font-size: 1.6rem; color: var(--primary); }
.stat span { color: var(--muted); font-size: 0.9rem; }

.checks { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.checks label { display: flex; gap: 0.35rem; align-items: center; font-weight: 500; white-space: nowrap; }
.inline-checks { flex-wrap: nowrap; gap: 0.5rem 0.85rem; }
.total-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Pedido cliente: lista/tabla con scroll horizontal en móvil */
.pedido-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.pedido-list-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1rem;
}
.pedido-list {
  min-width: 980px;
  margin: 0;
  border: 0;
}
.pedido-list th,
.pedido-list td {
  vertical-align: middle;
  white-space: nowrap;
}
.pedido-list .form-control {
  min-width: 110px;
  padding: 0.45rem 0.55rem;
}
.pedido-list .cantidad { min-width: 72px; max-width: 88px; }
.pedido-list .esp-cell {
  white-space: normal;
  min-width: 280px;
}
.pedido-list .sub-cell { font-variant-numeric: tabular-nums; }
.pedido-list .line-num {
  color: var(--muted);
  font-weight: 650;
  width: 2rem;
}
.pedido-list tbody tr:hover td { background: #fffaf3; }
.pedido-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.pedido-actions .total-box { margin-left: auto; }

@media (max-width: 900px) {
  .pedido-meta { grid-template-columns: 1fr; }
  .pedido-actions { flex-direction: column; align-items: stretch; }
  .pedido-actions .total-box { margin-left: 0; }
  .pedido-list-wrap::after {
    content: "Desliza →";
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: var(--muted);
    padding: 0.35rem 0.75rem 0.55rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
  }
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .hero, .app-shell, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid #3d2f23; }
  .app-shell { min-height: auto; }
}
