:root {
  --ink: #101816;
  --muted: #56635f;
  --paper: #f8f9f5;
  --white: #ffffff;
  --line: #d5ddd8;
  --green: #146b58;
  --green-dark: #0b463b;
  --green-wash: #e8f3ee;
  --blue-wash: #edf3f7;
  --amber: #9a641f;
  --amber-wash: #fbf2df;
  --red: #963c3c;
  --red-wash: #faecea;
  --shadow: 0 20px 55px rgba(16, 24, 22, 0.12);
  color-scheme: light;
}

.connection-guide { margin-block: 1.5rem; min-width: 0; }
.connection-guide table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; }
.connection-guide th, .connection-guide td { padding: .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.connection-guide th:first-child { width: 26%; }

@media (max-width: 600px) {
  .connection-guide table, .connection-guide tbody { display: block; }
  .connection-guide thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .connection-guide tbody tr { display: block; margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; }
  .connection-guide tbody th, .connection-guide tbody td { display: block; padding: .5rem 0; border: 0; }
  .connection-guide tbody th:first-child { width: auto; }
  .connection-guide tbody td::before { content: attr(data-label); display: block; font-weight: 700; }
}


* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; }

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

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }

.wrap { width: min(1080px, calc(100% - 36px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(16, 24, 22, 0.12);
  background: rgba(248, 249, 245, 0.94);
  backdrop-filter: blur(14px);
}

.nav, .nav-state, .brand, .portal-heading, .app-heading, .app-actions, .footer-inner {
  display: flex;
  align-items: center;
}

.nav { min-height: 66px; justify-content: space-between; gap: 18px; }
.nav-state { gap: 10px; }

.brand { gap: 11px; color: var(--ink); font-weight: 860; text-decoration: none; }
.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--white);
  font-size: 12px;
}

.private-badge, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.hero {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 15%, rgba(47, 99, 133, 0.13), transparent 30%),
    linear-gradient(135deg, #e4efea 0%, var(--paper) 60%, #eef3f6 100%);
}

.hero-grid {
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 54px;
  align-items: center;
  padding: 70px 0 56px;
}

