:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #dfe6ef;
  --ink: #17202a;
  --muted: #637083;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --warning: #9a5b00;
  --soft: #f7f9fc;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1, h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: 30px; }
h2 { font-size: 18px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.warning, .user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.warning {
  border-color: #f4d08a;
  background: #fff8e7;
  color: var(--warning);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  gap: 6px;
  padding: 12px 28px;
  background: rgba(238, 242, 247, .95);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button,
button,
.download-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.tabs button.active,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button:hover,
.download-link:hover {
  border-color: #b8c4d4;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
}

.icon-danger {
  color: var(--danger);
  min-height: 32px;
}

main {
  padding: 22px 28px 36px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.jobs-grid {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(23, 32, 42, .04);
}

.panel + .panel,
.grid + .panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel > h2 {
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.registrar-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.stack {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.download-link:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .18);
  border-color: var(--accent);
}

.upload-row,
.inline-check {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.inline-check {
  grid-template-columns: repeat(4, minmax(90px, 1fr)) auto;
  margin: 0;
  max-width: 780px;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.table-wrap.compact {
  max-height: 480px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: var(--soft);
  color: #3b4858;
  font-size: 12px;
  text-transform: uppercase;
}

td form {
  margin: 0;
}

.empty,
.pathline {
  color: var(--muted);
}

.pathline {
  margin: 0 0 14px;
  overflow-wrap: anywhere;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.flash-row {
  display: grid;
  gap: 8px;
  padding: 14px 28px 0;
}

.flash {
  border: 1px solid #b7ddce;
  background: #edfdf6;
  color: #115e45;
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 700;
}

.flash.error {
  border-color: #f4b8b0;
  background: #fff1ef;
  color: var(--danger);
}

.job-list {
  display: grid;
  gap: 8px;
}

.job-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  text-align: left;
}

.status {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
}

.status.running,
.status.queued {
  background: #e6f5ff;
  color: #075985;
}

.status.done {
  background: #e8f8ef;
  color: #166534;
}

.status.error {
  background: #fff1ef;
  color: var(--danger);
}

.log-panel pre {
  min-height: 520px;
  max-height: 68vh;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #111827;
  color: #d1fae5;
  line-height: 1.45;
  white-space: pre-wrap;
}

.plain-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.muted-panel {
  background: #fbfcfe;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(440px, 100%);
  padding: 0;
}

.login-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 42, .08);
}

.login-panel h1 {
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .grid.two,
  .jobs-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .registrar-grid,
  .inline-check {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .tabs,
  main,
  .flash-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  .form-grid,
  .registrar-grid,
  .inline-check,
  .upload-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  .panel {
    padding: 14px;
  }
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.subtabs button {
  background: #fff;
}

.subtabs button.active {
  border-color: var(--accent);
  background: #e9f7f4;
  color: var(--accent-strong);
}

.access-panel { display: none; }
.access-panel.active { display: block; }

.narrow-panel {
  max-width: 760px;
}

.hintline {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.action-row,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.action-row {
  margin: -4px 0 14px;
}

.csv-editor-panel {
  padding: 0;
  overflow: hidden;
}

.csv-editor {
  min-height: 68vh;
  border: 0;
  border-radius: 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
}

.csv-editor-panel .form-actions {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--soft);
}
.wide-table {
  max-height: 520px;
}

.wide-table input,
.wide-table select {
  min-width: 150px;
}

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions-cell form {
  margin: 0;
}

.picker-field {
  display: grid;
  gap: 8px;
}

.field-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.compact-picker {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.server-picker {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  max-height: 180px;
}

.pick-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .16s ease;
}

.pick-card:hover {
  border-color: #8bb9b3;
  box-shadow: 0 10px 22px rgba(23, 32, 42, .07);
  transform: translateY(-1px);
}

.pick-card input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.pick-card:has(input:checked) {
  border-color: var(--accent);
  background: #eefaf7;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.pick-card.disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #f1f5f9;
}

.pick-card.disabled:hover {
  transform: none;
  box-shadow: none;
}

.pick-main {
  min-width: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-meta {
  grid-column: 2 / 4;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-badge {
  justify-self: end;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.picker-empty {
  grid-column: 1 / -1;
  padding: 16px;
}

.preset-panel {
  max-height: 760px;
  overflow: auto;
}

.preset-form {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.preset-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.preset-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preset-item form:last-child {
  justify-self: start;
}

.copy-state {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.drop-result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.compact-head {
  margin-bottom: 8px;
}

.compact-head h3 {
  margin: 0;
  font-size: 16px;
}

.mini-log {
  max-height: 220px;
  overflow: auto;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ai-report {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.report-row strong {
  color: var(--ink);
  font-size: 13px;
  text-align: right;
}

.report-summary {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.report-output {
  max-height: 150px;
  margin-top: 0;
}


.posting-panel {
  overflow: hidden;
}

.posting-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.posting-edit-table {
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.posting-edit-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.posting-edit-table th,
.posting-edit-table td {
  padding: 7px;
  border-bottom: 1px solid var(--line);
}

.posting-edit-table input {
  min-width: 150px;
  min-height: 34px;
  border-radius: 5px;
}

.posting-edit-table th:last-child,
.posting-edit-table td:last-child {
  width: 74px;
  min-width: 74px;
}

.small-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}


.posting-subtabs {
  margin-bottom: 14px;
}

.posting-script-panel {
  display: none;
}

.posting-script-panel.active {
  display: block;
}

.posting-panel {
  max-width: none;
}

.posting-table-wrap {
  max-height: 520px;
}

.posting-edit-table {
  width: max-content;
  min-width: 100%;
}

.users-table-wrap {
  max-height: 560px;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  min-width: 360px;
}

.inline-password-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.inline-password-form input {
  min-width: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .inline-password-form {
    grid-template-columns: 1fr;
  }
}

.posting-edit-table input.paste-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}


.template-sync-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}

.template-sync-panel h2 {
  margin-bottom: 6px;
}

.template-sync-panel form {
  margin: 0;
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .template-sync-panel {
    align-items: stretch;
    flex-direction: column;
  }
}
