/* ============================================================================
   KITH — Upload flow (Login + Upload) component layer.
   Bespoke screens built on the core tokens (colors_and_type.css).
   Visual language: flat solid fills, hairline borders, sharp radii,
   single gold accent, Clash Display headings / Inter body / mono for data.
   ============================================================================ */

.app * { box-sizing: border-box; }
.app {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -0.011em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.app button, .app input, .app textarea, .app select { font: inherit; color: inherit; }
.app :focus-visible { outline: 2px solid color-mix(in oklab, var(--accent) 60%, transparent); outline-offset: 2px; }
.app ::selection { background: color-mix(in oklab, var(--accent) 26%, transparent); }
.app a { color: var(--accent-strong); text-decoration: none; }
.app a:hover { color: var(--accent); }

/* faint instrument-panel dot grid backdrop */
.app-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in oklab, var(--ink) 4%, transparent) 1px, transparent 1.5px) 0 0 / 30px 30px;
}

/* --- shared chrome -------------------------------------------------------- */
.app-chrome {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 40px);
}
.app-brand { display: flex; align-items: center; gap: 11px; }
.app-mark { width: 34px; height: 34px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.app-mark svg { width: 21px; height: 21px; }
.app-brand .bn { display: block; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.05; }
.app-brand .bs { display: block; margin-top: 1px; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }

/* theme toggle (matches kit) */
.app-theme {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-soft);
  color: var(--ink-2); padding: 5px 12px 5px 6px; font-size: 12px; font-weight: 800;
}
.app-theme .track { position: relative; width: 40px; height: 22px; border-radius: 4px; background: color-mix(in oklab, var(--accent) 14%, var(--panel)); border: 1px solid var(--line); }
.app-theme .thumb { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; color: var(--accent); box-shadow: var(--shadow-sm); transition: transform .34s cubic-bezier(.22,1,.36,1); }
.app-theme .thumb svg { width: 11px; height: 11px; }
html[data-theme="dark"] .app-theme .thumb { transform: translateX(18px); }

.app-label { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }

/* --- buttons -------------------------------------------------------------- */
.btn {
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 42px; padding: 11px 16px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 13px; font-weight: 700; transition: all .16s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.primary:disabled { background: color-mix(in oklab, var(--accent) 32%, var(--panel)); border-color: transparent; color: color-mix(in oklab, var(--accent-ink) 50%, transparent); cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }

/* --- login ---------------------------------------------------------------- */
.auth-wrap { position: relative; z-index: 2; display: grid; place-items: center; padding: 2vh 20px 8vh; min-height: calc(100vh - 72px); }
.auth-card {
  width: 100%; max-width: 408px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 34px 34px 22px; animation: rise .4s cubic-bezier(.22,1,.36,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .glyph { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; }
.auth-head .glyph svg { width: 26px; height: 26px; }
.auth-head h1 { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -0.01em; }
.auth-head p { margin-top: 7px; color: var(--ink-2); font-size: 13px; }

.oauth-row { display: grid; gap: 10px; }
.oauth-btn {
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 42px; padding: 10px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 13px; font-weight: 600; transition: all .15s ease;
}
.oauth-btn:hover { background: var(--panel-soft); border-color: var(--ink-3); }
.oauth-btn svg, .oauth-btn img { width: 18px; height: 18px; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink-3); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-divider span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-2); display: flex; justify-content: space-between; white-space: nowrap; }
.field label a { font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; min-height: 42px; padding: 11px 13px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent); }
.input.has-btn { padding-right: 44px; }
.input-eye { position: absolute; right: 6px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: 6px; }
.input-eye:hover { color: var(--ink-2); }

.auth-foot { margin-top: 18px; text-align: center; color: var(--ink-2); font-size: 13px; }
.secured { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--ink-3); font-size: 11px; font-weight: 600; }
.secured svg { width: 13px; height: 13px; }
.secured b { color: var(--ink-2); font-weight: 700; }

