/*
 * Arcelor · Control de Calidad — Inspector asistido
 * Industrial dark theme · Inter + JetBrains Mono
 */

:root {
  --bg-0: #0b0d10;
  --bg-1: #11141a;
  --bg-2: #181c24;
  --bg-3: #232936;
  --line: #2a3140;
  --line-strong: #3a4255;
  --text-0: #f3f5f9;
  --text-1: #c9cfdb;
  --text-2: #8a93a6;
  --text-3: #5b6577;
  --ok: #34c171;
  --ok-bg: rgba(52, 193, 113, 0.12);
  --ok-border: rgba(52, 193, 113, 0.35);
  --warn: #f4b740;
  --ng: #ef4f4f;
  --ng-bg: rgba(239, 79, 79, 0.12);
  --ng-border: rgba(239, 79, 79, 0.40);
  --accent: #f37021;
  --accent-soft: rgba(243, 112, 33, 0.16);
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  /* theme-specific tokens */
  --app-bg: radial-gradient(1200px 600px at 50% -200px, #1a1f29 0%, transparent 60%), var(--bg-0);
  --header-bg: rgba(11, 13, 16, 0.75);
  --plan-stripe: #2b323e;
  --plan-bg-top: #2f3744;
  --plan-bg-bot: #262d39;
  --plan-grid: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] {
  --bg-0: #f4f6f9;
  --bg-1: #ffffff;
  --bg-2: #eef0f5;
  --bg-3: #e2e6ef;
  --line: #d0d6e4;
  --line-strong: #b8c0d4;
  --text-0: #111318;
  --text-1: #3a4255;
  --text-2: #5b6577;
  --text-3: #8a93a6;
  --ok-bg: rgba(52, 193, 113, 0.10);
  --ok-border: rgba(52, 193, 113, 0.28);
  --ng-bg: rgba(239, 79, 79, 0.09);
  --ng-border: rgba(239, 79, 79, 0.32);
  --accent-soft: rgba(243, 112, 33, 0.12);
  --app-bg: radial-gradient(1200px 600px at 50% -200px, #e4e9f5 0%, transparent 60%), var(--bg-0);
  --header-bg: rgba(248, 250, 253, 0.90);
  --plan-stripe: #c8d2e4;
  --plan-bg-top: #d8e2f4;
  --plan-bg-bot: #ccd8ec;
  --plan-grid: rgba(0, 0, 30, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: pointer; }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }

.app {
  display: grid;
  grid-template-rows: 56px 1fr 28px;
  height: 100vh; width: 100vw;
  background: var(--app-bg);
}

/* ── Header ── */
.header {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.header-right { justify-content: flex-end; }
.hdr-divider { width: 1px; height: 26px; background: var(--line); }
.hdr-product { display: flex; flex-direction: column; line-height: 1.15; }
.hdr-product .t1 { font-size: 13px; color: var(--text-0); font-weight: 600; letter-spacing: 0.01em; }
.hdr-product .t2 { font-size: 10.5px; color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1px; }
.header-line {
  display: flex; gap: 22px; align-items: center;
  padding: 6px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--bg-1);
}
.hl-item { display: flex; gap: 7px; align-items: baseline; }
.hl-item .lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }
.hl-item .val { font-size: 13px; color: var(--text-0); font-weight: 500; }
.hl-divider { width: 1px; height: 14px; background: var(--line); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 0 var(--ok);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 193, 113, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(52, 193, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 193, 113, 0); }
}

/* ── Main Layout ── */
.main {
  display: grid;
  grid-template-columns: minmax(320px, 1.0fr) minmax(280px, 0.85fr) minmax(440px, 1.55fr);
  gap: 14px; padding: 14px; min-height: 0;
}
.col { display: flex; flex-direction: column; min-height: 0; }

