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

:root {
  --sidebar-w:  240px;
  --bg:         #f5f6f8;
  --surface:    #ffffff;
  --border:     #e5e7eb;
  --primary:    #2563eb;
  --primary-lt: #eff6ff;
  --danger:     #dc2626;
  --danger-lt:  #fef2f2;
  --success:    #059669;
  --success-lt: #ecfdf5;
  --warning:    #d97706;
  --text:       #111827;
  --muted:      #6b7280;
  --sidebar-bg: #1e2130;
  --sidebar-text: #c9cdd8;
  --sidebar-active: #2563eb;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Login ──────────────────────────────────────────────────── */
#login-screen {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #1e2130 0%, #2d3250 100%);
}
#login-box {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 2.5rem; width: 360px;
}
.login-logo { font-size: 2rem; margin-bottom: .5rem; }
#login-box h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: .25rem; }
.login-subtitle { font-size: .875rem; color: var(--muted); margin-bottom: 1.75rem; }
#login-box label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
#login-box input {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem; transition: border-color .15s;
}
#login-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.login-input-wrap { margin-bottom: 1.25rem; }
#login-box button {
  width: 100%; padding: .7rem; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: .95rem; font-weight: 600;
  transition: background .15s;
}
#login-box button:hover { background: #1d4ed8; }
#login-error { color: var(--danger); font-size: .85rem; margin-top: .75rem; min-height: 1.2em; }

/* ── App shell — sidebar layout ────────────────────────────── */
#app { display: none; height: 100vh; display: none; }
#app.visible { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; overflow: hidden;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-header {
  padding: 1rem 1.25rem; 
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: #fff;
  border-right: 1px solid rgba(0,0,0,.6);
}
.sidebar-header img { display: block; width: 150px; height: auto; margin: 0 auto; }
.sidebar-brand-sub { font-size: 1.2rem; text-align: center; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: black; margin-top: .5rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.nav-group { margin-bottom: .25rem; }
.nav-group-label {
  font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.3); padding: .6rem 1.25rem .3rem;
}
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem 1.25rem; cursor: pointer; border-radius: 0;
  color: var(--sidebar-text); text-decoration: none; font-size: .875rem;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(37,99,235,.2); color: #fff; font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--sidebar-active); border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; opacity: .8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-desc { font-size: .7rem; color: rgba(255,255,255,.35); margin-top: .1rem; line-height: 1.3; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.06); padding: 1rem 1.25rem;
}
#sidebar-user { margin-bottom: .65rem; line-height: 1.3; }
#sidebar-user:empty { display: none; }
.sidebar-user-name { color: #fff; font-size: .88rem; font-weight: 600; }
.sidebar-user-role { color: rgba(255,255,255,.5); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
#btn-logout {
  width: 100%; padding: .5rem; background: rgba(255,255,255,.06); color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,.1); border-radius: 6px; cursor: pointer; font-size: .85rem;
  transition: background .12s;
}
#btn-logout:hover { background: rgba(220,38,38,.2); color: #fca5a5; border-color: rgba(220,38,38,.3); }

/* ── Main content area ───────────────────────────────────── */
#main-content { overflow-y: auto; display: flex; flex-direction: column; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .75rem 1.25rem; border-radius: 8px; font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-md); animation: slideUp .2s ease; max-width: 320px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: #1e40af; color: #fff; }
@keyframes slideUp { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* ── Panels ──────────────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; min-height: 100%; }

.page-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.page-header-left {}
.page-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: .25rem; }
.page-desc { font-size: .85rem; color: var(--muted); max-width: 640px; line-height: 1.5; }
.page-header-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.page-body { padding: 1.75rem 2rem; }

