/* Curagenex brand theme — deep sage-green gradient page background (unchanged from
   the original design), with "boxes" (panels, tree items, file rows, toasts, modals,
   inputs, buttons) rendered as white glass floating on top.

   --text/--dim/--heading/--accent default to LIGHT (for text sitting directly on the
   green background: topbar, login hero, footer). The box selectors below locally
   redefine those same custom properties to DARK values — since CSS variables
   inherit, every existing `color: var(--text)` etc. rule automatically picks up the
   right shade depending on whether it's inside a white box or on the green page
   background, with no per-rule special-casing needed. One theme; no light/dark toggle. */

:root {
  --bg-0: #2e463f;
  --bg-1: #587569;
  --panel: rgba(255, 255, 255, 0.62);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(46, 70, 63, 0.16);
  --text: #e9efec;
  --dim: #b4c8bf;
  --heading: #ffffff;
  --accent: #cfe0d8;
  --btn-bg: #e6eae7;
  --btn-text: #24363f;
  --ok: #2f8f57;
  --ok-bg: rgba(47, 143, 87, 0.12);
  --warn: #b8873a;
  --warn-bg: rgba(184, 135, 58, 0.12);
  --danger: #c1594d;
  --danger-bg: rgba(193, 89, 77, 0.12);
  --radius: 14px;
  --ease: 200ms ease;
}

/* "White glass" boxes: opaque-ish white/blur surfaces, so their own content needs
   dark text/headings/accents regardless of the green page background behind them. */
.panel, .tree-node, .file-row, .toast, .modal, input, .btn {
  --text: #26362f;
  --dim: #64766c;
  --heading: #1c2b24;
  --accent: #4c7361;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-0) 0%, #41594f 55%, var(--bg-1) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* faint molecular-network motif, fixed behind everything */
.motif { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5; }
.motif-net line { stroke: rgba(223, 234, 228, 0.16); stroke-width: 2; }
.motif-net circle { fill: rgba(223, 234, 228, 0.13); }

.hidden { display: none !important; }
.dim { color: var(--dim); }
a { color: var(--accent); }

/* ---------- top bar ---------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.4rem 2.2rem;
}
.wordmark {
  font-weight: 800; font-size: 1.35rem; letter-spacing: 0.38em;
  text-transform: uppercase; color: var(--heading);
}
.topbar-right { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; }

/* ---------- views ---------- */
.view {
  position: relative; z-index: 1; flex: 1;
  animation: fade-up 320ms ease both;
  padding: 0 2.2rem 2rem;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hero {
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  line-height: 1.08; font-weight: 700; color: var(--heading);
  margin: 0 0 0.8rem;
}
.lead { font-size: 1.02rem; margin: 0 0 1.6rem; }

/* ---------- auth card ---------- */
.auth-card { max-width: 430px; margin: 8vh auto 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--dim); }
input {
  padding: 0.65rem 0.75rem; font-size: 0.95rem; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 9px;
  transition: border-color var(--ease), background var(--ease);
}
input:focus { outline: none; border-color: var(--accent); background: var(--panel-strong); }
input:disabled { opacity: 0.55; }

/* ---------- buttons ---------- */
.btn {
  cursor: pointer; font-size: 0.9rem; font-weight: 600;
  padding: 0.6rem 1.15rem; border-radius: 9px;
  color: var(--text); background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  transition: transform var(--ease), background var(--ease), border-color var(--ease), opacity var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: #ffffff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(193, 89, 77, 0.4); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.8rem; }
.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-size: 0.85rem; text-decoration: underline;
}

/* ---------- app layout ---------- */
.layout {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.6rem;
  max-width: 1180px; margin: 0 auto; width: 100%;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.sidebar { display: flex; flex-direction: column; gap: 0.9rem; }
.side-title {
  font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim); margin: 0.4rem 0 0; font-weight: 600;
}

/* ---------- sample tree ---------- */
.tree { display: flex; flex-direction: column; gap: 0.45rem; }
.tree-node {
  border: 1px solid var(--panel-border); border-radius: 11px; background: var(--panel);
  backdrop-filter: blur(6px);
  overflow: hidden; transition: border-color var(--ease), background var(--ease);
  color: var(--text);
}
.tree-node.active { border-color: var(--accent); background: var(--panel-strong); }
.tree-head {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.6rem 0.75rem; cursor: pointer; background: none; border: none;
  color: var(--text); text-align: left; font-size: 0.9rem;
}
.tree-head .chev { transition: transform var(--ease); font-size: 0.7rem; color: var(--dim); }
.tree-node.open .chev { transform: rotate(90deg); }
.tree-head .t-id { font-weight: 700; }
.tree-head .t-sub { color: var(--dim); font-size: 0.8rem; margin-left: auto; padding-left: 0.5rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.tree-files { max-height: 0; overflow: hidden; transition: max-height 260ms ease; }
.tree-node.open .tree-files { max-height: 400px; }
.tree-file {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 1.9rem; font-size: 0.8rem; color: var(--dim);
}
.tree-file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty { padding: 0.8rem; font-size: 0.85rem; color: var(--dim); }

/* ---------- status chips ---------- */
.chip {
  border-radius: 999px; padding: 0.14rem 0.6rem; font-size: 0.7rem; font-weight: 700;
  white-space: nowrap; letter-spacing: 0.02em;
}
.chip.uploaded { background: var(--ok-bg); color: var(--ok); }
.chip.uploading { background: var(--warn-bg); color: var(--warn); }
.chip.partial { background: var(--warn-bg); color: var(--warn); }
.chip.aborted, .chip.failed { background: var(--danger-bg); color: var(--danger); }
.chip.none, .chip.ready { background: var(--panel-strong); color: var(--dim); }
.chip.in_analysis { background: rgba(58, 105, 138, 0.14); color: #3a698a; }

/* ---------- main panel ---------- */
/* No entrance animation here on purpose: #panel-host's innerHTML is replaced on
   every background poll tick (uploaded_bytes changes live while any upload is in
   progress, even on a sample the user isn't looking at), and a CSS animation on
   .panel would retrigger on every one of those replacements — a visible flicker
   even though nothing the user is looking at actually changed. */
.panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 1.6rem 1.8rem;
  backdrop-filter: blur(6px);
  /* `color` is an inherited *value*, not a live var() re-evaluation per descendant —
     any text in here without its own explicit `color: var(--text)` (e.g. the bare
     subject/project values next to .sample-meta .k labels) needs this so it inherits
     the box's dark scope instead of leaking the light on-background body color. */
  color: var(--text);
}
.panel + .panel { margin-top: 1.1rem; }

.sample-hero { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.sample-hero .grow { flex: 1; min-width: 220px; }
.sample-id {
  font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800; color: var(--heading);
  margin: 0; line-height: 1.1; word-break: break-all;
}
.sample-meta { margin: 0.45rem 0 0; font-size: 1.02rem; }
.sample-meta .k { color: var(--dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; display: block; }
.sample-meta-row { display: flex; gap: 2.2rem; flex-wrap: wrap; margin-top: 0.5rem; }
.hero-actions { display: flex; gap: 0.5rem; }

/* guided steps */
.step { margin-top: 1.4rem; }
.step-label {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem;
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); font-weight: 700;
}
.step-label .n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--panel-strong); border: 1px solid var(--panel-border);
  color: var(--accent); font-size: 0.75rem;
}

/* dropzone */
.dropzone {
  border: 2px dashed var(--panel-border); border-radius: var(--radius);
  padding: 2.2rem 1rem; text-align: center; color: var(--dim);
  cursor: pointer; transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--panel-strong); color: var(--text); }
