/* ============================================================
   MFX Parser — components (Matflixx dark)
   ============================================================ */

/* App shell: top nav + content ------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topnav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 22px;
  background: rgba(8, 7, 20, 0.55);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.brand img { height: 26px; display: block; }
.brand__fallback { font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: 0.04em; }

.topnav__links { display: flex; align-items: center; gap: 6px; }
.nav-item {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.nav-item img, .nav-item svg { width: 16px; height: 16px; }
.nav-item:hover { color: var(--ink); background: var(--row-hover); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.topnav__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-pill {
  height: 38px; min-width: 44px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--sub-panel); color: var(--ink-2); cursor: pointer;
}
.nav-pill:hover { border-color: var(--line-strong); color: var(--ink); }
.nav-pill img { width: 16px; height: 16px; }

.main {
  flex: 1; min-width: 0;
  padding: 16px 22px 28px;
  display: flex; flex-direction: column; gap: var(--gap);
}

/* Panels ----------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--inner-glow), var(--shadow-panel);
  padding: var(--pad-panel);
}
.sub-panel {
  background: var(--sub-panel);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-sub);
  padding: var(--pad-sub);
}
.panel--tight { padding: 14px 16px; }

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.panel-title {
  font-family: var(--f-display); font-size: 17px; font-weight: 600; color: var(--ink);
  margin: 0; display: flex; align-items: center; gap: 8px; letter-spacing: 0.01em;
}
.panel-title--upper { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 14px; }
.panel-sub { font-size: 13px; color: var(--ink-3); margin: 3px 0 0; }

/* Pill toggle ------------------------------------------------ */
.pill-toggle { display: inline-flex; gap: 4px; }
.pill-toggle button, .pill-toggle a {
  border: none; background: transparent; height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; color: var(--ink-3); font-weight: 600;
  cursor: pointer; transition: color 0.12s, background 0.12s; text-decoration: none;
  display: inline-flex; align-items: center;
}
.pill-toggle button:hover { color: var(--ink); }
.pill-toggle button.active, .pill-toggle a.active { color: var(--accent); }

/* Tags ------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; height: 24px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1;
  background: var(--tag-neutral-bg); color: var(--tag-neutral-dot); white-space: nowrap;
}
.tag--accent { background: var(--tag-accent-bg); color: var(--tag-accent-dot); }
.tag--sage   { background: var(--tag-sage-bg);   color: var(--tag-sage-dot); }
.tag--brick  { background: var(--tag-brick-bg);  color: var(--tag-brick-dot); }
.tag--amber  { background: var(--tag-amber-bg);  color: var(--tag-amber-dot); }
.tag--running{ background: var(--tag-running-bg);color: var(--tag-running-dot); }
.tag--neutral{ background: var(--tag-neutral-bg);color: var(--tag-neutral-dot); }
.tag--mono { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.02em; }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Buttons (≈1.2× the previous sizing) ------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; border-radius: 11px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--sub-panel); color: var(--ink);
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.06s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn img, .btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); color: #ffffff; border-color: transparent; font-weight: 700; }
.btn--primary:hover { color: #ffffff; }
.btn--primary img, .btn--primary svg { filter: brightness(0) invert(1); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--sub-panel); color: var(--ink); }
.btn--secondary:hover { background: var(--row-hover); border-color: var(--line-strong); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn--ghost:hover { background: var(--row-hover); color: var(--ink); }
.btn--danger { background: var(--st-error-bg); color: var(--st-error); border-color: transparent; }
.btn--danger:hover { background: rgba(255,107,107,0.28); }
.btn--sm { height: 37px; padding: 0 15px; font-size: 14px; }
.btn--lg { height: 52px; padding: 0 26px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; }
.btn--dashed { border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-3); }
.btn--dashed:hover { background: var(--row-hover); color: var(--ink-2); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-3);
}
.icon-btn:hover { background: var(--row-hover); color: var(--ink); }
.icon-btn img, .icon-btn svg { width: 18px; height: 18px; }

/* Loading spinner (htmx indicator) */
.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: currentColor;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.htmx-request .indicator-idle { display: none; }

/* Inputs ----------------------------------------------------- */
.input, .select {
  display: block; width: 100%; height: 42px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-input);
  background: rgba(0,0,0,0.4); color: var(--ink);
  font-family: var(--f-ui); font-size: 15px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--ink-4); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input--mono { font-family: var(--f-mono); }