/* ── Stat cards (Health) ─────────────────────────────────── */
.health-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; box-shadow: var(--shadow);
}
.stat-card .label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; margin-top: .4rem; line-height: 1; }
.stat-card .sub   { font-size: .8rem; color: var(--muted); margin-top: .35rem; word-break: break-all; }
.ok    { color: var(--success); }
.error { color: var(--danger);  }
.warn  { color: var(--warning); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 6px; font-size: .875rem; font-weight: 500; cursor: pointer; border: none; transition: opacity .15s, background .15s; }
.btn:hover { opacity: .88; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost     { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); opacity: 1; }
.btn-danger    { background: var(--danger-lt); color: var(--danger); border: 1.5px solid #fca5a5; }
.btn-danger:hover { background: var(--danger); color: #fff; opacity: 1; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ── Log table controls ──────────────────────────────────── */
.log-controls { display: flex; gap: .75rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.log-controls select { padding: .45rem .75rem; border: 1.5px solid var(--border); border-radius: 6px; font-size: .875rem; background: var(--surface); cursor: pointer; }
.log-meta { font-size: .8rem; color: var(--muted); margin-left: auto; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap, .data-table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left; padding: .7rem 1rem; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  border-bottom: 1.5px solid var(--border); background: #fafafa; white-space: nowrap;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f9fafb; }
tbody td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.data-table thead th { text-align: left; padding: .6rem .9rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }
.data-table tbody td { padding: .55rem .9rem; border-bottom: 1px solid var(--border); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-gray  { background: #f3f4f6; color: #374151; }
.badge-orange { background: #fef3c7; color: #92400e; }

.errors-cell { font-size: .78rem; color: var(--danger); max-width: 300px; background: none; border: none; padding: 0; font-family: inherit; }
.errors-cell.clickable { cursor: pointer; text-decoration: underline dotted; }
.errors-cell.clickable:hover { color: #991b1b; }
.no-data { text-align: center; color: var(--muted); padding: 3rem 2rem; }
.no-data-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.no-data-title { font-size: .95rem; font-weight: 600; margin-bottom: .35rem; }
.no-data-desc { font-size: .85rem; }
.loading { text-align: center; padding: 2.5rem; color: var(--muted); font-size: .9rem; }

/* ── Error detail modal ──────────────────────────────────── */
#err-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  align-items: center; justify-content: center;
}
#err-modal-overlay.open { display: flex; }
#err-modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: min(680px, 92vw); max-height: 80vh; overflow: hidden; display: flex; flex-direction: column;
}
#err-modal-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
#err-modal-header h4 { font-size: .95rem; font-weight: 700; }
#err-modal-body { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }
#err-modal-body pre {
  font-family: monospace; font-size: .78rem; white-space: pre-wrap; word-break: break-all;
  background: #0f172a; color: #86efac; padding: .85rem 1rem; border-radius: 6px; line-height: 1.6;
}
#err-modal-close {
  background: none; border: none; cursor: pointer; font-size: 1.4rem;
  color: var(--muted); line-height: 1; padding: .25rem .4rem; border-radius: 4px;
}
#err-modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; margin-top: 1rem; justify-content: flex-end; }
.pagination button {
  padding: .35rem .65rem; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: .82rem; background: var(--surface); cursor: pointer; transition: all .12s;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity: .35; cursor: default; }
.pagination button.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Collapsible info panel ─────────────────────────────── */
.info-panel {
  background: var(--primary-lt); border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: .65rem 1rem;
  margin-bottom: 1rem;
}
.info-panel summary {
  cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--primary);
  list-style: none; outline: none; padding: .15rem 0;
}
.info-panel summary::-webkit-details-marker { display: none; }
.info-panel summary::before { content: '▸ '; display: inline-block; margin-right: .2rem; transition: transform .15s; }
.info-panel[open] summary::before { transform: rotate(90deg); }
.info-panel-body { font-size: .85rem; line-height: 1.55; margin-top: .65rem; color: var(--text); }
.info-panel-body p { margin-bottom: .55rem; }
.info-panel-body p:last-child { margin-bottom: 0; }
.info-panel-body code { background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 3px; font-size: .82em; }

/* ── Synonyms ────────────────────────────────────────────── */
.syn-toolbar { display: flex; gap: .75rem; margin-bottom: 1.25rem; align-items: center; flex-wrap: wrap; }
.syn-toolbar input { flex: 1; min-width: 200px; padding: .5rem .75rem; border: 1.5px solid var(--border); border-radius: 6px; font-size: .875rem; }
.syn-toolbar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }

/* ── Drawer ──────────────────────────────────────────────── */
.drawer-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  align-items: flex-start; justify-content: flex-end;
}
.drawer-overlay.open { display: flex; }
.drawer {
  background: var(--surface); width: min(540px, 100vw); height: 100vh;
  box-shadow: -6px 0 24px rgba(0,0,0,.12); padding: 1.75rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.drawer h3 { font-size: 1.05rem; font-weight: 700; }
.drawer label { font-size: .82rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .04em; }
.drawer input, .drawer select, .drawer textarea {
  width: 100%; padding: .55rem .8rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .875rem; transition: border-color .15s;
}
.drawer input:focus, .drawer select:focus, .drawer textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.drawer textarea { min-height: 120px; resize: vertical; font-family: monospace; font-size: .82rem; }
.drawer-actions { display: flex; gap: .75rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.drawer-error { color: var(--danger); font-size: .82rem; min-height: 1.2em; }
.term-pill, .pill {
  display: inline-flex; align-items: center; gap: .3rem; background: #eff6ff;
  border: 1px solid #bfdbfe; border-radius: 20px; padding: .2rem .6rem;
  font-size: .8rem; color: #1d4ed8; margin: .2rem;
}
.term-pill button, .pill button { background: none; border: none; cursor: pointer; color: #93c5fd; font-size: .9rem; line-height: 1; padding: 0; }
.term-pill button:hover, .pill button:hover { color: var(--danger); }
.terms-input-row { display: flex; gap: .5rem; }
.terms-input-row input { flex: 1; }
#terms-container { min-height: 44px; border: 1.5px solid var(--border); border-radius: 6px; padding: .4rem; }

/* ── Drawer sub-structure (curation) ─────────────────────── */
.drawer-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: .25rem; }
.drawer-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; padding: .25rem 0; }
.drawer-footer { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: auto; }
.drawer-close { background: none; border: none; cursor: pointer; font-size: 1.4rem; color: var(--muted); line-height: 1; padding: .25rem; border-radius: 4px; }
.drawer-close:hover { color: var(--text); background: var(--bg); }
.drawer-body label { font-size: .82rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: .3rem; margin-top: .5rem; text-transform: uppercase; letter-spacing: .04em; }
.drawer-body label:first-child { margin-top: 0; }
.drawer-body input, .drawer-body select { width: 100%; padding: .5rem .75rem; border: 1.5px solid var(--border); border-radius: 6px; font-size: .875rem; }
.drawer-body h4 { font-size: .875rem; font-weight: 600; margin-bottom: .4rem; margin-top: .5rem; }
.drawer-body hr { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }
.field-error { color: var(--danger); font-size: .82rem; min-height: 1.2em; }
.hint { color: var(--muted); font-size: .8rem; }

/* ── Analytics cards (Health page) ───────────────────────── */
.analytics-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 800px) { .analytics-row { grid-template-columns: 1fr; } }
.analytics-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.25rem;
}
.analytics-card--full { margin-bottom: 1rem; }
.card-title { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .65rem; }
.card-title-sub { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .72rem; margin-left: .2rem; }
.card-body { font-size: .875rem; }

