:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #17211f;
  --ink-soft: #5a6763;
  --ink-faint: #8b9793;
  --line: #dfe4e2;
  /* Paleta de marca VoyPaCuba (bandera cubana): azul royal + rojo */
  --accent: #1e3f9e;
  --accent-ink: #16307a;
  --accent-wash: #e9edf9;
  --brand-red: #e12b22;
  --ok: #2f9e5f;
  --ok-wash: #e3f3ea;
  --crit: #d12a20;
  --crit-wash: #fbe7e5;
  --warn: #a86a1a;
  --warn-wash: #f5ead4;
  --money: #9a6a12;
  --shadow: 0 1px 2px rgba(23,33,31,.05), 0 8px 24px -14px rgba(23,33,31,.18);
  --r: 12px;
  --font: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout: sidebar + main ---- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: #0f1a38; color: #cdd8f0; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 4px 4px 18px; }
.brand-logo {
  display: block; width: 100%; background: #fff; border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 2px 10px rgba(0,0,0,.22);
}
.brand-sub {
  text-align: center; font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: #8fa0c8; margin-top: 8px;
}
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #b6c4e6; font-size: 14.5px; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; box-shadow: inset 3px 0 0 var(--brand-red); }
.nav .ico { width: 18px; text-align: center; }
.nav-logout { margin-top: 14px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px !important; color: #9fb0d6 !important; }
.nav-logout:hover { color: #fff !important; }

.main { padding: 26px 30px 60px; max-width: 1200px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.pagehead h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; }
.pagehead .sub { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

/* ---- Cards / stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat .v.money { color: var(--money); }
.stat .v.accent { color: var(--accent-ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 22px; }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); display:flex; align-items:center; justify-content:space-between; }
.card .card-head h2 { font-size: 15px; margin: 0; }
.card .card-body { padding: 18px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; background: var(--surface-2); }
tbody tr:hover, tr:hover { background: var(--surface-2); }
td.mono, .mono { font-family: var(--mono); }
td.money { color: var(--money); font-variant-numeric: tabular-nums; }
.code-pill { font-family: var(--mono); font-size: 12.5px; background: var(--accent-wash); color: var(--accent-ink); padding: 2px 8px; border-radius: 6px; }

/* ---- Badges ---- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.badge-gris { background: #eceeed; color: #5a6763; }
.badge-azul { background: #e2ecf5; color: #275b86; }
.badge-ambar { background: #f5ead4; color: #8a5a13; }
.badge-verde { background: #e2efe7; color: #2f7d54; }
.badge-rojo { background: #f6e4e0; color: #b04537; }

/* ---- Forms ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
input, select, textarea {
  font-family: var(--font); font-size: 14px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 140px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 64px; resize: vertical; width: 100%; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 14px; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form .field { min-width: 0; }
.grid-form input, .grid-form select, .grid-form textarea { min-width: 0; width: 100%; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 14px; }
.detail-grid .row { display: contents; }
.detail-grid dt { color: var(--ink-soft); padding: 6px 0; }
.detail-grid dd { margin: 0; padding: 6px 0; font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 12px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); white-space: nowrap; }

/* ---- Consola de operaciones (chat) ---- */
.consola { display: grid; grid-template-columns: 250px 1fr; height: calc(100vh - 190px); min-height: 460px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.g-list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; background: var(--surface-2); }
.g-sec { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); padding: 14px 14px 6px; }
.g-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 14px; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 14px; }
.g-item:hover { background: var(--surface); text-decoration: none; }
.g-item.active { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.g-item .pill { background: var(--crit); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 7px; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.chat-head h2 { margin: 0; font-size: 16px; }
.chat-metrics { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.chat-metrics .m { font-size: 11px; color: var(--ink-faint); }
.chat-metrics .m b { display: block; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.chat-metrics .m b.money { color: var(--money); }

.acciones { padding: 10px 16px; background: var(--warn-wash); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.acciones .accion { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.acciones form { display: flex; gap: 6px; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 7px; border: 0; cursor: pointer; font-weight: 600; }
.btn-ok { background: var(--ok); color: #fff; } .btn-no { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }

.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 7px; }
.bubble { max-width: 76%; padding: 7px 11px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; }
.bubble .who { font-size: 11px; color: var(--accent-ink); font-weight: 600; margin-bottom: 2px; }
.bubble .content { white-space: pre-wrap; word-break: break-word; }
.bubble .when { font-size: 10px; color: var(--ink-faint); text-align: right; margin-top: 3px; }
.bubble.otros { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.bubble.bot { align-self: flex-end; background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); }
.bubble.orden { align-self: flex-start; background: var(--ok-wash); box-shadow: inset 3px 0 0 var(--ok); }
.bubble.alerta { align-self: flex-end; background: var(--warn-wash); box-shadow: inset 3px 0 0 var(--warn); }
.bubble.ruido { align-self: flex-start; background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); font-size: 12.5px; max-width: 62%; opacity: .85; }
.bubble.comando { align-self: flex-start; background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.bubble.entrada { align-self: flex-start; background: var(--ok-wash); box-shadow: inset 3px 0 0 var(--ok); }
.bubble.salida { align-self: flex-start; background: var(--crit-wash); box-shadow: inset 3px 0 0 var(--crit); }
.bubble.pago { align-self: flex-start; background: var(--money-wash); box-shadow: inset 3px 0 0 var(--money); }
.bubble.estado-pend { background: var(--crit-wash); box-shadow: inset 3px 0 0 var(--crit); }
.bubble.estado-ok { background: var(--ok-wash); box-shadow: inset 3px 0 0 var(--ok); }
.bubble .aprobar-inline { display: flex; gap: 6px; margin-top: 6px; }
.bubble .msg-img { max-width: 220px; max-height: 260px; border-radius: 8px; display: block; margin: 2px 0; cursor: zoom-in; }
.bubble.ordencard { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--accent); max-width: 84%; }
.bubble.ordencard.estado-ok { box-shadow: inset 3px 0 0 var(--ok); background: var(--ok-wash); }
.bubble.ordencard.estado-pend { box-shadow: inset 3px 0 0 var(--warn); background: var(--warn-wash); }
.oc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; font-size: 14px; }
.oc-head a { font-weight: 700; }
.oc-body { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }
.oc-body .money { color: var(--money); font-weight: 600; }
.bubble .tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.chat-empty { margin: auto; color: var(--ink-faint); text-align: center; }

@media (max-width: 760px){ .consola { grid-template-columns: 1fr; height: auto; } .g-list { max-height: 200px; } }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab { padding: 9px 16px; border-radius: 9px 9px 0 0; color: var(--ink-soft); font-weight: 600; font-size: 14px; border: 1px solid transparent; border-bottom: none; }
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--accent-ink); border-color: var(--line); position: relative; top: 1px; }
.tab .count { background: var(--crit); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 6px; }

.flash { background: var(--accent-wash); border: 1px solid var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 9px; margin-bottom: 18px; font-size: 14px; }
.empty { color: var(--ink-faint); padding: 24px; text-align: center; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 6px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .detail-grid { grid-template-columns: 1fr; }
}
