:root {
  --bg: #070b0a;
  --bg-elev: #0e1513;
  --bg-soft: #15201c;
  --bg-panel: rgba(14, 21, 19, 0.88);
  --line: rgba(90, 120, 108, 0.35);
  --line-strong: rgba(120, 160, 140, 0.45);
  --text: #e8f3ec;
  --muted: #7f9a8c;
  --faint: #5a7266;
  --amber: #f0b429;
  --amber-soft: rgba(240, 180, 41, 0.14);
  --green: #3dde8c;
  --green-soft: rgba(61, 222, 140, 0.12);
  --red: #ff6b5a;
  --red-soft: rgba(255, 107, 90, 0.12);
  --cyan: #5ce1e6;
  --cyan-soft: rgba(92, 225, 230, 0.1);
  --violet: #c9b8ff;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  --radius: 20px;
  --radius-sm: 12px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Outfit", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(240, 180, 41, 0.1), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(92, 225, 230, 0.07), transparent 48%),
    radial-gradient(700px 400px at 70% 100%, rgba(61, 222, 140, 0.04), transparent 50%),
    var(--bg);
}

.bg-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(92, 225, 230, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 225, 230, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  opacity: 0.7;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 36px));
  margin: 28px auto 56px;
  display: grid;
  gap: 18px;
  animation: boot 0.55s var(--ease) both;
}

@keyframes boot {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 6px 2px;
}

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

.mark {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, var(--amber), #d98324 70%, #b86a12);
  box-shadow:
    0 0 0 1px rgba(240, 180, 41, 0.4),
    0 12px 28px rgba(240, 180, 41, 0.22);
}

.mark-glow {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(255,255,255,0.35), transparent 55%);
  animation: shimmer 4s ease-in-out infinite;
}

.mark-text {
  position: relative;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #14110a;
  font-size: 1.05rem;
}

@keyframes shimmer {
  0%, 100% { transform: translate(-12%, -8%); opacity: 0.5; }
  50% { transform: translate(18%, 14%); opacity: 0.9; }
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--amber);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.4vw, 2.05rem);
  letter-spacing: -0.035em;
  font-weight: 700;
  line-height: 1.15;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  max-width: 46ch;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 21, 19, 0.85);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  max-width: min(520px, 100%);
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(61, 222, 140, 0.15), 0 0 14px rgba(61, 222, 140, 0.65);
  animation: pulse-dot 2s ease-in-out infinite;
}

.dot.bad {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 107, 90, 0.15), 0 0 14px rgba(255, 107, 90, 0.65);
}

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

.slots {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(21, 32, 28, 0.95), rgba(10, 14, 13, 0.75));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.slot-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--amber);
  font-weight: 600;
}

.slot-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 8px;
  max-width: 420px;
}

.slot-cell {
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #060908;
  overflow: hidden;
  position: relative;
}

.slot-cell.on::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a7a4e, var(--green));
  box-shadow: 0 0 16px rgba(61, 222, 140, 0.45);
  animation: pulse 1.6s ease-in-out infinite;
}

.slot-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: 0.96fr 1.24fr;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.03);
  padding: 20px;
}

.submit-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.queue-panel {
  min-height: 420px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.panel-head.tight {
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.chip {
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid rgba(92, 225, 230, 0.32);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--cyan-soft);
  white-space: nowrap;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

label span em {
  font-style: normal;
  color: var(--faint);
  margin-left: 6px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #080d0b;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s ease;
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: #4d6358;
}

.hidden { display: none !important; }

.source-box,
.school-box,
.selected-box,
.notify-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(8, 13, 11, 0.72);
  display: grid;
  gap: 12px;
}

.source-box {
  margin-bottom: 2px;
}

.notify-box {
  border-color: rgba(92, 225, 230, 0.28);
  box-shadow: inset 0 0 0 1px rgba(92, 225, 230, 0.06);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 2px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}

.mode-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.mode-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.mode-btn.active {
  color: #071112;
  background: linear-gradient(145deg, var(--cyan), #3bb8c4);
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(92, 225, 230, 0.2);
}

.mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

#tokenRaw {
  font-family: var(--mono);
  font-size: 11px;
  word-break: break-all;
}

.job-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--muted);
}

.job-source.direct {
  color: #071112;
  border-color: transparent;
  background: rgba(92, 225, 230, 0.88);
}

.job-source.window {
  color: var(--amber);
  border-color: rgba(240, 180, 41, 0.35);
  background: var(--amber-soft);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(240, 180, 41, 0.65);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.12);
  background: #0a110e;
}

.pwd-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ghost, .primary {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.ghost {
  border-radius: var(--radius-sm);
  padding: 0 14px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line-strong);
  background: #1a2823;
}

.ghost.full {
  width: 100%;
  margin-top: 4px;
  padding: 12px 14px;
  text-align: center;
}

