:root {
  font-family: Vazirmatn, IRANSans, "Segoe UI", Tahoma, system-ui, sans-serif;
  color: #172033;
  background: #edf2f8;
  color-scheme: light;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --border: rgba(113, 130, 158, 0.2);
  --muted: #68758b;
  --primary: #405cf5;
  --primary-dark: #2e45d5;
  --success: #118c64;
  --warning: #b36a09;
  --danger: #c43c4b;
  --shadow: 0 20px 55px rgba(36, 51, 80, 0.13);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.background-orb {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
}
.orb-one { background: #8297ff; top: -160px; right: -120px; }
.orb-two { background: #72e0c1; bottom: -180px; left: -120px; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 32px auto 70px; }
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.auth-card {
  width: min(430px, 100%);
  margin: 12vh auto;
  padding: 38px;
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #435ff6, #7b4ce2);
  margin-bottom: 24px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.auth-card > p { margin: 0 0 28px; color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  border-radius: 28px;
}
.topbar h1 { margin: 5px 0 6px; font-size: clamp(26px, 4vw, 38px); }
.topbar p { margin: 0; color: var(--muted); }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}
.metric { border-radius: 22px; padding: 20px; display: flex; justify-content: space-between; align-items: center; }
.metric span { color: var(--muted); }
.metric strong { font-size: 28px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 18px; }
.upload-card, .guide-card, .jobs-card { border-radius: 28px; padding: 28px; }
.jobs-card { margin-top: 18px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.section-heading h2, .guide-card h2 { margin: 5px 0 0; font-size: 24px; }
.badge { padding: 7px 11px; border-radius: 999px; background: #ecf0ff; color: var(--primary); font-size: 12px; font-weight: 800; }

.stack { display: grid; gap: 14px; }
label { font-weight: 750; font-size: 14px; }
input[type="password"], textarea {
  width: 100%;
  color: inherit;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 13px 15px;
  outline: none;
  transition: .2s ease;
}
input:focus, textarea:focus { border-color: rgba(64,92,245,.6); box-shadow: 0 0 0 4px rgba(64,92,245,.1); }
textarea { resize: vertical; min-height: 130px; line-height: 1.8; }

.drop-zone {
  min-height: 225px;
  border: 2px dashed rgba(64,92,245,.3);
  background: linear-gradient(135deg, rgba(64,92,245,.06), rgba(79,197,164,.07));
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  transition: .2s ease;
}
.drop-zone:hover, .drop-zone.dragging { transform: translateY(-2px); border-color: var(--primary); background: rgba(64,92,245,.09); }
.drop-zone span, .drop-zone small { color: var(--muted); }
.upload-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 17px; background: white; color: var(--primary) !important; font-size: 29px; box-shadow: 0 10px 25px rgba(64,92,245,.13); }
.selected-file { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 15px; border-radius: 15px; background: rgba(17,140,100,.08); border: 1px solid rgba(17,140,100,.15); }
.selected-file div { display: grid; gap: 3px; min-width: 0; }
.selected-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file span { color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .ghost-button, .icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: .2s ease;
}
.primary-button { min-height: 48px; padding: 0 20px; border-radius: 14px; background: var(--primary); color: white; font-weight: 800; box-shadow: 0 12px 24px rgba(64,92,245,.22); }
.primary-button:hover { background: var(--primary-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button.compact { min-height: 40px; }
.secondary-button { min-height: 42px; padding: 0 16px; border-radius: 13px; background: #eef1ff; color: var(--primary); font-weight: 800; }
.secondary-button:hover { background: #e0e6ff; }
.ghost-button { min-height: 42px; padding: 0 15px; border-radius: 13px; background: rgba(255,255,255,.62); color: #364056; border: 1px solid var(--border); }
.ghost-button:hover { background: white; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; color: #4a566c; background: rgba(255,255,255,.75); font-size: 22px; }

.steps { list-style: none; padding: 0; margin: 25px 0; display: grid; gap: 20px; }
.steps li { display: flex; gap: 13px; align-items: flex-start; }
.steps li > span { flex: 0 0 35px; height: 35px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: #eef1ff; font-weight: 900; }
.steps strong { display: block; margin-bottom: 4px; }
.steps p { color: var(--muted); margin: 0; line-height: 1.65; font-size: 13px; }
.resource-links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; border-top: 1px solid var(--border); }
.resource-links a { font-size: 12px; color: var(--primary); text-decoration: none; padding: 7px 9px; border-radius: 9px; background: #eef1ff; }

.jobs-list { display: grid; gap: 12px; }
.job-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(170px, .75fr) auto; gap: 16px; align-items: center; padding: 16px; border-radius: 18px; background: rgba(255,255,255,.7); border: 1px solid var(--border); }
.job-main { min-width: 0; }
.job-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 5px; }
.job-main small, .job-meta small { color: var(--muted); }
.job-meta { display: grid; gap: 6px; justify-items: start; }
.job-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.mini-button { border: 1px solid var(--border); background: white; color: #38445b; border-radius: 10px; padding: 7px 10px; cursor: pointer; }
.mini-button.danger { color: var(--danger); }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 9px; font-size: 12px; font-weight: 800; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pending { color: var(--warning); background: rgba(179,106,9,.1); }
.status-processing { color: var(--primary); background: rgba(64,92,245,.1); }
.status-completed { color: var(--success); background: rgba(17,140,100,.1); }
.status-failed { color: var(--danger); background: rgba(196,60,75,.1); }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.message { min-height: 24px; color: var(--muted); font-size: 13px; }
.message.success { color: var(--success); }
.message.error, .error-text { color: var(--danger); }

.result-dialog { width: min(860px, calc(100% - 28px)); border: 0; padding: 0; border-radius: 24px; box-shadow: 0 30px 90px rgba(21,29,48,.28); }
.result-dialog::backdrop { background: rgba(19,27,44,.52); backdrop-filter: blur(5px); }
.dialog-shell { padding: 25px; }
.dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-header h2 { margin: 5px 0 0; }
.dialog-shell pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; line-height: 1.9; max-height: 58vh; overflow: auto; background: #f5f7fb; padding: 18px; border-radius: 16px; border: 1px solid var(--border); }
.dialog-actions { justify-content: flex-end; }

@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .job-row { grid-template-columns: 1fr; }
  .job-actions { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .shell { width: min(100% - 18px, 1180px); margin-top: 9px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 22px; }
  .topbar-actions { width: 100%; }
  .topbar-actions > * { flex: 1; }
  .metrics-grid { gap: 9px; }
  .metric { padding: 15px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .upload-card, .guide-card, .jobs-card { padding: 20px; border-radius: 22px; }
  .drop-zone { min-height: 195px; }
}

/* v2.9 heartbeat and public progress timeline */
.job-row-progress { grid-template-columns: minmax(0, 1.8fr) minmax(180px, .65fr) auto; align-items: start; }
.progress-summary {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  padding: 12px 13px;
  border-radius: 14px;
  background: rgba(64, 92, 245, .055);
  border: 1px solid rgba(64, 92, 245, .12);
}
.progress-line { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; line-height: 1.7; }
.progress-line span { color: #34405a; }
.progress-line strong { color: var(--primary); white-space: nowrap; }
.progress-summary small { color: var(--muted); }
.progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(64, 92, 245, .12); direction: ltr; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #405cf5, #7b4ce2); transition: width .35s ease; }
.status-stalled { color: var(--danger); background: rgba(196,60,75,.1); }
#heartbeatBadge { margin-inline-start: auto; }
@media (max-width: 900px) {
  .job-row-progress { grid-template-columns: 1fr; }
}
