:root {
  --bg: #fbf7f4;
  --card: #ffffff;
  --text: #3a2e2b;
  --muted: #8a7b76;
  --line: #eee3dd;
  --primary: #c2185b;
  --primary-dark: #a0124a;
  --primary-soft: #fce4ec;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --danger: #c62828;
  --danger-soft: #ffebee;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80, 40, 30, .06);
}
/* El tema de cada marca vive en su propio archivo (theme-<marca>.css). */
.search-wrap { display: flex; flex-direction: row; align-items: center; }
.login-logo { width: 100%; max-width: 280px; margin: 0 auto 4px; display: block; }
.side-logo { width: 100%; max-width: 200px; display: block; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.brand.big { font-size: 1.6rem; text-align: center; }
#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a { text-decoration: none; color: var(--text); padding: 10px 12px; border-radius: 10px; font-weight: 500; }
#nav a:hover { background: var(--primary-soft); }
#nav a.active { background: var(--primary); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1200px; }

/* Componentes */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 18px; }
.grid2 > .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.stat.warn .value { color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #f3c6c6; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { border: none; background: none; font-size: 1.2rem; cursor: pointer; padding: 6px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.low { background: var(--warn-soft); color: var(--warn); }
.badge.neg { background: var(--danger-soft); color: var(--danger); }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.alert.warn { background: var(--warn-soft); color: #7a4a00; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--primary-soft); color: #7a1038; }

/* Formularios */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid #ddcfc8; border-radius: 10px; background: #fff; color: var(--text); width: 100%; min-height: 42px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; flex-shrink: 0; }
.rate-now { background: var(--primary-soft); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
.rate-now .value { font-size: 1.6rem; font-weight: 700; }
#rate-form label.check { margin-bottom: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 120px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 14px; margin-bottom: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-weight: 600; min-height: 1em; margin: 6px 0; white-space: pre-line; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.preview { background: var(--primary-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.search { max-width: 320px; }

/* Tablas: en teléfono se convierten en tarjetas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; }
td .actions { justify-content: flex-end; flex-wrap: nowrap; }
tr.total td { font-weight: 700; border-bottom: none; }
input.margin-input { width: 90px; text-align: right; padding: 6px 8px; min-height: 34px; }

/* Recetas */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.recipe-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.recipe-card:hover { border-color: var(--primary); }
.recipe-card .ph { height: 140px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.recipe-card img, .recipe-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card .body { padding: 12px 14px; }
.recipe-card .name { font-weight: 700; }
.recipe-photo { width: 100%; max-height: 300px; height: 260px; border-radius: var(--radius); overflow: hidden; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 4rem; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; }
.kv .v.big { font-size: 1.25rem; color: var(--primary); }
.kv hr { grid-column: 1 / -1; border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.prep { white-space: pre-wrap; }
.item-row { display: grid; grid-template-columns: 1fr 130px 110px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row .cost { text-align: right; font-weight: 600; font-size: .9rem; }
.qty-wrap { display: flex; align-items: center; gap: 6px; }
.qty-wrap span { color: var(--muted); font-size: .85rem; min-width: 40px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); padding: 30px; border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); }
.login-card p { text-align: center; margin: 0; }

/* Modal y avisos */
.modal { position: fixed; inset: 0; background: rgba(40, 20, 15, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-box { background: var(--card); border-radius: 18px; width: 100%; max-width: 620px; padding: 20px 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); }

/* Teléfono */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 20; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px; border-right: none; border-bottom: 1px solid var(--line); }
  .brand { flex: 1; }
  .side-logo { max-width: 160px; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; }
  #rate-badge { display: none; }
  #nav { order: 3; width: 100%; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  #nav a { white-space: nowrap; padding: 8px 10px; font-size: .9rem; }
  main { padding: 18px 16px 60px; }
  h1 { font-size: 1.35rem; }
  .item-row { grid-template-columns: 1fr 1fr 40px; }
  .item-row .cost { grid-column: 1 / 3; text-align: left; }
  table.rt thead { display: none; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.rt tr.total { border: none; background: transparent; }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: none; padding: 5px 0; text-align: right; }
  table.rt td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .85rem; text-align: left; }
  table.rt td[data-label=""]::before { content: none; }
  table.rt td .actions { justify-content: flex-end; flex-wrap: wrap; width: 100%; }
  .modal { padding: 16px 10px; }
  .modal-box { padding: 16px; }
}
