:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #d8e0ea;
  --primary: #1663d7;
  --primary-dark: #0f4fb0;
  --danger: #c93636;
  --success: #16834b;
  --warning: #ad6a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.current-user {
  color: var(--muted);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

nav a,
.link-button {
  color: var(--primary);
  border: 0;
  background: transparent;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.app {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto;
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 24px;
}

.login {
  max-width: 420px;
  margin: 10vh auto;
}

h1 {
  margin: 0 0 18px;
  font-size: 24px;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #eef3f9;
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  padding: 18px;
}

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

.hint {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.error {
  color: var(--danger);
  margin-top: 12px;
}

.danger-link {
  color: var(--danger);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef3f9;
  font-size: 13px;
}

.status.success {
  background: #e8f7ef;
}

.status.failed {
  background: #fdecec;
}

.status.running,
.status.pending {
  background: #fff5dd;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

pre {
  overflow: auto;
  max-height: 420px;
  padding: 14px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
}

.upload-form {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.project-admin {
  margin-bottom: 18px;
}

.user-admin {
  margin-bottom: 18px;
}

.project-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.project-permissions {
  grid-column: 1 / -1;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

.form-message {
  margin-top: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.user-table {
  margin-top: 16px;
}

@media (max-width: 760px) {
  .topbar,
  .toolbar,
  .upload-form {
    align-items: stretch;
    flex-direction: column;
  }

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

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

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

  table {
    display: block;
    overflow-x: auto;
  }
}
