*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette (from the OCVigilance mark + mockups) */
  --primary:    #1a5276;
  --primary-2:  #2e86c1;
  --primary-lt: #eaf4fb;
  --accent:     #2aa9e0; /* lens highlight */
  --teal:       #1f8aa6; /* lens ring */
  --danger:     #c0392b;
  --warning:    #b9770e;
  --success:    #1e8449;
  /* Neutrals */
  --gray-50:    #f8fafc;
  --gray-100:   #f0f4f8;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;
  --gray-500:   #64748b;
  --gray-700:   #334155;
  --gray-900:   #0f172a;
  --border:     #d5dfe8;
  /* Spacing + radius scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 28px;
  --radius:    8px;
  --radius-lg: 12px;
  --sidebar-w: 232px;
  --shadow-card: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.4;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #0d3d5c; }
.btn-ghost { background: white; color: var(--gray-700); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-50); }

/* ── Form fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.field label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
}
.field input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .92rem;
  font-family: inherit;
  background: white;
  color: var(--gray-900); /* readable, high-contrast typed text */
}
.field input::placeholder { color: var(--gray-500); opacity: 1; }
/* Keep browser-autofilled values dark on a plain background (no washed-out tint). */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--gray-900);
  caret-color: var(--gray-900);
  transition: background-color 9999s ease-out 0s;
}
.field input:focus {
  outline: 2px solid var(--primary-lt);
  border-color: var(--primary-2);
}

/* ── Login screen ── */
.login-page {
  background: linear-gradient(135deg, #0f172a 0%, #1a5276 100%);
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card .brand { text-align: center; margin-bottom: 28px; }
.login-card .brand .logo { width: 100%; max-width: 230px; height: auto; }
.login-card .brand h1 {
  font-size: 1.6rem;
  color: var(--primary);
  letter-spacing: -.01em;
}
.login-card .brand .subtitle {
  color: var(--gray-500);
  font-size: .8rem;
  margin-top: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.login-card .btn { width: 100%; padding: 12px; font-size: .95rem; margin-top: 6px; }
.login-card .login-error { margin: 14px 0 0; }

/* Password field with an inline show/hide toggle. */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { width: 100%; padding-right: 42px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--gray-500);
  border-radius: 6px;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--gray-700); background: var(--gray-100); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary-lt); }

/* Discreet field note (Caps Lock warning, etc.). */
.field-note { font-size: .72rem; color: var(--warning); margin-top: 4px; }

/* App version, bottom-right of the login screen. */
.login-version {
  position: fixed;
  bottom: 14px;
  right: 18px;
  font-size: .72rem;
  letter-spacing: .02em;
  color: rgba(255, 255, 255, .55);
}

.alert {
  display: none;
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c0;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 14px;
}
.alert.show { display: block; }
.alert.alert-success { background: #eafaf1; color: #1e7e46; border-color: #b7e4c7; }

/* ── Authenticated shell (sidebar + main) ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  padding: 22px var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; flex-direction: column; gap: var(--sp-1); padding: 0 6px; }
.sidebar .brand .logo { width: 100%; max-width: 184px; height: auto; }
.sidebar .brand .tag {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--gray-500); font-weight: 600;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: var(--radius);
}
.sidebar nav a:hover { background: var(--gray-50); }
.sidebar nav a.active {
  background: var(--primary-lt);
  color: var(--primary);
  font-weight: 600;
}
.sidebar .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.sidebar .sidebar-foot .user { font-size: .82rem; color: var(--gray-500); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .breadcrumb { flex: 1; font-size: .92rem; color: var(--gray-700); }
.topbar .breadcrumb a { color: var(--gray-500); text-decoration: none; }
.topbar .breadcrumb a:hover { color: var(--primary); }
.topbar .user { color: var(--gray-500); font-size: .85rem; }
.content { padding: 28px 32px; }
.content h2 { font-size: 1.4rem; margin-bottom: 8px; }
.content p { color: var(--gray-500); }

/* Collapse the sidebar into a top strip on narrow viewports. */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px 14px; padding: 12px 16px;
  }
  .sidebar .brand { flex-direction: row; align-items: center; flex: 1; }
  .sidebar .brand .logo { max-width: 150px; }
  .sidebar .brand .tag { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .sidebar-foot { margin-top: 0; flex-direction: row; align-items: center; }
  .content { padding: 20px; }
}

/* ── Buttons (extra) ── */
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a5311f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; flex: 1; }
.card-body { padding: 18px; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-header h2 { flex: 1; margin: 0; }
.page-header .subtitle { color: var(--gray-500); font-size: .88rem; margin-top: 2px; }

/* ── Layout grid ── */
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }

