:root {
  --ink: #14241c;
  --muted: #4d6156;
  --canvas: #e3ebe6;
  --paper: #f4f7f5;
  --card: #ffffff;
  --line: #d5e0d9;
  --rail: #0d1c16;
  --rail-text: #d7e7dc;
  --rail-dim: #8eab9a;
  --green: #1c7c45;
  --green-press: #17693a;
  --green-deep: #0e3d24;
  --field: #ffffff;
  --danger: #8f2d2d;
  --danger-bg: #f8ecec;
  --ok-bg: #e7f5ec;
  --focus: #1c7c45;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #e6f0ea;
  --muted: #a9bfb2;
  --canvas: #070d0b;
  --paper: #101816;
  --card: #18241f;
  --line: #2d3d34;
  --rail: #0a1411;
  --rail-text: #d7e7dc;
  --rail-dim: #8eab9a;
  --green: #3caf68;
  --green-press: #2f9460;
  --green-deep: #b7e0c6;
  --field: #121a16;
  --danger: #f0b4b4;
  --danger-bg: #3a2222;
  --ok-bg: #173226;
  --focus: #3caf68;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Figtree, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, .figure, .login-panel h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.4rem; line-height: 1.1; margin: 0; }
h2 { font-size: 1.35rem; margin: 0 0 0.75rem; }

a { color: inherit; }

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

button {
  background: var(--green);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
}

button:hover { background: var(--green-press); }

button.quiet {
  background: transparent;
  color: var(--green-deep);
  border: 1px solid var(--line);
}

button.quiet:hover { background: var(--paper); }

input, select, textarea {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

textarea { resize: vertical; }

label { display: block; font-weight: 560; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.shell { min-height: 100vh; }

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 228px;
  background: var(--rail);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem 1.25rem;
}

.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  text-decoration: none;
  font-weight: 650;
  margin-bottom: 1.5rem;
}

.mark {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-family: Fraunces, Georgia, serif;
}

.rail nav { display: flex; flex-direction: column; gap: 0.25rem; }

.rail nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  color: var(--rail-dim);
}

.rail nav a svg { width: 1.15rem; height: 1.15rem; flex: none; }

.rail nav a[aria-current="page"] {
  background: rgba(60, 175, 104, 0.2);
  color: #f4fff8;
}

.rail nav a:hover { background: rgba(255, 255, 255, 0.06); color: white; }

.workspace {
  margin-left: 228px;
  width: calc(100% - 228px);
  min-height: 100vh;
  padding: 0.75rem 0.75rem 0.75rem 0;
  box-sizing: border-box;
}

.sheet {
  background: var(--paper);
  border-radius: 24px;
  min-height: calc(100vh - 1.5rem);
  width: 100%;
}

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.45rem 0.15rem;
}