/* --- upload --------------------------------------------------------------- */
.up-main { position: relative; z-index: 2; max-width: 720px; margin: 0 auto; padding: 8px clamp(18px,4vw,40px) 100px; }
.up-intro { margin: 18px 0 26px; }
.up-intro h1 { font-family: var(--font-display); font-size: clamp(24px, 3vw, 30px); font-weight: 600; letter-spacing: -0.01em; }
.up-intro p { margin-top: 9px; color: var(--ink-2); font-size: 14px; max-width: 56ch; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.step { display: inline-flex; align-items: center; gap: 9px; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink-3); }
.step.active { color: var(--ink); }
.step.active .dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step.done .dot { background: color-mix(in oklab, var(--accent) 14%, var(--panel)); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); color: var(--accent-strong); }
.step.done { color: var(--ink-2); }
.step-line { width: 26px; height: 1px; background: var(--line); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.card-head p { margin-top: 3px; color: var(--ink-2); font-size: 12.5px; }
.card-body { padding: 22px; }

/* source tabs */
.src-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--panel-soft); border: 1px solid var(--line); }
.src-tab { border: 0; border-radius: 5px; background: transparent; padding: 8px 15px; cursor: pointer; color: var(--ink-3); font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.src-tab svg { width: 16px; height: 16px; }
.src-tab:hover { color: var(--ink); }
.src-tab.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }

/* dropzone */
.dropzone {
  border: 1.5px dashed color-mix(in oklab, var(--ink-3) 45%, var(--line)); border-radius: var(--r-card);
  background: var(--panel-soft); padding: 44px 28px; text-align: center; cursor: pointer;
  transition: border-color .18s, background-color .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 6%, var(--panel-soft)); }
.dropzone .dz-icon { width: 52px; height: 52px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 16px; color: var(--accent); }
.dropzone .dz-icon svg { width: 26px; height: 26px; }
.dropzone h3 { font-size: 15px; font-weight: 700; }
.dropzone p { margin-top: 6px; color: var(--ink-3); font-size: 12.5px; }
.dropzone .browse { color: var(--accent-strong); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.dz-formats { margin-top: 16px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.dz-formats span { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line); background: var(--panel); border-radius: 4px; padding: 3px 7px; }

/* paste */
.paste-area {
  width: 100%; min-height: 190px; resize: vertical; padding: 14px 15px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; letter-spacing: 0;
}
.paste-area:focus { outline: none; border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent); }

/* selected file row */
.file-row { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--panel-soft); }
.file-row .fi { width: 44px; height: 44px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent); flex: 0 0 auto; }
.file-row .fi svg { width: 22px; height: 22px; }
.file-row .meta { min-width: 0; flex: 1; }
.file-row .meta b { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta span { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.file-row .x { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 6px; border-radius: 6px; }
.file-row .x:hover { color: var(--danger); background: color-mix(in oklab, var(--danger) 8%, transparent); }

/* config rows */
.cfg { margin-top: 18px; display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; }
.cfg-row + .cfg-row { border-top: 1px solid var(--line-2); }
.cfg-row .k { font-size: 13px; font-weight: 600; color: var(--ink); }
.cfg-row .k small { display: block; font-weight: 500; color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.cfg-row .v { display: flex; align-items: center; gap: 8px; }
.select {
  min-height: 36px; padding: 7px 32px 7px 12px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.toggle { position: relative; width: 40px; height: 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-soft); cursor: pointer; transition: background .18s, border-color .18s; flex: 0 0 auto; }
.toggle i { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: transform .2s, background .2s; }
.toggle.on { background: color-mix(in oklab, var(--accent) 22%, var(--panel)); border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); }
.toggle.on i { transform: translateX(18px); background: var(--accent); }

.card-foot { padding: 16px 22px; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); }
.card-foot .note { color: var(--ink-3); font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.card-foot .note svg { width: 14px; height: 14px; }

/* preview table */
.prev-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12.5px; }
.prev-table th, .prev-table td { min-width: 128px; max-width: 220px; }
.prev-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel); color: var(--ink-3); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.prev-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prev-table tr:last-child td { border-bottom: 0; }
.prev-wrap {
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: auto; max-height: min(360px, 55vh); margin-top: 14px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.prev-cap { margin-top: 10px; color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; }

.people-select { margin-top: 18px; }
.people-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.people-count { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.people-count b { color: var(--ink); font-family: var(--font-mono); }
.people-count span { color: var(--ink-3); }
.people-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini-btn {
  min-height: 30px; padding: 6px 9px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-2); cursor: pointer; font-size: 11px; font-weight: 800;
}
.mini-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.people-controls { display: grid; grid-template-columns: minmax(0, 1fr) 116px; gap: 10px; }
.people-controls .input { min-height: 36px; font-size: 12.5px; }
.cap-input { font-family: var(--font-mono); }
.people-wrap { max-height: min(420px, 58vh); }
.people-table { width: max-content; min-width: 100%; table-layout: auto; }
.people-table th, .people-table td { min-width: 136px; max-width: 220px; }
.people-table thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); }
.people-table tr.selected td { background: color-mix(in oklab, var(--accent) 5%, transparent); color: var(--ink); }
.people-table tr.selected .pick-col { background: color-mix(in oklab, var(--accent) 8%, var(--panel)); }
.pick-col {
  position: sticky; left: 0; z-index: 3; width: 38px; min-width: 38px !important; max-width: 38px !important;
  text-align: center !important; padding-left: 10px !important; padding-right: 10px !important; background: var(--panel);
}
.people-table thead .pick-col { z-index: 4; }
.pick-col input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

