:root {
  --ink: #132019;
  --muted: #64736c;
  --line: #d9e3de;
  --surface: #ffffff;
  --subtle: #f3f7f5;
  --green: #087f3f;
  --green-dark: #056632;
  --green-soft: #e6f5ec;
  --amber: #9a6500;
  --amber-soft: #fff5d8;
  --red: #a52b2b;
  --red-soft: #fbeaea;
  --shadow: 0 12px 28px rgba(21, 45, 33, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: #f6f8f7;
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(8, 127, 63, 0.28); outline-offset: 2px; }

.topbar {
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font-size: 18px; }
.brand small { color: var(--muted); font-size: 12px; }
.account { display: flex; align-items: center; gap: 12px; }
.account form { margin: 0; }
.account-name { font-weight: 700; }
.role, .state {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.text-link { color: var(--green-dark); font-weight: 700; text-decoration: none; }

.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 64px; }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.message-error { border-color: #efc5c5; background: var(--red-soft); color: #762020; }
.message-success { border-color: #b7ddc6; background: var(--green-soft); color: #075f31; }

.button {
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-secondary { border-color: #a9c6b7; background: #fff; color: var(--green-dark); }
.button-danger { border-color: #dfb2b2; background: #fff; color: var(--red); }
.button-quiet { min-height: 36px; padding: 6px 10px; border-color: var(--line); background: #fff; color: var(--muted); }
.button-wide { width: 100%; }

.auth-page, .empty-page { min-height: calc(100vh - 72px); display: grid; place-items: center; }
.auth-panel {
  width: min(440px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.auth-panel-wide { width: min(560px, 100%); }
.eyebrow { margin-bottom: 6px; color: var(--green); font-size: 13px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; letter-spacing: 0; }
h2 { margin-bottom: 4px; font-size: 23px; line-height: 1.2; letter-spacing: 0; }
.auth-panel > p, .section-heading p { color: var(--muted); }
.form-stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 6px; color: #35473e; font-weight: 700; }
label small { color: var(--muted); font-weight: 500; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #b9c9c1;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
.code-input { font-size: 24px; font-weight: 800; text-align: center; letter-spacing: 0; }
.security-state { margin: 24px 0 10px; display: flex; align-items: center; gap: 9px; color: var(--green-dark); }
.setup-steps { margin: 22px 0; padding-left: 22px; color: #35473e; }
.setup-steps li { margin-bottom: 8px; }
.secret-box { padding: 16px; display: grid; gap: 8px; border: 1px solid #b7ddc6; border-radius: 6px; background: var(--green-soft); }
.secret-box span { color: var(--muted); font-size: 13px; font-weight: 750; text-transform: uppercase; }
.secret-box strong { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 19px; }
.secret-box a { color: var(--green-dark); font-weight: 750; }

.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-heading { margin-bottom: 24px; }
.preview-dialog {
  width: min(1560px, calc(100vw - 28px));
  height: calc(100vh - 28px);
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(12, 30, 21, 0.24);
}
.preview-dialog::backdrop { background: rgba(19, 32, 25, 0.48); }
.preview-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.preview-toolbar {
  min-height: 72px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.preview-title-row, .preview-actions { display: flex; align-items: center; gap: 10px; }
.preview-toolbar h2 { margin: 0; font-size: 20px; }
.preview-toolbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.state-draft { background: var(--amber-soft); color: var(--amber); }
.preview-close {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}
.preview-frame-wrap { min-height: 0; background: #eef3f0; }
.preview-frame { width: 100%; height: 100%; display: block; border: 0; background: #fff; }
.section {
  margin-bottom: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(21, 45, 33, 0.05);
}
.section-heading { margin-bottom: 20px; }
.section-heading p { margin-bottom: 0; }
.release-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.release-panel { min-height: 132px; padding: 16px; display: grid; align-content: start; gap: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); }
.release-panel strong { overflow-wrap: anywhere; font-size: 17px; }
.release-panel > span { color: var(--muted); font-size: 14px; }
.release-label { display: flex; align-items: center; gap: 8px; color: #3f5148; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #7c8b84; }
.status-live { background: var(--green); }
.status-draft { background: #d98c00; }
.status-previous { background: #45536d; }
.action-row { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action-row form { margin: 0; }
.inline-form { flex: 1 1 440px; display: flex; gap: 8px; }
.inline-form input { flex: 1; }

.invite-form { display: grid; grid-template-columns: 1.1fr 1.1fr 0.75fr auto; align-items: end; gap: 10px; margin-bottom: 20px; }
.invite-result { margin-bottom: 16px; padding: 14px; display: grid; gap: 8px; border: 1px solid #b7ddc6; border-radius: 6px; background: var(--green-soft); }
.invite-result input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--subtle); color: #4e5e56; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); }
.table-action { width: 1%; white-space: nowrap; }
.state-active { background: var(--green-soft); color: var(--green-dark); }
.state-disabled { background: var(--red-soft); color: var(--red); }
.empty-state { max-width: 560px; text-align: center; }
.empty-state p { color: var(--muted); }
.error-code { margin-bottom: 10px; color: var(--green); font-size: 48px; font-weight: 850; }

@media (max-width: 900px) {
  .release-grid { grid-template-columns: 1fr; }
  .invite-form { grid-template-columns: 1fr 1fr; }
  .invite-form .button { width: 100%; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  .account { justify-content: flex-end; flex-wrap: wrap; }
  .account-name, .role { display: none; }
  .page { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .section, .auth-panel { padding: 18px; }
  .page-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .preview-dialog { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
  .preview-toolbar { align-items: flex-start; padding: 10px 12px; }
  .preview-toolbar p, .preview-actions .button { display: none; }
  .preview-title-row { align-items: flex-start; flex-direction: column; gap: 3px; }
  .inline-form { flex-direction: column; }
  .action-row > form:not(.inline-form), .action-row > form:not(.inline-form) .button { width: 100%; }
  .invite-form { grid-template-columns: 1fr; }
}