.dropzone .big { font-size: 1.05rem; color: var(--text); margin-bottom: 0.3rem; }

/* file rows */
.file-list { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.9rem; }
.file-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0.9rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--panel-border);
  border-radius: 11px; background: var(--panel);
  backdrop-filter: blur(6px);
  transition: border-color var(--ease);
  color: var(--text);
}
.file-row .f-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .f-side { display: flex; align-items: center; gap: 0.55rem; justify-content: flex-end; }
.file-row .f-info { grid-column: 1 / -1; font-size: 0.8rem; color: var(--dim);
  font-variant-numeric: tabular-nums; display: flex; gap: 1rem; flex-wrap: wrap; }
.file-row.failed { border-color: rgba(193, 89, 77, 0.5); }

.bar { grid-column: 1 / -1; height: 7px; border-radius: 5px; background: rgba(0, 0, 0, 0.25); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), #82a892); transition: width 400ms ease; }

.resume-note {
  grid-column: 1 / -1; font-size: 0.82rem; color: var(--warn);
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
}

/* forms in panel */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.1rem; }
.hint { font-size: 0.75rem; color: var(--dim); margin-top: 0.25rem; }

.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--dim); }
.empty-state .hero { font-size: 1.6rem; }

.analysis-note { text-align: center; padding: 1.2rem 1rem 0.4rem; }
.analysis-note .big { font-size: 1.05rem; color: var(--text); margin-bottom: 0.3rem; font-weight: 600; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 1.2rem; bottom: 1.2rem; display: flex; flex-direction: column;
  gap: 0.55rem; z-index: 50; max-width: 380px; }
.toast {
  padding: 0.75rem 1rem; border-radius: 11px; font-size: 0.9rem;
  background: var(--panel-strong); border: 1px solid var(--panel-border); color: var(--text);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 22px rgba(14, 24, 20, 0.3);
  animation: fade-up 220ms ease both;
}
.toast.ok { border-color: rgba(47, 143, 87, 0.4); }
.toast.err { border-color: rgba(193, 89, 77, 0.5); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(28, 43, 36, 0.35); z-index: 40;
  display: flex; align-items: center; justify-content: center;
  animation: fade-up 180ms ease both;
}
.modal {
  background: var(--panel-strong); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(10px);
  padding: 1.5rem 1.7rem; max-width: 420px; width: calc(100% - 2rem);
  box-shadow: 0 20px 50px rgba(14, 24, 20, 0.35);
  color: var(--text);
}
.modal h3 { margin: 0 0 0.6rem; color: var(--heading); }

.foot { position: relative; z-index: 1; text-align: center; padding: 1.2rem; font-size: 0.78rem; }
