:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft JhengHei UI", sans-serif;
  color: #172437;
  background: #f3f5f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink-muted: #58697f;
  --line: #dfe6ef;
  --surface: #fff;
  --brand: #244ec3;
  --brand-dark: #193d9e;
  --danger: #9b2733;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: #e8efff;
  color: var(--brand);
  font-size: 20px;
  font-weight: 700;
}

.brand-copy {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 29px);
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.35;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

h4 {
  margin-bottom: 0;
  font-size: 14px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button-primary {
  background: var(--brand);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.button-secondary {
  border-color: #c9d4e2;
  background: var(--surface);
  color: #26364a;
}

.button-secondary:hover:not(:disabled),
.button-tertiary:hover:not(:disabled) {
  border-color: #91a6c1;
  background: #f8faff;
}

.button-tertiary {
  min-height: 36px;
  padding: 7px 11px;
  border-color: transparent;
  background: transparent;
  color: #344962;
  font-size: 13px;
}

.button:focus-visible,
.text-button:focus-visible,
.tool-row:focus-visible,
a:focus-visible {
  outline: 3px solid #86a6ff;
  outline-offset: 3px;
}

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

.access-panel {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.status {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.5;
}

.status[data-kind="error"],
.inline-status[data-kind="error"] {
  color: var(--danger);
}

.status[data-kind="success"],
.inline-status[data-kind="success"] {
  color: #176344;
}

.account-status {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tool-workspace {
  display: grid;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 6px 22px rgb(20 38 64 / 4%);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading--compact {
  margin-bottom: 12px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: #33465e;
  font-size: 13px;
  font-weight: 600;
}

.field b {
  color: var(--danger);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #172437;
  font-size: 14px;
  font-weight: 400;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #6283e5;
  outline: 3px solid rgb(134 166 255 / 35%);
}

.field small {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 400;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.78fr) minmax(0, 1.22fr);
  align-items: start;
  gap: 18px;
}

.list-panel,
.detail-panel,
.form-panel {
  min-height: 260px;
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf0f5;
}

.muted,
.list-meta p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
}

.text-button {
  padding: 5px 2px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

.inline-status {
  min-height: 18px;
  margin: 8px 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.tool-list {
  display: grid;
  gap: 8px;
}

.tool-row {
  display: grid;
  width: 100%;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid #e5eaf1;
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.tool-row:hover {
  border-color: #b8c9ee;
  background: #fafbff;
}

.tool-row.is-selected {
  border-color: #7392e5;
  background: #f4f7ff;
  box-shadow: inset 3px 0 0 var(--brand);
}

.tool-row__top,
.tool-row__bottom {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tool-row__name {
  overflow: hidden;
  color: #172437;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-row__type,
.tool-row__owner {
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge,
.count-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #43566d;
  font-size: 11px;
  font-weight: 650;
}

.status-badge--development {
  background: #edf3ff;
  color: #2956a8;
}

.status-badge--prototype {
  background: #f3efff;
  color: #6745a6;
}

.status-badge--pilot {
  background: #fff5df;
  color: #835500;
}

.status-badge--production {
  background: #e8f6ee;
  color: #176344;
}

.status-badge--maintenance {
  background: #fff0e9;
  color: #985328;
}

.status-badge--retired {
  background: #f0f1f3;
  color: #59616b;
}

.detail-column {
  display: grid;
  gap: 18px;
}

.empty-state {
  margin: 8px 0;
  padding: 18px 12px;
  color: var(--ink-muted);
  font-size: 14px;
  text-align: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(118px, 0.35fr) minmax(0, 1fr);
  gap: 0;
  margin: 0;
  border-top: 1px solid #edf0f5;
}

.detail-grid dt,
.detail-grid dd {
  min-width: 0;
  margin: 0;
  padding: 10px 8px;
  border-bottom: 1px solid #edf0f5;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.detail-grid dt {
  color: var(--ink-muted);
}

.detail-grid dd {
  color: #172437;
  white-space: pre-wrap;
}

.external-link {
  color: var(--brand);
  overflow-wrap: anywhere;
}

.detail-updated {
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.history-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e9edf3;
}

.subsection-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.count-pill {
  padding: 3px 8px;
  background: #edf1f7;
  color: #455a73;
}

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

.history-entry {
  padding: 13px 14px;
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  background: #fcfdff;
}

.history-entry__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.history-entry__time,
.history-entry__actor {
  color: var(--ink-muted);
  font-size: 12px;
}

.history-entry__actor {
  margin: 6px 0 10px;
}

.history-changes {
  display: grid;
  grid-template-columns: minmax(90px, 0.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
}

.history-change__label {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: #354a63;
  font-size: 12px;
  font-weight: 700;
}

.history-change__before,
.history-change__after {
  min-width: 0;
  margin: 0;
  padding: 7px 8px;
  border-radius: 6px;
  color: #43566d;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-change__before {
  background: #f3f4f6;
}

.history-change__after {
  background: #edf5ff;
}

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

.field-span {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .page-shell {
    padding: 22px 20px 36px;
  }

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

  .field-search {
    grid-column: 1 / -1;
  }

  .workspace-grid {
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 16px 12px 28px;
  }

  .app-header {
    flex-wrap: wrap;
  }

  .brand-copy {
    flex-basis: calc(100% - 66px);
  }

  .account-actions {
    width: 100%;
  }

  .account-actions .button {
    flex: 1;
  }

  .access-panel {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .panel {
    padding: 16px;
  }

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

@media (max-width: 480px) {
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-search,
  .field-span {
    grid-column: auto;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading .button {
    padding-inline: 10px;
  }

  .detail-grid {
    grid-template-columns: minmax(95px, 0.4fr) minmax(0, 1fr);
  }

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

  .history-change__label {
    grid-column: 1 / -1;
  }

  .history-entry__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
