:root {
  --ink: #241f1c;
  --muted: #736a64;
  --paper: #fffdf8;
  --canvas: #f4efe7;
  --line: #dfd5ca;
  --primary: #b63b24;
  --primary-dark: #8b2818;
  --green: #27724a;
  --green-soft: #e8f4ec;
  --red: #a72e2e;
  --red-soft: #fbeaea;
  --yellow: #9b640f;
  --yellow-soft: #fff3d5;
  --shadow: 0 12px 36px rgba(59, 40, 27, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(230, 154, 82, 0.14), transparent 30rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.4rem; font-size: clamp(1.7rem, 5vw, 2.5rem); line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 1.1rem; }
small { color: var(--muted); }

.topbar {
  min-height: 66px;
  padding: 0.7rem max(1rem, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: white;
  background: #30241f;
}
.brand { display: flex; align-items: center; gap: 0.65rem; color: white; text-decoration: none; font-weight: 800; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--primary); font-size: 0.8rem; letter-spacing: 0.08em; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; }
.user-menu form { margin: 0; }
.user-name { font-size: 0.9rem; }
.user-menu .link-button { color: #ffd9c9; }

.nav-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem max(1rem, calc((100vw - 1180px) / 2));
  overflow-x: auto;
  background: #fffaf3;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.nav-tabs a { flex: 0 0 auto; padding: 0.55rem 0.75rem; border-radius: 999px; color: #51443d; text-decoration: none; font-size: 0.9rem; font-weight: 700; }
.nav-tabs a:hover { background: #f0e4d8; }

.container { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 2.5rem; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.8rem; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.4rem; }
.eyebrow { margin-bottom: 0.4rem; color: var(--primary); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 900; }

.panel, .auth-card, .metric-card {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 1.25rem; margin-bottom: 1.25rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading.compact { margin-top: 0.3rem; }
.panel-danger { border-color: #e7b6b0; }
.auth-card { width: min(470px, 100%); margin: 5vh auto; padding: clamp(1.4rem, 5vw, 2.4rem); }
.auth-card p { color: var(--muted); }
.error-card { text-align: center; }
.error-symbol { display: grid; width: 64px; height: 64px; place-items: center; margin: 0 auto 1rem; border-radius: 50%; color: white; background: var(--red); font-size: 2rem; font-weight: 900; }

.form-stack { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 0.4rem; color: #51443d; font-size: 0.86rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
  background: white;
  border: 1px solid #cfc1b6;
  border-radius: 11px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(182, 59, 36, 0.12); }
.check-label { display: flex; align-items: center; gap: 0.6rem; min-height: 46px; }
.check-label input { width: 20px; min-height: 20px; }
.narrow-form { width: min(680px, 100%); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 11px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: #4f4038; background: #f5e9de; border-color: #dbc9ba; }
.button-danger { color: white; background: var(--red); }
.button-large { min-height: 52px; }
.button-full { width: 100%; margin-top: 1rem; }
.link-button { padding: 0; border: 0; color: var(--primary-dark); background: transparent; font-weight: 800; cursor: pointer; }
.icon-button { align-self: end; width: 42px; height: 46px; border: 0; border-radius: 11px; color: var(--red); background: var(--red-soft); font-size: 1.5rem; cursor: pointer; }

.alert { margin-bottom: 1rem; padding: 0.9rem 1rem; border-radius: 12px; font-weight: 700; }
.alert-success { color: var(--green); background: var(--green-soft); border: 1px solid #b7dbc4; }
.alert-error { color: var(--red); background: var(--red-soft); border: 1px solid #e8baba; }
.status-line { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 1.25rem; padding: 0.8rem 1rem; border-radius: 12px; }
.status-open { color: var(--green); background: var(--green-soft); }
.status-closed { color: var(--muted); background: #e8e2dc; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(39, 114, 74, 0.12); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.metric-card { display: grid; gap: 0.25rem; padding: 1.2rem; }
.metric-card span { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.metric-card strong { font-size: clamp(1.3rem, 4vw, 2rem); }
.metric-main { color: white; background: linear-gradient(135deg, #b63b24, #d46d35); border-color: transparent; }
.metric-main span, .metric-main small { color: #ffe7dd; }
.metric-warning { color: var(--red); background: var(--red-soft); }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.two-columns > .panel { min-width: 0; }

.badge { display: inline-flex; width: fit-content; padding: 0.25rem 0.55rem; border-radius: 999px; color: #5d514a; background: #eee6df; font-size: 0.72rem; font-weight: 850; }
.badge-success { color: var(--green); background: var(--green-soft); }
.badge-warning { color: var(--yellow); background: var(--yellow-soft); }
.danger-text { color: var(--red); font-weight: 800; }
.empty { margin: 0; padding: 1.2rem 0; color: var(--muted); text-align: center; }
.list { display: grid; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid #ebe2da; }
.list-row:last-child { border-bottom: 0; }
.list-row > div { display: grid; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { color: var(--muted); text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
th, td { padding: 0.75rem; border-bottom: 1px solid #e9dfd6; vertical-align: middle; }
.table-subtitle { display: block; }
.row-muted { opacity: 0.56; }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, 0.75fr); gap: 1.25rem; align-items: start; }
.cart-panel { position: sticky; top: 1rem; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.product-button { display: grid; gap: 0.25rem; min-height: 112px; padding: 1rem; text-align: left; border: 1px solid #dacbc0; border-radius: 14px; color: var(--ink); background: white; cursor: pointer; }
.product-button:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(74, 49, 31, 0.09); }
.product-button strong { color: var(--primary-dark); font-size: 1.1rem; }
.cart-list { display: grid; }
.cart-empty { padding: 1.3rem 0; color: var(--muted); text-align: center; }
.cart-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid #e8ddd4; }
.cart-row > div:first-child { display: grid; }
.quantity-control { display: flex; align-items: center; gap: 0.7rem; }
.quantity-control button { width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--primary-dark); background: #f2e4da; font-size: 1.1rem; font-weight: 900; cursor: pointer; }
.cart-total { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; padding-top: 1rem; border-top: 2px solid var(--ink); font-size: 1.15rem; }
.cart-total strong { font-size: 1.5rem; }

.purchase-lines { display: grid; gap: 0.8rem; }
.purchase-line { display: grid; grid-template-columns: 1.5fr 0.65fr 0.75fr 0.8fr 1fr 42px; gap: 0.6rem; align-items: end; padding: 0.9rem; border-radius: 14px; background: #f8f1ea; }
.create-panel summary { cursor: pointer; font-size: 1.05rem; font-weight: 850; }
.create-panel summary + form { margin-top: 1.2rem; }

@media (max-width: 850px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns, .pos-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchase-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchase-line .icon-button { grid-column: 2; justify-self: end; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .container { width: min(100% - 1rem, 1180px); padding-top: 1.2rem; }
  .topbar { padding-inline: 0.75rem; }
  .brand > span:last-child, .user-name { display: none; }
  .nav-tabs { padding-inline: 0.5rem; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .date-filter { display: grid; grid-template-columns: 1fr auto; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .metric-card { padding: 0.9rem; }
  .metric-card strong { font-size: 1.2rem; }
  .metric-main { grid-column: 1 / -1; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .product-button { min-height: 98px; padding: 0.75rem; }
  .purchase-line { grid-template-columns: 1fr; }
  .purchase-line .icon-button { grid-column: 1; }
  .panel { padding: 1rem; border-radius: 14px; }
  .footer { flex-direction: column; }
}

/* ---- vigilancia: anulaciones y auditoría ---- */
.badge-danger { background: #fdecea; color: #b3261e; }
.row-muted td { opacity: 0.55; text-decoration: line-through; }
.row-muted td:last-child, .row-muted td .badge { text-decoration: none; }
.void-form { display: flex; gap: 6px; align-items: center; }
.void-form input[name="reason"] { width: 150px; min-width: 0; font-size: 0.85rem; padding: 6px 8px; }
.void-form .button { padding: 6px 10px; font-size: 0.85rem; }
.audit-detail { font-size: 0.85rem; color: #555; max-width: 340px; }

/* ---- logo del local ---- */
.brand-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #fff; }
