/* ─── Design Tokens ───────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg:          #08080a;
  --surface:     #0e0e12;
  --surface-2:   #141418;
  --surface-3:   #1c1c22;
  --border:      #242430;
  --border-2:    #2e2e3c;
  --text:        #ebebf0;
  --muted:       #64647a;
  --muted-2:     #9494a8;
  --accent:      #ff8800;
  --accent-dim:  rgba(255,136,0,0.10);
  --accent-glow: rgba(255,136,0,0.25);
  --success:     #1fcb7c;
  --success-dim: rgba(31,203,124,0.12);
  --danger:      #ff4560;
  --danger-dim:  rgba(255,69,96,0.12);
  --info:        #4d9fff;
  --info-dim:    rgba(77,159,255,0.12);

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;

  --font-body:   'Barlow', system-ui, sans-serif;
  --font-mono:   'Space Mono', 'Menlo', monospace;
  --font-cond:   'Barlow Condensed', sans-serif;
}

/* ─── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

/* ─── Noise texture overlay ──────────────────────────────────────────── */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ─── Body ────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(255,100,0,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 0% 100%, rgba(0,80,200,0.04) 0%, transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */
.app-shell {
  width: min(1220px, 96vw);
  margin: 0 auto;
  padding-bottom: 3rem;
}

.hidden { display: none !important; }
.view { animation: fadeIn 0.2s ease; }

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

/* ─── Auth Screen ─────────────────────────────────────────────────────── */
.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-frame {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-logo-text {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}

.auth-panel {
  padding: 2rem 2rem 1.75rem;
}

.auth-desc {
  color: var(--muted-2);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

/* ─── Panel base ──────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

/* top accent bar */
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2) 30%, var(--border-2) 70%, transparent);
}

/* ─── Section header ──────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.4rem 0;
  margin-bottom: 1.1rem;
}

.section-header h2 {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.48rem;
  border-radius: 4px;
  background: var(--accent-dim);
  border: 1px solid rgba(255,136,0,0.3);
  color: var(--accent);
}

/* ─── Eyebrow / kicker ────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

h1 {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 0.6rem;
}

/* ─── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-name {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-module {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 0.15rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.live-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--success);
  font-weight: 700;
}

/* ─── Upload panel ────────────────────────────────────────────────────── */
.upload-panel {
  margin-bottom: 1rem;
  padding: 1.4rem;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Public watch page ─────────────────────────────────────────────── */
.watch-shell {
  max-width: 980px;
  min-height: 100dvh;
}

.watch-topbar {
  margin-bottom: 0.9rem;
}

.watch-panel {
  padding: 1.4rem;
}

.watch-job-id {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  margin: 0 0 1rem;
}

.watch-job-id span {
  color: var(--text);
}

.watch-state {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--muted-2);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.watch-ready {
  border-color: rgba(31, 203, 124, 0.4);
  color: var(--success);
  background: var(--success-dim);
}

.watch-error {
  border-color: rgba(255, 69, 96, 0.35);
  color: var(--danger);
  background: var(--danger-dim);
}

.watch-video {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #000;
  margin-bottom: 1rem;
}

.watch-actions {
  display: flex;
  justify-content: flex-start;
}

.appeal-btn {
  text-decoration: none;
}

.file-input-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-md);
  color: var(--muted-2);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-label:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}

/* ─── Inputs / Selects ───────────────────────────────────────────────── */
input,
select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
}

input::placeholder { color: var(--muted); }
input[type="search"]::-webkit-search-cancel-button { display: none; }

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364647a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}

.field-group {
  margin-bottom: 1.25rem;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
button {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: rgba(255,136,0,0.6);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: #ffa030;
  box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-2);
  border-color: var(--border-2);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-2);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.42rem 0.75rem;
}

/* ─── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0 1.4rem 1rem;
  align-items: center;
}

.search-wrapper {
  position: relative;
  flex: 1 1 200px;
  min-width: 160px;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-wrapper input {
  padding-left: 2.2rem;
}

.toolbar select,
.toolbar input[type="date"] {
  flex: 0 1 auto;
  width: auto;
}

/* ─── Table ───────────────────────────────────────────────────────────── */
.queue-panel { padding: 1.4rem 0 1rem; }

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th {
  font-family: var(--font-cond);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover td {
  background: var(--surface-2);
}

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

/* ─── Table cell components ──────────────────────────────────────────── */
.file-name {
  font-weight: 500;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.job-id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.25rem;
  display: block;
}

.sub-row {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.22rem;
  word-break: break-all;
  line-height: 1.5;
}

.size-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.size-label {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.size-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ─── Status tags ─────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border-2);
  color: var(--muted-2);
  background: var(--surface-3);
}

.tag::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.tag-success {
  color: var(--success);
  border-color: rgba(31,203,124,0.3);
  background: var(--success-dim);
}

.tag-danger {
  color: var(--danger);
  border-color: rgba(255,69,96,0.3);
  background: var(--danger-dim);
}

.tag-progress {
  color: var(--info);
  border-color: rgba(77,159,255,0.3);
  background: var(--info-dim);
  animation: blink 1.5s ease infinite;
}

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

.queue-pos {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.3rem;
  display: block;
}

/* ─── Compression ratio ──────────────────────────────────────────────── */
.ratio-good { color: var(--success); }
.ratio-ok   { color: var(--info); }
.ratio-bad  { color: var(--danger); }

/* ─── Actions cell ────────────────────────────────────────────────────── */
.actions-cell {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-action {
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--muted-2);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-action:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--accent);
}

.btn-action.copy-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.error-line {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  line-height: 1.4;
}

/* ─── Empty state ─────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  font-size: 0.875rem;
}

.empty svg {
  display: block;
  margin: 0 auto 0.75rem;
  opacity: 0.3;
}

/* ─── Status messages ─────────────────────────────────────────────────── */
.status-msg {
  min-height: 1.2rem;
  font-size: 0.82rem;
  color: var(--muted-2);
  margin-top: 0.75rem;
  font-family: var(--font-mono);
}

.status-msg.error { color: var(--danger); }
.status-msg.ok    { color: var(--success); }

/* ─── Jobs meta badge ─────────────────────────────────────────────────── */
.jobs-meta-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar select,
  .toolbar input[type="date"] {
    width: 100%;
  }

  .upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    justify-content: center;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .inline-field {
    grid-template-columns: 1fr;
  }
}
