:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #666b70;
  --line: #deded8;
  --accent: #0f6b63;
  --accent-ink: #ffffff;
  --high: #b34d00;
  --urgent: #b42318;
  --normal: #3561a7;
  --low: #687076;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 32px auto 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, calc((100vw - 1180px) / 2));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
button,
input[type="submit"] {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  text-decoration: none;
  font: inherit;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.danger {
  border-color: #d8b4ad;
  color: var(--urgent);
}

.workspace-header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  margin-bottom: 8px;
}

h2 {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
}

.workspace-header p,
.detail-header p,
.task-card p,
.empty {
  color: var(--muted);
}

.lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.lane {
  min-width: 0;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-list.full {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

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

.task-card {
  padding: 14px;
}

.task-card-header,
.card-actions,
.actions,
.source-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-card-header,
.card-actions {
  justify-content: space-between;
}

.actions.compact {
  flex-wrap: nowrap;
}

.task-card h3 {
  margin: 10px 0 8px;
}

.task-card h3 a {
  text-decoration: none;
}

.priority,
.chip,
.score {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 700;
}

.priority {
  color: white;
}

.priority.low {
  background: var(--low);
}

.priority.normal {
  background: var(--normal);
}

.priority.high {
  background: var(--high);
}

.priority.urgent {
  background: var(--urgent);
}

.chip,
.score,
.workspace-chip {
  background: #ecece5;
  color: var(--ink);
  text-decoration: none;
}

.workspace-chip {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.8rem;
  margin-bottom: 8px;
  min-height: 26px;
  padding: 4px 9px;
}

.text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
}

.detail,
.auth-panel {
  padding: 24px;
}

.auth-panel {
  width: min(460px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.prose {
  max-width: 70ch;
  margin-bottom: 32px;
}

.source-list {
  display: grid;
  gap: 10px;
}

.source {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
}

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

.settings-link {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 16px;
  text-decoration: none;
}

.settings-link span {
  color: var(--muted);
}

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

.provider-card {
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 12px;
  grid-template-columns: 44px minmax(0, 1fr);
  min-height: 132px;
  padding: 16px;
  text-decoration: none;
}

.provider-card strong,
.provider-card small {
  display: block;
}

.provider-card small {
  color: var(--muted);
  margin-top: 4px;
}

.provider-icon {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  flex: 0 0 auto;
  height: 44px;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  padding: 8px;
  width: 44px;
}

.provider-icon img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.provider-icon-fallback {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.provider-icon.small {
  border-radius: 6px;
  height: 28px;
  padding: 5px;
  width: 28px;
}

.provider-inline,
.provider-heading {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.provider-heading {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 12px;
}

.table-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

.data-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.token-reveal {
  background: #fff8df;
  border: 1px solid #e2c76c;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
}

.token-reveal code {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  overflow-x: auto;
  padding: 12px;
  white-space: nowrap;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 26px;
  padding: 4px 9px;
}

.status-pill.active {
  background: #dcefe8;
  color: #0f513d;
}

.status-pill.expired {
  background: #ecece5;
  color: var(--muted);
}

.status-pill.revoked {
  background: #f6dfdc;
  color: var(--urgent);
}

.task-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

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

.inline-filter,
.workspace-switcher {
  min-width: 180px;
}

.workspace-switcher select {
  min-height: 38px;
  padding-block: 7px;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 44px;
}

.checkbox-row input {
  width: auto;
}

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

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

.integration-config {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.integration-fields {
  display: grid;
  gap: 14px;
}

.integration-config p {
  color: var(--muted);
  margin-bottom: 0;
}

.integration-fields p {
  color: var(--muted);
  margin-bottom: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 72ch;
}

.field-hint a {
  color: var(--accent);
  font-weight: 700;
}

.field-hint code {
  color: var(--ink);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.webhook-registration {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding-top: 14px;
}

select[multiple] {
  min-height: 150px;
}

.notice {
  width: min(1180px, calc(100vw - 32px));
  margin: 16px auto 0;
  padding: 10px 12px;
  background: #e7f3ef;
  border: 1px solid #b8d8ce;
  border-radius: 8px;
}

.errors {
  padding: 12px;
  border-color: var(--urgent);
}

@media (max-width: 820px) {
  main {
    width: min(100vw - 20px, 680px);
    margin-top: 20px;
  }

  .workspace-header,
  .detail-header,
  .webhook-registration {
    display: grid;
  }

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

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