.eyebrow, .kicker {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 12px;
  font-weight: 880;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 { margin-top: 0; letter-spacing: -0.035em; line-height: 1.02; }
h1 { max-width: 720px; margin-bottom: 22px; font-size: clamp(46px, 7vw, 78px); }
h2 { margin-bottom: 12px; font-size: clamp(30px, 4vw, 44px); }
h3 { margin-bottom: 8px; font-size: 24px; }

.lede, .section-lede { max-width: 760px; margin: 0; color: #35443f; font-size: 19px; }

.journey {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.journey li {
  min-height: 88px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0 12px;
  align-items: center;
  padding: 15px;
  border: 1px solid rgba(16, 24, 22, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 30px rgba(16, 24, 22, 0.05);
}

.journey li > span {
  width: 34px;
  height: 34px;
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  font-weight: 850;
}

.journey strong { align-self: end; }
.journey small { align-self: start; color: var(--muted); }

.workspace { min-height: 500px; padding: 48px 0 70px; }

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
}

.notice:empty { display: none; }
.notice[data-tone="success"] { border-color: rgba(20, 107, 88, 0.28); background: var(--green-wash); color: var(--green-dark); }
.notice[data-tone="warning"] { border-color: rgba(154, 100, 31, 0.28); background: var(--amber-wash); color: #73490f; }
.notice[data-tone="error"] { border-color: rgba(150, 60, 60, 0.28); background: var(--red-wash); color: #762c2c; }

.auth-card {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 38px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth-card p { color: var(--muted); }
.bootstrap-form { display: grid; align-content: start; gap: 10px; }
label { font-size: 14px; font-weight: 820; }

input, textarea {
  width: 100%;
  border: 1px solid #aebbb5;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

input { min-height: 48px; padding: 11px 12px; }
#accept-form label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
}
#accept-form input[type="checkbox"] {
  appearance: auto;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  accent-color: #146b58;
  cursor: pointer;
}
#accept-form label:focus-within { outline: 2px solid #146b58; outline-offset: 3px; }
textarea { min-height: 104px; padding: 12px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.45; }
input:focus, textarea:focus, button:focus-visible { box-shadow: 0 0 0 3px rgba(20, 107, 88, 0.2); }
.field-help { margin: 0 0 4px; font-size: 13px; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 820;
}

.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--ink); color: var(--white); }
.account-nav { flex-wrap: wrap; justify-content: flex-start; padding-block: 12px; }
.account-nav #logout { margin-left: auto; }
.nav .button-owner-admin { background: #6d28d9; border-color: #6d28d9; color: #fff; font-weight: 820; box-shadow: 0 2px 6px rgba(76, 29, 149, .2); }
.nav .button-owner-admin:hover { background: #5b21b6; border-color: #5b21b6; color: #fff; text-decoration: none; }
.nav .button-owner-admin:focus-visible { outline: 3px solid #4c1d95; outline-offset: 3px; }

.button-danger { border-color: var(--red); color: var(--red); }
.button-quiet { min-height: 36px; padding: 7px 10px; border-color: var(--line); font-size: 13px; }

.portal-heading { justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.apps { display: grid; gap: 18px; }
.app-card { padding: 26px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: 0 12px 36px rgba(16, 24, 22, 0.07); }
.app-heading { justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.app-heading p { margin: 0; color: var(--muted); }
.app-actions { flex-wrap: wrap; gap: 9px; }

.status-pill[data-status="connected"] { color: var(--green-dark); border-color: rgba(20, 107, 88, 0.25); background: var(--green-wash); }
.status-pill[data-status="waiting"] { color: #73490f; border-color: rgba(154, 100, 31, 0.25); background: var(--amber-wash); }
.status-pill[data-status="inactive"] { color: var(--muted); background: #f2f4f1; }

.setup-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }
.setup-step { min-height: 150px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcf9; }
.setup-step > span { display: block; margin-bottom: 10px; color: var(--green); font-size: 12px; font-weight: 880; text-transform: uppercase; letter-spacing: 0.06em; }
.setup-step strong { display: block; margin-bottom: 7px; }
.setup-step p { margin: 0; color: var(--muted); font-size: 14px; }
.secret-name { display: inline-block; padding: 2px 6px; border-radius: 5px; background: #e8eeea; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.connection-detail { margin: 0 0 20px; padding: 14px 16px; border-left: 3px solid var(--green); background: var(--green-wash); color: #33443e; }
.connection-detail strong { color: var(--green-dark); }

.safety-note { margin-top: 18px; display: grid; gap: 4px; padding: 17px 19px; border: 1px solid rgba(154, 100, 31, 0.24); border-radius: 10px; background: var(--amber-wash); }
.safety-note span { color: #664916; }

footer { border-top: 1px solid var(--line); background: #eef2ee; }
.footer-inner { min-height: 74px; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(10, 18, 16, 0.68); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border-radius: 13px; background: var(--white); box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28); }
.modal p { color: var(--muted); }
.modal-alert { padding: 12px 14px; border: 1px solid rgba(154, 100, 31, 0.25); border-radius: 8px; background: var(--amber-wash); color: #664916 !important; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.modal-instructions { margin: 18px 0 0; padding: 16px; border-radius: 8px; background: var(--green-wash); }
.modal-instructions strong { display: block; margin-bottom: 5px; color: var(--green-dark); }
.modal-instructions p { margin: 0; color: #33443e; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
  .hero-grid, .auth-card { grid-template-columns: 1fr; }
  .hero-grid { min-height: auto; gap: 34px; padding: 52px 0 44px; }
  .setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .wrap { width: min(100% - 24px, 1080px); }
  .private-badge { display: none; }
  h1 { font-size: 44px; }
  .workspace { padding-top: 32px; }
  .auth-card, .app-card, .modal { padding: 20px; }
  .portal-heading, .app-heading, .footer-inner { align-items: flex-start; flex-direction: column; }
  .setup-grid { grid-template-columns: 1fr; }
  .button { width: 100%; }
  .nav .button { width: auto; }
}