:root {
  --blue: #1e6fd9;
  --blue-dark: #145bb0;
  --teal: #14a3b0;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e2e6ea;
  --text: #24303d;
  --muted: #6b7785;
  --danger: #d64545;
  --success: #1f9d55;
  --warn: #c98a12;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
}
.login-card {
  background: var(--card);
  padding: 36px 32px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 340px;
}
.login-logo { display: block; max-width: 220px; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--blue-dark); text-align: center; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.btn {
  display: inline-block; border: none; border-radius: 6px; padding: 9px 16px;
  background: var(--blue); color: white; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--blue-dark); }
.btn.secondary { background: white; color: var(--blue); border: 1px solid var(--blue); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  color: white; display: flex; align-items: center; padding: 0 16px; z-index: 20;
  gap: 12px;
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 9px; }
.topbar .brand img { height: 30px; width: auto; display: block; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: .95; }
.topbar button.logout {
  background: rgba(255,255,255,.15); border: none; color: white; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.sidebar {
  position: fixed; top: 52px; left: 0; bottom: 0; width: 220px;
  background: white; border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 0 30px;
}
.sidebar h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 16px 6px; }
.sidebar a {
  display: block; padding: 8px 16px; font-size: 14px; text-decoration: none; color: var(--text); border-left: 3px solid transparent;
}
.sidebar a:hover { background: #f0f4ff; }
.sidebar a.active { border-left-color: var(--blue); background: #eaf2ff; color: var(--blue-dark); font-weight: 600; }
.content { margin-left: 220px; margin-top: 52px; padding: 22px 26px; flex: 1; max-width: 1400px; }
.content h1 { font-size: 22px; margin: 0 0 18px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; min-width: 150px; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; min-width: 180px; }
.stat-tile .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-tile .value { font-size: 24px; font-weight: 700; color: var(--blue-dark); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; background: var(--blue); color: white; padding: 9px 10px; font-weight: 600; position: sticky; top: 0;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f7faff; }
.table-scroll { max-height: 560px; overflow: auto; border-radius: 8px; border: 1px solid var(--border); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.ok { background: #e5f7ec; color: var(--success); }
.badge.bad { background: #fbe9e9; color: var(--danger); }
.badge.warn { background: #fdf3df; color: var(--warn); }
.badge.info { background: #e6f3fb; color: var(--blue-dark); }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none; border: none; padding: 10px 16px; font-size: 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--blue-dark); border-bottom-color: var(--blue); font-weight: 600; }

.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.pos-products { max-height: 74vh; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 10px; }
.pos-product-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; background: white; }
.pos-product-card:hover { border-color: var(--blue); box-shadow: 0 2px 8px rgba(30,111,217,.15); }
.pos-product-card .name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.pos-product-card .variant { font-size: 12px; color: var(--muted); }
.pos-product-card .price { font-size: 15px; font-weight: 700; color: var(--blue-dark); margin-top: 6px; }
.pos-product-card .stock { font-size: 11.5px; color: var(--muted); }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cart-item .qty { display: flex; align-items: center; gap: 6px; }
.cart-item .qty button { width: 22px; height: 22px; border: 1px solid var(--border); background: white; border-radius: 4px; cursor: pointer; }
.cart-line { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cart-line .cl-name { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; margin-bottom: 6px; }
.cart-line .cl-name button { border: none; background: none; color: var(--danger); font-size: 15px; cursor: pointer; line-height: 1; padding: 0 2px; }
.cart-line .cl-fields { display: flex; gap: 8px; }
.cart-line .cl-fields > div { flex: 1; }
.cart-line .cl-fields label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.cart-line .cl-fields input { width: 100%; padding: 5px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 12.5px; }
.cart-line .cl-subtotal { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.pago-row { gap: 8px; }
.pago-row select { flex: 1; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.pago-row input { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.pago-row .pago-quitar { width: 26px; height: 26px; border: 1px solid var(--danger); background: white; border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.summary-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.summary-row.total { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--text); color: white; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.toast.warn { background: var(--warn); }

.empty-hint { color: var(--muted); font-size: 13px; padding: 24px; text-align: center; }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,40,.45); display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-box {
  background: white; border-radius: 10px; padding: 22px; max-width: 560px; width: 92%; max-height: 84vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-box h3 { margin-top: 0; }
.modal-close { float: right; cursor: pointer; font-size: 18px; color: var(--muted); border: none; background: none; }

.objetivo-row { display: flex; gap: 24px; flex-wrap: wrap; }
.objetivo-item { flex: 1; min-width: 220px; }
.objetivo-bar-track { background: #eef1f4; border-radius: 20px; height: 10px; overflow: hidden; margin: 8px 0 4px; }
.objetivo-bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 20px; }
.objetivo-bar-fill.over { background: var(--success); }
.objetivo-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
