
:root {
  color-scheme: light;
  --bg: #f0eadf;
  --panel: rgba(251, 246, 238, 0.96);
  --panel-strong: #f7f0e5;
  --ink: #1f2a1f;
  --muted: #647062;
  --line: rgba(31, 42, 31, 0.12);
  --brand: #234c35;
  --brand-strong: #173524;
  --accent: #cb8f2a;
  --accent-soft: rgba(203, 143, 42, 0.14);
  --danger: #b33c21;
  --danger-soft: rgba(179, 60, 33, 0.12);
  --success-soft: rgba(35, 76, 53, 0.1);
  --shadow: 0 20px 44px rgba(27, 40, 29, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(203, 143, 42, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(35, 76, 53, 0.14), transparent 30%),
    linear-gradient(180deg, #f4ede2 0%, #eadfcd 100%);
}
body.is-locked .sidebar,
body.is-locked .content,
body.is-locked #toast {
  filter: blur(10px);
  pointer-events: none;
  user-select: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 320px;
  padding: 30px 26px;
  background: linear-gradient(180deg, rgba(18, 40, 27, 0.98) 0%, rgba(28, 64, 43, 0.96) 100%);
  color: #f8f2e8;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  z-index: 5;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), transparent 30%),
    repeating-linear-gradient(-35deg, transparent 0 28px, rgba(255, 255, 255, 0.025) 28px 30px);
  pointer-events: none;
}
.brand, nav, .sidebar-footer { position: relative; z-index: 1; }
.brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 2px;
}
.brand-mark {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 248, 238, 0.96);
  color: var(--brand-strong);
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
  flex: 0 0 auto;
  overflow: hidden;
}
.brand-mark img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}
.brand-mark.has-logo img { display: block; }
.brand-mark.has-logo span { display: none; }
.brand strong {
  display: block;
  margin: 4px 0 6px;
  color: #f7cb72;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.brand span:last-child {
  display: block;
  color: rgba(245, 239, 230, 0.72);
  font-size: 0.82rem;
  line-height: 1.3;
}
.tab-nav {
  display: grid;
  gap: 10px;
}
.tab-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: rgba(248, 242, 232, 0.88);
  text-decoration: none;
  background: rgba(255, 248, 238, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 800;
  transition: background 140ms ease, transform 140ms ease, color 140ms ease;
  box-shadow: none;
}
.tab-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 248, 238, 0.14);
  color: #fff7ec;
}
.tab-link.active {
  background: rgba(255, 248, 238, 0.92);
  color: var(--brand-strong);
}
.tab-hint {
  color: rgba(245, 239, 230, 0.68);
  font-size: 0.75rem;
  line-height: 1.45;
}
.tab-panel[hidden] { display: none !important; }
.audit-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  color: rgba(245, 239, 230, 0.68);
  font-size: 0.78rem;
  font-weight: 700;
}
.branding-form { margin-top: 16px; }

