@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/static/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  --bg: #0b1020;
  --panel: #121a2e;
  --surface: #0f1629;
  --surface-hover: #18223b;
  --border: #26324f;
  --divider: #1c2640;
  --text: #e7ecf5;
  --text-2: #c9d1e0;
  --muted: #9aa6bd;
  --faint: #8692ab;
  --accent: #3ddbb4;
  --on-accent: #062a22;
  --link: #7debd0;
  --link-hover: #b5f5e5;
  --danger: #f06a6a;
  --on-danger: #2a0b0e;
  --danger-bg: #2a1519;
  --danger-border: #5c2a31;
  --danger-text: #ffb3b3;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }

.shell { min-height: 100vh; display: flex; }

.hero {
  flex: 1 1 auto;
  background: var(--panel) url('/static/lightscape.jpg') center / cover no-repeat;
}

.side {
  flex: 0 0 560px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding: 48px 72px;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 32px;
}

.stack {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }

.heading { display: flex; flex-direction: column; gap: 8px; }
.meta { margin: 0; font-size: 14px; color: var(--muted); }
.num, .who-cid { font-variant-numeric: tabular-nums; }

.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin: -12px 0 -12px -4px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}

.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; font-weight: 500; color: var(--text-2); }

input[type='text'],
input[type='password'] {
  height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
input[name='cid'] { font-variant-numeric: tabular-nums; }
input[aria-invalid='true'] { border-color: var(--danger); }
input:focus-visible, .btn:focus-visible, .account-pick:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.alert {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-size: 14px;
}
.alert svg { flex-shrink: 0; }

.actions { display: flex; flex-direction: column; gap: 12px; }
.actions.split { flex-direction: row; }
.actions.split > * { flex: 1; }

.btn {
  height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.secondary { border: 1px solid var(--border); background: transparent; color: var(--text); }
.btn.secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger { border: 0; background: var(--danger); color: var(--on-danger); font-weight: 600; }

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.list > * + * { border-top: 1px solid var(--divider); }

.account { display: flex; align-items: center; }
.account form { flex: 1; min-width: 0; margin: 0; }
.account.static { gap: 14px; min-height: 68px; padding: 12px 16px; }

.account-pick {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.account-pick:hover { background: var(--surface-hover); }

.icon-btn {
  width: 44px;
  height: 44px;
  margin-right: 12px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
}
.icon-btn:hover { background: var(--danger-bg); color: var(--danger-text); }

.avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.avatar-0 { background: #15433a; color: #7debd0; }
.avatar-1 { background: #2a2350; color: #c4b5ff; }
.avatar-2 { background: #3d2a14; color: #ffc98a; }

.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who-name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-cid { font-size: 13px; color: var(--muted); }

.scopes li { display: flex; gap: 12px; align-items: center; padding: 12px 16px; font-size: 14px; }
.scopes svg { color: var(--accent); flex-shrink: 0; }

.copyright { margin: 0; font-size: 13px; color: var(--faint); }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .hero { flex: 0 0 160px; }
  .side { flex: 1; padding: 32px 24px 24px; }
  .content { justify-content: flex-start; padding-bottom: 0; }
  .stack { max-width: none; flex: 1; gap: 20px; }
  h1 { font-size: 26px; }
  .actions { margin-top: auto; padding-top: 24px; }
  .actions.split { flex-direction: column-reverse; }
  .btn { height: 52px; font-size: 16px; }
  input[type='text'], input[type='password'] { height: 50px; font-size: 16px; }
  .copyright { margin-top: 16px; text-align: center; font-size: 12px; }
}

/* ---------- Account picker extras ---------- */

.account form { display: flex; align-items: center; gap: 4px; }
.account form .account-pick { flex: 1; min-width: 0; }
.current { display: inline-flex; margin-left: 6px; color: var(--accent); vertical-align: -1px; }
.role-btn {
  height: 44px;
  padding: 0 12px;
  flex-shrink: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.role-admin { border: 1px solid #1f4d45; background: #0f2a26; color: var(--link); }
.role-admin:hover { background: #15433a; }
.role-manager { border: 1px solid var(--border); background: transparent; color: var(--text); }
.role-manager:hover { background: var(--surface-hover); }
.account .icon-btn { margin-right: 8px; }
.account.static .role-btn { margin-left: auto; text-decoration: none; }

/* ---------- Organization and app editor ---------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--divider);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.crumbs a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: #6f7b94; }
.chip { display: flex; align-items: center; gap: 10px; min-height: 44px; flex-shrink: 0; color: var(--text); text-decoration: none; font-size: 14px; }
.chip:hover { color: var(--text); }
.avatar-small { width: 32px; height: 32px; font-size: 12px; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 48px clamp(16px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.app-copy { padding: 24px clamp(16px, 4vw, 40px); }
h2 { margin: 0; font-size: 22px; font-weight: 600; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 16px; }
.page-title:empty { display: none; }
.btn-compact { height: 44px; }
.btn-small { height: 44px; font-size: 14px; flex-shrink: 0; }
.btn-link {
  align-self: flex-start;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.btn-link:hover { background: var(--surface-hover); }
.btn.danger-outline { border: 1px solid var(--danger-border); background: transparent; color: var(--danger-text); }
.btn.danger-outline:hover { background: var(--danger-bg); color: var(--danger-text); }

.row-link { display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 14px 20px; color: inherit; text-decoration: none; flex-wrap: wrap; }
.row-link:hover { background: var(--surface-hover); color: inherit; }
.row-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-size: 16px; font-weight: 500; }
.row-meta { font-size: 13px; color: var(--muted); }
.row-chevron { color: #6f7b94; display: flex; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 4px 10px; border-radius: 999px; background: #1b2540; font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); }
.tabs a { min-height: 44px; padding: 0 14px; display: flex; align-items: center; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }

.form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; }
.form.wide { max-width: 560px; }
.form.gap-lg { gap: 32px; }
.form-body { display: flex; flex-direction: column; gap: 24px; }
.actions.narrow { max-width: 420px; }
.hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--danger-text); }
.optional { color: var(--faint); font-weight: 400; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.url-list { display: flex; flex-direction: column; gap: 8px; }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; min-width: 0; }
input[type='url'] {
  height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.icon-btn.bordered { width: 48px; height: 48px; margin: 0; border: 1px solid var(--border); border-radius: 10px; background: transparent; cursor: pointer; }
button.icon-btn { border: 0; background: transparent; cursor: pointer; font: inherit; }
.radios { display: flex; flex-direction: column; gap: 4px; }
.radios .check { flex-wrap: wrap; }
.radios input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.radios code { color: var(--faint); }
.muted { color: var(--muted); }
.error-list { margin: 0; padding-left: 18px; }

.details { margin: 0; }
.details > div { display: grid; grid-template-columns: minmax(0, 168px) minmax(0, 1fr); gap: 16px; padding: 12px 16px; font-size: 14px; }
.details > div + div { border-top: 1px solid var(--divider); }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.details dd.mono { font-weight: 400; }
.line { display: block; }
.person-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.app-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; }

.panel { padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.add-member { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.cid-field { flex: 1 1 160px; }
.cid-field input { height: 44px; }
.perm-fields { flex: 2 1 280px; }
.checks { display: flex; flex-wrap: wrap; gap: 0 20px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.table th { padding: 12px 20px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.table td { padding: 12px 20px; border-top: 1px solid var(--divider); vertical-align: middle; }
.table .cell-action { width: 56px; padding: 8px 12px; }
.table .icon-btn { margin: 0; }
.person { display: flex; align-items: center; gap: 12px; }

.copy-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 16px; }
.copy-row + .copy-row { border-top: 1px solid var(--divider); }
.copy-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.copy-text .mono { font-size: 14px; overflow-wrap: anywhere; }
.copy-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.secret { color: var(--link); }
.copy-row .icon-btn { margin: 0; }
.copy-row .icon-btn.copied { color: var(--accent); }

.notice-warn, .notice-ok { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.notice-warn { background: #2d2410; border: 1px solid #5c4a1f; color: #ffd98a; }
.notice-ok { background: #0f2a26; border: 1px solid #1f4d45; color: var(--link); }
.notice-warn svg, .notice-ok svg { flex-shrink: 0; }
.danger-zone { padding-top: 24px; border-top: 1px solid var(--divider); }

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

@media (max-width: 640px) {
  .chip-name { display: none; }
  .app-main { padding-top: 32px; }
  .details > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .actions.split.narrow { flex-direction: column-reverse; }
}
