/* ============================================================================
   Pedidos — estilo sobrio, funcional, minimalista.
   Pensado para móvil. Tipografía de sistema, paleta neutra.
============================================================================ */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-dim: #6b7280;
  --accent: #1f2937;      /* gris pizarra profundo */
  --accent-ink: #ffffff;
  --ok: #10a36f;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }

/* -------- Layout principal -------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
}
.app-header .meta {
  font-size: 13px;
  color: var(--text-dim);
  text-align: right;
}

.app-main {
  padding: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: 120px;
}

.window-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.window-banner.open   { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.window-banner.closed { background: #fef3c7; color: #7c2d12; border: 1px solid #fcd34d; }

/* -------- Login -------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}
.login-card p {
  margin: 0 0 22px;
  color: var(--text-dim);
  font-size: 14px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-dim);
}
.input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #111827; }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; padding: 13px; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 8px 12px; font-size: 14px; }

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
  min-height: 18px;
}

/* -------- Proveedores (acordeones) -------- */
.proveedor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.proveedor.interno { border-color: #dbeafe; background: #f8fafc; }
.proveedor-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.proveedor-head:hover { background: var(--surface-2); }
.proveedor-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.proveedor-head .badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.proveedor-head .chev {
  transition: transform 0.2s;
  color: var(--text-dim);
}
.proveedor.open .proveedor-head .chev { transform: rotate(90deg); }
.proveedor-body {
  display: none;
  border-top: 1px solid var(--border);
}
.proveedor.open .proveedor-body { display: block; }

/* -------- Productos -------- */
.producto {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.producto:first-child { border-top: none; }
.producto-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.producto-title .nombre {
  font-size: 15px;
  font-weight: 500;
}
.producto-title .unidad {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.producto-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.producto.tres-campos .producto-fields {
  grid-template-columns: 1fr 1fr 1fr;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field .num-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}
.field .num-input button {
  width: 36px;
  background: var(--surface-2);
  border: none;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.field .num-input button:active { background: var(--border); }
.field .num-input input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 10px 6px;
  text-align: center;
  font-size: 16px;
  background: #fff;
  outline: none;
}

.producto .save-state {
  font-size: 11px;
  min-height: 14px;
  color: var(--text-dim);
}
.producto .save-state.saved   { color: var(--ok); }
.producto .save-state.saving  { color: var(--warn); }
.producto .save-state.error   { color: var(--danger); }

/* -------- Sección "Otros" -------- */
.otros-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 18px;
}
.otros-section h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}
.otros-section p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.otros-section textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  outline: none;
}
.otros-section textarea:focus { border-color: var(--accent); }

/* -------- Admin -------- */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.admin-card:hover { border-color: var(--accent); background: #fafbfc; }
.admin-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
}
.admin-card .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  margin: 3px 0;
}
.admin-card .status {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 8px;
}
.admin-card .status.sin-pedido { background: #fee2e2; color: #991b1b; }
.admin-card .status.abierto    { background: #dcfce7; color: #166534; }
.admin-card .status.cerrado    { background: #dbeafe; color: #1e40af; }

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.admin-tabs button {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.audit-entry {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-entry .when {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.audit-entry .who { font-weight: 500; }
.audit-entry .what {
  grid-column: 1 / -1;
  color: var(--text);
}

/* -------- Detalle pedido admin -------- */
.detalle-bloque { margin-top: 18px; }
.detalle-bloque h2 {
  margin: 20px 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.detalle-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.detalle-tabla th, .detalle-tabla td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.detalle-tabla th {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
}
.detalle-tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------- Spinner / loading -------- */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}
