:root {
  --ink: #17202a;
  --muted: #64727d;
  --line: #d7dfe2;
  --soft: #f3f6f6;
  --surface: #ffffff;
  --teal: #0e7490;
  --teal-dark: #0b5c72;
  --green: #15803d;
  --red: #b42318;
  --amber: #a15c00;
  --shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eef2f2; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f8faf9 0, #eef2f2 100%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
a { color: inherit; }
svg { width: 19px; height: 19px; stroke-width: 1.8; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 5vw;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 6px;
}
.brand-mark-large { width: 46px; height: 46px; }
.brand-mark-large svg { width: 25px; height: 25px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions form { margin: 0; }
.user-name { margin: 0 4px 0 8px; color: var(--muted); font-size: 14px; }
.icon-link { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; padding: 8px; }
.icon-link:hover, .back-link:hover { color: var(--teal); }

.page-shell { width: min(1180px, 90vw); margin: 0 auto; padding: 42px 0 72px; }
.workspace-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 5px; color: var(--teal); font-size: 12px; font-weight: 750; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 32px; line-height: 1.15; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.25; }
.worker-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #dcfce7; }

.upload-tool {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.tool-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.tool-heading { margin-bottom: 18px; }
.tool-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 650; }
.field input, .field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
  border: 1px solid #bfcace;
  border-radius: 5px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 116, 144, .13); }
.compact-field { width: min(240px, 45%); }
.drop-zone {
  position: relative;
  min-height: 174px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  background: #f7f9f9;
  border: 1px dashed #9babb1;
  border-radius: 6px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.is-dragging { color: var(--teal); background: #eff8f8; border-color: var(--teal); }
.drop-zone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-zone svg { width: 30px; height: 30px; }
.drop-zone strong { color: var(--ink); font-size: 16px; }
.drop-zone span { font-size: 13px; }
.upload-progress { margin-top: 18px; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.progress-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 7px; overflow: hidden; background: #e1e8e9; border-radius: 4px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--teal); transition: width .2s; }

.jobs-section { margin-top: 34px; }
.section-heading { margin-bottom: 12px; }
.jobs-list { border-top: 1px solid var(--line); }
.job-row {
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(230px, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: 18px 10px;
  border-bottom: 1px solid var(--line);
}
.job-name { min-width: 0; }
.job-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { display: flex; gap: 10px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.job-status { min-width: 0; }
.job-status-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 13px; }
.job-status-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-error { color: var(--red); font-size: 12px; line-height: 1.35; }
.job-actions { display: flex; justify-content: flex-end; gap: 6px; min-width: 102px; }
.job-row .progress-track { height: 5px; }
.empty-state { min-height: 220px; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; }
.empty-state p { margin: 0; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.badge-ready { color: #11632f; background: #dcfce7; }
.badge-working { color: #075c73; background: #dff5f7; }
.badge-waiting { color: #7c4800; background: #fff1d6; }
.badge-error { color: #8f1d14; background: #fee4e2; }
.badge-muted { color: #59656e; background: #e7ebed; }

.button, .icon-button {
  border: 0;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 5px; font-weight: 700; }
.button-primary { color: white; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button-wide { width: 100%; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; color: var(--muted); background: transparent; border-radius: 5px; }
.icon-button:hover { color: var(--ink); background: #e5ebec; }
.icon-button.danger:hover { color: var(--red); background: #fee4e2; }
.icon-button:active, .button:active { transform: translateY(1px); }

.alert { margin: 14px 0; padding: 10px 12px; border-radius: 5px; font-size: 13px; }
.alert-error { color: #8f1d14; background: #fee4e2; border: 1px solid #f5b7b1; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px 0; }
.login-panel { width: min(430px, 100%); padding: 32px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand h1 { font-size: 24px; }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.form-stack { display: grid; gap: 17px; }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 13px; text-decoration: none; }
.admin-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 38px; align-items: start; }
.user-create { display: grid; gap: 16px; padding: 22px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); }
.users-table th, .users-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.users-table th { color: var(--muted); background: var(--soft); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.users-table tr:last-child td { border-bottom: 0; }
.table-action { width: 56px; text-align: right !important; }
.role-label { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app-header { padding: 0 4vw; }
  .page-shell { width: 92vw; padding-top: 28px; }
  .icon-link span, .user-name { display: none; }
  .workspace-head { align-items: start; }
  h1 { font-size: 27px; }
  .tool-heading { align-items: end; }
  .compact-field { width: 48%; }
  .job-row { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
  .job-status { grid-column: 1 / -1; grid-row: 2; }
  .job-actions { grid-column: 2; grid-row: 1; min-width: auto; }
  .admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .brand > span:last-child { display: none; }
  .upload-tool { padding: 18px; }
  .tool-heading { align-items: stretch; flex-direction: column; }
  .compact-field { width: 100%; }
  .drop-zone { min-height: 150px; }
  .login-panel { padding: 25px 20px; }
  .worker-state { display: none; }
}
