:root {
  --radius: 0.65rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.852 0.199 91.936);
  --primary-foreground: oklch(0.421 0.095 57.708);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(1 0 0);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.852 0.199 91.936);
  --chart-1: oklch(0.905 0.182 98.111);
  --chart-2: oklch(0.795 0.184 86.047);
  --chart-3: oklch(0.681 0.162 75.834);
  --chart-4: oklch(0.554 0.135 66.442);
  --chart-5: oklch(0.476 0.114 61.907);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: oklch(0.681 0.162 75.834);
  --sidebar-primary-foreground: oklch(0.987 0.026 102.212);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.852 0.199 91.936);
}

.dark {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.795 0.184 86.047);
  --primary-foreground: oklch(0.421 0.095 57.708);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.421 0.095 57.708);
  --chart-1: oklch(0.905 0.182 98.111);
  --chart-2: oklch(0.795 0.184 86.047);
  --chart-3: oklch(0.681 0.162 75.834);
  --chart-4: oklch(0.554 0.135 66.442);
  --chart-5: oklch(0.476 0.114 61.907);
  --sidebar: oklch(0.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.795 0.184 86.047);
  --sidebar-primary-foreground: oklch(0.987 0.026 102.212);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.421 0.095 57.708);
}

* {
  border-color: var(--border);
}

html,
body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--background);
  color: var(--foreground);
}

.app-shell__top-menu {
  flex-shrink: 0;
  z-index: 30;
}

.app-shell__sidebar-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.app-shell__content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

/* Allow sidebar/inset to shrink inside the viewport-bound row so menu scrolls
   under the profile footer instead of stretching the shell with page content. */
.app-shell__content > * {
  min-height: 0;
}

.app-shell__sidebar-trigger {
  margin-left: -0.5rem;
}

.app-shell__header {
  align-items: center;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  height: 3.5rem;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-shell__brand {
  color: var(--foreground);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.app-shell__spacer {
  flex: 1;
}

.app-shell__user {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.app-shell__button,
.app-shell__icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--foreground);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.875rem;
  gap: 0.5rem;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
}

.app-shell__button:hover,
.app-shell__icon-button:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.app-shell__button--primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.app-shell__button--primary:hover {
  filter: brightness(0.95);
}

.app-shell__icon-button {
  width: 2.25rem;
}

.app-shell__sidebar {
  background: var(--background);
  border-right: 1px solid var(--border);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  position: fixed;
  top: 3.5rem;
  width: 16rem;
}

.app-shell__sidebar--closed {
  display: none;
}

.app-shell__main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem;
}

.app-shell__breadcrumbs {
  margin: -0.25rem 0 1rem;
}

.app-nav {
  padding: 1rem 0.75rem;
}

.app-nav__group-label {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 1rem 0.75rem 0.5rem;
  text-transform: uppercase;
}

.app-nav__link {
  align-items: center;
  border-radius: var(--radius);
  color: var(--foreground);
  display: flex;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  text-decoration: none;
}

.app-nav__link:hover,
.app-nav__link.active {
  background: var(--accent);
  color: var(--accent-foreground);
}

.app-nav__group {
  margin: 0.125rem 0;
}

.app-nav__summary {
  cursor: pointer;
  list-style: none;
}

.app-nav__summary::-webkit-details-marker {
  display: none;
}

.app-nav__group .app-nav__link:not(.app-nav__summary) {
  margin-left: 1.25rem;
}

.app-nav__icon {
  height: 1.25rem;
  width: 1.25rem;
}

.app-alert {
  border-radius: var(--radius);
  padding: 1rem;
}

.app-alert--error {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.app-alert--info {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--card-foreground);
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}

.app-card h1,
.app-card h2,
.app-card h3,
.app-card p {
  margin: 0;
}

.app-table {
  border-collapse: collapse;
  width: 100%;
}

.app-table th,
.app-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

.app-spinner {
  animation: app-spin 1s linear infinite;
  border: 3px solid var(--muted);
  border-radius: 999px;
  border-top-color: var(--primary);
  height: 2rem;
  width: 2rem;
}

@keyframes app-spin {
  to {
    transform: rotate(360deg);
  }
}

.app-empty-state {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.app-empty-state__icon {
  color: var(--primary);
  font-size: 4rem;
  font-weight: 800;
}

@media (max-width: 768px) {
  .app-shell__sidebar {
    width: 100%;
    z-index: 10;
  }

  .app-shell__main {
    margin-left: 0;
  }

  .app-shell__user {
    display: none;
  }
}

.setup-layout {
  background: var(--background);
  min-height: 100vh;
}

.setup-layout__main {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.setup-card {
  max-width: 32rem;
  width: 100%;
}

.setup-card__header,
.setup-form {
  display: grid;
  gap: 1rem;
}

.setup-card__header {
  justify-items: center;
  text-align: center;
}

.bb-input,
.form-control {
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  display: block;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

.settings-grid,
.setting-editor {
  display: grid;
  gap: 1rem;
}

.setting-editor {
  gap: 0.35rem;
}

.setting-editor > span {
  font-weight: 600;
}

.setting-editor small {
  color: var(--muted-foreground);
}

.theme-picker-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.theme-picker-card {
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--card-foreground);
  cursor: pointer;
  display: grid;
  gap: 0.5rem;
  justify-items: start;
  padding: 0.75rem;
  text-align: left;
}

.theme-picker-card--selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}

.theme-swatch {
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-block;
  height: 1.25rem;
  width: 1.25rem;
}

.theme-chip {
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
}

.app-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 50;
}

.app-modal__content {
  max-height: calc(100vh - 2rem);
  max-width: 48rem;
  overflow: auto;
  width: 100%;
}