.panel {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.panel-title { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-1); }
.panel-title .ico { color: var(--text-3); margin-right: 8px; }
.panel-meta { display: flex; gap: 10px; align-items: center; font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ── Camera tiles ── */
.cams { flex: 1; display: grid; grid-template-rows: 1fr 1fr; gap: 10px; padding: 10px; min-height: 0; }
.cam-tile {
  position: relative; background: #000;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; min-height: 0;
}
.cam-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-overlay {
  position: absolute; inset: 0; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 75%, rgba(0,0,0,0.6) 100%);
}
.cam-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cam-label { display: flex; gap: 8px; align-items: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.08em; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
.cam-rec { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: #fff; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.1); border-radius: 3px; padding: 2px 7px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.05em; }
.rec-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ng); animation: pulse-red 1.4s ease-out infinite; }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.cam-bot { display: flex; justify-content: space-between; align-items: flex-end; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.85); text-shadow: 0 1px 2px rgba(0,0,0,0.7); letter-spacing: 0.05em; }
.cam-scan { position: absolute; inset: 0; pointer-events: none; }
.cam-scan .scan-line { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); box-shadow: 0 0 12px var(--accent); animation: scan 2.2s linear infinite; }
@keyframes scan { 0% { top: -2%; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { top: 102%; opacity: 0; } }

/* ── Plano ── */
.plano-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-shrink: 0; }
.plano-head-id { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chapa-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500; }
.chapa-id { font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 600; color: var(--text-0); letter-spacing: 0.01em; white-space: nowrap; }
.chapa-meta { display: flex; gap: 18px; font-size: 11px; color: var(--text-2); align-items: flex-end; }
.chapa-meta .item { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.chapa-meta .lbl { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }
.chapa-meta .val { font-family: 'JetBrains Mono', monospace; color: var(--text-1); font-size: 12px; }

.status-banner { display: flex; align-items: center; gap: 14px; margin: 12px 14px 0; padding: 14px 16px; border-radius: 8px; border: 1px solid; flex-shrink: 0; }
.status-banner.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.status-banner.ng { background: var(--ng-bg); border-color: var(--ng-border); color: var(--ng); }
.status-banner .icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid currentColor; font-size: 18px; flex-shrink: 0; }
.status-banner .text { display: flex; flex-direction: column; gap: 1px; }
.status-banner .text .main { font-size: 17px; font-weight: 600; color: var(--text-0); letter-spacing: 0.01em; }
.status-banner .text .sub { font-size: 11.5px; color: var(--text-2); }

.plano-body { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(280px, 1.4fr); gap: 14px; padding: 14px; flex: 1; min-height: 0; }
.plano-wrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; display: flex; align-items: stretch; justify-content: stretch; position: relative; min-height: 0; overflow: hidden; }
.chapa-plan {
  position: relative; flex: 1; width: 100%; height: 100%;
  background: repeating-linear-gradient(45deg, var(--plan-stripe) 0 1px, transparent 1px 6px), linear-gradient(180deg, var(--plan-bg-top) 0%, var(--plan-bg-bot) 100%);
  border: 1px solid var(--line-strong); border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 30px rgba(0,0,0,0.25);
}
.chapa-plan .grid-h, .chapa-plan .grid-v { position: absolute; background: var(--plan-grid); }
.chapa-plan .grid-h { left: 0; right: 0; height: 1px; }
.chapa-plan .grid-v { top: 0; bottom: 0; width: 1px; }

.defect-marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; color: #fff;
  cursor: pointer; z-index: 2;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: var(--ng); box-shadow: 0 0 0 2px rgba(239,79,79,0.25), 0 0 14px rgba(239,79,79,0.6);
}
.defect-marker.falso-positivo { background: var(--text-3); box-shadow: none; opacity: 0.6; }
.defect-marker:hover, .defect-marker.active { transform: translate(-50%, -50%) scale(1.18); }
.defect-pulse { position: absolute; inset: -8px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0; animation: marker-pulse 1.8s ease-out infinite; }
@keyframes marker-pulse { 0% { transform: scale(0.7); opacity: 0.9; } 100% { transform: scale(1.8); opacity: 0; } }
.no-defect-stamp { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg); font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--ok); border: 2.5px solid var(--ok); padding: 6px 18px; border-radius: 4px; letter-spacing: 0.15em; opacity: 0.55; white-space: nowrap; }

