/* ==========================================================================
   Validator — sistema de diseno de DMARC Defense
   Paleta y componentes tomados del portal de onboarding (tailwind.config.ts)
   para que ambas herramientas se vean como una sola plataforma.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Teal de marca: #08afa9 del isotipo, #005d54 del logotipo DMARC */
  --brand-50:  #ecfbfa;
  --brand-100: #cef5f1;
  --brand-200: #9eebe4;
  --brand-300: #5fdbd2;
  --brand-400: #2bc4ba;
  --brand-500: #08afa9;
  --brand-600: #08948f;
  --brand-700: #0a7873;
  --brand-800: #0c5f5b;
  --brand-900: #005d54;
  --brand-950: #003a35;

  --navy:       #005d54;
  --navy-light: #0a7873;
  --navy-dark:  #003a35;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --bg: var(--gray-50);
  --surface: #ffffff;
  --surface-2: var(--gray-50);
  --border: var(--gray-200);
  --text: var(--gray-900);
  --muted: var(--gray-500);
  --accent: var(--brand-600);
  --accent-strong: var(--brand-700);
  --accent-soft: var(--brand-50);

  --ok: #047857;    --ok-bg: #ecfdf5;
  --warn: #b45309;  --warn-bg: #fffbeb;
  --error: #b91c1c; --error-bg: #fef2f2;
  --info: var(--brand-700); --info-bg: var(--brand-50);

  --sidebar-w: 256px;
  --header-h: 64px;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}

[data-theme="dark"] {
  --bg: #0b1614;
  --surface: #10201d;
  --surface-2: #162b27;
  --border: #1f3b36;
  --text: #e6f2f0;
  --muted: #8aa8a3;
  --accent: var(--brand-400);
  --accent-strong: var(--brand-300);
  --accent-soft: #12302c;
  --ok: #34d399;   --ok-bg: #0d2a20;
  --warn: #fbbf24; --warn-bg: #2c2410;
  --error: #f87171;--error-bg: #2e1618;
  --info: var(--brand-300); --info-bg: #12302c;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .4);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / .45);
  --shadow-lg: 0 10px 20px -5px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================== estructura ============================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
  background: var(--navy); color: #fff; transition: width .3s;
}
.sidebar.collapsed { width: 64px; }

.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 20px 16px; background: rgb(255 255 255 / .95);
  border-bottom: 1px solid rgb(255 255 255 / .1);
}
.sidebar-brand img { display: block; width: 160px; height: auto; }
.sidebar-brand .subtitle {
  margin: 4px 0 0; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .2em; color: var(--brand-700);
}
.sidebar.collapsed .sidebar-brand { padding: 20px 8px; justify-content: center; }
.sidebar.collapsed .brand-full { display: none; }
.brand-badge {
  display: none; width: 36px; height: 36px; border-radius: 6px; background: var(--brand-600);
  color: #fff; font-size: 13px; font-weight: 700; align-items: center; justify-content: center;
}
.sidebar.collapsed .brand-badge { display: flex; }
.collapse-btn {
  flex: none; background: none; border: 0; cursor: pointer; padding: 6px;
  border-radius: 6px; color: var(--navy); line-height: 0;
}
.collapse-btn:hover { background: var(--brand-50); }
.sidebar.collapsed .collapse-btn { display: none; }

