
:root{
  --bg: #0b1222;
  --bg2:#0f172a;
  --card:#0e1528;
  --muted:#9ca3af;
  --text:#e5e7eb;
  --primary:#3b82f6;
  --primary-2:#60a5fa;
  --danger:#ef4444;
  --border:#1f2937;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial;
  background: radial-gradient(1200px 800px at 20% -10%, #142042 0%, var(--bg) 60%),
              radial-gradient(1000px 600px at 110% 10%, #0d1a36 0%, var(--bg2) 60%);
  color:var(--text);
}
a{color:inherit;text-decoration:none}
.container{max-width:1200px;margin:0 auto;padding:24px}
.card{
  background:linear-gradient(180deg,var(--bg2),var(--card));
  border:1px solid var(--border);
  border-radius:16px;
  padding:20px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.h1{font-size:28px;font-weight:800;letter-spacing:.3px}
.subtitle{color:var(--muted);margin-top:4px}
.btn{
  display:inline-flex;align-items:center;gap:8px;
  padding:10px 14px;border-radius:12px;border:1px solid transparent;
  background:var(--primary);color:white;font-weight:700;cursor:pointer;text-decoration:none
}
.btn:hover{background:var(--primary-2)}
.btn-ghost{background:transparent;border-color:var(--border);color:var(--text);border:1px solid var(--border)}
.btn-danger{background:var(--danger)}
.input, select, textarea{
  width:100%;padding:12px 14px;border-radius:12px;border:1px solid var(--border);
  background:#0b1428;color:var(--text);
}
.row{display:grid;grid-template-columns:1fr;gap:12px}
label>div{font-size:13px;color:var(--muted);margin-bottom:6px}
.alert{padding:12px 14px;border-radius:12px}
.alert-danger{background:#2a0d0d;border:1px solid #7f1d1d;color:#fecaca}
.topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}
.logo{font-weight:900;font-size:18px;letter-spacing:.2px}

.grid-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px}
.tile{
  text-decoration:none;color:inherit;border:1px solid var(--border);
  border-radius:14px;padding:18px;background:linear-gradient(180deg,var(--bg2),var(--card));
}
.tile .icon{font-size:28px}
.kv{display:flex;justify-content:space-between;color:var(--muted);font-size:12px;margin-top:10px}

/* Table styling */
.table-wrap{overflow-x:auto;background:rgba(255,255,255,0.02);border:1px solid var(--border);border-radius:14px;padding:10px}
table{width:100%;border-collapse:collapse;min-width:900px}
th,td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:left}
th{background:#0f172a;color:#e5e7eb;position:sticky;top:0}
tr:hover td{background:rgba(255,255,255,0.02)}
img.thumb{
  width:120px;height:120px;object-fit:cover;border-radius:10px;
  box-shadow:0 1px 3px rgba(0,0,0,.25);cursor:pointer;
}

/* App form layout */
.filtros-barra{display:grid;grid-template-columns:1fr;gap:12px;margin:16px 0}
@media (min-width:768px){
  .row{grid-template-columns:1fr 1fr}
  .filtros-barra{grid-template-columns:repeat(3,1fr)}
}
@media (min-width:1024px){
  .login-card{max-width:520px;margin:12vh auto}
}


/* v3: strict thumbnail wrapper to avoid giant images on desktop */
.thumb-wrap{
  width: 150px; height: 150px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: #0b1428;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.thumb-wrap img.thumb{
  width: 100% !important; height: 100% !important; object-fit: cover; display: block; cursor: zoom-in;
}
@media (max-width: 1279px){
  .thumb-wrap{ width: 140px; height: 140px; }
}
#catalogo td { vertical-align: middle; }


/* v4: clamp hard + column width */
#catalogo { table-layout: fixed; }
#catalogo th:nth-child(9), #catalogo td:nth-child(9){ width: 180px; }
#catalogo td img,
img.thumb {
  width: 150px !important;
  height: 150px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1428;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  cursor: zoom-in;
}
@media (max-width: 1279px){
  #catalogo td img,
  img.thumb { width: 140px !important; height: 140px !important; }
}


/* v5: nuclear option to defeat global img styles */
#catalogo td img.thumb{
  all: unset;
  width: 150px !important;
  height: 150px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  background: #0b1428 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.25) !important;
  cursor: zoom-in !important;
}
@media (max-width: 1279px){
  #catalogo td img.thumb{ width: 140px !important; height: 140px !important; }
}


/* v7 — Light table theme */
.table-light{
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.table-light table{ min-width: 900px; width: 100%; border-collapse: collapse; table-layout: fixed; }
.table-light thead th{
  position: sticky; top: 0;
  background: #f8fafc; color: #0f172a;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 700;
}
.table-light th, .table-light td{
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.table-light tbody tr:hover td{ background: #fafcff; }
.table-light .muted{ color: #64748b; }

/* Image column width smaller */
#catalogo th:nth-child(9), #catalogo td:nth-child(9){ width: 140px; }

/* Smaller thumbnails */
#catalogo td img.thumb{
  all: unset;
  width: 110px !important;
  height: 110px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 12px !important;
  border: 1px solid #e5e7eb !important;
  background: #f1f5f9 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.08) !important;
  cursor: zoom-in !important;
}
.thumb-wrap{ width: 110px !important; height: 110px !important; overflow: hidden !important; border-radius: 12px; }

/* Filters bar */
.filters{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 16px 0 10px;
}
.filters .flex-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.filters .pill{ background:#f1f5f9; border:1px solid #e5e7eb; color:#0f172a; padding:8px 10px; border-radius:999px; font-size:13px; }
.input-light, .select-light{
  width: 100%; padding:10px 12px; border-radius:10px; border:1px solid #e5e7eb;
  background:#ffffff; color:#0f172a;
}
@media (min-width: 768px){
  .filters{ grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* Pager */
.pager{ display:flex; gap:8px; align-items:center; justify-content:center; flex-wrap:wrap; margin: 14px 0 4px; }
.pager .btn{ background:#0f172a; }
.pager .btn[disabled]{ opacity:.5 }


/* v8 — smaller thumbs 96x96 and extra safety */
#catalogo th:nth-child(9), #catalogo td:nth-child(9){ width: 130px; }
.thumb-wrap{ width: 96px !important; height: 96px !important; overflow: hidden !important; border-radius: 10px; }
#catalogo td img.thumb{
  all: unset;
  width: 96px !important; height: 96px !important;
  object-fit: cover !important; display: block !important;
  border-radius: 10px !important; border: 1px solid #e5e7eb !important;
  background: #f1f5f9 !important; box-shadow: 0 1px 3px rgba(0,0,0,.08) !important;
  cursor: zoom-in !important;
}


/* v9 — Enhanced search field styles */
.input-light, .select-light{
  background:#ffffff; color:#0f172a;
  border:1px solid #dbe2ea; border-radius:12px;
  padding:12px 14px; outline:none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 1px 2px rgba(15,23,42,.05);
  transition: box-shadow .2s, border-color .2s, background .2s;
}
.input-light::placeholder{ color:#94a3b8 }
.input-light:focus, .select-light:focus{
  border-color:#93c5fd;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  background:#ffffff;
}
.filters label{ font-size:12px; color:#64748b; display:block; margin-bottom:6px }
.filters .field{ display:flex; flex-direction:column }
.filters .stack{ display:grid; gap:10px; grid-template-columns:1fr }
@media (min-width: 768px){
  .filters .stack{ grid-template-columns: repeat(4, 1fr); }
}


/* v10 — Unified theme closer to Bitácora */
.topbar { margin-bottom: 12px }
.card { border-radius: 18px }
.btn{
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 6px 16px rgba(37,99,235,.25);
}
.btn:hover{ filter: brightness(1.05) }
.btn.btn-ghost{
  background:#ffffff; color:#0f172a;
  border:1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.table-light{
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(2,6,23,.08);
}
.table-light thead th{
  background: #f8fafc;
}
.pill{ background:#f1f5f9; border-color:#e5e7eb }
.filters .field label{ font-weight:600 }
.logo{ font-weight: 900; letter-spacing:.2px }


/* v11 — Professional filter toolbar */
.filter-toolbar{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
  margin: 8px 0 4px;
}
.field label{
  display:block;
  font-size:12px;
  font-weight:600;
  letter-spacing:.2px;
  color:#475569;
  margin-bottom:6px;
}
.input-affix{ position:relative; }
.input-affix .icon{
  position:absolute; left:12px; top:50%; transform:translateY(-50%);
  font-size:14px; opacity:.55; pointer-events:none;
}
.input-affix .input-light, .input-affix .select-light{ padding-left:36px; }
.toolbar-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  margin: 10px 0 6px;
}
.toolbar-row .right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.toolbar-row .label{ font-size:12px; color:#475569 }


/* v12 — Professional light theme like the reference */
.hero{
  background: #eaf1fb;
  border:1px solid #dbe7ff;
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  text-align:center;
  color:#0f172a;
}
.hero .title{
  font-size: 34px; font-weight: 900; letter-spacing:.3px; margin: 6px 0 0;
}
.primary-btn{
  background:#2d6ae3; color:#fff; border:none;
  padding:12px 18px; border-radius:10px; font-weight:800;
  box-shadow: 0 10px 20px rgba(45,106,227,.25);
}
.primary-btn:hover{ filter:brightness(1.05) }

.search-title{ font-size:22px; font-weight:900; text-align:center; margin: 4px 0 10px; color:#0f172a }
.filters-row{
  display:grid; grid-template-columns: 1fr;
  gap: 12px; margin: 6px 0 0;
}
.chip{ background:#eaf1fb; border:1px solid #dbe7ff; color:#0f172a; padding:10px 12px;
  border-radius:10px; font-weight:700; }
.stats-row{ display:grid; grid-template-columns:1fr; gap:10px; margin: 12px 0 10px; }
@media(min-width:768px){
  .filters-row{ grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr; }
  .stats-row{ grid-template-columns: repeat(4, 1fr); }
}

/* Table: header band blue, rows clean */
.table-light{ background:#fff; border:1px solid #e5e7eb; border-radius:18px; padding:0 }
.table-light .table-head{
  background:#1e6be1; color:#fff; font-weight:800; padding:10px 14px; border-top-left-radius:18px; border-top-right-radius:18px;
  display:grid; grid-template-columns: repeat(11, minmax(80px, auto)); gap:12px; align-items:center;
}
.table-wrap{ padding: 0 10px 10px; }
table{ width:100%; border-collapse: collapse; table-layout: fixed; }
th{ background:#f8fafc; color:#0f172a }
th, td{ padding:14px 10px; border-bottom:1px solid #eef2f7; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
tbody tr:hover td{ background:#fafcff }
.actions .btn{ padding:8px 10px }
.muted{ color:#64748b }

/* Input affix improvements */
.input-affix{ position:relative }
.input-affix .icon{ position:absolute; left:12px; top:50%; transform:translateY(-50%); font-size:14px; opacity:.55 }
.input-affix .input-light, .input-affix .select-light{ padding-left:36px }

/* Inputs consistency */
.input-light, .select-light{
  background:#ffffff; color:#0f172a; border:1px solid #dbe2ea; border-radius:12px; padding:12px 14px; outline:none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 1px 2px rgba(15,23,42,.05);
  transition: box-shadow .2s, border-color .2s, background .2s;
}
.input-light::placeholder{ color:#94a3b8 }
.input-light:focus, .select-light:focus{ border-color:#93c5fd; box-shadow: 0 0 0 3px rgba(59,130,246,.15); background:#fff }

/* Thumb size a bit larger and crisp */
.thumb-wrap{ width: 100px !important; height: 100px !important; overflow:hidden !important; border-radius: 10px; }
#catalogo td img.thumb{ width: 100px !important; height: 100px !important; object-fit: cover !important; display:block !important;
  border-radius: 10px !important; border:1px solid #e5e7eb !important; background:#f1f5f9 !important; box-shadow:0 1px 2px rgba(0,0,0,.05) !important }

/* Pager */
.pager{ display:flex; gap:8px; align-items:center; justify-content:center; flex-wrap:wrap; padding: 10px; }
.pager .btn{ background:#0f172a; color:#fff }
.pager .btn[disabled]{ opacity:.5 }


/* v13 — LIGHT theme (much clearer) */
.lego-surface{
  background:#f3f7fe;
  border:1px solid #e0e9ff;
  border-radius:18px;
  padding:18px;
  box-shadow: 0 10px 30px rgba(2,6,23,.06);
}
.hero{ background:#eef5ff; border:1px solid #d9e7ff; color:#0b1b3a }
.hero .title{ color:#0b1b3a }
.primary-btn{ background:#3b82f6 }
.primary-btn:hover{ filter:brightness(1.06) }
.chip{ background:#f0f6ff; border-color:#d9e7ff }
.table-light{ background:#ffffff; border-color:#e6eefc }
.table-light thead th{ background:#f5f8ff }
.table-head{ background:#2b76f0 !important }
.input-light, .select-light{
  background:#fff; border-color:#ccd9ff; color:#0b1b3a;
  box-shadow: 0 1px 2px rgba(2,6,23,.04), inset 0 1px 0 rgba(255,255,255,.8);
}
.input-light::placeholder{ color:#8aa0c8 }
.input-light:focus, .select-light:focus{ border-color:#86b7ff; box-shadow:0 0 0 3px rgba(59,130,246,.18) }
.btn{ background:linear-gradient(180deg,#3b82f6,#2b76f0); }
.btn.btn-ghost{ background:#ffffff; color:#0b1b3a; border:1px solid #e6eefc }
/* lighter table rows */
tbody tr:hover td{ background:#f7faff }


/* v14 — Minimal light */
.lego-surface{ background:#f6f9ff; border:1px solid #e4ecff; border-radius:16px; padding:16px; box-shadow:0 4px 16px rgba(2,6,23,.05) }
.hero{ background:#f1f6ff; border:1px solid #e2ebff; border-radius:14px; padding:14px }
.primary-btn{ background:#2563eb; border:none; color:#fff; padding:10px 16px; border-radius:10px; box-shadow:none; font-weight:800 }
.btn{ background:#2563eb; color:#fff; border:none; border-radius:10px; padding:8px 12px; box-shadow:none }
.btn:hover{ filter:brightness(1.05) }
.btn.btn-ghost{ background:#ffffff; color:#0b1b3a; border:1px solid #e6eefc }
.chip{ background:#f3f7ff; border:1px solid #e6eefc; color:#0b1b3a; padding:10px 12px; border-radius:10px; font-weight:700 }
.table-light{ background:#fff; border:1px solid #e9efff; border-radius:14px; padding:0 }
.table-light thead th{ background:#f7faff }
.table-head{ background:#2b76f0 !important }
.input-light, .select-light{ background:#fff; border:1px solid #d7e2ff; border-radius:12px; padding:12px 14px; color:#0b1b3a; box-shadow:none }
.input-light:focus, .select-light:focus{ border-color:#93c5fd; box-shadow:0 0 0 2px rgba(59,130,246,.15) }
.utilbar{ display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; margin-bottom:6px }
.spacer{ display:block; height:10px }


/* v16 — edit preview sizing + camera modal */
.preview-box{
  width: 240px;
  height: 240px;
  border: 1px dashed #c7d2fe;
  border-radius: 12px;
  background:
    repeating-linear-gradient(45deg, #f8fbff 0 10px, #f1f6ff 10px 20px);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.preview-img{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display:block;
  border-radius:10px;
}
.camera-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
#cameraModal{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.85); z-index:9999; padding:24px; }
#cameraModal .inner{ max-width: min(96vw, 860px); margin:0 auto; background:#0b1b3a; border-radius:12px; padding:12px; }
#cameraModal video{ width:100%; border-radius:10px; background:#000; }
#cameraModal .bar{ display:flex; gap:10px; justify-content:flex-end; margin-top:10px; }


/* v17 — layout width + inline cameras + dual preview */
@media (min-width: 1200px){
  .lego-surface{ width: var(--surface-width, 80%); margin: 0 auto; }
}
.preview-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap:10px; }
.cam-inline{ display:none; background:#0b1b3a; border-radius:12px; padding:10px; }
.cam-inline video{ width:100%; border-radius:10px; background:#000 }
.cam-inline .bar{ display:flex; gap:8px; justify-content:flex-end; margin-top:8px }


/* v18 — single inline camera */
.cam-inline{ display:none; background:#0b1b3a; border-radius:12px; padding:10px; }
.cam-inline video{ width:100%; border-radius:10px; background:#000 }
.cam-toggle-on{ background:#0ea5e9 !important; }


/* v19 — coherent image row */
.image-field{ grid-column: 1 / -1; }
.image-row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.image-row input[type="file"]{ flex:1 1 360px; min-width:260px }
.image-hint{ font-size:12px; color:#64748b }


/* v20 — single image picker */
.media-field{ grid-column:1 / -1; }
.media-title{ font-weight:800; margin-bottom:8px; }
.media-btn{ width:100%; padding:12px 16px; font-weight:800; }
.preview-rect{ width:100%; max-width:520px; height:220px; border:1px solid #e5e7eb; border-radius:10px; background:#fff; margin-top:12px }
.cam-inline{ display:none; margin-top:8px; max-width:520px }
.cam-inline video{ width:100%; border-radius:10px; background:#000 }


/* v22 — wide desktop surface */
:root{
  --surface-max: 1800px; /* puedes ajustar este límite si tu monitor es muy ancho */
}
@media (min-width: 1200px){
  .lego-surface{
    width: 96% !important;   /* ocupa casi todo el ancho */
    max-width: var(--surface-max);
    margin-left: auto;
    margin-right: auto;
  }
  .card,
  .hero,
  .table-light,
  .table-wrap{
    width: 100%;
    max-width: 100%;
  }
}


/* v23 — camera fit width + cancel button */
.cam-control-row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.media-btn{ width:100%; }
@media (min-width: 640px){
  .media-btn{ width:auto; }
}
#camInline{ display:none; width:100%; max-width:100%; }
#camInline video{ width:100%; height:auto; max-height:72vh; object-fit:contain; border-radius:10px; background:#000; }


/* v24 — wider surface and camera toolbar */
:root{ --surface-max: 2200px; } /* aún más ancho; ajustable */
@media (min-width: 1200px){
  .lego-surface{
    width: 98% !important;   /* aún más ancho */
    max-width: var(--surface-max);
  }
}
#camInline .cam-toolbar{
  display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; margin-top:8px;
}
#captureBtn{ width:100%; }
@media (min-width:640px){
  #captureBtn{ width:auto; }
}


/* v27 — camera toolbar hidden by default; only visible when camera active */
#camInline .cam-toolbar{ display:none; }
#camInline.camera-on .cam-toolbar{ display:flex; }