/* ── Defect list ── */
.defect-list { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.defect-card { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.defect-card:hover, .defect-card.active { border-color: var(--line-strong); background: var(--bg-3); }
.defect-card[data-estado="falso_positivo"] { opacity: 0.55; }
.defect-thumb { width: 62px; height: 62px; border-radius: 4px; background: #000; position: relative; overflow: hidden; border: 1px solid var(--line-strong); flex-shrink: 0; }
.defect-thumb-img { position: absolute; width: 200%; height: 200%; top: -50%; left: -50%; background-size: cover; background-position: center; filter: contrast(1.1) saturate(0.7); }
.defect-info { min-width: 0; }
.defect-info .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.defect-num { width: 18px; height: 18px; display: grid; place-items: center; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; border-radius: 50%; background: var(--ng); color: #fff; }
.defect-name { font-size: 13px; font-weight: 600; color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.defect-coords { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-2); }
.defect-ampliar { font-size: 14px; color: var(--text-3); padding: 0 4px; align-self: center; }
.defect-card:hover .defect-ampliar { color: var(--text-1); }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); padding: 28px; text-align: center; }
.empty-state .glyph { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--ok); color: var(--ok); display: grid; place-items: center; font-size: 22px; }
.empty-state .t { font-size: 13px; color: var(--text-1); font-weight: 500; }
.empty-state .s { font-size: 11.5px; color: var(--text-3); }

/* ── History ── */
.hist-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.hist-summary .cell { background: var(--bg-1); padding: 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.hist-summary .lbl { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }
.hist-summary .val { font-family: 'JetBrains Mono', monospace; font-size: 20px; font-weight: 600; color: var(--text-0); line-height: 1; }
.hist-summary .val.ok { color: var(--ok); }
.hist-summary .val.ng { color: var(--ng); }
.hist-list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.hist-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 5px; cursor: pointer; transition: background 0.12s ease; border: 1px solid transparent; }
.hist-row:hover { background: var(--bg-2); }
.hist-row.active { background: var(--bg-2); border-color: var(--line-strong); }
.hist-row.in-progress { background: var(--accent-soft); border-color: rgba(243,112,33,0.45); border: 1px solid rgba(243,112,33,0.45); }
.hist-status-dot { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
.hist-status-dot.ok { background: var(--ok); }
.hist-status-dot.ng { background: var(--ng); }
.hist-status-dot.scanning { background: transparent; position: relative; width: 10px; height: 10px; border: 1.5px solid var(--accent); }
.scan-pulse { position: absolute; inset: -3px; border-radius: 50%; border: 1.5px solid var(--accent); animation: marker-pulse 1.4s ease-out infinite; opacity: 0.8; }
.hist-id { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.hist-time { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--text-0); font-weight: 500; }
.hist-fotos { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-3); margin-top: 1px; }
.hist-badge { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; min-width: 28px; text-align: center; }
.hist-badge.ok       { background: var(--ok-bg);       color: var(--ok);     border: 1px solid var(--ok-border); }
.hist-badge.ng       { background: var(--ng-bg);       color: var(--ng);     border: 1px solid var(--ng-border); }
.hist-badge.annotated{ background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(243,112,33,0.35); }
.hist-badge.scanning { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(243,112,33,0.4); letter-spacing: 0.1em; }
.hist-status-dot.annotated { background: var(--accent); }

/* ── History tabs ── */
.hist-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.hist-tab-btn {
  flex: 1; padding: 10px 12px 9px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); background: transparent; border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .12s;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.hist-tab-btn:hover { color: var(--text-1); }
.hist-tab-btn.active { color: var(--text-0); border-bottom-color: var(--accent); }
.hist-tab-count {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; min-width: 20px; text-align: center;
  background: var(--bg-3); color: var(--text-2);
}
.hist-tab-count.ng {
  background: var(--ng-bg); color: var(--ng); border: 1px solid var(--ng-border);
}

/* ── History filter bar ── */
.hist-filter-bar {
  display: flex; gap: 6px; padding: 7px 8px;
  flex-shrink: 0; border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.hist-filter-input {
  flex: 1; min-width: 0;
  background: var(--bg-2); color: var(--text-1);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 5px 8px; font-size: 12px; font-family: inherit;
  transition: border-color 0.12s;
}
.hist-filter-input:focus { outline: none; border-color: var(--accent); }
.hist-filter-input.date { max-width: 128px; cursor: pointer; }
.hist-filter-input::-webkit-search-cancel-button { cursor: pointer; }
.hist-filter-clear {
  width: 26px; height: 26px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 4px; color: var(--text-3); font-size: 11px;
  transition: background 0.12s, color 0.12s;
}
.hist-filter-clear:hover { background: var(--bg-3); color: var(--text-1); }

.hist-date-sep {
  padding: 8px 10px 5px; flex-shrink: 0;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.hist-date-sep + .hist-date-sep { margin-top: 2px; }

/* ── Footer ── */
.footer { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 10px; color: var(--text-3); border-top: 1px solid var(--line); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.05em; }
.footer-left, .footer-right { display: flex; gap: 14px; align-items: center; }

/* ── Modal ── */
[hidden] { display: none !important; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.78); backdrop-filter: blur(6px); z-index: 50; display: grid; place-items: center; padding: 40px; animation: fade-in 0.18s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(900px, 92vw); max-height: 86vh; background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; animation: scale-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes scale-in { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-title { display: flex; align-items: center; gap: 12px; }
.modal-title h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-0); }
.modal-close { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 5px; color: var(--text-2); transition: background 0.12s, color 0.12s; }
.modal-close:hover { background: var(--bg-3); color: var(--text-0); }
.modal-body { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1px; background: var(--line); flex: 1; min-height: 0; }
.modal-photo { background: #000; position: relative; overflow: hidden; display: grid; place-items: center; min-height: 320px; }
.modal-photo-img { width: 100%; height: 100%; background-size: cover; background-position: center; filter: contrast(1.08); min-height: 320px; }
.modal-photo-placeholder { color: var(--text-3); font-size: 13px; text-align: center; padding: 20px; }
.modal-side { background: var(--bg-1); padding: 18px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.kv-list { display: flex; flex-direction: column; gap: 12px; }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }
.kv .v { font-size: 13px; color: var(--text-0); font-family: 'JetBrains Mono', monospace; }
.kv .v.big { font-size: 16px; font-weight: 600; font-family: 'Inter', sans-serif; }
.confidence-bar { height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.confidence-bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ffb070); }
.btn-row { display: flex; gap: 8px; margin-top: auto; }
.btn { flex: 1; padding: 10px 14px; border-radius: 6px; font-size: 12px; font-weight: 500; letter-spacing: 0.04em; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background 0.12s, border-color 0.12s; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--text-1); }
.btn:hover { background: var(--bg-3); color: var(--text-0); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0a00; font-weight: 600; }
.btn.primary:hover { background: #ff8233; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 1px; padding: 8px 10px 0; flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.tab-btn { padding: 6px 14px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); border: 0; background: transparent; cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.12s; white-space: nowrap; }
.tab-btn:hover { color: var(--text-1); }
.tab-btn.active { color: var(--text-0); border-bottom-color: var(--accent); }
.tab-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Cam selector ── */
.cam-selector { display: flex; gap: 6px; padding: 8px 12px; flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.cam-btn { padding: 4px 16px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; transition: all 0.12s; cursor: pointer; }
.cam-btn:hover { color: var(--text-0); }
.cam-btn.active { color: var(--text-0); background: var(--bg-3); border-color: var(--line-strong); }

/* ── Galería ── */
.foto-grid { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; align-content: start; }
.foto-thumb { position: relative; aspect-ratio: 4/3; border-radius: 4px; overflow: hidden; cursor: zoom-in; border: 1px solid var(--line); transition: border-color 0.12s, transform 0.12s; }
.foto-thumb:hover { border-color: var(--accent); transform: scale(1.04); }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb.has-anotacion { border: 2px solid var(--ng); }
.foto-thumb.has-anotacion:hover { border-color: var(--ng); }
.foto-thumb-badge {
  position: absolute; top: 5px; right: 5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--ng); color: #fff;
  font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700;
  border-radius: 999px; display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4); pointer-events: none;
}
.foto-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); padding: 28px; text-align: center; font-size: 13px; }