main {
  margin-left: 320px;
  min-height: 100vh;
  padding: 28px;
  display: grid;
  gap: 18px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 6px 2px 2px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 6px;
  font-size: clamp(1.55rem, 1.1rem + 1vw, 2.15rem);
  line-height: 1.08;
  letter-spacing: 0;
  color: var(--brand-strong);
}
h2 {
  margin-bottom: 6px;
  color: var(--brand-strong);
  font-size: 1.05rem;
  letter-spacing: 0;
}
h3 {
  margin-bottom: 12px;
  color: var(--brand-strong);
  font-size: 0.96rem;
  letter-spacing: 0;
}
p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}
.health {
  flex: 0 0 auto;
  min-width: 116px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(203, 143, 42, 0.26);
  background: var(--accent-soft);
  color: #8a5d15;
  font-weight: 800;
  text-align: center;
}
.health.ok {
  color: var(--brand-strong);
  background: var(--success-soft);
  border-color: rgba(35, 76, 53, 0.18);
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.two { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.compact-form, .directory-form {
  margin-top: 16px;
  align-items: end;
}
.directory-form { margin-bottom: 18px; }
.compact-form h3, .directory-form h3 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}
label {
  display: block;
  color: #425044;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
label input, label select, label textarea { margin-top: 8px; }
input, textarea, select, button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(31, 42, 36, 0.12);
  font: inherit;
}
input, textarea, select {
  color: var(--ink);
  background: rgba(255, 253, 249, 0.96);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(203, 143, 42, 0.42);
  outline-offset: 1px;
  border-color: rgba(203, 143, 42, 0.48);
}
textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
select[multiple] { min-height: 86px; }

.api-doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.api-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 247, 0.78);
  padding: 14px;
  min-width: 0;
}
.api-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.api-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.icon-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  flex: 0 0 auto;
}
.copy-glyph {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.7px solid currentColor;
  border-radius: 3px;
}
.copy-glyph::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.7px solid currentColor;
  border-radius: 3px;
  top: -5px;
  left: 5px;
  opacity: 0.72;
  background: transparent;
}
.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  color: white;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.method.post { background: var(--brand); }
.method.get { background: #6f5b17; }
.api-card code, .api-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}
.api-card pre {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: #17231b;
  color: #f7f0e5;
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.55;
}
.api-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  border: 1px solid rgba(35, 76, 53, 0.16);
}
.api-note strong {
  color: var(--brand-strong);
}
.docs-stack {
  display: grid;
  gap: 14px;
}
.doc-section {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.8);
}
.doc-section h3 {
  margin-bottom: 10px;
}
.doc-section p + p {
  margin-top: 10px;
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.doc-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(31, 42, 31, 0.08);
  background: rgba(255, 255, 255, 0.55);
}
.doc-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-strong);
}
.doc-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.doc-list li + li {
  margin-top: 8px;
}
.doc-section pre {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: #17231b;
  color: #f7f0e5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.55;
}
.doc-section code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}
.doc-callout {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(203, 143, 42, 0.12);
  border: 1px solid rgba(203, 143, 42, 0.18);
  color: var(--ink);
}
.session-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 247, 0.78);
  border: 1px solid var(--line);
}
.session-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}
.session-banner span {
  color: var(--muted);
  font-size: 0.84rem;
}
.login-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 26, 18, 0.34);
  backdrop-filter: blur(14px);
}
.login-shell[hidden] {
  display: none;
}
.login-panel {
  width: min(460px, 100%);
  padding: 24px;
  border-radius: 22px;
  background: rgba(251, 246, 238, 0.98);
  border: 1px solid rgba(31, 42, 31, 0.12);
  box-shadow: 0 28px 60px rgba(18, 32, 22, 0.22);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.login-brand strong {
  display: block;
  margin-bottom: 4px;
}
.login-brand span:last-child {
  color: var(--muted);
  font-size: 0.84rem;
}
.login-copy h2 {
  margin: 0 0 8px;
}
.login-copy p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}
.login-form,
.otp-inline {
  display: grid;
  gap: 12px;
}
.otp-inline {
  margin-top: 12px;
}
.slim-form {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.72);
}
.otp-inline[hidden] {
  display: none;
}
.app-assignment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 240px;
  max-width: 360px;
}
.app-assignment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 36, 0.12);
  background: rgba(255, 253, 249, 0.9);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.app-assignment-pill.selected {
  background: var(--success-soft);
  border-color: rgba(35, 76, 53, 0.28);
  color: var(--brand-strong);
}
.app-assignment-pill input {
  width: 14px;
  min-width: 14px;
  min-height: 14px;
  margin: 0;
  accent-color: var(--brand);
}
.empty-assignment {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(31, 42, 36, 0.06);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}
button {
  cursor: pointer;
  border: 0;
  background: var(--brand);
  color: white;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
button:hover { background: var(--brand-strong); transform: translateY(-1px); }
button:focus-visible {
  outline: 2px solid rgba(247, 203, 114, 0.92);
  outline-offset: 2px;
}
.secondary {
  background: rgba(255, 248, 238, 0.7);
  color: var(--ink);
  border: 1px solid rgba(31, 42, 36, 0.16);
  box-shadow: none;
}
.secondary:hover { background: rgba(255, 248, 238, 0.95); }
.danger { background: var(--danger); }
.danger:hover { background: #8f2f1a; }
.icon-button {
  width: auto;
  min-width: 92px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
}
.small-button {
  width: auto;
  min-width: 70px;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 12px;
}
.actions, .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.actions { margin-top: 16px; }
.result {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 247, 0.72);
}
.stacked-table { margin: 14px 0 18px; }
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.84rem;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  min-width: 0;
  overflow-wrap: anywhere;
}
th {
  color: #4c584e;
  font-weight: 800;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(35, 76, 53, 0.05);
}
tr:last-child td { border-bottom: 0; }
td input, td select {
  min-height: 36px;
  min-width: 150px;
  padding: 8px 10px;
  border-radius: 10px;
}
td select[multiple] { min-width: 190px; }
td input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  accent-color: var(--brand);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  background: var(--brand-strong);
  color: white;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 180ms ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (hover: none) {
  button:hover { transform: none; }
}
@media (max-width: 980px) {
  body { font-size: 14px; }
  .sidebar {
    position: sticky;
    top: 0;
    width: auto;
    min-height: 0;
    max-height: none;
    padding: 14px 14px 12px;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .brand {
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
  }
  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .brand strong {
    margin: 0 0 4px;
    font-size: 0.82rem;
  }
  .brand span:last-child { font-size: 0.72rem; }
  .tab-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-link {
    min-width: max-content;
    min-height: 38px;
    padding: 10px 12px;
    border-radius: 999px;
    scroll-snap-align: start;
  }
  main {
    margin-left: 0;
    padding: 14px;
  }
  .topbar {
    flex-direction: column;
    gap: 12px;
  }
  .health { align-self: flex-start; }
}
@media (max-width: 640px) {
  input, textarea, select, button { font-size: 16px; }
  .panel {
    padding: 14px;
    border-radius: 16px;
  }
  .panel-heading {
    flex-direction: column;
    gap: 12px;
  }
  .icon-button, .small-button, .actions button { width: 100%; }
  .actions, .row-actions { align-items: stretch; }
  .two { grid-template-columns: 1fr; }
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  table, thead, tbody, tr, th, td { display: block; }
  table {
    min-width: 0;
    font-size: 0.82rem;
  }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tr {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 252, 247, 0.82);
  }
  td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(31, 42, 31, 0.08);
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  td[colspan] {
    display: block;
    padding: 12px;
  }
  td[colspan]::before { content: none; }
  td input, td select { min-width: 0; width: 100%; }
  .app-assignment-list { min-width: 0; max-width: none; }
  .api-doc-grid { grid-template-columns: 1fr; }
  .api-card pre { font-size: 0.72rem; }
  td select[multiple] { min-width: 0; }
  .session-banner {
    align-items: stretch;
    flex-direction: column;
  }
  .login-panel {
    padding: 18px;
    border-radius: 18px;
  }
}
