:root {
  --bg:          #08090a;
  --surface:     #0d0f0b;
  --surface-2:   #111410;
  --ink:         #dfe1d8;
  --muted:       #575c50;
  --line:        #1a1d17;
  --line-strong: #262b20;
  --accent:      #d4a843;
  --accent-dim:  rgba(212, 168, 67, 0.08);
  --accent-glow: rgba(212, 168, 67, 0.18);
  --success:     #52c07a;
  --danger:      #d95446;
  --font:        "Azeret Mono", "Courier New", monospace;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, summary, a { font: inherit; }

/* ─── ATMOSPHERIC LAYERS ───────────────────────────── */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.04) 3px,
    rgba(0, 0, 0, 0.04) 4px
  );
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(212, 168, 67, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 168, 67, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 40%, transparent 100%);
}

/* ─── APP WRAPPER ──────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 36px 0 72px;
  animation: app-enter 0.45s ease both;
}

@keyframes app-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── TOPBAR ───────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 7px;
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.6vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
}

.title-sep {
  color: var(--accent);
  margin: 0 5px;
  font-weight: 300;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.sys-time {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ─── STATUS BADGE ─────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  transition: border-color 0.25s, background 0.25s;
}

.status-badge.is-busy {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.status-badge.is-busy .status-text { color: var(--accent); }

.status-badge.is-error { border-color: var(--danger); }
.status-badge.is-error .status-text { color: var(--danger); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: dot-pulse 2.8s ease infinite;
}

.status-badge.is-busy .status-dot {
  background: var(--accent);
  animation: dot-pulse 0.9s ease infinite;
}

.status-badge.is-error .status-dot {
  background: var(--danger);
  animation: none;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.25; transform: scale(0.7); }
}

/* ─── RULES / DIVIDERS ─────────────────────────────── */
.h-rule {
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--line-strong) 12%, var(--line-strong) 88%, transparent 100%);
  margin: 0 0 28px;
}

/* ─── EYEBROW / LABELS ─────────────────────────────── */
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ─── INTRO ────────────────────────────────────────── */
.intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 24px 0 28px;
  flex-wrap: wrap;
}

.intro-left {
  flex: 1;
  min-width: 260px;
}

.intro h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
  color: var(--ink);
  max-width: 34ch;
}

.intro-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding-bottom: 2px;
}

.tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0.8;
}

/* ─── MAIN LAYOUT ──────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line-strong);
}

.panel {
  background: var(--surface);
  padding: 28px 30px;
}

.form-panel {
  border-right: 1px solid var(--line-strong);
}

/* ─── PANEL HEADER ─────────────────────────────────── */
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}

.panel-head-wide { align-items: center; }

.result-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.panel-index {
  font-size: 3rem;
  font-weight: 300;
  font-style: italic;
  color: var(--line-strong);
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.panel h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

/* ─── FORM ─────────────────────────────────────────── */
.form-stack {
  display: grid;
  gap: 14px;
}

.dropzone {
  display: grid;
  gap: 8px;
  min-height: 172px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
  position: relative;
  overflow: hidden;
}

.dropzone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}

.dropzone:hover::after,
.dropzone.is-dragover::after {
  opacity: 1;
}

.dropzone-chip {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  width: fit-content;
  position: relative;
  z-index: 1;
}

.dropzone strong {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

.dropzone span:last-child {
  font-size: 0.76rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

/* ─── FIELDS ───────────────────────────────────────── */
.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.field input {
  height: 46px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  outline: none;
  border-radius: 0;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

.field input:focus {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.07);
}

/* ─── ADVANCED ─────────────────────────────────────── */
.advanced { display: grid; gap: 10px; }

.advanced summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  transition: color 0.15s;
  user-select: none;
}

.advanced summary:hover { color: var(--accent); }
.advanced summary::-webkit-details-marker { display: none; }
.compact-field { margin-top: 4px; }

/* ─── BUTTONS ──────────────────────────────────────── */
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 50px;
  padding: 0 20px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.primary-button {
  background: var(--accent);
  color: #08090a;
  border-color: var(--accent);
  width: 100%;
}

.primary-button:hover {
  background: #e0b84e;
  border-color: #e0b84e;
  box-shadow: 0 4px 20px rgba(212, 168, 67, 0.3);
  transform: translateY(-1px);
}

.primary-button:active { transform: translateY(0); box-shadow: none; }

.btn-sym {
  font-weight: 300;
  opacity: 0.5;
}

.secondary-button {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  height: 44px;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.secondary-button:hover .btn-sym { color: var(--accent); }

.primary-button:disabled,
.secondary-button.is-disabled {
  opacity: 0.28;
  pointer-events: none;
}

/* ─── HELPER / MESSAGES ────────────────────────────── */
.helper-text {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

.form-message {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  min-height: 1.2em;
  transition: color 0.2s;
}

.form-message.is-error   { color: var(--danger); }
.form-message.is-success { color: var(--success); }

/* ─── EMPTY STATE ──────────────────────────────────── */
.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  text-align: center;
}

.empty-inner { display: grid; gap: 8px; justify-items: center; }

.empty-cursor {
  display: block;
  font-size: 2.8rem;
  font-weight: 300;
  color: var(--accent);
  animation: cursor-blink 1.1s step-end infinite;
  line-height: 1;
  margin-bottom: 6px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.empty-state strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.empty-state p {
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 32ch;
  margin: 0 auto;
  line-height: 1.7;
}

/* ─── RESULT BODY ──────────────────────────────────── */
.result-body {
  display: grid;
  gap: 14px;
  margin-top: 22px;
  animation: result-enter 0.3s ease both;
}

@keyframes result-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
}

.meta-card {
  padding: 14px 16px;
  background: var(--surface-2);
}

.meta-card strong {
  font-size: 0.82rem;
  font-weight: 500;
  display: block;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.5;
}

/* ─── METRICS ──────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
}

.metric {
  padding: 18px 16px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.5;
}

.metric .kicker {
  margin: 0 0 6px;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
}

.metric strong {
  display: block;
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ─── WARNINGS ─────────────────────────────────────── */
.warnings {
  padding: 16px 18px;
  border: 1px solid rgba(217, 84, 70, 0.28);
  background: rgba(217, 84, 70, 0.04);
}

.warnings ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.warnings li {
  font-size: 0.78rem;
  color: var(--danger);
  line-height: 1.65;
}

/* ─── TABLE ────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  max-height: 480px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table { min-width: 860px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 13px;
  text-align: left;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

tbody td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.82rem;
}

tbody tr:last-child td { border-bottom: 0; }

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover td { background: var(--accent-dim); }

.primary-cell {
  min-width: 280px;
  font-weight: 600;
  color: var(--ink);
}

.numeric {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 500;
}

/* ─── RESPONSIVE ───────────────────────────────────── */
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .form-panel {
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
  }
}

@media (max-width: 700px) {
  .app {
    width: calc(100vw - 24px);
    padding: 20px 0 48px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 14px;
  }
  .topbar h1 { font-size: 1.35rem; }
  .panel { padding: 20px; }
  .intro { flex-direction: column; padding: 18px 0 22px; }
  .meta-grid,
  .metrics { grid-template-columns: 1fr; }
  .result-actions { flex-direction: row-reverse; }
}
