:root {
  --bg: #f5f2ee;
  --panel: #ffffff;
  --ink: #2c2825;
  --muted: #7d746c;
  --line: #e6dfd7;
  --accent: #5d8a6f;
  --accent-ink: #ffffff;
  --accent-soft: #e5efe8;
  --rose: #c4827d;
  --rose-soft: #f6e6e4;
  --warn: #b7791f;
  --warn-soft: #fbf0dc;
  --danger: #b84a4a;
  --danger-soft: #f8e3e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(44, 40, 37, .06), 0 4px 16px rgba(44, 40, 37, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Botones y campos */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap;
}
.btn:hover { border-color: #cfc5ba; background: #fbf9f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: #e7c1c1; }
.btn.big { padding: 14px 18px; font-size: 16px; font-weight: 600; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }

/* Paneles y tablas */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #faf8f5; position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #faf7f3; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #efebe6; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.rose { background: var(--rose-soft); color: var(--rose); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 14px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 5px 12px; border-radius: 99px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Modal y avisos */
.overlay { position: fixed; inset: 0; background: rgba(30, 26, 23, .38); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 520px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--accent); }

/* Inicio de sesión */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 380px; max-width: 100%; padding: 28px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .logo { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; }

/* Barras simples para reportes */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .b:hover { background: #4b765c; }
.hbar { display: grid; grid-template-columns: 160px 1fr 100px; gap: 10px; align-items: center; padding: 4px 0; }
.hbar .track { background: #f0ebe5; border-radius: 4px; height: 10px; }
.hbar .fill { background: var(--accent); height: 100%; border-radius: 4px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ticket */
.ticket { font: 13px/1.35 Consolas, "Courier New", monospace; width: 300px; margin: 0 auto; }
.ticket .c { text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #999; }
.ticket table { width: 100%; border-collapse: collapse; }
.ticket td { padding: 1px 0; vertical-align: top; }
