:root {
  color-scheme: light;
  --ink: #101828;
  --muted: #667085;
  --line: #dfe5ef;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --accent: #2454d6;
  --accent-dark: #173caa;
  --hot: #ff5a2a;
  --danger: #b42318;
  --warn: #9a6700;
  --done: #087443;
  --shadow: 0 18px 42px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f4f6fa;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.logo,
.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
}

.logoMark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
}

.topnav a,
.textButton {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(360px, 540px) minmax(0, 1fr);
  gap: 24px;
}

.workspace,
.result,
.upload,
.panel,
.publicTabPanel {
  min-width: 0;
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
}

.upload,
.panel,
.result,
.authPanel,
.settingsForm,
.userForm,
.tabPanel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.upload {
  padding: 24px;
  border-radius: 8px;
  display: grid;
  gap: 18px;
}

.brand,
.panelHead,
.controls,
.jobTop,
.jobActions,
.loadHead,
.userHead,
.userTools,
.formTitleRow,
.formActions,
.userState,
.userActions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand,
.panelHead,
.jobTop,
.jobActions,
.loadHead,
.userHead,
.formTitleRow {
  justify-content: space-between;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.12;
  font-weight: 820;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 760;
}

p,
.subline {
  color: var(--muted);
}

.brand p,
.loadHead p,
.userHead p,
.settingsForm p,
.authPanel p {
  margin-top: 7px;
}

.health,
.status {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  background: #edf3ff;
  color: var(--accent-dark);
  white-space: nowrap;
}

.health.bad,
.status.failed {
  background: #fff0ef;
  color: var(--danger);
}

.dropzone {
  min-height: 176px;
  border: 1px dashed #9aa8bd;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8faff, #f4f6fb);
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.active {
  border-color: var(--accent);
  background: #eef4ff;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropIcon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--hot);
  color: #fff;
  font-size: 26px;
  line-height: 1;
}

#fileName {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 720;
}

.selectedFiles {
  display: grid;
  gap: 6px;
}

.selectedFiles div {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: #344054;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.controls {
  align-items: stretch;
}

.controls label,
.wideLabel,
.authPanel label,
.settingsForm label,
.userForm label,
.filters label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.controls label {
  flex: 1 1 0;
}

label span,
.controls span,
.wideLabel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="text"],
input[type="password"],
input[type="date"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.primary,
.ghost,
.linkButton,
.tab,
.iconButton {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
}

.primary {
  height: 48px;
  background: var(--hot);
  color: #fff;
}

.primary:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.primary:hover:not(:disabled) {
  background: #e5491d;
}

.ghost,
.linkButton {
  min-height: 36px;
  padding: 0 12px;
  background: #edf2fb;
  color: #203b7a;
}

.successGhost {
  color: #287a2f;
  background: #eefaf0;
}

.publicTabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.publicTabPanel {
  display: none;
}

.publicTabPanel.active {
  display: grid;
  gap: 18px;
}

.uploadProgress {
  display: grid;
  gap: 8px;
}

.progressText {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.panel,
.result {
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.flatPanel {
  box-shadow: none;
}

.jobs {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.job {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.job.selected {
  border-color: var(--accent);
}

.jobName {
  font-weight: 760;
  overflow-wrap: anywhere;
}

.jobMeta {
  color: var(--muted);
  font-size: 13px;
}

.status.queued {
  background: #f2f4f7;
  color: #475467;
}

.status.running {
  background: #fff6dc;
  color: var(--warn);
}

.status.done {
  background: #e8f7ef;
  color: var(--done);
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--hot));
  transition: width 0.2s ease;
}

.result {
  min-height: calc(100vh - 120px);
  padding: 22px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

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

.downloads a {
  height: 36px;
  min-width: 54px;
  padding: 8px 11px;
  border-radius: 8px;
  background: #edf3ff;
  color: var(--accent-dark);
  text-decoration: none;
  text-align: center;
  font-weight: 780;
}

pre {
  margin: 18px 0 0;
  min-height: 0;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 18px;
  line-height: 1.58;
  font-size: 15px;
}

.empty {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.authBody {
  display: grid;
  place-items: center;
}

.authShell {
  width: min(440px, calc(100% - 28px));
}

.authPanel,
.settingsForm,
.userForm {
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.formError {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.formOk {
  min-height: 20px;
  color: var(--done);
  font-weight: 700;
}

.adminShell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.adminLogin {
  width: min(460px, 100%);
  margin: 40px auto;
}

.hidden {
  display: none !important;
}

.adminApp {
  display: grid;
  gap: 18px;
}

.adminTabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab {
  min-height: 40px;
  padding: 0 16px;
  background: #edf2fb;
  color: #203b7a;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.tabPanel {
  display: none;
  border-radius: 8px;
  padding: 22px;
}

.tabPanel.active {
  display: grid;
  gap: 20px;
}

.settingsForm {
  max-width: 620px;
  box-shadow: none;
}

.userHead {
  gap: 20px;
}

.userTools {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.userTools input {
  width: min(280px, 100%);
}

.userForm {
  box-shadow: none;
}

.userFormGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.checkLine {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  color: var(--ink);
  font-weight: 700;
}

.checkLine input {
  width: 18px;
  height: 18px;
}

.formActions {
  justify-content: flex-start;
}

.userList {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.userRow {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 0.8fr) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.userRow:last-child {
  border-bottom: 0;
}

.userIdentity,
.userDates {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.userIdentity strong {
  overflow-wrap: anywhere;
}

.userIdentity span,
.userDates span {
  color: var(--muted);
  font-size: 13px;
}

.rolePill {
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf3ff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.userActions {
  justify-content: flex-end;
}

.iconButton {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: #f3f4ff;
  color: #695cff;
  font-size: 20px;
  line-height: 1;
}

.iconButton:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dangerButton {
  color: var(--danger);
  background: #fff0ef;
}

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
}

.metricGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metricCard {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  display: grid;
  gap: 8px;
}

.metricCard span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metricCard strong {
  font-size: 22px;
}

.metricCard em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.metricChart {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.adminColumns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.eventList {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.eventItem {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  background: #fff;
}

.eventItem strong {
  overflow-wrap: anywhere;
}

.eventItem span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .shell,
  .adminColumns,
  .userFormGrid,
  .userRow {
    grid-template-columns: 1fr;
  }

  .userRow {
    align-items: stretch;
  }

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

@media (max-width: 620px) {
  .topbar,
  .controls,
  .jobTop,
  .jobActions,
  .panelHead,
  .loadHead,
  .userHead,
  .userTools,
  .formTitleRow,
  .formActions,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .shell,
  .adminShell {
    padding: 14px;
  }

  .metricGrid {
    grid-template-columns: 1fr;
  }

  .downloads {
    justify-content: flex-start;
  }
}