.select option { background: var(--panel-solid); color: var(--ink); }

.pwd-wrap { display: flex; gap: 8px; align-items: center; }
.pwd-wrap .input { flex: 1; min-width: 0; }

.field { display: block; }
.field-label {
  font-family: var(--f-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 7px; display: block;
}

/* Page header ------------------------------------------------ */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.page-header h1 { font-family: var(--f-display); font-size: 26px; font-weight: 700; margin: 0; color: var(--ink); }
.page-header__crumb { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* Search ----------------------------------------------------- */
.search { position: relative; display: flex; align-items: center; }
.search img, .search svg { position: absolute; left: 12px; width: 16px; height: 16px; opacity: 0.6; pointer-events: none; }
.search .input { padding-left: 38px; }

/* KPIs ------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi__label { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.kpi__value { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 32px; font-weight: 700; color: var(--ink); line-height: 1; letter-spacing: -0.02em; }

/* Tags / status pills helpers ------------------------------- */
.live-dots { display: inline-flex; gap: 3px; align-items: center; }
.live-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.live-dots span:nth-child(2) { animation-delay: 0.15s; }
.live-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Empty states ---------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 16px; text-align: center; color: var(--ink-3); }
.empty__icon { width: 40px; height: 40px; opacity: 0.5; margin-bottom: 10px; }
.empty__title { font-size: 15px; font-weight: 600; color: var(--ink-2); margin: 0; }
.empty__body { font-size: 13px; color: var(--ink-4); margin: 4px 0 0; max-width: 260px; }

/* Masked SVG icon (recolours the original Matflixx symbols by status) */
.mask-ic {
  display: inline-block; width: 22px; height: 22px;
  background-color: currentColor;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: contain; mask-size: contain;
}

/* Pipeline stage (icon + status bar) ------------------------ */
.pipeline { display: inline-flex; align-items: flex-start; gap: 14px; }
.stage-col {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.stage-ic { color: var(--st-idle); transition: color 0.15s, transform 0.1s; }
.stage-col:hover .stage-ic { transform: translateY(-1px); }
.stage-bar { width: 34px; height: 3px; border-radius: 999px; background: var(--st-idle); opacity: 0.9; }
.stage-label { font-family: var(--f-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }

.tone-done    .stage-ic, .tone-done.stage-ic       { color: var(--st-done); }
.tone-done    .stage-bar, .tone-done .stage-bar    { background: var(--st-done); }
.tone-running .stage-ic { color: var(--st-running); }
.tone-running .stage-bar { background: var(--st-running); }
.tone-error   .stage-ic { color: var(--st-error); }
.tone-error   .stage-bar { background: var(--st-error); }
.tone-wait    .stage-ic { color: var(--st-wait); }
.tone-wait    .stage-bar { background: var(--st-wait); }
.tone-idle    .stage-ic { color: var(--st-idle); }
.tone-idle    .stage-bar { background: var(--st-idle); }

/* Modal ------------------------------------------------------ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal {
  background: var(--glass-bg); backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--glass-edge); border-radius: 16px; box-shadow: var(--shadow-modal);
  width: 100%; max-width: 480px; padding: 24px;
}
.modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal__title { font-family: var(--f-display); font-size: 21px; font-weight: 700; margin: 0; }
.modal__body { display: flex; flex-direction: column; gap: 14px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Utility ---------------------------------------------------- */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--ink-3); }
.divider { height: 1px; background: var(--line-faint); margin: 14px 0; border: none; }
.divider--dashed { border-top: 1px dashed var(--line); height: 0; background: none; margin: 14px 0; }

/* Toast ------------------------------------------------------ */
#toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--glass-bg); backdrop-filter: blur(16px); border: 1px solid var(--glass-edge); color: var(--ink); border-radius: 10px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow-modal); animation: toast-in 0.18s ease; max-width: 340px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.htmx-request.btn { opacity: 0.65; pointer-events: none; }

/* Parser logo fallback: when no SVG exists, show a colored badge with the
   first three letters of the parser name. White text on accent, matching the
   primary button look rather than the soft-blue avatar style. */
.parser-logo--fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent, #2563eb);
  color: #ffffff;
  font-weight: 700; letter-spacing: 0.02em;
}
.parser-logo__initials {
  font-family: var(--f-mono, monospace);
  font-size: 22px; line-height: 1;
}