.sparkline { width: 100%; height: 90px; display: block; }
.spark-line { fill: none; stroke: var(--primary); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.spark-fill { fill: var(--primary); opacity: .08; }
.spark-meta {
  display: flex; gap: 1rem; align-items: baseline; margin-top: .55rem;
  font-size: .82rem; color: var(--text);
}
.spark-meta .hint { margin-left: auto; font-size: .75rem; }

.query-list { list-style: decimal; padding-left: 1.25rem; margin: 0; font-size: .85rem; }
.query-list li { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.query-list li:last-child { border-bottom: none; }
.q-term { font-family: monospace; }
.q-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.q-count--zero { color: var(--danger); font-weight: 600; }

/* ── Tracking warning (no /search-log POSTs reaching backend) ─ */
.tracking-warning {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px;
  padding: .85rem 1rem; font-size: .85rem; line-height: 1.55; color: #92400e;
}
.tracking-warning strong { color: #78350f; }
.tracking-warning p { margin-top: .5rem; }
.tracking-warning ol { margin: .55rem 0 0 1.2rem; }
.tracking-warning li { margin-bottom: .35rem; }
.tracking-warning code { background: #fef3c7; padding: 1px 4px; border-radius: 3px; font-size: .92em; }
.tracking-warning a { color: #1d4ed8; }

/* ── Webhook detail modal ─────────────────────────────── */
.wh-detail-h {
  font-size: .8rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-top: 1rem; margin-bottom: .4rem; padding-top: .6rem; border-top: 1px solid var(--border);
}
.wh-detail-h:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.id-chip-row { display: flex; flex-wrap: wrap; gap: .25rem; }
.id-chip {
  font-family: monospace; font-size: .75rem; padding: .2rem .55rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.id-chip:hover { background: var(--primary-lt); color: var(--primary); border-color: var(--primary); }
#err-modal { width: min(820px, 95vw); }

/* ── Sync trigger ────────────────────────────────────────── */
.sync-trigger { margin-top: 1.5rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.sync-trigger h3 { font-size: .95rem; font-weight: 700; margin-bottom: .5rem; }
.sync-trigger .hint { margin-bottom: 1rem; }
.sync-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sync-controls select { padding: .5rem .75rem; border: 1.5px solid var(--border); border-radius: 6px; background: var(--surface); font-size: .875rem; }
#sync-output { margin-top: 1rem; display: none; background: #0f172a; color: #86efac; font-family: monospace; font-size: .78rem; padding: 1rem; border-radius: 6px; max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.sync-status-badge { font-size: .8rem; padding: .3rem .7rem; border-radius: 20px; font-weight: 600; }
.sync-status-badge.running  { background: #fef3c7; color: #92400e; }
.sync-status-badge.done-ok  { background: var(--success-lt); color: var(--success); }
.sync-status-badge.done-err { background: var(--danger-lt); color: var(--danger); }

/* ── Search Config ───────────────────────────────────────── */
.cfg-section { margin-bottom: 1.75rem; }
.cfg-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; }
.cfg-section .hint { margin-bottom: .85rem; }
.pills-input { min-height: 40px; display: flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; border: 1.5px solid var(--border); border-radius: 6px; margin-bottom: .5rem; }
.form-footer { display: flex; align-items: center; gap: 1rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.cfg-field-input {
  width: 72px; padding: .4rem .5rem; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: .875rem; text-align: center;
}
.cfg-field-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.cfg-text-input {
  width: 100%; padding: .55rem .8rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .875rem;
}
.cfg-text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.cfg-field-group { display: flex; flex-direction: column; gap: .2rem; }
.cfg-field-group > label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Search Config — + Add field picker */
.cfg-add-field-wrap { margin-top: .75rem; }
.cfg-add-field-picker {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .75rem 1rem; margin-top: .5rem;
  background: var(--primary-lt); border: 1px solid #bfdbfe; border-radius: 6px;
}
.cfg-add-field-picker select {
  padding: .4rem .6rem; border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: .875rem; min-width: 220px;
}
.cfg-add-field-picker .hint { width: 100%; margin: 0; }

/* ── Product picker (curation drawer) ───────────────────── */
/* Bulletproof layout: explicit display:block on the container, no :empty
 * hiding (we set "" innerHTML to clear), and explicit colors and widths
 * everywhere so flex-shrink games can't make text invisible. */
.product-picker-list {
  display: block;
  margin: .35rem 0 1rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  /* max-height: 320px; overflow-y: auto; */
  background: var(--surface);
}
.product-picker-list:empty { border: none; }

.picker-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 64px;
}
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: #fafafa; }

.picker-thumb {
  width: 48px; height: 48px;
  flex: 0 0 48px;
  object-fit: cover;
  border-radius: 4px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  display: block;
}
.picker-thumb--placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 1.1rem;
}

.picker-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.picker-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  /* Allow two-line wrap before ellipsis — product titles often need it. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.picker-meta {
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.picker-meta .picker-price { font-weight: 600; color: var(--text); }
.picker-meta .picker-id { font-size: .68rem; color: var(--muted); }

.picker-actions {
  display: flex;
  gap: .35rem;
  flex: 0 0 auto;
  align-self: center;
}
.picker-actions button:disabled { opacity: .55; cursor: default; }

.picker-status { padding: .85rem .75rem; font-size: .85rem; color: var(--muted); text-align: center; }
.picker-status--err { color: var(--danger); }

/* Stacked-card layout for pinned + hidden product lists. Same visual
 * vocabulary as .picker-row above so the drawer reads as one coherent
 * thing top-to-bottom: thumbnail · title/meta · actions. */
.picks-stack { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.pick-card {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text);
}
.pick-card-controls {
  display: flex; align-items: center; gap: .6rem;
  flex: 0 0 auto;
}
.pick-pos-label {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.pick-pos-label input[type="number"] {
  width: 60px; padding: .3rem .4rem; font-size: .85rem;
  border: 1.5px solid var(--border); border-radius: 4px; text-align: center;
}
.toolbar { display: flex; gap: .75rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }

/* ── Curations row + drawer polish ───────────────────────── */
.cur-row-actions { display: flex; gap: .4rem; white-space: nowrap; }
.cur-row-actions .cur-delete-btn { color: var(--danger); border-color: #fca5a5; }
.cur-row-actions .cur-delete-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.drawer-body h4 { margin-top: 1.1rem; padding-top: .25rem; border-top: 1px dashed var(--border); }
.drawer-body h4:first-of-type { border-top: none; padding-top: 0; }
#cur-pins-list table { font-size: .85rem; }
#cur-pins-list th { background: transparent; padding: .4rem .5rem; font-size: .7rem; }
#cur-pins-list td { padding: .4rem .5rem; }
#cur-pins-list td input[type="number"] { padding: .3rem .4rem; }
#cur-pins-list td button, #cur-hides-list .pill button { font-size: .9rem; }
