/* ═══════════════ Tokens ═══════════════ */
:root {
  --bg:          #f6f7f9;
  --bg-elev:     #ffffff;
  --bg-sunken:   #eef0f4;
  --border:      #dcdfe6;
  --border-soft: #e7e9ef;
  --text:        #14161a;
  --text-dim:    #5c6470;
  --text-faint:  #8a919c;

  --accent:      #2f5fd0;
  --accent-soft: #e8eefb;

  --ok:          #1a7f52;
  --ok-soft:     #e3f3ea;
  --warn:        #a86414;
  --warn-soft:   #fbf0dd;
  --bad:         #b3341f;
  --bad-soft:    #fbe6e1;
  --neutral:     #5c6470;
  --neutral-soft:#e9ebef;

  --radius:   12px;
  --radius-s: 8px;
  --shadow:   0 1px 2px rgba(16,20,28,.05), 0 6px 20px rgba(16,20,28,.06);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --bg:          #0e1014;
  --bg-elev:     #161a21;
  --bg-sunken:   #1c212a;
  --border:      #2a313c;
  --border-soft: #232932;
  --text:        #e8eaee;
  --text-dim:    #a0a8b4;
  --text-faint:  #6e7885;

  --accent:      #7aa2f7;
  --accent-soft: #1c2740;

  --ok:          #58c795;
  --ok-soft:     #14301f;
  --warn:        #e0a44a;
  --warn-soft:   #332510;
  --bad:         #ef7a63;
  --bad-soft:    #351812;
  --neutral:     #a0a8b4;
  --neutral-soft:#242a33;

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
code, pre, .mono { font-family: var(--mono); }

/* ═══════════════ Topbar ═══════════════ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linejoin: round; }
.brand-mark path:first-child { fill: var(--accent-soft); }
.brand-check { stroke-linecap: round; stroke-width: 2.1; }
.brand-name { display: block; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-sub  { display: block; font-size: 11.5px; color: var(--text-faint); line-height: 1.2; }

.nav { display: flex; gap: 2px; margin-left: auto; background: var(--bg-sunken);
       padding: 3px; border-radius: 10px; }
.nav-btn {
  border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 7px 14px; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover:not(:disabled) { color: var(--text); }
.nav-btn.is-active { background: var(--bg-elev); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.nav-btn:disabled { opacity: .38; cursor: not-allowed; }

.theme-toggle {
  border: 1px solid var(--border); background: var(--bg-elev);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; color: var(--text-dim);
}
.theme-toggle svg { width: 17px; height: 17px; fill: currentColor; }
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }

/* ═══════════════ Layout ═══════════════ */
.main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
.screen { display: none; animation: fade .25s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-head { margin-bottom: 24px; }
.screen-head h1 { font-size: 26px; font-weight: 700; }
.lede { margin: 6px 0 0; color: var(--text-dim); max-width: 64ch; font-size: 14.5px; }

.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 13px; font-weight: 600; text-transform: uppercase;
              letter-spacing: .07em; color: var(--text-faint); margin-bottom: 14px; }
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-title-row .card-title { margin-bottom: 14px; }
.card-note { margin: -6px 0 14px; font-size: 13.5px; color: var(--text-dim); }

/* ═══════════════ Buttons ═══════════════ */
.btn {
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 16px; border-radius: var(--radius-s);
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn-lg { width: 100%; padding: 12px; font-size: 15px; margin-top: 18px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.actions .btn-primary { margin-left: auto; }

/* ═══════════════ Dropzone ═══════════════ */
.dropzone {
  border: 2px dashed var(--border); border-radius: 16px;
  background: var(--bg-elev); padding: 52px 24px; text-align: center;
  cursor: pointer; transition: border-color .18s, background .18s, transform .18s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.008); }
.dz-icon { width: 42px; height: 42px; fill: none; stroke: var(--accent);
           stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dz-title { margin: 14px 0 2px; font-size: 17px; font-weight: 600; }
.dz-sub { margin: 0; color: var(--text-dim); font-size: 14px; }
.dz-formats { margin: 14px 0 0; font-size: 12.5px; color: var(--text-faint); letter-spacing: .02em; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ═══════════════ File card ═══════════════ */
.file-card { margin-top: 20px; background: var(--bg-elev); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.file-card-head { display: flex; align-items: center; gap: 14px; }
.file-thumb {
  width: 54px; height: 54px; flex: none; border-radius: var(--radius-s);
  background: var(--bg-sunken); display: grid; place-items: center; overflow: hidden;
  font-size: 11px; font-weight: 700; color: var(--text-faint); letter-spacing: .04em;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ident h2 { font-size: 16px; font-weight: 600; word-break: break-all; }
.file-meta { margin: 1px 0 0; font-size: 13px; color: var(--text-dim); }
.file-card-head .btn-ghost { margin-left: auto; flex: none; }

.kv { margin: 18px 0 0; }
.kv-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px;
          padding: 9px 0; border-top: 1px solid var(--border-soft); align-items: baseline; }
.kv-row:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--text-dim); font-size: 13.5px; }
.kv dd { margin: 0; font-size: 13.5px; word-break: break-word; }
.kv dd code { font-size: 12.5px; background: var(--bg-sunken); padding: 2px 6px;
              border-radius: 5px; color: var(--text); }
.hash { word-break: break-all; }
.kv .muted { color: var(--text-faint); font-style: italic; }

/* ═══════════════ Pipeline ═══════════════ */
.pipeline { margin-top: 24px; }
.pipeline-title { font-size: 13px; font-weight: 600; text-transform: uppercase;
                  letter-spacing: .07em; color: var(--text-faint); margin-bottom: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.step {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 12px 16px;
  opacity: .45; transition: opacity .3s, border-color .3s;
}
.step.is-running { opacity: 1; border-color: var(--accent); }
.step.is-done { opacity: 1; }
.step-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.step.is-running .step-dot { background: var(--accent); animation: pulse 1s infinite; }
.step.is-done .step-dot { background: var(--ok); }
.step.is-skip .step-dot { background: var(--warn); }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .5; } }
.step-name { font-weight: 500; font-size: 14px; }
.step-status { margin-left: auto; font-size: 13px; color: var(--text-dim); }

/* ═══════════════ Verdict ═══════════════ */
.verdict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.verdict-card { text-align: center; }

.gauge-wrap { position: relative; max-width: 300px; margin: 4px auto 0; }
.gauge { width: 100%; display: block; overflow: visible; }
.gauge path { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge-track { stroke: var(--bg-sunken); }
.gauge-fill  { stroke: var(--accent); stroke-dasharray: 258; stroke-dashoffset: 258;
               transition: stroke-dashoffset 1s cubic-bezier(.25,1,.3,1), stroke .4s; }
.gauge-value { position: absolute; left: 0; right: 0; bottom: 4px; }
.gauge-num { font-size: 46px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.gauge-pct { font-size: 20px; font-weight: 600; color: var(--text-dim); }
.gauge-label { display: block; font-size: 12px; text-transform: uppercase;
               letter-spacing: .09em; color: var(--text-faint); margin-top: 2px; }
.gauge-caption { margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }

.verdict-tags { display: flex; gap: 8px; justify-content: center; margin: 16px 0 0; flex-wrap: wrap; }
.tag { font-size: 13px; font-weight: 600; padding: 5px 13px; border-radius: 999px;
       background: var(--neutral-soft); color: var(--neutral); }
.tag[data-v="Original"]      { background: var(--ok-soft);   color: var(--ok); }
.tag[data-v="Sintético"]     { background: var(--bad-soft);  color: var(--bad); }
.tag[data-v="Editado"]       { background: var(--warn-soft); color: var(--warn); }
.tag[data-v="Indeterminado"] { background: var(--neutral-soft); color: var(--neutral); }
.tag-conf { background: var(--accent-soft); color: var(--accent); }

.verdict-source { margin: 16px 0 0; font-size: 14px; color: var(--text-dim); }
.verdict-source strong { color: var(--text); }
.verdict-explain { margin: 8px 0 0; font-size: 13.5px; color: var(--text-dim);
                   text-align: left; border-top: 1px solid var(--border-soft); padding-top: 12px; }

/* ═══════════════ Sources ═══════════════ */
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.source {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start;
  padding: 11px 13px; background: var(--bg-sunken); border-radius: var(--radius-s);
  border-left: 3px solid var(--text-faint);
}
.source[data-r="hit"]  { border-left-color: var(--bad); }
.source[data-r="ok"]   { border-left-color: var(--ok); }
.source[data-r="miss"] { border-left-color: var(--text-faint); }
.source[data-r="na"]   { border-left-color: var(--border); opacity: .72; }
.source-name { font-weight: 600; font-size: 13.5px; }
.source-detail { grid-column: 2; font-size: 13px; color: var(--text-dim); margin-top: 1px; }
.source-res { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
              background: var(--bg-elev); color: var(--text-dim); white-space: nowrap; }
.source-kind { grid-row: 1 / 3; width: 22px; height: 22px; border-radius: 6px;
               display: grid; place-items: center; font-size: 11px; font-weight: 700;
               background: var(--accent-soft); color: var(--accent); }

.conflict, .next-steps {
  margin-top: 16px; padding: 13px 15px; border-radius: var(--radius-s);
  font-size: 13.5px; display: flex; gap: 11px;
}
.conflict { background: var(--warn-soft); color: var(--warn); }
.conflict svg { width: 19px; height: 19px; flex: none; margin-top: 2px;
                fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.conflict p { margin: 3px 0 0; }
.next-steps { background: var(--bg-sunken); color: var(--text-dim); display: block; }
.next-steps ul { margin: 6px 0 0; padding-left: 18px; }
.next-steps li { margin-top: 3px; }

/* ═══════════════ Tabs ═══════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border);
        margin-bottom: 20px; overflow-x: auto; }
.tab { border: 0; background: transparent; font: inherit; font-size: 14px;
       color: var(--text-dim); padding: 10px 14px; cursor: pointer;
       border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .2s ease; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.meta-grid .card + .card { margin-top: 0; }

.iptc { font-size: 14px; }
.iptc-value { font-family: var(--mono); font-size: 13px; background: var(--bg-sunken);
              padding: 8px 11px; border-radius: 6px; display: inline-block; margin-bottom: 10px; }
.iptc-note { color: var(--text-dim); font-size: 13.5px; margin: 0; }

.hexdump { background: var(--bg-sunken); padding: 14px; border-radius: var(--radius-s);
           font-size: 12.5px; line-height: 1.7; overflow-x: auto; margin: 0; color: var(--text-dim); }
.hexdump .off { color: var(--text-faint); }
.hexdump .asc { color: var(--accent); }

.heatmap-wrap { text-align: center; }
#heatmapCanvas { max-width: 100%; border-radius: var(--radius-s); background: var(--bg-sunken); }
.heatmap-legend { display: flex; align-items: center; gap: 9px; justify-content: center;
                  margin-top: 12px; font-size: 12px; color: var(--text-faint); }
.legend-bar { width: 160px; height: 8px; border-radius: 4px;
              background: linear-gradient(90deg, #1b3a6b, #2f9e6b, #e8c341, #d94f2b); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px;
                    width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 5px;
                   width: 10px; height: 10px; border-radius: 50%;
                   background: var(--bg-elev); border: 2px solid var(--accent); }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-meta { font-size: 12.5px; color: var(--text-faint); font-family: var(--mono); }
.tl-detail { font-size: 13.5px; color: var(--text-dim); margin-top: 2px; }

.model-box { font-size: 14px; }
.model-name { font-size: 18px; font-weight: 700; }
.model-conf { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

.json-view { background: var(--bg-sunken); padding: 16px; border-radius: var(--radius-s);
             font-size: 12.5px; line-height: 1.65; overflow-x: auto; margin: 0; max-height: 540px; }
.json-view .k { color: var(--accent); }
.json-view .s { color: var(--ok); }
.json-view .n { color: var(--bad); }
.json-view .b { color: var(--warn); }

/* ═══════════════ Dashboard ═══════════════ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.stat-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; margin-bottom: 16px; }
.dash-grid .card + .card { margin-top: 0; }

.dist { display: grid; gap: 12px; }
.dist-row { display: grid; grid-template-columns: 96px 1fr 38px; gap: 10px; align-items: center; font-size: 13.5px; }
.dist-bar { height: 9px; border-radius: 5px; background: var(--bg-sunken); overflow: hidden; }
.dist-fill { height: 100%; border-radius: 5px; transition: width .6s cubic-bezier(.25,1,.3,1); }
.dist-count { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.trend-wrap { position: relative; }
.trend { width: 100%; height: 200px; display: block; overflow: visible; }
.trend-grid { stroke: var(--border-soft); stroke-width: 1; }
.trend-area { fill: var(--accent); opacity: .12; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2.2;
              stroke-linejoin: round; stroke-linecap: round; }
.trend-dot { fill: var(--bg-elev); stroke: var(--accent); stroke-width: 2.2; }
.trend-lbl { fill: var(--text-faint); font-size: 11px; font-family: var(--sans); }
.trend-empty { position: absolute; inset: 0; display: grid; place-items: center;
               color: var(--text-faint); font-size: 13.5px; background: var(--bg-elev); }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
            color: var(--text-faint); font-weight: 600; padding: 8px 10px;
            border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg-sunken); }
.table .td-name { font-weight: 500; max-width: 230px; overflow: hidden;
                  text-overflow: ellipsis; white-space: nowrap; }
.table .td-fid { font-variant-numeric: tabular-nums; font-weight: 600; }
.table .td-date { color: var(--text-faint); font-size: 12.5px; white-space: nowrap; }
.mini-tag { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
            background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.mini-tag[data-v="Original"]      { background: var(--ok-soft);   color: var(--ok); }
.mini-tag[data-v="Sintético"]     { background: var(--bad-soft);  color: var(--bad); }
.mini-tag[data-v="Editado"]       { background: var(--warn-soft); color: var(--warn); }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--text-faint); font-size: 13.5px; padding: 26px 0 8px; margin: 0; }

/* ═══════════════ Toast ═══════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 130%);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500; z-index: 60; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.25,1,.3,1); max-width: 90vw; text-align: center;
}
.toast.is-visible { transform: translate(-50%, 0); }

/* ═══════════════ Responsive ═══════════════ */
@media (max-width: 900px) {
  .verdict-grid, .meta-grid, .dash-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .theme-toggle { margin-left: auto; }
  .main { padding: 24px 16px 64px; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
  .actions .btn-primary { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
