:root {
  --bg: #070b12;
  --panel: #0e1624;
  --card: #121c2c;
  --line: #1e2d44;
  --text: #e8eef8;
  --muted: #8ea0b8;
  --cyan: #5eead4;
  --neon: #34f5c5;
  --blue: #5b8cff;
  --warn: #f5c542;
  --danger: #ff6b8a;
  --ok: #3dff9a;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Sora", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #123055 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

.shell { display: grid; grid-template-columns: 76px 1fr; height: 100%; }

.rail {
  border-right: 1px solid var(--line);
  background: #080d16;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 28px;
}
.brand { color: var(--cyan); }
.rail nav { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.nav {
  width: 54px; height: 54px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 16px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.nav span { font-size: 16px; line-height: 1; }
.nav small { font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }
.nav.active, .nav:hover {
  color: var(--text);
  background: #152238;
  border-color: #234063;
}

main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  height: 100%;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px 8px;
}
.kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 { margin: 2px 0 0; font-size: 28px; font-weight: 650; }
h2 { margin: 0 0 8px; font-size: 22px; }
.top-actions { display: flex; gap: 10px; align-items: center; }

.online {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .12em; color: var(--ok);
}
.online i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.toggle input { accent-color: var(--cyan); }

.btn {
  border: 1px solid var(--line);
  background: #152033;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { border-color: #3a5c88; }
.btn.ghost { background: transparent; color: #ff8aa3; border-color: #5a2a38; }
.btn.accent { background: linear-gradient(180deg, #2a4d8a, #1c355f); }
.btn.primary { background: linear-gradient(180deg, #2dd4bf, #0f766e); color: #04221e; border: 0; min-width: 140px; }
.btn.slim { padding: 8px 12px; font-size: 13px; }
.btn.slim input { display: none; }

.view { padding: 8px 28px 18px; overflow: auto; }
.hidden { display: none; }

.metrics {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(420px, 1fr);
  gap: 14px;
  align-items: stretch;
}
.card {
  background: linear-gradient(180deg, #132033, #0d1624);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
}
.label {
  margin: 0;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.value { margin: 6px 0 4px; font-size: 44px; font-weight: 720; letter-spacing: -0.03em; }
.value.neon { color: var(--neon); }
.value.cyan { color: #7dd3fc; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }

.files-card { display: flex; flex-direction: column; justify-content: center; }

.ticket-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(52, 245, 197, 0.28);
  background: #0a1218;
}
.ticket-card.is-pass { border-color: rgba(61, 255, 154, 0.4); }
.ticket-card.is-blocked { border-color: rgba(255, 107, 138, 0.4); }
.ticket-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.ticket-card-head .eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ticket-card-head strong {
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--ok);
}
.ticket-card.is-blocked .ticket-card-head strong { color: var(--danger); }
.ticket-card:not(.is-pass):not(.is-blocked) .ticket-card-head strong { color: var(--cyan); }
.ticket-mark::after { content: ""; }
.ticket-card.is-pass .ticket-mark::after { content: "✓"; color: var(--ok); font-size: 20px; }
.ticket-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.ticket-card-grid > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.ticket-card-grid > div:nth-child(3n) { border-right: 0; }
.ticket-card-grid > div:nth-last-child(-n + 3) { border-bottom: 0; }
.ticket-card-grid span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.ticket-card-grid strong {
  color: var(--text);
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.ticket-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.ticket-card-foot span { min-width: 0; }

.progress-wrap { margin: 16px 0 14px; }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.bar {
  position: relative;
  height: 6px;
  background: #1a283c;
  border-radius: 99px;
  overflow: visible;
}
.bar i {
  display: block; height: 100%; width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  transition: width .18s ease;
  overflow: hidden;
}
.bar.busy i {
  background: linear-gradient(90deg, #134, var(--cyan), var(--blue), var(--cyan), #134);
  background-size: 220% 100%;
  animation: bar-shimmer 1.1s linear infinite;
}
.scan-cursor {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan), 0 0 22px var(--blue);
  left: 0;
  z-index: 2;
  pointer-events: none;
  transition: left .15s linear;
}
.bar.busy .scan-cursor {
  animation: cursor-glow 0.9s ease-in-out infinite;
}
@keyframes bar-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes cursor-glow {
  0%, 100% { box-shadow: 0 0 8px var(--cyan); transform: translateY(-50%) scale(1); }
  50% { box-shadow: 0 0 22px var(--neon), 0 0 40px var(--cyan); transform: translateY(-50%) scale(1.15); }
}
.scan-cursor { transform: translateY(-50%); margin-top: 0; }

#folder-path.scanning {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(94, 234, 212, 0.4);
  animation: path-pulse 1.15s ease-in-out infinite;
}
#folder-path.ready {
  border-color: var(--ok);
  box-shadow: 0 0 14px rgba(61, 255, 154, 0.45);
}
@keyframes path-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(94, 234, 212, 0.25); }
  50% { box-shadow: 0 0 22px rgba(94, 234, 212, 0.7); }
}
body.busy, body.busy * { cursor: progress !important; }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.work { display: grid; grid-template-columns: 1.4fr .8fr; gap: 14px; }
.drop {
  min-height: 210px;
  border: 1.5px dashed #335577;
  border-radius: 20px;
  background: rgba(20, 40, 70, 0.18);
  display: grid; place-items: center;
}
.drop:focus, .drop.over { border-color: var(--cyan); background: rgba(34, 211, 238, 0.06); outline: none; }
.drop-inner { text-align: center; padding: 18px; width: min(520px, 92%); }
.drop-title { margin: 0; font-size: 20px; }
.drop-sub { color: var(--muted); margin: 8px 0 16px; }
.drop-actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
#folder-path {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}
.drop-hint { margin: 8px 0 0; font-size: 12px; color: var(--cyan); min-height: 1.2em; }

.unsupported {
  border: 1px solid #5a4a18;
  background: #1a1608;
  border-radius: 18px;
  padding: 14px;
}
.unsupported[hidden], [hidden] { display: none !important; }
.warn-title { margin: 0; color: var(--warn); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 12px; }
.warn-sub { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #2a2412;
  border: 1px solid #6a5a22;
  color: #ffe9a8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.term {
  margin-top: 14px;
  background: #070b10;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.term-head {
  padding: 8px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.term-body {
  margin: 0;
  padding: 10px 12px 12px;
  max-height: 260px;
  overflow: auto;
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: #b7c8dc;
  white-space: pre-wrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
}
.hint { color: var(--muted); margin-top: 0; }
.edition-pick { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 20px; }
.edition-pick label { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.edition-pick input { accent-color: var(--cyan); }
textarea, select, input[type="number"], input[type="text"] {
  font: inherit; color: var(--text);
}
textarea {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.row.single { grid-template-columns: auto; justify-content: start; }
.brief-source {
  min-height: 1.2em;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--cyan);
}
.pack-sum {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0 16px;
}
.pack-sum article {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.pack-sum .value { font-size: 28px; margin: 4px 0 0; }
.pack-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow: auto;
  margin-bottom: 14px;
}
.pack-file {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0b1220;
  border: 1px solid var(--line);
}
.pack-file.off { opacity: 0.42; }
.pack-file label { color: var(--text); font-size: 13px; cursor: pointer; }
.pack-file .path { color: var(--muted); font-size: 11px; margin-top: 2px; }
.pack-file .preview {
  color: #b7c8dc;
  font-size: 12.5px;
  line-height: 1.4;
  margin-top: 4px;
}
.pack-file .tok {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  white-space: nowrap;
}
.pack-cert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.45;
  color: #c9d7e8;
}
.pack-cert strong { color: var(--text); }
.pack-cert .ok { color: var(--ok); }
.pack-cert .warn { color: var(--warn); }
.pack-cert .fail { color: var(--danger); }
.row label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
select, input[type="number"] {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.legal { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 18px; }
pre {
  white-space: pre-wrap;
  background: #0b1220;
  border-radius: 12px;
  padding: 14px;
  max-height: 52vh;
  overflow: auto;
  font-size: 12px;
}

.context-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 28px 18px;
  border-top: 1px solid var(--line);
  background: #0a111c;
}
#context-mini {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #123; color: white; padding: 12px 16px;
  border-radius: 12px; border: 1px solid #345;
}

@media (max-width: 980px) {
  .metrics, .work, .row, .pack-sum { grid-template-columns: 1fr; }
  .value { font-size: 34px; }
}