/* Count next to a page H1, e.g. "Clientes (12)". */
.h2-count { color: var(--gray-500); font-weight: 500; font-size: .85em; }

/* Discreet help marker with a native tooltip. */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-700);
  font-size: .7rem; font-weight: 700; cursor: help; margin-left: 6px;
  vertical-align: middle;
}

/* Inline text link (e.g. "Sugerir destinatarios del cliente"). */
.link-sm { display: inline-block; font-size: .8rem; color: var(--primary-2); text-decoration: none; }
.link-sm:hover { text-decoration: underline; }

/* Split button (main action + caret menu). */
.split-btn { position: relative; display: inline-flex; }
.split-btn .btn-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn .btn-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 8px; padding-right: 8px; border-left: 1px solid rgba(255, 255, 255, .35); }
.split-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  min-width: 260px; background: white;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.split-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; background: none; border: none; cursor: pointer;
  font: inherit; font-size: .85rem; color: var(--gray-900);
}
.split-menu button:hover { background: var(--gray-50); }
.split-menu .sub { font-size: .72rem; color: var(--gray-500); margin-top: 2px; }
/* Let the executions card show the split-button dropdown (not clip it). */
.exec-card { overflow: visible; }

/* Sticky bottom action bar (save / schedule always reachable). */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; margin-top: 8px;
  background: var(--gray-100); border-top: 1px solid var(--border);
}

/* Contextual list/panel layout: list full-width until the panel opens. */
.clients-layout, .ctx-layout { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.clients-layout.with-panel, .ctx-layout.with-panel { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1200px) {
  /* Narrow viewport: the panel takes over the main column, list hides. */
  .clients-layout.with-panel, .ctx-layout.with-panel { grid-template-columns: 1fr; }
  .clients-layout.with-panel .list-card, .ctx-layout.with-panel .list-card { display: none; }
}

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: .9rem;
  color: var(--gray-500);
  cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary-2); font-weight: 600; }
.tab:disabled { color: var(--gray-300); cursor: not-allowed; }

/* ── Tables ── */
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
/* Results grid uses fixed layout so the <colgroup> widths are authoritative. */
table.data.results-table { table-layout: fixed; }
/* Light provenance tag (where the abstract / author country came from). */
.src-tag { font-size: .66rem; color: var(--gray-400); margin-left: 5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
table.data th {
  text-align: left;
  padding: 10px 14px;
  background: var(--gray-50);
  font-weight: 600;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: top; overflow-wrap: anywhere; word-break: break-word; }
table.data tr { cursor: pointer; }
table.data tr:hover { background: var(--gray-50); }
table.data tr.selected { background: var(--primary-lt); }

/* ── Badges & chips ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-blue { background: #eaf4fb; color: var(--primary); border: 1px solid #c3dff0; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--border); }
.badge-orange { background: #fef5e7; color: #b9770e; border: 1px solid #fad7a0; }
.badge-green { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.badge-red { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: .78rem;
  color: var(--gray-700);
}
.chip .x { cursor: pointer; color: var(--gray-500); font-weight: 700; }
.chip .x:hover { color: var(--danger); }

/* ── Form extras ── */
.field select, .field textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: white;
}
.field .hint { font-size: .72rem; color: var(--gray-500); }
.inline-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.inline-add .field { flex: 1; min-width: 120px; margin-bottom: 0; }

/* ── Query preview ── */
.preview-block { margin-bottom: 12px; }
.preview-country { font-weight: 600; font-size: .82rem; color: var(--gray-700); margin-bottom: 4px; }
.preview-query {
  background: #0f172a;
  color: #7dd3fc;
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: .8rem;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  word-break: break-word;
}

.muted, .text-muted { color: var(--gray-500); }
.text-xs { font-size: .75rem; }
.text-sm { font-size: .85rem; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.items-center { align-items: center; }

/* Two fields side by side. */
.field-row { display: flex; gap: var(--sp-3); }
.field-row .field { flex: 1; }

/* Status dots (last-execution health, etc.). */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--gray-300); }
.dot-green { background: #2ecc71; }
.dot-orange { background: #e67e22; }
.dot-red { background: var(--danger); }

/* ── Filters bar ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 220px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--gray-200);
  font-size: .82rem;
  color: var(--gray-500);
}
.pagination .spacer { margin-left: auto; }

/* ── Results table ── */
table.data tr.article-row { cursor: pointer; }
tr.abstract-row td {
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: .82rem;
  line-height: 1.5;
  padding: 14px 18px;
}
.future-col { display: none; } /* reserved for F2/F3/F5 columns */
.abstract-lang { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); margin-bottom: 2px; }
.idx-meta { font-size: .72rem; color: var(--gray-500); }
.kpis { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); }
.kpi .value { font-size: 1.3rem; font-weight: 700; }
/* Primary KPI ("Artículos"): larger and brand-coloured. */
.kpi-primary { padding-right: 8px; }
.kpi-primary .value { font-size: 1.95rem; line-height: 1.1; color: var(--primary); }

