:root {
  --canvas: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #f7f8f9;
  --line: #e3e6e8;
  --ink: #25292d;
  --muted: #697078;
  --blue: #335ed4;
  --blue-dark: #274cb2;
  --green: #18795a;
  --green-soft: #eff8f3;
  --amber: #986100;
  --amber-soft: #fff5d8;
  --red: #bd3b3b;
  --red-soft: #fff0ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { min-width: 320px; margin: 0; background: var(--surface); line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.member-shell { width: min(1120px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 32px 48px; }
.topbar { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; color: #fff; background: var(--green); border-radius: 7px; }
.brand strong { font-size: 15px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 500; }

.login-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; max-width: 360px; margin: 64px auto; }
.login-copy h1, .account-band h1 { margin: 0; font-size: 22px; line-height: 1.45; overflow-wrap: anywhere; font-weight: 650; }
.login-form { display: grid; gap: 20px; padding: 0; }
.login-password-field { display: grid; gap: 8px; min-width: 0; }
.login-password-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-warning { margin: 0; color: var(--amber); font-size: 13px; overflow-wrap: anywhere; }
label { display: grid; gap: 8px; color: #494f56; font-size: 13px; font-weight: 550; }
label small { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
input, textarea { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid #cdd3d8; border-radius: 6px; outline: none; }
input { height: 44px; padding: 0 12px; }
textarea { min-height: 70px; padding: 10px 12px; resize: vertical; line-height: 1.5; font-weight: 400; }
textarea::placeholder { color: #80868d; opacity: 1; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; transition: background-color .15s, border-color .15s; }
.button:hover:not(:disabled) { background: var(--canvas); border-color: #bdc6cd; }
.button-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.button-success { color: #fff; background: var(--green); border-color: var(--green); }
.button-success:hover:not(:disabled) { background: #126046; border-color: #126046; }
.button-danger { color: var(--red); background: var(--red-soft); border-color: #edc3c0; }
.button-quiet { color: #505860; background: var(--surface); }
.icon-button { width: 36px; min-height: 36px; height: 36px; padding: 0; flex: 0 0 36px; }

.member-view { padding-top: 24px; }
.account-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding-bottom: 24px; }
.workspace-name { margin: 6px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.account-status { display: grid; justify-items: end; gap: 8px; }
.account-status small { color: var(--muted); font-size: 12px; }
.account-status small:empty { display: none; }
.status-pill { display: inline-flex; min-height: 28px; align-items: center; padding: 4px 10px; color: var(--green); background: var(--green-soft); border: 1px solid #d2e9dc; border-radius: 5px; font-size: 12px; font-weight: 600; }
.status-pill.is-cooling { color: var(--amber); background: var(--amber-soft); border-color: #ead79c; }

.credentials-panel { margin: 0 0 24px; padding: 16px 20px; color: #22553f; background: var(--green-soft); border: 1px solid #d5e9df; border-left: 3px solid var(--green); }
.credentials-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.credentials-panel h2, .action-band h2, .history-section h2 { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.5; }
.credentials-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.credentials-panel dl { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(160px, 1fr); gap: 24px; margin: 0; }
.credentials-panel dl div { min-width: 0; }
.credentials-panel dt { display: flex; align-items: center; min-height: 24px; margin-bottom: 4px; color: #5b7466; font-size: 12px; font-weight: 500; }
.credentials-panel dd { margin: 0; min-height: 23px; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 600; }

.action-band { display: grid; gap: 14px; padding: 22px 0 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.action-controls { display: grid; grid-template-columns: minmax(0, 1fr) 176px; align-items: end; gap: 20px; }
.action-controls .button { min-height: 42px; margin-bottom: 1px; }
.export-band { grid-template-columns: minmax(0, 1fr) auto; }
.export-actions { display: flex; gap: 10px; }

.message { margin: 16px 0 0; padding: 10px 12px; color: var(--green); background: var(--green-soft); border: 1px solid #c6e8d8; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }
.message-error { color: var(--red); background: var(--red-soft); border-color: #edc3c0; }
.message-warning { color: var(--amber); background: var(--amber-soft); border-color: #ead79c; }

.history-section { padding-top: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.history-wrap { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
th, td { padding: 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 500; }
th:first-child { width: 18%; }
th:nth-child(2) { width: 42%; }
th:nth-child(3) { width: 26%; }
th:last-child { width: 14%; }
th:last-child, .history-action { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.history-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.account-change { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: baseline; gap: 8px; }
.account-change + .account-change { margin-top: 6px; }
.account-change-label { color: #858b92; font-size: 11px; }
.account-change:first-child { color: var(--muted); }
.account-change:last-child { color: var(--ink); }
.empty-cell { padding: 36px 16px; color: var(--muted); text-align: center; }
.history-status { display: inline-flex; padding: 2px 7px; border-radius: 4px; color: #53616d; background: #f0f3f6; font-size: 12px; font-weight: 550; }
.history-status.is-completed { color: var(--green); background: var(--green-soft); }
.history-status.is-failed, .history-status.is-rejected { color: var(--red); background: var(--red-soft); }
.history-status.is-pending_approval, .history-status.is-paused { color: var(--amber); background: var(--amber-soft); }
.history-status.is-superseded { color: var(--muted); background: var(--canvas); }
.history-stage { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.table-action { min-height: 34px; padding: 6px 10px; color: var(--green); font-size: 12px; }
.replacement-progress { display: grid; gap: 10px; padding: 18px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.replacement-progress progress { width: 100%; height: 8px; accent-color: var(--green); }
.reveal-button { display: inline-flex; min-height: 24px; align-items: center; gap: 5px; margin-left: 12px; color: var(--green); font-size: 12px; cursor: pointer; }
.reveal-button input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); }

@media (max-width: 800px) {
  .credentials-content { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .credentials-content > .button { justify-self: start; }
  .account-band { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .account-status { justify-items: start; }
}

@media (max-width: 600px) {
  .member-shell { padding: 0 20px 32px; }
  .topbar { min-height: 64px; }
  .brand strong { font-size: 14px; }
  .topbar .button { padding: 6px 8px; }
  .login-layout { margin: 44px auto; }
  .account-band h1 { font-size: 20px; }
  .credentials-panel { padding: 14px 16px; }
  .credentials-panel dl { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .credentials-content > .button { justify-self: stretch; }
  .credentials-heading { margin-bottom: 14px; }
  .action-controls, .export-band { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .export-actions { display: grid; grid-template-columns: 1fr 1fr; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: block; min-width: 0; padding: 0; border: 0; }
  .history-time, .history-accounts { grid-column: 1 / -1; }
  .history-time::before { content: attr(data-label); margin-right: 12px; }
  .history-action { align-self: center; }
  .empty-cell { grid-column: 1 / -1; padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
