/* MUNA CRM · estilo Apple: neutro, aireado, colores solo para estados. */
:root {
  --bg: #F5F5F7; --card: #FFFFFF; --soft: #FAFAFA; --ink: #1D1D1F; --muted: #6E6E73; --faint: #86868B;
  --line: #E8E8ED; --line2: #D2D2D7; --btn: #1D1D1F; --btn-ink: #FFFFFF; --accent: #0071E3; --sel: #F2F2F4;
  --ok-bg: #E8F7EE; --ok: #1E7B45; --warn-bg: #FFF4E5; --warn: #A35A00; --bad-bg: #FDECEC; --bad: #C2352B;
  --gray-bg: #F2F2F4; --gray: #6E6E73; --shadow: 0 1px 3px rgba(0,0,0,.05);
  --r: 20px; --r-sm: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
  color: var(--ink); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --card: #1C1C1E; --soft: #242426; --ink: #F5F5F7; --muted: #98989D; --faint: #8E8E93;
    --line: #2C2C2E; --line2: #3A3A3C; --btn: #F5F5F7; --btn-ink: #1D1D1F; --accent: #0A84FF; --sel: #2C2C2E;
    --ok-bg: #12301F; --ok: #5FD08A; --warn-bg: #3A2A10; --warn: #FFB547; --bad-bg: #3A1614; --bad: #FF7A70;
    --gray-bg: #2C2C2E; --gray: #A1A1A6; --shadow: none;
  }
  .logo-claro { display: none !important; }
  .logo-oscuro { display: block !important; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.logo-oscuro { display: none; }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line); padding: 24px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { width: 108px; margin: 2px 12px 22px; }
.nav-grupo { font-size: 11px; font-weight: 600; color: var(--faint); padding: 16px 12px 6px; letter-spacing: .4px; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--ink); font-size: 14px; }
.nav-item:hover { background: var(--sel); }
.nav-item.activo { background: var(--sel); font-weight: 600; }
.nav-item .pronto { margin-left: auto; font-size: 10px; color: var(--faint); }
.main { flex: 1; min-width: 0; padding: 28px 36px 60px; max-width: 1280px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.4px; }
.sub { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.bottombar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 18px 16px 110px; }
  .topbar h1 { font-size: 24px; }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); justify-content: space-around; align-items: center; }
  .bb-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--faint); min-width: 56px; background: none; border: 0; padding: 4px; }
  .bb-item.activo { color: var(--ink); font-weight: 600; }
  .bb-mas { width: 50px; height: 50px; border-radius: 25px; background: var(--btn); color: var(--btn-ink); border: 0; font-size: 26px; font-weight: 300; margin-top: -10px; }
}

/* ---- Componentes ---- */
.card { background: var(--card); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: 17px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; gap: 14px; } .card { padding: 18px; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

.btn { height: 40px; padding: 0 18px; border-radius: 20px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: var(--sel); }
.btn.primario { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); font-weight: 600; }
.btn.primario:hover { opacity: .88; }
.btn.chico { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 16px; }
.btn.verde { background: #25D366; border-color: #25D366; color: #fff; font-weight: 600; }
.btn.peligro { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-icono { width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.gray { background: var(--gray-bg); color: var(--gray); }

label.campo { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line2); background: var(--card); color: var(--ink); font-size: 14px; outline: none; }
textarea.input { resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.seg { display: inline-flex; background: var(--sel); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.activo { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.lista { display: flex; flex-direction: column; }
.lista-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lista-item:last-child { border-bottom: 0; }
.alerta { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--soft); }
.alerta .t { font-size: 14px; font-weight: 600; }
.alerta .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.3px; }
.kpi .c { font-size: 12px; margin-top: 2px; }
.sube { color: var(--ok); } .baja { color: var(--bad); }

table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabla td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr.click { cursor: pointer; }
.tabla tr.click:hover td { background: var(--soft); }
.tabla-wrap { overflow-x: auto; }

/* Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.columna { flex: 0 0 250px; background: var(--sel); border-radius: 18px; padding: 10px; min-height: 120px; }
.columna.sobre { outline: 2px dashed var(--accent); }
.columna-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-size: 13px; font-weight: 600; }
.tarjeta { background: var(--card); border-radius: 14px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.tarjeta .n { font-size: 14px; font-weight: 600; }
.tarjeta .m { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Stock */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.foto { aspect-ratio: 1; border-radius: 14px; background: var(--sel); display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 12px; overflow: hidden; }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.tallas { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.tallas button { border: 0; cursor: pointer; }

/* Ficha pedido */
.ficha { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1080px) { .ficha { grid-template-columns: 1fr; } }
.pasos { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.paso { flex-shrink: 0; border: 1px solid var(--line2); background: var(--card); border-radius: 16px; padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.paso.hecho { color: var(--ink); }
.paso.actual { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); font-weight: 600; }
.productos-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 6px; align-items: center; font-size: 13px; }
.productos-grid .h { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; }
.cant { display: inline-flex; align-items: center; gap: 4px; justify-content: center; }
.cant button { width: 26px; height: 26px; border-radius: 13px; border: 1px solid var(--line2); background: var(--card); cursor: pointer; }
.cant span { min-width: 16px; text-align: center; font-weight: 600; }
.copiar-fila { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.copiar-fila .k { font-size: 12px; color: var(--muted); width: 150px; flex-shrink: 0; }
.copiar-fila .v { font-size: 13px; flex: 1; word-break: break-word; }
.mensaje { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }

.vacio { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--btn); color: var(--btn-ink); padding: 10px 18px; border-radius: 20px; font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.modal-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border-radius: 22px; padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.menu-flotante { max-height: 70vh; overflow-y: auto; position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: var(--card); border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 8px; z-index: 40; display: flex; flex-direction: column; min-width: 220px; }
.menu-flotante button { border: 0; background: none; text-align: left; padding: 12px 14px; border-radius: 12px; font-size: 15px; cursor: pointer; }
.menu-flotante button:hover { background: var(--sel); }

/* Login */
.login-pantalla { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; text-align: center; padding: 40px 32px; }
.login-card .logo { width: 160px; margin: 0 auto 26px; display: block; }
.login-card h1 { font-size: 28px; margin: 0; }
.login-card .btn { width: 100%; height: 50px; border-radius: 25px; margin-top: 26px; }
