:root {
  --brand: #ef5330;        /* rojo tomate del dragón */
  --brand-dark: #d63e1f;
  --gold: #f5a623;         /* dorado del logotipo "Chifa Quispe" */
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --sidebar-tx: #cbd5e1;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --blue: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

svg { display: block; }
.nav-ic { display: inline-flex; align-items: center; }
.nav-ic svg { width: 18px; height: 18px; }

/* ================= LAYOUT ================= */
.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

/* ================= SIDEBAR ================= */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-tx);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; padding: 8px 6px 24px; min-height: 46px; }
.brand-logo-full { width: 100%; max-width: 210px; height: auto; display: block; }
.brand-fallback { display: none; align-items: center; gap: 12px; }
.bf-ic { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; font-size: 24px; background: var(--brand); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 1.02rem; }
.brand-text strong .q { color: var(--gold); }
.brand-text small { color: var(--gold); font-size: .74rem; opacity: .85; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; cursor: pointer;
  color: var(--sidebar-tx); font-size: .92rem; font-weight: 500; font-family: inherit;
  padding: 11px 12px; border-radius: 9px; text-align: left; width: 100%;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item .nav-ic svg { width: 19px; height: 19px; }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid #1e293b; }
.conn { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #94a3b8; padding: 0 4px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; flex: none; }
.conn.ok .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.conn.err .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
.side-btn {
  display: flex; align-items: center; gap: 9px; justify-content: flex-start;
  background: var(--sidebar-2); border: 1px solid #334155; color: #e2e8f0;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: .85rem; font-family: inherit;
  transition: background .12s;
}
.side-btn:hover { background: #334155; }
.side-btn.on { background: var(--success); border-color: var(--success); color: #fff; }

/* ================= MAIN ================= */
.main { display: flex; flex-direction: column; min-width: 0; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 18px 28px; position: sticky; top: 0; z-index: 5;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; }
.page-header p { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.updated { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; }
.updated svg { width: 15px; height: 15px; }

.content { padding: 26px 28px; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer;
  font-family: inherit; font-size: .88rem; font-weight: 600; padding: 9px 15px; border-radius: 9px; transition: all .12s; }
.btn svg { width: 16px; height: 16px; }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-solid { background: var(--brand); color: #fff; align-self: start; }
.btn-solid:hover { background: var(--brand-dark); }
.hidden { display: none !important; }

/* KPIs */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow); }
.card-ic { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.card-ic svg { width: 23px; height: 23px; }
.ic-brand { background: #fde8e8; color: var(--brand); }
.ic-blue  { background: #e0edff; color: var(--blue); }
.ic-amber { background: #fef3e2; color: var(--warning); }
.ic-green { background: #dcfce7; color: var(--success); }
.card-body { display: flex; flex-direction: column; }
.card-label { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.card-value { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head h2 svg { width: 18px; height: 18px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tabla */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
thead th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: 13px 20px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: .9rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge svg { width: 13px; height: 13px; }
.badge-verde { background: #dcfce7; color: #15803d; }
.badge-naranja { background: #fef3e2; color: #b45309; }
.badge-gris { background: #f1f5f9; color: #475569; }
.badge-rojo { background: #fee2e2; color: #b91c1c; }
.toggle { cursor: pointer; }

/* Formularios admin */
.admin-form { padding-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 13px; padding: 18px 20px; }
.form-grid .span2 { grid-column: span 2; }
.admin-form input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: .9rem; font-family: inherit; background: #f8fafc; }
.admin-form input:focus { outline: none; border-color: var(--brand); background: #fff; }
.admin-form .btn-solid { margin: 0 20px; }

/* Info restaurante */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px; padding: 8px; }
.info-item { display: flex; align-items: center; gap: 13px; padding: 15px; }
.info-item svg { width: 20px; height: 20px; color: var(--brand); }
.info-item > span { flex: none; }
.info-item small { display: block; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.info-item b { font-size: .96rem; }

/* Acciones fila */
.row-btn { border: none; background: transparent; cursor: pointer; padding: 6px; border-radius: 7px; color: var(--muted); display: inline-flex; }
.row-btn svg { width: 17px; height: 17px; }
.row-btn:hover { background: #fee2e2; color: var(--danger); }

/* Extras KPIs */
.ic-red { background: #fee2e2; color: var(--danger); }
.card-alert { border-color: #fecaca; }
.nav-badge { background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 999px;
  padding: 1px 7px; margin-left: auto; }

/* Botón fantasma */
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }

/* Toolbar de filtros */
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-size: .82rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .12s; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.chip-alt.active { background: var(--brand); border-color: var(--brand); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-hint { color: var(--muted); font-size: .78rem; font-weight: 500; }

/* Fila de pedido clicable */
tr.clickable { cursor: pointer; }
.thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); display: block; }
.thumb-none { width: 34px; height: 34px; border-radius: 8px; border: 1px dashed var(--line); display: grid; place-items: center; color: #cbd5e1; }
.thumb-none svg { width: 16px; height: 16px; }
.cell-open { color: var(--muted); }
.cell-open svg { width: 16px; height: 16px; }

/* Select en línea (estado de reservas) */
.mini-select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: .82rem;
  font-family: inherit; background: #f8fafc; cursor: pointer; }
.mini-select:focus { outline: none; border-color: var(--brand); }

/* ================= MODALES ================= */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50;
  overflow-y: auto; }
.overlay[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(15,23,42,.3); overflow: hidden; animation: pop .16s ease; }
.modal-drawer { max-width: 620px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-head h3 svg { width: 18px; height: 18px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.icon-btn { border: none; background: transparent; cursor: pointer; color: var(--muted); padding: 6px;
  border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* Campos de formulario en modal */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: .76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: .9rem; font-family: inherit; background: #f8fafc; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); background: #fff; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field-grid .span2 { grid-column: span 2; }

/* Builder de items del nuevo pedido */
.builder { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #f8fafc; }
.builder-head { font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; margin-bottom: 10px; }
.builder-row { display: flex; gap: 8px; }
.builder-row .grow { flex: 1; }
.builder-row select, .builder-row input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: .88rem; font-family: inherit; background: #fff; }
.builder-row .qty { width: 66px; }
.line-list { list-style: none; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.line-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: .88rem; }
.line-empty { justify-content: center; color: var(--muted); font-style: italic; }
.line-list .line-rm { border: none; background: transparent; cursor: pointer; color: var(--muted); padding: 2px; display: inline-flex; }
.line-list .line-rm:hover { color: var(--danger); }
.line-list .line-rm svg { width: 16px; height: 16px; }
.builder-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--line); font-size: .84rem; color: var(--muted); font-weight: 600; }
.builder-total b { font-size: 1.15rem; color: var(--ink); }

/* Detalle de pedido */
.od-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.od-summary .od-item { display: flex; flex-direction: column; gap: 2px; }
.od-summary small { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.od-summary b { font-size: .92rem; font-weight: 600; }
.od-items { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: .9rem; }
.od-block { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.od-block > h4 { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
  display: flex; align-items: center; gap: 7px; }
.od-block > h4 svg { width: 16px; height: 16px; }
.od-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.od-row select { flex: 1; min-width: 150px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: .9rem; font-family: inherit; background: #f8fafc; }

/* Aviso regla de pago */
.notice { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 9px;
  font-size: .84rem; font-weight: 500; }
.notice svg { width: 17px; height: 17px; flex: none; }
.notice-warn { background: #fef3e2; color: #b45309; }
.notice-ok { background: #dcfce7; color: #15803d; }

/* Zona de foto (subida + miniatura) */
.photo-slot { display: flex; align-items: center; gap: 12px; }
.photo-preview { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line);
  cursor: zoom-in; flex: none; }
.photo-empty { width: 84px; height: 84px; border-radius: 10px; border: 1px dashed var(--line); flex: none;
  display: grid; place-items: center; color: #cbd5e1; }
.photo-empty svg { width: 26px; height: 26px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-name { font-size: .8rem; color: var(--muted); }

/* Lightbox */
.lightbox { align-items: center; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox-close { position: fixed; top: 20px; right: 24px; color: #fff; background: rgba(0,0,0,.35); }
.lightbox-close:hover { background: rgba(0,0,0,.55); color: #fff; }

.modal-sm { max-width: 400px; }

/* Toolbar: lado derecho (vista + export) */
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ================= TABLERO (KANBAN COCINA) ================= */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { flex: 0 0 250px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 12px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.board-col-head b { font-size: .82rem; font-weight: 700; }
.board-col-head .count { background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.board-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.board-empty { color: #94a3b8; font-size: .8rem; text-align: center; padding: 14px 4px; font-style: italic; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); cursor: pointer; }
.kcard:hover { border-color: var(--brand); }
.kcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kcard-top strong { font-size: .9rem; }
.kcard-total { font-weight: 700; font-size: .9rem; }
.kcard-items { color: var(--muted); font-size: .8rem; margin: 5px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kcard-moves { display: flex; gap: 4px; }
.kmove { border: 1px solid var(--line); background: var(--surface); color: var(--muted); width: 28px; height: 26px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.kmove:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.kmove:disabled { opacity: .35; cursor: not-allowed; }
.kmove svg { width: 15px; height: 15px; }

/* ================= RESPONSIVE ================= */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
  .brand { padding: 0 8px 0 4px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .nav-item { width: auto; }
  .nav-badge { margin-left: 6px; }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
  .content { padding: 18px; }
  .page-header { padding: 16px 18px; }
  .field-grid, .od-summary { grid-template-columns: 1fr; }
}