.topbar h1 { font-size: clamp(1.7rem, 2vw, 2.05rem); min-width: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.topbar-actions .button,
.topbar-actions a.button {
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
}

.who {
  margin: 0 0 0.5rem;
  color: var(--rail-dim);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.signout button {
  width: 100%;
  background: transparent;
  color: var(--rail-text);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.signout button:hover { background: rgba(255, 255, 255, 0.06); }

main {
  margin: 0;
  padding: 0.85rem 1.45rem 3rem;
  width: 100%;
}

.lede { margin: 0 0 1.2rem; max-width: 42rem; color: var(--muted); }
.hint, .empty { color: var(--muted); }
.hint a { color: var(--green-deep); }
.hint { margin: 0; font-size: 0.95rem; }

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.totals article {
  padding: 1.15rem 1.25rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.totals h2 { font-family: Figtree, sans-serif; font-size: 1rem; font-weight: 650; }
.totals p { margin: 0; color: var(--muted); }
.totals .figure { color: var(--ink); font-size: 2.6rem; line-height: 1.05; margin: 0.2rem 0 0.35rem; }

.ledger {
  background: var(--green-deep);
  color: #f3f6f4;
  border-radius: 16px;
  padding: 1.4rem 1.5rem 1.6rem;
}

.ledger h2 { color: #c9e2d4; font-family: Figtree, sans-serif; font-size: 1rem; font-weight: 650; }
.ledger-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.ledger .figure { font-size: 3.2rem; line-height: 1; margin: 0; }
.ledger p { margin: 0.25rem 0 0; color: #c9e2d4; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem 1.35rem 1.4rem;
  margin-bottom: 1rem;
}

.stack { display: grid; gap: 0.9rem; width: 100%; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.inline-form { grid-template-columns: 1fr auto; align-items: end; max-width: none; }
.inline-form button { margin-bottom: 1px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 560; font-size: 0.92rem; }
td form { margin: 0; }

code, .secret {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.92rem;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  padding: 0.45rem 0.45rem 0.45rem 0.9rem;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.secret {
  display: block;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.35rem 0;
  background: transparent;
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-button {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.copy-button.copy-text {
  width: auto;
  padding: 0 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 650;
}

.copy-button:hover { background: var(--paper); color: var(--ink); }

.copy-button svg { width: 1.15rem; height: 1.15rem; }

.copy-button .copied-icon { display: none; }

.copy-button[data-copied] .copy-icon { display: none; }

.copy-button[data-copied] .copied-icon { display: block; }

.copy-button[data-copied] { color: var(--green); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.secret-label { margin: 0.8rem 0 0; font-weight: 650; }

.key-open td { background: var(--ok-bg); }

.key-reveal td {
  background: var(--ok-bg);
  padding-top: 0.15rem;
  padding-bottom: 1rem;
}

.key-reveal .secret-label { margin-top: 0; }

.key-reveal .secret-box {
  margin-top: 0.35rem;
  background: var(--card);
}

.key-reveal .hint { margin: 0.55rem 0 0; }

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.8rem;
}

.flash {
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.flash p { margin: 0; }
.flash-ok { background: var(--ok-bg); }
.flash-err { background: var(--danger-bg); color: var(--danger); }

.pair { display: grid; gap: 0.8rem; margin: 1rem 0 0; }
.pair div { margin: 0; }
.pair dt { color: var(--muted); }
.pair dd { margin: 0.15rem 0 0; }
.pair code { overflow-wrap: anywhere; }

.docs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

a.button {
  display: inline-block;
  text-decoration: none;
  background: var(--green);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
}

a.button:hover { background: var(--green-press); }

a.button.quiet {
  background: transparent;
  color: var(--green-deep);
  border: 1px solid var(--line);
}

a.button.quiet:hover { background: var(--paper); }

pre.sample {
  margin: 0.8rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

pre.sample code { font-size: 0.88rem; }

.verb {
  display: inline-block;
  min-width: 3.2rem;
  margin-right: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: var(--ok-bg);
  color: var(--green-deep);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-align: center;
}

.swagger-frame {
  display: block;
  width: 100%;
  height: 720px;
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
}

.login-panel {
  background: var(--rail);
  color: #f3f6f4;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.8rem;
}

.login-panel .mark {
  width: 3rem;
  height: 3rem;
  font-size: 1.4rem;
  margin-bottom: auto;
}

.login-panel h1 { font-size: clamp(2.4rem, 4vw, 4rem); max-width: 10ch; }
.login-panel p { max-width: 32ch; color: var(--rail-text); margin: 0; }

.login-form {
  display: grid;
  align-items: center;
  padding: 2rem;
}

.login-form form { width: min(100%, 24rem); margin: 0 auto; display: grid; gap: 0.9rem; }
.login-form h2 { font-size: 2rem; }

.form-error {
  margin: 0;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  margin-top: 0.3rem;
  padding-right: 2.8rem;
}

.icon-button {
  position: absolute;
  right: 0.3rem;
  bottom: 0.35rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.icon-button:hover { background: var(--paper); color: var(--ink); }

.icon-button svg { width: 1.2rem; height: 1.2rem; }

.theme-toggle {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.theme-toggle:hover { background: var(--paper); }

.login-tools {
  display: flex;
  justify-content: flex-end;
}

.login-tools .theme-toggle { width: auto; }

.theme-sun { display: none; }
html[data-theme="dark"] .theme-moon { display: none; }
html[data-theme="dark"] .theme-sun { display: block; }

button.bar-button {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
}

button.bar-button:hover { background: var(--paper); }

button.bar-button svg { width: 1.15rem; height: 1.15rem; }

.profile-menu { position: relative; }

details.profile-menu:not([open]) > .menu { display: none; }

.profile-button {
  list-style: none;
  height: 2.6rem;
  padding: 0.15rem 0.55rem 0.15rem 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.profile-button::-webkit-details-marker { display: none; }
.profile-button::marker { content: ""; }

.profile-button:hover { background: var(--paper); }

.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar-lg { width: 3.4rem; height: 3.4rem; font-size: 1.1rem; }

.profile-label {
  font-weight: 650;
  font-size: 0.92rem;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--muted);
  transition: transform 150ms ease;
}

.profile-menu[open] .chevron { transform: rotate(180deg); }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  width: 15.5rem;
  padding: 0.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(12, 28, 22, 0.14);
  z-index: 6;
}

.menu-id { padding: 0.45rem 0.7rem 0.55rem; }
.menu-name { margin: 0; font-weight: 700; }
.menu-email { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }

.menu a,
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

.menu a:hover,
.menu button:hover,
.menu a[aria-current="page"] { background: var(--paper); }

.profile-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.4rem;
}

.profile-hero h2 { margin: 0; }
.profile-hero p { margin: 0.15rem 0 0; color: var(--muted); }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

td .quiet { padding: 0.45rem 0.7rem; white-space: nowrap; }

.key-list { list-style: none; margin: 0; padding: 0; }
.key-list li {
  display: grid;
  grid-template-columns: minmax(16rem, 1.15fr) minmax(0, 1.5fr) auto;
  gap: 0.75rem 1.1rem;
  align-items: center;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}
.key-list li:last-child { border-bottom: 0; padding-bottom: 0.15rem; }
.key-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 1rem;
  margin: 0;
}
.key-facts div { margin: 0; min-width: 0; }
.key-facts div:first-child { grid-column: 1 / -1; }
.key-facts dt { color: var(--muted); font-size: 0.82rem; }
.key-facts dd { margin: 0.05rem 0 0; overflow-wrap: break-word; }
.key-missing { margin: 0.35rem 0 0; font-size: 0.88rem; }
.key-main { min-width: 0; }
.secret-box { width: 100%; max-width: none; align-items: flex-start; }
td .secret-box { margin-top: 0; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 650;
}

.status::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--green);
}

.status-off { color: var(--muted); font-weight: 560; }
.status-off::before { background: #9aaba1; }

@media (max-width: 860px) {
  .rail {
    position: static;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.8rem;
  }
  .brand { margin: 0; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .workspace { margin-left: 0; width: 100%; padding: 0; }
  .sheet { border-radius: 0; min-height: 0; }
  .topbar { align-items: flex-start; padding: 1rem 1rem 0.2rem; }
  .profile-label { display: none; }
  .profile-button { padding-right: 0.45rem; }
  main { padding: 0.75rem 1rem 2.5rem; }
  .totals, .ledger-row, .split, .login { grid-template-columns: 1fr; }
  .inline-form, .key-list li, .key-facts { grid-template-columns: 1fr; }
  .key-list form { justify-self: start; }
  .login-panel { min-height: 16rem; justify-content: flex-start; }
  .login-panel h1 { max-width: 16ch; }
  .ledger .figure, .totals .figure { font-size: 2.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