@media (max-width: 560px) {
  .people-toolbar { align-items: flex-start; flex-direction: column; }
  .people-actions { justify-content: flex-start; }
  .people-controls { grid-template-columns: 1fr; }
  .prev-table th, .prev-table td { min-width: 116px; max-width: 200px; }
  .people-table th, .people-table td { min-width: 124px; }
  .pick-col { min-width: 38px !important; max-width: 38px !important; }
}

/* --- ingest progress ------------------------------------------------------ */
.ingest-stages { display: grid; gap: 10px; margin-top: 18px; }
.ingest-stage { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 14px; padding: 13px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); transition: border-color .2s, background .2s; }
.ingest-stage .si { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel-soft); color: var(--ink-3); }
.ingest-stage .si svg { width: 18px; height: 18px; }
.ingest-stage .sb b { font-size: 13.5px; font-weight: 700; display: block; }
.ingest-stage .sb span { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.ingest-stage .st { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink-3); display: inline-flex; align-items: center; gap: 7px; }
.ingest-stage.run { border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); background: color-mix(in oklab, var(--accent) 5%, var(--panel)); }
.ingest-stage.run .si { background: color-mix(in oklab, var(--accent) 12%, var(--panel)); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); color: var(--accent); }
.ingest-stage.run .st { color: var(--accent-strong); }
.ingest-stage.done .si { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 36%, var(--line)); background: color-mix(in oklab, var(--ok) 9%, var(--panel)); }
.ingest-stage.done .st { color: var(--ok); }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid color-mix(in oklab, var(--accent) 30%, transparent); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ingest-bar { height: 8px; border-radius: 999px; background: var(--panel-soft); border: 1px solid var(--line); overflow: hidden; margin: 4px 0 2px; }
.ingest-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

/* live log */
.log { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-soft); max-height: 200px; overflow: auto; }
.log-row { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line-2); font-size: 12px; animation: logfade .25s ease both; }
.log-row:last-child { border-bottom: 0; }
.log-row .t { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); }
.log-row .s { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.log-row .m { color: var(--ink-2); }
.log-row.ok .m { color: var(--ink); }
@keyframes logfade { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* --- success -------------------------------------------------------------- */
.done-wrap { position: relative; z-index: 2; display: grid; place-items: center; padding: 4vh 20px 10vh; min-height: calc(100vh - 72px); }
.done-card { width: 100%; max-width: 520px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 40px 36px 30px; animation: rise .4s cubic-bezier(.22,1,.36,1) both; }
.done-card .check { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 20px; display: grid; place-items: center; background: color-mix(in oklab, var(--ok) 12%, var(--panel)); border: 1px solid color-mix(in oklab, var(--ok) 40%, var(--line)); color: var(--ok); animation: pop .42s cubic-bezier(.22,1.4,.4,1) both; }
.done-card .check svg { width: 32px; height: 32px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.done-card h1 { font-family: var(--font-display); font-size: 25px; font-weight: 600; letter-spacing: -0.01em; }
.done-card p { margin-top: 9px; color: var(--ink-2); font-size: 14px; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 26px 0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.done-stat { padding: 16px 12px; }
.done-stat + .done-stat { border-left: 1px solid var(--line-2); }
.done-stat .v { font-family: var(--font-mono); font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.done-stat .l { margin-top: 5px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.done-actions { display: grid; gap: 10px; }
.live-link {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 18px; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  font-size: 14px; font-weight: 800; transition: background .16s; white-space: nowrap;
}
.live-link:hover { background: var(--accent-strong); color: var(--accent-ink); }
.live-link svg { width: 18px; height: 18px; }
.live-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-ink); box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent-ink) 50%, transparent); animation: lp 1.6s ease-out infinite; }
@keyframes lp { 0%{box-shadow:0 0 0 0 color-mix(in oklab,var(--accent-ink) 45%,transparent);} 70%{box-shadow:0 0 0 7px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }
.url-hint { margin-top: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); word-break: break-all; }
