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

:root {
  --c-primary:       #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-primary-light: #eff6ff;
  --c-success:       #16a34a;
  --c-success-bg:    #f0fdf4;
  --c-success-bdr:   #bbf7d0;
  --c-error:         #dc2626;
  --c-error-bg:      #fef2f2;
  --c-error-bdr:     #fecaca;
  --c-warn:          #d97706;
  --c-warn-bg:       #fffbeb;
  --c-processing:    #7c3aed;
  --c-processing-bg: #f5f3ff;

  --c-bg:            #f1f5f9;
  --c-surface:       #ffffff;
  --c-header:        #0f172a;
  --c-text:          #1e293b;
  --c-text-muted:    #64748b;
  --c-border:        #e2e8f0;
  --c-border-hover:  #cbd5e1;

  --radius-sm:  6px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 150ms ease;
}

html, body { height: 100%; font-family: var(--font); color: var(--c-text); background: var(--c-bg); }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.screen  { min-height: 100vh; }

.link { color: var(--c-primary); cursor: pointer; text-decoration: underline; }
.link:hover { color: var(--c-primary-hover); }

/* ── Spinner ────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 8px;
}
.alert-error  { background: var(--c-error-bg);   border: 1px solid var(--c-error-bdr);   color: var(--c-error); }
.alert-info   { background: var(--c-primary-light); border: 1px solid #bfdbfe; color: var(--c-primary); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary       { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }

.btn-ghost       { background: transparent; color: var(--c-text-muted); border: 1px solid var(--c-border); }
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }

.btn-success       { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-full { width: 100%; margin-top: 8px; }

/* ── Form fields ────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-group label { font-size: 13px; font-weight: 600; color: var(--c-text); }

input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px;
  background: var(--c-surface); color: var(--c-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / .15);
}

.select-wrap { position: relative; }
.select-wrap select { padding-right: 32px; cursor: pointer; }
.select-arrow {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--c-text-muted); font-size: 12px;
}

.badge-ext {
  font-size: 11px; font-weight: 500; padding: 2px 6px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: 4px; color: var(--c-text-muted); margin-left: 6px;
}

/* ── LOGIN SCREEN ───────────────────────────────────────────────────────── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e293b 100%);
}
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }

.login-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px 36px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgb(255 255 255 / .08);
}

.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .brand-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.login-brand h1 { font-size: 22px; font-weight: 700; color: var(--c-text); margin-bottom: 4px; }
.login-brand p  { font-size: 14px; color: var(--c-text-muted); }

/* ── APP HEADER ─────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 60px;
  background: var(--c-header);
  box-shadow: 0 1px 0 rgb(255 255 255 / .07);
}

.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand .brand-icon { font-size: 22px; }
.header-title { font-size: 16px; font-weight: 700; color: #fff; display: block; line-height: 1.2; }
.header-sub   { font-size: 11px; color: #94a3b8; display: block; }

.header-user  { display: flex; align-items: center; gap: 12px; }
.user-pill    { display: flex; align-items: center; gap: 8px; color: #e2e8f0; font-size: 14px; }
.user-avatar  {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
#logout-btn { color: #94a3b8; border-color: #334155; font-size: 13px; padding: 6px 14px; }
#logout-btn:hover { background: #1e293b; color: #e2e8f0; border-color: #475569; }

/* ── APP MAIN ───────────────────────────────────────────────────────────── */
.app-main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 28px 24px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 800px) { .app-main { grid-template-columns: 1fr; } }

/* ── Panels ─────────────────────────────────────────────────────────────── */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.panel-header { margin-bottom: 20px; }
.panel-header h2 { font-size: 16px; font-weight: 700; }
.panel-sub { font-size: 12px; color: var(--c-text-muted); margin-top: 4px; line-height: 1.5; }
.panel-header-row { display: flex; align-items: center; gap: 8px; }

.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--c-text-muted);
}

/* ── Drop Zone ──────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-sm);
  min-height: 150px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative; overflow: hidden;
}
.drop-zone:hover, .drop-zone:focus { border-color: var(--c-primary); background: var(--c-primary-light); }
.drop-zone.drag-over { border-color: var(--c-primary); background: var(--c-primary-light); }
.drop-zone.has-file  { border-style: solid; border-color: var(--c-success); background: var(--c-success-bg); }
.drop-zone.uploading { border-style: solid; border-color: var(--c-primary); background: var(--c-primary-light); cursor: default; }

.dz-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; text-align: center; }
.dz-icon  { color: var(--c-text-muted); opacity: .7; width: 36px; height: 36px; }
.dz-icon-ok { color: var(--c-success); opacity: 1; }
.dz-title { font-size: 14px; font-weight: 500; color: var(--c-text); }
.dz-sub   { font-size: 12px; color: var(--c-text-muted); }

.dz-file-info { display: flex; flex-direction: column; gap: 2px; }
.dz-filename { font-size: 14px; font-weight: 600; color: var(--c-text); word-break: break-all; }
.dz-filesize { font-size: 12px; color: var(--c-text-muted); }

.dz-spinner { width: 28px; height: 28px; border-width: 3px; color: var(--c-primary); }

.dz-clear {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--c-text-muted); line-height: 1;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background var(--transition);
}
.dz-clear:hover { background: var(--c-border); color: var(--c-text); }

/* ── Jobs Panel ─────────────────────────────────────────────────────────── */
.jobs-panel { max-height: calc(100vh - 140px); overflow-y: auto; }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  padding: 48px 24px; text-align: center;
  color: var(--c-text-muted);
}
.empty-state svg { opacity: .4; }
.empty-state p   { font-size: 14px; }
.empty-sub       { font-size: 12px; opacity: .8; }

/* ── Job Card ───────────────────────────────────────────────────────────── */
.job-card {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition);
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.job-card:last-child { margin-bottom: 0; }

.job-card.status-processing { border-color: #c4b5fd; background: var(--c-processing-bg); }
.job-card.status-done       { border-color: var(--c-success-bdr); background: var(--c-success-bg); }
.job-card.status-error      { border-color: var(--c-error-bdr);   background: var(--c-error-bg); }

.job-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.job-name   { font-size: 13px; font-weight: 600; color: var(--c-text); word-break: break-all; line-height: 1.3; }
.job-meta   { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }

.job-status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.job-card.status-pending    .status-dot { background: var(--c-text-muted); }
.job-card.status-processing .status-dot { background: var(--c-processing); animation: pulse 1.2s ease infinite; }
.job-card.status-done       .status-dot { background: var(--c-success); }
.job-card.status-error      .status-dot { background: var(--c-error); }

.job-card.status-processing .job-status { color: var(--c-processing); }
.job-card.status-done       .job-status { color: var(--c-success); }
.job-card.status-error      .job-status { color: var(--c-error); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}

.job-footer { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.job-detail { font-size: 11px; color: var(--c-text-muted); }
.job-error  { font-size: 11px; color: var(--c-error); line-height: 1.4; margin-top: 4px; }

.btn-download {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  background: var(--c-success); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition);
}
.btn-download:hover { background: #15803d; }

.btn-dismiss {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--c-text-muted); line-height: 1;
  padding: 2px 4px; border-radius: 4px;
  transition: background var(--transition);
}
.btn-dismiss:hover { background: var(--c-border); color: var(--c-text); }