.primary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  color: #14110a;
  font-weight: 700;
  font-family: var(--display);
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--amber), #ffcf70 45%, #e39b20);
  box-shadow: 0 12px 28px rgba(240, 180, 41, 0.22);
  transition: transform 0.15s var(--ease), box-shadow 0.15s ease, filter 0.15s ease;
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(240, 180, 41, 0.28);
  filter: brightness(1.03);
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.15);
}

.primary kbd {
  font: inherit;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
}

.hint {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
}

.hint.error { color: var(--red); }
.hint.ok { color: var(--green); }

.stats-inline {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.job-list {
  display: grid;
  gap: 10px;
  max-height: min(620px, calc(100vh - 220px));
  overflow: auto;
  padding-right: 4px;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,0.18);
}

.job {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: linear-gradient(180deg, #101815, #0c1210);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s ease;
}

.job:hover {
  border-color: #3d5248;
  transform: translateY(-1px);
}

.job.active {
  border-color: rgba(240, 180, 41, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(240, 180, 41, 0.12),
    0 0 0 1px rgba(240, 180, 41, 0.08),
    0 10px 28px rgba(0,0,0,0.25);
}

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.job-email {
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
  font-family: var(--display);
  letter-spacing: -0.01em;
}

.badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.badge.queued { color: var(--muted); }
.badge.running {
  color: var(--amber);
  border-color: rgba(240,180,41,0.4);
  background: var(--amber-soft);
}
.badge.success {
  color: var(--green);
  border-color: rgba(61,222,140,0.35);
  background: var(--green-soft);
}
.badge.failed {
  color: var(--red);
  border-color: rgba(255,107,90,0.35);
  background: var(--red-soft);
}
.badge.stopped {
  color: var(--violet);
  border-color: rgba(201,184,255,0.35);
  background: rgba(201,184,255,0.08);
}

.job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stop-btn {
  border: 1px solid rgba(255, 107, 90, 0.45);
  background: var(--red-soft);
  color: var(--red);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.stop-btn:hover:not(:disabled) {
  background: rgba(255, 107, 90, 0.2);
}

.stop-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.job-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 11px;
}

.log-panel {
  min-height: 220px;
}

.log {
  margin: 0;
  min-height: 180px;
  max-height: 300px;
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(4, 8, 7, 0.95), #050807);
  border: 1px solid var(--line);
  color: #b7d0c2;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35);
}

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

.school-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.school-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #101614;
  transition: border-color 0.15s ease;
}

.school-item[open] {
  border-color: rgba(92, 225, 230, 0.28);
}

.school-item summary {
  cursor: pointer;
  list-style: none;
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-family: var(--display);
  font-weight: 560;
}

.school-item summary::-webkit-details-marker { display: none; }

.tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin-top: 10px;
}

.tpl-grid label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.tpl-grid input {
  width: auto;
  margin: 0;
  accent-color: var(--amber);
}

.choice-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.choice-tag {
  border: 1px solid rgba(92, 225, 230, 0.3);
  background: var(--cyan-soft);
  color: var(--cyan);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Scrollbars */
.job-list::-webkit-scrollbar,
.school-list::-webkit-scrollbar,
.log::-webkit-scrollbar,
.submit-panel::-webkit-scrollbar {
  width: 8px;
}
.job-list::-webkit-scrollbar-thumb,
.school-list::-webkit-scrollbar-thumb,
.log::-webkit-scrollbar-thumb,
.submit-panel::-webkit-scrollbar-thumb {
  background: rgba(90, 120, 108, 0.4);
  border-radius: 999px;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .submit-panel {
    position: static;
    max-height: none;
  }
  .slots { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
  .health { max-width: 100%; }
  .tpl-grid { grid-template-columns: 1fr; }
  .job-list { max-height: 420px; }
}

.link { color: var(--cyan); text-decoration: underline; }

::selection {
  background: rgba(240, 180, 41, 0.28);
  color: var(--text);
}

/* tabs / history / collapsible sections (aligned with desktop) */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab {
  border: 1px solid var(--line);
  background: rgba(14, 21, 19, 0.7);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
  transition: 0.2s var(--ease);
}
.tab:hover { color: var(--text); border-color: var(--line-strong); }
.tab.active {
  color: #08110c;
  background: linear-gradient(135deg, var(--amber), #f6d36b);
  border-color: transparent;
  font-weight: 600;
}
.tab-page.hidden { display: none !important; }
.history-filters {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  margin-bottom: 14px;
}
.history-list, .history-item { display: grid; gap: 10px; }
.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(8, 14, 12, 0.55);
}
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.secrets summary {
  cursor: pointer;
  color: var(--cyan);
  margin: 6px 0;
}
.secret-box {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #050807;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
}
.warn-hint { color: var(--amber) !important; }
@media (max-width: 720px) {
  .history-filters { grid-template-columns: 1fr; }
}

details.fold {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 14, 12, 0.45);
  overflow: hidden;
}
details.fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  font-family: var(--display);
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after {
  content: "▸";
  color: var(--muted);
  transition: transform 0.2s var(--ease);
}
details.fold[open] > summary::after {
  transform: rotate(90deg);
}
details.fold .fold-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
