@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,600;0,800;1,800&family=Barlow:wght@400;500;600;700&display=swap");

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --surface-3: #252525;
  --border: #2c2c2c;
  --text: #f5f5f5;
  --muted: #9b9b9b;
  --red: #e3121c;
  --red-hover: #ff2a33;
  --red-soft: rgba(227, 18, 28, 0.14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f5a524;
  --amber-soft: rgba(245, 165, 36, 0.14);
  --blue: #60a5fa;
  --radius: 10px;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --font: "Barlow", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: .3px; margin: 0; text-transform: uppercase; }
h1 { font-size: 30px; font-style: italic; }
h2 { font-size: 20px; }
h3 { font-size: 16px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.red { color: var(--red); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: #000; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { padding: 18px 18px 10px; border-bottom: 3px solid var(--red); }
.sidebar .logo img { width: 100%; display: block; }
.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: #cfcfcf; font-weight: 600; margin-bottom: 2px; }
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: #fff; }
.nav a.active { background: var(--red); color: #fff; }
.nav a .count { margin-left: auto; background: var(--red); color: #fff; font-size: 12px; border-radius: 99px; padding: 0 7px; }
.nav a.active .count { background: #fff; color: var(--red); }
.nav .sep { font-family: var(--display); text-transform: uppercase; color: #666; font-size: 12px; letter-spacing: 1.5px; padding: 14px 12px 4px; }
.sidebar .user { border-top: 1px solid var(--border); padding: 12px 16px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px 28px 60px; }
.menu-btn { display: none; }
.backup-btn { border: 1px solid var(--border); white-space: nowrap; }
.backup-btn:hover { border-color: var(--red); }
.backup-btn.busy { opacity: .6; cursor: wait; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; cursor: default; }
.kpi[data-go] { cursor: pointer; }
.kpi[data-go]:hover { border-color: #444; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-family: var(--display); font-size: 34px; font-weight: 800; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.accent { border-left: 4px solid var(--red); }
.kpi.ok .value { color: var(--green); }
.kpi.warn .value { color: var(--amber); }
.kpi.bad .value { color: var(--red); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 8px 14px; border-radius: 8px; font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: #3a3a3a; }
.btn svg { width: 16px; height: 16px; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-white { background: #fff; color: #000; border-color: #fff; }
.btn-white:hover { background: #e7e7e7; }
.btn-ghost { background: transparent; }
.btn-wa { background: #128c4a; border-color: #128c4a; color: #fff; }
.btn-wa:hover { background: #16a457; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: #fff; background: var(--surface-3); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.b-al_dia { background: var(--green-soft); color: var(--green); }
.b-por_vencer { background: var(--amber-soft); color: var(--amber); }
.b-vencido { background: var(--red-soft); color: #ff5a61; }
.b-sin_pago { background: var(--surface-3); color: #bbb; }
.b-baja { background: var(--surface-3); color: #777; }
.b-info { background: rgba(96, 165, 250, .14); color: var(--blue); }
.b-desc { background: rgba(255, 255, 255, .08); color: #fff; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #202020; vertical-align: middle; }
td a { text-decoration: none; }
td a:hover { color: var(--red-hover); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.anulado td { opacity: .45; text-decoration: line-through; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 9px 11px; font: 15px var(--font); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
input[type="checkbox"] { width: auto; accent-color: var(--red); }
textarea { min-height: 70px; resize: vertical; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form .full { grid-column: 1 / -1; }
.form h3 { grid-column: 1 / -1; margin-top: 8px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; margin: 0; cursor: pointer; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { max-width: 340px; }
.toolbar select, .toolbar input[type="date"], .toolbar input[type="month"] { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: #ccc; border-radius: 99px; padding: 6px 13px; font: 600 13px var(--font); cursor: pointer; }
.chip.on { background: #fff; color: #000; border-color: #fff; }
.chip .n { opacity: .6; margin-left: 4px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .72); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--red); border-radius: 12px; width: 100%; max-width: 640px; padding: 22px; }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* toast */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #fff; color: #000; padding: 11px 16px; border-radius: 8px; font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); border-left: 5px solid var(--green); max-width: 380px; }
.toast.err { border-left-color: var(--red); }

/* acceso */
.acceso { max-width: 920px; margin: 0 auto; }
.acceso-input { display: flex; gap: 10px; }
.acceso-input input { font-size: 26px; padding: 16px 18px; font-family: var(--display); letter-spacing: 1px; }
.acceso-res { margin-top: 20px; border-radius: 14px; padding: 26px; border: 2px solid var(--border); background: var(--surface); }
.acceso-res.ok { border-color: var(--green); background: linear-gradient(135deg, rgba(34, 197, 94, .16), var(--surface) 55%); }
.acceso-res.no { border-color: var(--red); background: linear-gradient(135deg, rgba(227, 18, 28, .22), var(--surface) 55%); }
.acceso-res .big { font-family: var(--display); font-size: 52px; font-weight: 800; font-style: italic; line-height: 1; text-transform: uppercase; }
.acceso-res.ok .big { color: var(--green); }
.acceso-res.no .big { color: var(--red); }
.acceso-res .name { font-family: var(--display); font-size: 34px; font-weight: 800; text-transform: uppercase; margin-top: 10px; }
.avisos { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.aviso { background: var(--amber-soft); color: var(--amber); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.feed { margin-top: 24px; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid #202020; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--green); }
.dot.no { background: var(--red); }

/* horario */
.horario { display: grid; grid-template-columns: 70px repeat(6, minmax(110px, 1fr)); gap: 6px; min-width: 760px; }
.horario .hd { font-family: var(--display); text-transform: uppercase; text-align: center; background: var(--red); border-radius: 6px; padding: 6px; font-weight: 800; }
.horario .hr { font-family: var(--display); font-weight: 800; color: var(--red); display: flex; align-items: center; justify-content: center; background: #000; border-radius: 6px; }
.horario .cell { min-height: 48px; display: flex; flex-direction: column; gap: 4px; }
.clase-pill { background: #fff; color: #000; border-radius: 6px; padding: 6px 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; cursor: pointer; line-height: 1.2; }
.clase-pill:hover { outline: 2px solid var(--red); }
.clase-pill.off { opacity: .35; }
.clase-pill .s { font-weight: 600; text-transform: none; color: #555; font-size: 11px; }

/* bars */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.3fr) 2fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--red); border-radius: 99px; }
.cols { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 10px; }
.cols .c { flex: 1; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.cols .c:hover { background: var(--red-hover); }
.cols-x { display: flex; gap: 3px; font-size: 10px; color: var(--muted); margin-top: 4px; }
.cols-x span { flex: 1; text-align: center; }

/* ficha */
.ficha-head { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.ficha-head .nm { font-family: var(--display); font-size: 32px; font-weight: 800; text-transform: uppercase; line-height: 1.05; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 14px; overflow-x: auto; }
.tab { background: none; border: 0; color: var(--muted); font: 700 14px var(--font); padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: #fff; border-color: var(--red); }

/* pos */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.prod { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.prod:hover { border-color: var(--red); }
.prod .p { font-family: var(--display); font-size: 22px; font-weight: 800; }
.prod.agotado { opacity: .4; cursor: not-allowed; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #222; }
.cart-line .nm { flex: 1; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-3); color: #fff; cursor: pointer; }
.total-big { font-family: var(--display); font-size: 40px; font-weight: 800; }

/* resumen pago */
.resumen { background: var(--bg); border: 1px dashed #3a3a3a; border-radius: 10px; padding: 14px; margin-top: 4px; }
.resumen .ln { display: flex; justify-content: space-between; padding: 3px 0; }
.resumen .tot { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-family: var(--display); font-size: 28px; font-weight: 800; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 50% 0%, #2a0507 0%, #000 60%); }
.login .box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--red); border-radius: 14px; padding: 28px; }
.login img { width: 100%; margin-bottom: 18px; }
.login form > div { margin-bottom: 14px; }

/* carnet */
.carnet { width: 340px; background: #000; border: 2px solid var(--red); border-radius: 14px; padding: 16px; margin: 0 auto; color: #fff; text-align: center; }
.carnet img.lg { width: 70%; }
.carnet .qr { background: #fff; padding: 10px; border-radius: 8px; display: inline-block; margin: 10px 0; }
.carnet .qr img, .carnet .qr svg { display: block; }
.carnet .nm { font-family: var(--display); font-size: 24px; font-weight: 800; text-transform: uppercase; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .g2, .g3, .g4, .pos { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .form { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 90px; }
}
