:root {
  /* Paleta NAVY (náutica) */
  --bg: #0a1729;        /* azul marino profundo */
  --bg2: #0e2038;
  --panel: #102340;
  --line: #1f3a5c;
  --txt: #e7eef8;
  --muted: #8ea6c4;
  --accent: #38bdf8;    /* azul cielo (acento principal) */
  --accent2: #1d4ed8;   /* azul */
  --grad: linear-gradient(90deg, #1d4ed8, #38bdf8);
  --in: #2dd4bf;        /* entra (teal) */
  --out: #f59e0b;       /* sale (ámbar) */
  --num-grad: linear-gradient(90deg, #08a5f4, #5cc8fb);  /* nº ocupación (oscuro: azul claro del logo) */
}

/* Tema CLARO (navy sobre fondo claro) */
:root[data-theme="light"] {
  --bg: #eef3f9;
  --bg2: #ffffff;
  --panel: #ffffff;
  --line: #d7e1ee;
  --txt: #0f2340;
  --muted: #5f7690;
  --accent: #1d4ed8;
  --accent2: #0ea5e9;
  --grad: linear-gradient(90deg, #1d4ed8, #0ea5e9);
  --in: #0d9488;
  --out: #c2740a;
  --num-grad: linear-gradient(90deg, #0063f3, #0ea5e9);  /* claro: azul más profundo sobre fondo blanco */
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  transition: background .2s ease, color .2s ease;
}
.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-img {
  height: 40px; width: auto; display: block;
  filter: drop-shadow(0 2px 8px rgba(8, 165, 244, 0.28));
}
.wordmark {
  font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 700;
  font-size: 22px; letter-spacing: -0.5px;
}
.brand .sub { color: var(--muted); font-size: 13px; }
.live { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .5px; display: inline-flex; align-items: center; gap: 6px; }
.live svg { width: 15px; height: 15px; }
.live #clock { color: var(--muted); }

/* Iconos Lucide: tamaños por contexto */
.icon-btn svg { width: 18px; height: 18px; }
.badge svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.kpi .label svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.pill svg { width: 11px; height: 11px; vertical-align: -1px; margin-right: 3px; }
.timeline .ev svg { width: 13px; height: 13px; vertical-align: -2px; }

/* Switch de tema sol/luna: muestra el icono según el tema activo */
:root[data-theme="light"] .ic-moon { display: none; }
:root:not([data-theme="light"]) .ic-sun { display: none; }

main { padding: 24px; max-width: 1280px; margin: 0 auto; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad);
}
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.kpi .value { font-family: "Space Grotesk", sans-serif; font-size: 40px; font-weight: 700; line-height: 1.1; }
.kpi.big .value { background: var(--num-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2,1fr); } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; }
.panel h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--txt); flex: none; }

/* La tabla rellena la altura de la tarjeta (la fija el panel más alto de la fila) */
.table-wrap { flex: 1 1 auto; min-height: 0; max-height: 80vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.desc td { opacity: .45; }
.badge { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.ENTRA { background: rgba(45,212,191,.15); color: var(--in); }
.badge.SALE { background: rgba(245,158,11,.15); color: var(--out); }
.badge.dup { background: rgba(142,166,196,.2); color: var(--muted); }
.thumb { width: 54px; height: 34px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.boat-cell .name { font-weight: 600; }
.boat-cell .plate { color: var(--muted); font-size: 11px; }
.boat-cell .unk { color: var(--muted); font-style: italic; }

.fichas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ficha { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.ficha:hover { border-color: var(--accent); transform: translateY(-2px); }
.ficha img { width: 100%; height: 96px; object-fit: cover; display: block; background: #000; }
.ficha .body { padding: 10px 12px; }
.ficha .name { font-weight: 600; font-size: 14px; }
.ficha .name.unk { color: var(--muted); font-style: italic; font-weight: 500; }
.ficha .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pill { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .3px; }
.pill.dentro { background: rgba(45,212,191,.15); color: var(--in); }
.pill.fuera { background: rgba(142,166,196,.18); color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(3,10,20,.68); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; padding: 22px; position: relative; }
.close { position: absolute; right: 14px; top: 12px; background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal h3 { margin: 0 0 4px; font-family: "Space Grotesk", sans-serif; font-size: 22px; }
.modal .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0; font-size: 13px; }
.modal .kv b { color: var(--muted); font-weight: 500; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.timeline .ev { position: relative; padding: 6px 0; font-size: 13px; }
.timeline .ev::before { content: ""; position: absolute; left: -22px; top: 11px; width: 9px; height: 9px; border-radius: 50%; background: var(--grad); }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 24px; border-top: 1px solid var(--line); margin-top: 24px; }
footer b { color: var(--txt); }

/* ===== Responsive (al final para ganar el cascade) ===== */
/* Navbar en pantallas medianas: fuera el subtítulo largo */
@media (max-width: 900px) {
  .brand .sub { display: none; }
}

/* Navbar en móvil: compacta y en una sola fila */
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  .brand { gap: 8px; }
  .logo-img { height: 32px; }
  .wordmark { font-size: 19px; }
  .topbar .right { gap: 8px; }
  .live { font-size: 12px; }
  .live #clock { display: none; }   /* el reloj no cabe; queda el estado EN VIVO */
  .icon-btn { width: 30px; height: 30px; }
  main { padding: 16px; }
}

/* Movimientos como CARDS en móvil/tablet estrecha: la fila de tabla se recompone en tarjeta */
@media (max-width: 768px) {
  /* sin scroll interno: se listan todas las cards y desplaza la página */
  .table-wrap { max-height: none; overflow: visible; flex: none; }
  #eventos, #eventos tbody { display: block; }
  #eventos thead { display: none; }
  #eventos tr {
    display: grid;
    grid-template-columns: 76px 1fr auto;
    grid-template-areas:
      "foto dir   hora"
      "foto barco barco"
      "foto tipo  tipo";
    gap: 3px 12px;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--bg2);
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  #eventos td { display: block; padding: 0; border-bottom: none; }
  #eventos td:nth-child(1) { grid-area: hora; color: var(--muted); font-size: 12px; text-align: right; }
  #eventos td:nth-child(2) { grid-area: dir; }
  #eventos td:nth-child(3) { grid-area: tipo; color: var(--muted); font-size: 12px; }
  #eventos td:nth-child(4) { grid-area: barco; }
  #eventos td:nth-child(5) { grid-area: foto; }
  #eventos .thumb { width: 76px; height: 56px; border-radius: 8px; }
  #eventos .boat-cell .plate { font-size: 12px; }
}

