/* ========== Variables ========== */
:root {
  --bg: #0f0f10;
  --side: #141415;
  --card: #1a1a1b;
  --line: #262628;
  --text: #f2f2f2;
  --muted: #8b8b90;
  --accent: #ffc20e;
  --ok: #8bf04a;
  --bad: #ff5d5d;
  --radius: 14px;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h3 { font-size: 1rem; margin-bottom: 4px; }
small { color: var(--muted); }

/* ========== Menú lateral ========== */
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--side);
  border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 1.3rem; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.logo { background: var(--accent); color: #000; border-radius: 8px; padding: 4px 6px; font-size: .7rem; letter-spacing: -2px; }
.menu-label { color: var(--muted); font-size: .75rem; margin-bottom: 10px; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav a {
  color: #d6d6d8; text-decoration: none; padding: 11px 12px;
  border-radius: 10px; font-size: .9rem;
}
nav a:hover { background: #1f1f21; }
nav a.active { background: #2a2308; color: var(--accent); font-weight: 600; }
.nav-bottom { margin-top: auto; }

/* ========== Contenido ========== */
.content { flex: 1; min-width: 0; padding: 0 32px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-size: .85rem; }
.topbar strong { display: block; }
main { padding-top: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }

/* ========== Botones y formularios ========== */
.btn {
  background: var(--accent); color: #000; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; cursor: pointer; font-size: .9rem; font-family: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #4a2222; }
.btn.sm { padding: 6px 10px; font-size: .8rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
input, select {
  background: #111112; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: .95rem; font-family: inherit;
}
.inline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline select, .inline input { min-width: 240px; }

/* ========== Tablas ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge.ok { background: #1c3010; color: var(--ok); }
.badge.off { background: #3a1818; color: var(--bad); }
.badge.warn { background: #3a2f08; color: var(--accent); }

/* ========== Panel ========== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .ico { width: 38px; height: 38px; background: #242426; border-radius: 10px; display: grid; place-items: center; margin-bottom: 14px; }
.stat small { display: block; margin-bottom: 4px; }
.stat strong { font-size: 1.3rem; }

.charts { display: grid; grid-template-columns: 1fr 1.5fr; gap: 20px; }
.gauge { width: 100%; max-width: 300px; display: block; margin: 10px auto 0; }
.g-bg, .g-fg { fill: none; stroke-width: 14; stroke-linecap: round; }
.g-bg { stroke: #3a3a3d; }
.g-fg { stroke: var(--ok); }
.gauge text { fill: #cfcfd2; font-size: 26px; font-weight: 700; text-anchor: middle; }
.gauge-msg { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.gauge-foot { display: flex; justify-content: space-around; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
.gauge-foot small { display: block; margin-bottom: 4px; }

.bars { height: 240px; display: flex; gap: 6px; align-items: stretch; margin-top: 16px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar-area { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { width: 55%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-col span { font-size: .72rem; color: var(--muted); margin-top: 8px; }

.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin: 8px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.line-chart { width: 100%; height: auto; }
.line-chart text { fill: var(--muted); font-size: 11px; text-anchor: middle; }

/* ========== Punto de venta ========== */
.pos { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.product {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 16px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-family: inherit;
}
.product:hover:not(:disabled) { border-color: var(--accent); }
.product:disabled { opacity: .4; cursor: not-allowed; }
.product span { color: var(--accent); font-weight: 600; }
.cart-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.2rem; padding: 16px 0; }
.cart .btn { width: 100%; }

/* ========== Ventana de formulario ========== */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: min(420px, 92vw); margin: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog h2 { margin-bottom: 18px; font-size: 1.2rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ========== Responsive ========== */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; gap: 12px; }
  .brand { margin: 0; }
  .menu-label { display: none; }
  nav { flex-direction: row; }
  nav a { white-space: nowrap; }
  .nav-bottom { margin: 0; }
  .content { padding: 0 16px 32px; }
  .charts, .pos { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
