/* ==================== ROOT VARIABLES ==================== */
:root {
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-light: #f1f5f9;
  --surface: #ffffff;
  --surface-raised: #f8fafc;
  --canvas: #f1f5f9;

  --navy: #0f172a;
  --navy-light: #1e293b;
  --navy-border: #334155;

  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #f0fdfa;
  --teal-border: #ccfbf1;

  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-light: #ecfdf5;

  --amber: #f59e0b;
  --amber-dark: #d97706;
  --amber-light: #fffbeb;

  --rose: #f43f5e;
  --rose-dark: #e11d48;
  --rose-light: #fff1f2;

  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-light: #eff6ff;

  --purple: #8b5cf6;
  --purple-dark: #7c3aed;
  --purple-light: #f5f3ff;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

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

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==================== BUTTONS ==================== */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.primary, .btn-primary {
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

.primary:hover:not(:disabled), .btn-primary:hover:not(:disabled) {
  background: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.primary:disabled, .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.secondary, .btn-secondary {
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}

.secondary:hover:not(:disabled), .btn-secondary:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: #cbd5e1;
  color: var(--ink);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ==================== COMMON ATOMS ==================== */
.eyebrow {
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 4px;
}

.muted {
  color: var(--muted);
}

/* ==================== LOGIN PAGE (SALEPORTAL STYLE) ==================== */
.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: #f8fafc;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.login-brand {
  padding: 10vh 10%;
  background: linear-gradient(140deg, #0f172a 0%, #134e4a 60%, #0f766e 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-brand::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-brand::after {
  content: "";
  position: absolute;
  bottom: -80px;
  left: -80px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12) 0%, rgba(15, 23, 42, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-brand-inner {
  position: relative;
  z-index: 2;
  max-width: 520px;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  border-radius: 12px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  width: 48px;
  height: 48px;
  font-size: 24px;
}

.login-brand .eyebrow {
  color: #5eead4;
  margin-top: 36px;
  letter-spacing: 0.12em;
}

.login-brand h1 {
  font-size: clamp(32px, 4.5vw, 52px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
  color: #ffffff;
}

.login-brand .brand-description {
  max-width: 480px;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1.6;
  margin: 0 0 28px;
}

.login-points {
  display: grid;
  gap: 12px;
  font-weight: 600;
  color: #f1f5f9;
}

.login-points span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.login-card-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  width: 100%;
}

.login-card {
  width: min(440px, 100%);
  background: #ffffff;
  padding: 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  position: relative;
}

.login-card-header {
  margin-bottom: 24px;
}

.login-card h2 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--ink);
}

.login-card form {
  display: grid;
  gap: 18px;
}

.login-card label {
  display: grid;
  gap: 7px;
  font-weight: 600;
  color: var(--ink-secondary);
  font-size: 13.5px;
}

.password-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 46px !important;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: 6px;
  padding: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.password-toggle-btn:hover {
  color: var(--ink);
  background: #f1f5f9;
}

.login-card input {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 11px 14px;
  color: var(--ink);
  outline: none;
  font-size: 15px;
  transition: all var(--transition-fast);
  width: 100%;
}

.login-card input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

.login-card input::placeholder {
  color: #b6c2d2;
  opacity: 1;
}

.login-submit-btn {
  margin-top: 6px;
  width: 100%;
  padding: 12px 18px;
}

.login-error-alert {
  margin-top: 14px;
  padding: 11px 14px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}

/* ==================== APP LAYOUT & HEADER ==================== */
.app-header {
  background: var(--navy);
  color: #ffffff;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--navy-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #ffffff;
}

.app-brand .logo-mark {
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 8px;
}

.brand-text {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-tag {
  background: rgba(45, 212, 191, 0.15);
  color: #5eead4;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(45, 212, 191, 0.3);
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: 20px;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.btn-logout {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: #ef4444;
}

/* ==================== DASHBOARD CONTENT ==================== */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  gap: 28px;
}

/* Stat Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.metric-sub {
  font-size: 12.5px;
  color: var(--muted-light);
}

/* Card Container */
.content-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 19px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
}

.card-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* Form Styles */
.job-form {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 14px;
  align-items: flex-end;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.form-group input {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: all var(--transition-fast);
}

.form-group input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

.form-group input::placeholder {
  color: #b6c2d2;
}

/* ==================== BADGES & TABLE ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.badge-queued {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-downloading {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-resizing {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-renaming {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-uploading {
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #99f6e4;
}

.badge-done {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-error {
  background: #fff1f2;
  color: #b91c1c;
  border: 1px solid #fecdd3;
}

.badge-review {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
}

/* Animated Spinner */
.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Table styling */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background: var(--surface-raised);
  color: var(--ink-secondary);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

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

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  margin-bottom: 12px;
  color: #cbd5e1;
}

/* ==================== STEPPER COMPONENT ==================== */
.stepper-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.step-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  transition: all var(--transition-fast);
}

.step-card.active {
  background: var(--teal-light);
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2);
}

.step-card.completed {
  background: #f0fdf4;
  border-color: #86efac;
}

.step-card.error {
  background: #fff1f2;
  border-color: #fda4af;
}

.step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  flex-shrink: 0;
}

.step-card.active .step-icon {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.step-card.completed .step-icon {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
}

.step-card.error .step-icon {
  background: var(--rose);
  color: #ffffff;
  border-color: var(--rose);
}

.step-info {
  display: grid;
  gap: 2px;
}

.step-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.step-status {
  font-size: 11.5px;
  color: var(--muted);
}

/* ==================== LOG TERMINAL VIEWER ==================== */
.terminal-card {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.terminal-header {
  background: #0f172a;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: #ef4444; }
.terminal-dots span:nth-child(2) { background: #f59e0b; }
.terminal-dots span:nth-child(3) { background: #10b981; }

.terminal-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: #94a3b8;
}

.terminal-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.terminal-body {
  height: 380px;
  overflow-y: auto;
  padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #cbd5e1;
  background: #090d16;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-body::-webkit-scrollbar {
  width: 8px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.terminal-line {
  margin: 0;
  padding: 1px 0;
}

.terminal-line.error { color: #f87171; }
.terminal-line.success { color: #4ade80; }
.terminal-line.info { color: #38bdf8; }
.terminal-line.step { color: #fbbf24; font-weight: bold; }

/* Pulse Indicator */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Responsive */
@media (max-width: 960px) {
  .login-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: #f8fafc;
  }

  .login-brand {
    padding: 36px 28px 30px;
    justify-content: flex-start;
    flex: none;
  }

  .login-brand .eyebrow {
    margin-top: 16px;
  }

  .login-brand h1 {
    font-size: 26px;
    margin: 0 0 8px;
    line-height: 1.25;
  }

  .login-brand .brand-description {
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 16px;
    max-width: 100%;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stepper-container {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