.sidebar-nav { flex: 1; padding: 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.nav-section {
  margin: 0 0 8px; padding: 0 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: rgb(206 245 241 / .55);
}
.sidebar-nav .nav-section:not(:first-child) { margin-top: 24px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: var(--radius);
  background: none; color: var(--gray-300); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background-color .15s, color .15s;
}
.nav-item:hover { background: rgb(255 255 255 / .1); color: #fff; }
.nav-item.active { background: var(--brand-600); color: #fff; }
.nav-item svg { flex: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-item span, .sidebar.collapsed .nav-section { display: none; }

.sidebar-foot { border-top: 1px solid rgb(255 255 255 / .1); padding: 16px; }
.sidebar-user { margin-bottom: 12px; min-width: 0; }
.sidebar-user .name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .mail { font-size: 12px; color: var(--gray-400); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar.collapsed .sidebar-user { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.appbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.appbar h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.appbar .crumb { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.appbar-actions { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-600);
  color: #fff; font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: center; flex: none;
}
.user-chip {
  display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 16px;
  border: 0; border-left: 1px solid var(--border); border-radius: var(--radius);
  background: none; color: inherit; font: inherit; cursor: default;
}
.user-chip .meta { text-align: left; line-height: 1.25; }
.user-chip .meta .name { font-size: 14px; font-weight: 500; }
@media (max-width: 640px) { .user-chip .meta { display: none; } }

.content { flex: 1; padding: 24px; }
.wrap { max-width: 1120px; margin: 0 auto; }

/* ============================== componentes ============================== */
.badge-role {
  display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid transparent;
  padding: 1px 8px; font-size: 10px; font-weight: 600;
  background: var(--brand-100); color: var(--brand-800);
}
[data-theme="dark"] .badge-role { background: var(--accent-soft); color: var(--brand-200); }

.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 36px; height: 36px; border-radius: var(--radius); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel { display: none; padding-bottom: 40px; }
.panel.active { display: block; }

.query-card, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.query-card { padding: 24px; display: grid; gap: 16px; }
.card { margin-top: 18px; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-body { padding: 20px; }
.card-body > :first-child { margin-top: 0; }

label { display: block; font-size: 14px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
[data-theme="dark"] label { color: var(--text); }

input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; height: 40px; padding: 8px 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--gray-300); border-radius: var(--radius);
}
[data-theme="dark"] input[type=text], [data-theme="dark"] input[type=email],
[data-theme="dark"] input[type=password], [data-theme="dark"] select, [data-theme="dark"] textarea {
  border-color: var(--border); background: var(--surface-2);
}
textarea { height: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--gray-400); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-500);
}

.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row input { flex: 1; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.primary, .add-btn, .export-btn, .copy, .chip, .seg-btn, .del-btn, .filters button {
  font-family: inherit;
}
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius);
  background: var(--brand-600); color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background-color .15s;
}
.primary:hover { background: var(--brand-700); }
.primary:disabled { opacity: .5; pointer-events: none; }
.primary.lg { height: 48px; font-size: 16px; padding: 0 32px; width: 100%; }

.export-btn {
  background: var(--surface); border: 1px solid var(--brand-600); color: var(--brand-700);
  border-radius: var(--radius); padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.export-btn:hover { background: var(--brand-600); color: #fff; }
.export-btn:disabled { opacity: .6; cursor: progress; }
[data-theme="dark"] .export-btn { color: var(--brand-300); border-color: var(--brand-500); }

.add-btn {
  background: var(--brand-50); border: 1px solid var(--brand-500); color: var(--brand-700);
  border-radius: var(--radius); padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.add-btn:hover { background: var(--brand-600); color: #fff; }
[data-theme="dark"] .add-btn { background: var(--accent-soft); color: var(--brand-300); }

.copy {
  background: var(--surface); border: 1px solid var(--gray-300); color: var(--gray-700);
  border-radius: var(--radius); padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.copy:hover { background: var(--gray-50); }
[data-theme="dark"] .copy { border-color: var(--border); color: var(--muted); background: var(--surface-2); }

.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.opt { font-weight: 400; color: var(--muted); }
.samples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.chip {
  background: var(--gray-100); border: 1px solid var(--border); color: var(--gray-700);
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px; cursor: pointer;
}
.chip:hover { color: var(--brand-700); border-color: var(--brand-500); background: var(--brand-50); }
[data-theme="dark"] .chip { background: var(--surface-2); color: var(--muted); }

.advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.advanced[open] summary { margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--gray-100); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.seg-btn { background: none; border: 0; padding: 7px 14px; border-radius: 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg { background: var(--surface-2); }
.check-line { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 500; }
.check-line input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand-600); }

/* ================================ estado ================================ */
.status {
  margin-top: 18px; padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); font-size: 14px;
}
.status.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.status.err { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.verdict {
  margin-top: 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.verdict.ok { border-left-color: var(--ok); }
.verdict.warn { border-left-color: var(--warn); }
.verdict.error { border-left-color: var(--error); }
.verdict h2 { margin: 0 0 4px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.verdict p { margin: 0; color: var(--muted); font-size: 14px; }
.verdict-actions { justify-self: end; }
@media (max-width: 680px) {
  .verdict { grid-template-columns: auto 1fr; }
  .verdict-actions { grid-column: 1 / -1; justify-self: start; }
}
.score-ring { width: 92px; height: 92px; position: relative; flex: none; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-size: 24px; font-weight: 700; line-height: 1;
}
.score-ring .val small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.tally { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.tally b { font-variant-numeric: tabular-nums; }
.t-error { color: var(--error); } .t-warn { color: var(--warn); }
.t-info { color: var(--info); } .t-ok { color: var(--ok); }

/* =============================== contenido =============================== */
.record {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 14px; white-space: pre-wrap;
}
.record .m-lookup { color: var(--brand-700); font-weight: 600; }
.record .m-ip { color: var(--ok); }
.record .m-all { font-weight: 700; }
.record ins { background: var(--ok-bg); color: var(--ok); text-decoration: none; font-weight: 700; border-radius: 3px; padding: 0 2px; }
[data-theme="dark"] .record .m-lookup { color: var(--brand-300); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.metric .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; line-height: 1.25; }
.metric .v.long { font-size: 13px; font-family: var(--mono); font-weight: 600; }
.metric.is-ok .v { color: var(--ok); } .metric.is-warn .v { color: var(--warn); } .metric.is-error .v { color: var(--error); }
.bar { height: 5px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); } .bar.error > i { background: var(--error); }

.checks { display: grid; gap: 10px; }
.check { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.check.ok { border-left-color: var(--ok); }
.check.info { border-left-color: var(--info); }
.check.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.check.error { border-left-color: var(--error); background: var(--error-bg); }
.check-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.check-title { font-weight: 600; font-size: 14px; }
.badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px; flex: none; border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--error-bg); color: var(--error); }
.cat { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.check p { margin: 6px 0 0; font-size: 13.5px; }
.check .fix { color: var(--muted); }
.check .fix b { color: var(--text); }
.check pre {
  margin: 8px 0 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; color: var(--muted);
}
.check .ref { font-size: 11.5px; color: var(--muted); margin-top: 7px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 4px 10px; font-size: 12.5px; cursor: pointer;
}
.filters button.active { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-700); font-weight: 600; }
[data-theme="dark"] .filters button.active { background: var(--accent-soft); color: var(--brand-300); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

.tree { font-family: var(--mono); font-size: 12.5px; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--border); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { margin: 5px 0; }
.node-name { font-weight: 700; }
.node-meta { color: var(--muted); font-size: 11.5px; }
.node-rec { color: var(--muted); word-break: break-all; display: block; margin-top: 2px; }
.pill { font-size: 10px; border-radius: 999px; padding: 2px 8px; margin-left: 6px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.error { background: var(--error-bg); color: var(--error); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }

.ipverdict {
  display: flex; align-items: center; gap: 16px; padding: 18px;
  border-radius: var(--radius-lg); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface);
}
.ipverdict .big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.ipverdict.pass { border-left-color: var(--ok); } .ipverdict.pass .big { color: var(--ok); }
.ipverdict.fail, .ipverdict.permerror { border-left-color: var(--error); }
.ipverdict.fail .big, .ipverdict.permerror .big { color: var(--error); }
.ipverdict.softfail, .ipverdict.neutral, .ipverdict.none, .ipverdict.temperror { border-left-color: var(--warn); }
.ipverdict.softfail .big, .ipverdict.neutral .big, .ipverdict.none .big, .ipverdict.temperror .big { color: var(--warn); }

.trace { display: grid; gap: 3px; font-family: var(--mono); font-size: 12px; }
.trace-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 5px 8px; border-radius: 6px; }
.trace-row.hit { background: var(--ok-bg); }
.trace-row.rec { background: var(--surface-2); font-weight: 600; }
.trace-row .mark { text-align: center; }
.trace-row .why { color: var(--muted); display: block; font-weight: 400; }
.trace-more { margin: 2px 0 6px; }
.trace-more summary { cursor: pointer; color: var(--muted); font-size: 11.5px; padding: 3px 8px; }
.trace-more summary:hover { color: var(--accent); }

.note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.steps { margin: 0; padding-left: 20px; font-size: 13.5px; }
.steps li { margin: 7px 0; }

/* ============================ constructores ============================ */
.builder { display: grid; gap: 8px; }
.builder-row {
  display: grid; grid-template-columns: minmax(150px, 1.1fr) 88px minmax(140px, 1.6fr) auto;
  gap: 8px; align-items: center;
}
.builder-row.no-qual { grid-template-columns: minmax(150px, 1.1fr) minmax(140px, 1.6fr) auto; }
.builder-row .cidrs { display: flex; gap: 6px; }
.builder-row .cidrs input { width: 74px; }
@media (max-width: 760px) {
  .builder-row, .builder-row.no-qual { grid-template-columns: 1fr 1fr; }
  .builder-row .del-btn { grid-column: 2; justify-self: end; }
}
.del-btn {
  background: none; border: 1px solid var(--gray-300); color: var(--muted);
  border-radius: var(--radius); width: 36px; height: 36px; font-size: 17px; line-height: 1; cursor: pointer; flex: none;
}
.del-btn:hover { color: var(--error); border-color: var(--error); }
.builder-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.builder-add select { max-width: 340px; }
.empty-hint {
  margin: 0; padding: 16px; text-align: center; font-size: 13px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.preview-meta { text-transform: none; letter-spacing: 0; font-weight: 400; }
.preview-meta .over { color: var(--error); font-weight: 700; }
.preview .record { margin: 0; border: 0; border-radius: 0; background: var(--surface); }

.defense-box { background: var(--brand-50); border: 1px solid var(--brand-500); border-radius: var(--radius); padding: 14px 16px; }
.defense-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-700); margin-bottom: 6px; }
.defense-box .mono { font-size: 12.5px; color: var(--text); }
[data-theme="dark"] .defense-box { background: var(--accent-soft); }
[data-theme="dark"] .defense-title { color: var(--brand-300); }

.diff { display: grid; gap: 10px; }
.diff-row { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted);
}
.diff-row.after .diff-label { background: var(--ok-bg); color: var(--ok); }
.diff-row .record { margin: 0; border: 0; border-radius: 0; }

.inv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.inv-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.inv-card h5 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.inv-count { font-size: 13px; margin-bottom: 8px; }
.inv-count b { font-size: 18px; font-variant-numeric: tabular-nums; }
.inv-count .arrow { color: var(--muted); margin: 0 6px; }
.inv ul { margin: 0; padding-left: 16px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.inv li { margin: 3px 0; word-break: break-all; }
.inv li.new { color: var(--ok); font-weight: 700; }

.item-details > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 16px 20px; background: var(--surface-2); border-bottom: 1px solid transparent; font-size: 14px;
}
.item-details[open] > summary { border-bottom-color: var(--border); }
.item-details > summary:hover { color: var(--accent); }
.sum-title { font-weight: 600; font-family: var(--mono); font-size: 13px; }

.foot { padding: 24px 0 8px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 24px; }
.foot p { margin: 0; }

/* ============================ pantalla de acceso ============================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 55%, var(--brand-800) 100%);
}
.login-box { width: 100%; max-width: 448px; }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .plate {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 16px; padding: 16px 28px; margin-bottom: 16px;
  box-shadow: 0 20px 25px -5px rgb(0 58 53 / .3), 0 8px 10px -6px rgb(0 58 53 / .3);
}
.login-brand .plate img { display: block; width: 220px; height: auto; }
.login-brand p { margin: 8px 0 0; font-size: 14px; color: var(--brand-100); }
.login-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.login-card .head { padding: 24px 24px 8px; text-align: center; }
.login-card .head h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--gray-900); }
.login-card .head p { margin: 4px 0 0; font-size: 14px; color: var(--gray-500); }
.login-card form { padding: 16px 24px 24px; display: grid; gap: 16px; }
.login-card label { color: var(--gray-700); }
.login-card input { background: #fff; color: var(--gray-900); border-color: var(--gray-300); }
.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.login-row label { margin: 0; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--gray-400); padding: 4px; line-height: 0;
}
.password-toggle:hover { color: var(--gray-600); }
.login-error {
  padding: 12px; border-radius: var(--radius); background: #fef2f2;
  border: 1px solid #fecaca; font-size: 14px; color: #b91c1c;
}
.login-link {
  background: none; border: 0; padding: 0; font: inherit; font-size: 13px;
  color: var(--brand-700); cursor: pointer; text-align: center; width: 100%;
}
.login-link:hover { color: var(--brand-900); text-decoration: underline; }
.login-note { text-align: center; font-size: 12px; color: rgb(206 245 241 / .8); margin: 24px 0 0; }
.code-input { text-align: center; font-size: 24px; letter-spacing: .35em; font-family: var(--mono); }

.actualizado { font-size: 11.5px; color: var(--muted); margin-right: 10px; font-variant-numeric: tabular-nums; }
.actualizado .desactualizado { color: var(--error); font-weight: 600; }