/* ── Slideshow ── */
.slideshow-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.slideshow-img-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; position: relative; }
.slideshow-expand-btn {
  position: absolute; bottom: 10px; right: 10px;
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 5px;
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.75);
  font-size: 11px; font-weight: 500; letter-spacing: .04em;
  border: 1px solid rgba(255,255,255,.15);
  opacity: .7; transition: opacity .15s, background .15s;
  pointer-events: auto;
}
.slideshow-expand-btn:hover { opacity: 1; background: rgba(0,0,0,.8); }
.slideshow-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.slideshow-controls { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--bg-1); }
.slideshow-play-btn { padding: 6px 16px; background: var(--accent); color: #1a0a00; border-radius: 4px; font-size: 12px; font-weight: 600; border: 0; cursor: pointer; transition: background 0.12s; }
.slideshow-play-btn:hover { background: #ff8233; }
.slideshow-counter { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-2); flex: 1; text-align: center; }
.slideshow-speed { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.slideshow-speed select { background: var(--bg-2); color: var(--text-1); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; font-size: 11px; cursor: pointer; }

/* ── Foto lightbox ── */
.foto-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; animation: fade-in 0.15s ease; }
/* .foto-lightbox-img now lives inside .foto-lightbox-img-wrap — see Anotación section */
.foto-lightbox-close { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: rgba(255,255,255,0.12); color: #fff; font-size: 16px; border: 0; cursor: pointer; transition: background 0.12s; }
.foto-lightbox-close:hover { background: rgba(255,255,255,0.22); }
.foto-lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; display: grid; place-items: center; border-radius: 6px; background: rgba(255,255,255,0.10); color: #fff; font-size: 36px; font-weight: 300; border: 0; cursor: pointer; transition: background 0.12s; line-height: 1; }
.foto-lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.foto-lightbox-nav.prev { left: 14px; }
.foto-lightbox-nav.next { right: 14px; }
.foto-lightbox-nav:disabled { opacity: 0.2; cursor: default; }
.foto-lightbox-counter { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-family: 'JetBrains Mono', monospace; font-size: 12px; color: rgba(255,255,255,0.55); letter-spacing: 0.05em; pointer-events: none; }

/* ── Anotación de imágenes ── */
.foto-lightbox-img-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: calc(95vw - 120px);
  max-height: calc(92vh - 100px);
}
.foto-lightbox-img-wrap .foto-lightbox-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block; border-radius: 4px; cursor: default;
}
.anotacion-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 4px; cursor: crosshair; z-index: 1;
}
.anotacion-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
}
.anotacion-overlay-box {
  position: absolute;
  border: 2px solid #34c171;
  background: rgba(52,193,113,0.15);
  pointer-events: auto;
  box-sizing: border-box;
}
.anotacion-overlay-label {
  position: absolute; top: -22px; left: 0;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  background: #34c171; color: #fff;
  padding: 3px 7px; border-radius: 4px 4px 4px 0;
  white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.anotacion-overlay-del {
  position: absolute; top: -22px; right: 0;
  width: 20px; height: 20px; display: grid; place-items: center;
  background: #333; border-radius: 50%;
  color: #fff; font-size: 9px; border: 0; cursor: pointer;
  pointer-events: auto; transition: background .12s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.anotacion-overlay-del:hover { background: var(--ng); }

/* ── Barra de anotación ── */
.foto-lightbox-counter {
  bottom: 62px !important;  /* queda por encima de la barra */
}
.anotacion-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center;
  background: #fff;
  border-top: 1px solid #e2e6ef;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.18);
}
.anotacion-toggle-btn {
  padding: 14px 20px; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: transparent; color: #555; border: 0;
  border-right: 1px solid #e2e6ef;
  transition: all .12s; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.anotacion-toggle-btn:hover { color: #111; background: #f5f6fa; }
.anotacion-toggle-btn.active {
  color: var(--accent); background: rgba(243,112,33,0.07);
  border-right-color: rgba(243,112,33,0.2);
}

.anotacion-form { display: flex; align-items: center; flex: 1; padding: 0 20px; min-width: 0; }

.anotacion-hint {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: #9399a8;
}
.anotacion-hint svg { flex-shrink: 0; stroke: #aab0bf; }

.anotacion-tipo-wrap {
  display: flex; align-items: center; gap: 16px; flex: 1;
  animation: fade-in .15s ease;
}
.anotacion-tipo-label {
  font-size: 11px; font-weight: 600; color: #666;
  text-transform: uppercase; letter-spacing: .08em;
  white-space: nowrap; flex-shrink: 0;
}
.anotacion-tipo-sel {
  background: #fff; color: #222; border: 1.5px solid #d0d5e2;
  border-radius: 6px; padding: 8px 12px; font-size: 12.5px;
  cursor: pointer; font-family: inherit; min-width: 160px;
  transition: border-color .12s, box-shadow .12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.anotacion-tipo-sel:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243,112,33,0.14);
}

.anotacion-action-btns { display: flex; gap: 10px; margin-left: auto; }
.anotacion-save-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 22px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
  transition: background .12s, box-shadow .12s, transform .08s;
  box-shadow: 0 2px 8px rgba(243,112,33,0.35);
}
.anotacion-save-btn:hover { background: #ff8233; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(243,112,33,0.4); }
.anotacion-save-btn:active { transform: translateY(0); }
.anotacion-cancel-btn {
  padding: 9px 16px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  background: #f3f4f8; color: #555; border: 1px solid #d5d8e8; cursor: pointer;
  transition: all .12s;
}
.anotacion-cancel-btn:hover { background: #e8eaf2; color: #222; }

/* ── Slideshow fullscreen ── */
.slideshow-fullscreen {
  display: none;
  position: fixed; inset: 0; z-index: 70;
  background: #000;
  flex-direction: column;
  align-items: center; justify-content: center;
}
.slideshow-fullscreen.open { display: flex; }
.slideshow-fs-img {
  max-width: 100%; max-height: calc(100vh - 72px);
  object-fit: contain; display: block;
  flex: 1; min-height: 0;
}
.slideshow-fs-controls {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; flex-shrink: 0;
  background: rgba(0,0,0,.75); border-top: 1px solid rgba(255,255,255,.08);
}
.slideshow-fs-close {
  position: absolute; top: 16px; right: 18px;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 6px; background: rgba(255,255,255,.12);
  color: #fff; font-size: 16px; border: 0; cursor: pointer;
  transition: background 0.12s; z-index: 2;
}
.slideshow-fs-close:hover { background: rgba(255,255,255,.25); }

/* ── Footer export ── */
.footer-export-link {
  color: var(--text-3); text-decoration: none; font-size: 10px; letter-spacing: .04em;
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 3px;
  transition: color .12s, border-color .12s;
}
.footer-export-link:hover { color: var(--text-1); border-color: var(--line-strong); }

/* ── Theme toggle ── */
.theme-toggle {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 5px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text-2); font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover { background: var(--bg-3); color: var(--text-0); }

/* ── Cam expand button ── */
.cam-expand-btn {
  position: absolute; bottom: 10px; right: 10px; z-index: 10;
  width: 30px; height: 30px; border-radius: 5px;
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s;
  cursor: pointer;
}
.cam-tile:hover .cam-expand-btn { opacity: 1; }
.cam-expand-btn:hover { background: rgba(0,0,0,.85); color: #fff; }

/* ── Cam lightbox ── */
.cam-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}
.cam-lightbox[hidden] { display: none; }
.cam-lightbox-img {
  max-width: 95vw; max-height: 90vh;
  object-fit: contain; border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,.7);
}
.cam-lightbox-label {
  color: rgba(255,255,255,.7); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: .08em;
}
.cam-lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 18px; width: 34px; height: 34px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.cam-lightbox-close:hover { background: rgba(255,255,255,.25); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4a546a; }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash {
  padding: .75rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  border-left: 4px solid;
  margin-bottom: 0;
  max-height: 80px;
  overflow: hidden;
}
.flash-notice {
  background: rgba(34, 197, 94, .12);
  border-color: #22c55e;
  color: #86efac;
}
.flash-alert {
  background: rgba(239, 68, 68, .12);
  border-color: #ef4444;
  color: #fca5a5;
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-body {
  overflow: auto;
  background: var(--bg-0);
  min-height: 100vh;
}

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
  background:
    radial-gradient(ellipse 900px 500px at 50% -80px, rgba(243,112,33,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 600px 400px at 80% 120%, rgba(243,112,33,0.04) 0%, transparent 60%),
    var(--bg-0);
}

.login-flash {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  border-left: none;
  border-bottom: 2px solid #ef4444;
  text-align: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 24px 64px rgba(0,0,0,0.55),
    0 8px 24px rgba(0,0,0,0.35);
}

/* Logo band — white background to keep the PNG logo legible */
.login-logo-band {
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 40px;
  border-bottom: 1px solid var(--line);
}

.login-logo {
  height: 64px;
  width: auto;
  display: block;
}

/* Form area */
.login-body-inner {
  background: var(--bg-1);
  padding: 32px 36px 36px;
}

.login-heading {
  margin-bottom: 28px;
}

.login-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.01em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.login-input {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-0);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 13px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.login-input::placeholder {
  color: var(--text-3);
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 112, 33, 0.18);
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  margin-top: -4px;
}

.login-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.login-btn {
  margin-top: 4px;
  width: 100%;
  padding: 11px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 2px 12px rgba(243, 112, 33, 0.35);
}

.login-btn:hover {
  background: #e8621a;
  box-shadow: 0 4px 18px rgba(243, 112, 33, 0.50);
}

.login-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 6px rgba(243, 112, 33, 0.30);
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.login-footer a {
  color: var(--text-2);
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--accent);
}

/* ── Header user / sign-out ─────────────────────────────────────────────── */
.hdr-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hdr-user-email {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hdr-signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  padding: 0;
  font-family: inherit;
}

.hdr-signout-btn:hover {
  color: var(--ng);
  background: var(--ng-bg);
  border-color: var(--ng-border);
}