/* Prominent client-exclusion switch above the results table. */
.exclusion-bar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--gray-300);
  border-radius: 999px; transition: background .15s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary-lt); }
.switch-label { display: flex; flex-direction: column; line-height: 1.25; }
.switch-label strong { font-size: .85rem; }
.switch-hint { font-size: .72rem; color: var(--gray-500); }

/* Alert level counts above the table. */
.level-counts { display: flex; align-items: center; gap: 10px; font-size: .82rem; margin: 0 0 16px; color: var(--gray-700); }
.level-counts .lc-critical { color: #c0392b; }
.level-counts .lc-error { color: #e67e22; }
.level-counts .lc-warning { color: var(--warning); }
.level-counts .lc-info { color: var(--gray-500); }
.level-counts .lc-sep { color: var(--gray-300); }

/* Highlight alert rows by severity (left accent; soft fill for CRITICAL). */
tr.alert-row.level-critical td { background: #fef2f2; }
tr.alert-row.level-critical td:first-child { border-left: 4px solid var(--danger); }
tr.alert-row.level-error td:first-child { border-left: 4px solid #e67e22; }
tr.alert-row.level-warning td:first-child { border-left: 4px solid var(--warning); }

/* Lightweight modal (e.g. reply content). */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 80vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  margin-bottom: 8px;
  cursor: pointer;
}
.check input { margin-top: 3px; }
.check .check-text { flex: 1; font-size: .85rem; }
.check .check-text .sub { font-size: .75rem; color: var(--gray-500); }
.font-bold { font-weight: 700; }

/* ── Dashboard ── */
.dash-head { margin-bottom: 22px; }
.dash-head h2 { margin-bottom: 4px; }
.dash-week { color: var(--gray-500); font-size: .9rem; }

/* Attention block: consistent gap to the next section in both states. */
#attention { display: block; margin-bottom: 20px; }
.all-clear {
  display: flex; align-items: center; gap: 8px;
  color: var(--success); font-weight: 600; font-size: .9rem;
  padding: 4px 0;
}

.attn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.attn-card { border-radius: var(--radius-lg); padding: 16px 18px; border: 2px solid; }
.attn-card.red { background: #fdecea; border-color: #f1948a; }
.attn-card.amber { background: #fef5e7; border-color: #f5cba7; }
.attn-card h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.attn-card .attn-count { font-size: 2.1rem; font-weight: 800; line-height: 1; }
.attn-card.red h3, .attn-card.red .attn-count { color: var(--danger); }
.attn-card.amber h3, .attn-card.amber .attn-count { color: var(--warning); }
.attn-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; font-size: .82rem; }
.attn-list a { color: var(--gray-700); text-decoration: none; }
.attn-list a:hover { text-decoration: underline; }
.attn-more { font-weight: 600; }
.attn-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attn-res, .attn-res-all {
  background: transparent; border: 1px solid var(--danger); color: var(--danger);
  border-radius: var(--radius-sm, 6px); padding: 2px 8px; font-size: .74rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.attn-res:hover, .attn-res-all:hover { background: var(--danger); color: #fff; }
.attn-res-all { margin-top: 12px; }

/* Secondary (muted) section: flatter cards, soft grey. */
.section-title {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--gray-500); font-weight: 700; margin: 6px 0 10px;
}
.card-flat { box-shadow: none; background: var(--gray-50); }
.sys-list { display: flex; flex-direction: column; gap: 14px; }
.sys-item .sys-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); }
.sys-item .sys-value { font-size: .92rem; font-weight: 600; margin-top: 2px; }
.actions-list { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.empty-state { color: var(--gray-500); font-size: .9rem; }
.health-green { color: var(--success); }
.health-amber { color: var(--warning); }
.health-red { color: var(--danger); }
.font-mono { font-family: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, monospace; }
code {
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: .85em;
  background: var(--gray-100);
  padding: 1px 4px;
  border-radius: 3px;
}
