:root {
  --background: #f6f7f9;
  --foreground: #111827;
  --card: #ffffff;
  --card-foreground: #111827;
  --muted: #f3f4f6;
  --muted-foreground: #6b7280;
  --border: #d9dee7;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-foreground: #ffffff;
  --destructive: #dc2626;
  --destructive-muted: #fef2f2;
  --success: #15803d;
  --success-muted: #f0fdf4;
  --ring: rgba(15, 118, 110, 0.26);
  --radius: 0.5rem;
  --sidebar-width: 16rem;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-size: 0.9375rem;
}

a {
  color: inherit;
}

img,
svg {
  max-width: 100%;
  vertical-align: middle;
}

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

button {
  cursor: pointer;
}

table {
  border-collapse: collapse;
}

.app-shell {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 160ms ease;
}

.sidebar-open .app-sidebar {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(17, 24, 39, 0.34);
}

.sidebar-open .sidebar-backdrop {
  display: block;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-height: 4rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: inline-flex;
  align-items: center;
}

.logo__image {
  width: auto;
  max-height: 2.4rem;
  object-fit: contain;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
}

.nav-group {
  display: block;
}

.nav-group summary {
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-item,
.nav-subitem {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #374151;
  text-decoration: none;
}

.nav-item {
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-weight: 500;
}

.nav-submenu {
  display: grid;
  gap: 0.125rem;
  margin: 0.125rem 0 0.5rem 2rem;
}

.nav-subitem {
  min-height: 2rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
}

.nav-item:hover,
.nav-subitem:hover,
.nav-item.is-active,
.nav-subitem.is-active {
  background: var(--muted);
  color: var(--foreground);
}

.nav-icon {
  display: inline-flex;
  justify-content: center;
  width: 1.25rem;
  color: var(--muted-foreground);
}

.app-frame {
  min-height: 100vh;
  padding-bottom: 3rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.75rem;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar-spacer {
  flex: 1;
}

.mobile-brand {
  display: inline-flex;
  align-items: center;
}

.user-chip {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
}

.icon-button:hover {
  background: var(--muted);
}

.app-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.app-footer a {
  font-weight: 600;
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
  pointer-events: none;
}

.htmx-indicator {
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease, visibility 120ms ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  visibility: visible;
}

.loader-image {
  width: 6rem;
  height: 6rem;
}

.loader-text {
  margin-top: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

main,
#content {
  padding: 1.25rem;
}

#content > .w-full,
main > .w-full {
  width: 100%;
}

.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 7rem);
}

.auth-card,
.card,
.bg-white {
  background: var(--card);
}

.auth-card {
  width: min(100%, 34rem);
  margin-top: 2rem;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.auth-header {
  text-align: center;
}

.auth-header h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

.auth-header p {
  margin: 0.75rem 0 0;
  color: var(--muted-foreground);
}

.auth-header a {
  font-weight: 600;
  color: var(--primary);
}

.auth-body {
  margin-top: 1.5rem;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.input,
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.125rem);
  background: var(--card);
  color: var(--foreground);
  outline: none;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
}

.button,
button[type="submit"],
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button-primary,
.bg-button-blue,
.bg-blue-600 {
  background: var(--primary);
  color: var(--primary-foreground);
}

.button-primary:hover,
.bg-button-blue:hover,
.hover\:bg-button-blue-hover:hover,
.hover\:bg-blue-700:hover {
  background: var(--primary-hover);
}

.button-outline {
  border-color: var(--border);
  background: var(--card);
  color: var(--foreground);
}

.button-outline:hover {
  background: var(--muted);
}

.button-sm {
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

.button-full,
.w-full {
  width: 100%;
}

.rounded-lg,
.rounded-xl,
.rounded-md {
  border-radius: var(--radius);
}

.rounded-full {
  border-radius: 999px;
}

.border,
.border-gray-200,
.border-gray-300 {
  border: 1px solid var(--border);
}

.border-t {
  border-top: 1px solid var(--border);
}

.shadow-sm {
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.shadow-2xs {
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.text-gray-500,
.text-gray-600,
.text-gray-700 {
  color: var(--muted-foreground);
}

.text-gray-800,
.text-black {
  color: var(--foreground);
}

.text-white,
.text-button-blue-text {
  color: #ffffff;
}

.text-red-500,
.text-red-600,
.text-red-700 {
  color: var(--destructive);
}

.text-green-600,
.text-green-700 {
  color: var(--success);
}

.bg-gray-50,
.bg-gray-100 {
  background: var(--muted);
}

.bg-gray-200,
.bg-gray-300,
.hover\:bg-gray-200:hover,
.hover\:bg-gray-300:hover,
.hover\:bg-gray-50:hover,
.hover\:bg-gray-100:hover {
  background: #e9edf3;
}

.bg-red-50 {
  background: var(--destructive-muted);
}

.bg-green-50 {
  background: var(--success-muted);
}

.bg-sky-50\/50 {
  background: #f0f9ff;
}

.inline-flex {
  display: inline-flex;
}

.flex {
  display: flex;
}

.grid {
  display: grid;
}

.hidden {
  display: none !important;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-start {
  justify-content: flex-start;
}

.justify-end {
  justify-content: flex-end;
}

.justify-between {
  justify-content: space-between;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-y-4 {
  row-gap: 1rem;
}

.space-y-1 > * + * {
  margin-top: 0.25rem;
}

.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.space-y-8 > * + * {
  margin-top: 2rem;
}

.space-x-3 > * + * {
  margin-left: 0.75rem;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.ml-auto {
  margin-left: auto;
}

.m-5 {
  margin: 1.25rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 0.75rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-5,
.mt-6 {
  margin-top: 1.5rem;
}

.mt-10 {
  margin-top: 2.5rem;
}

.mt-16 {
  margin-top: 4rem;
}

.my-4 {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.my-8 {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-8,
.mb-12 {
  margin-bottom: 2rem;
}

.p-2 {
  padding: 0.5rem;
}

.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.px-2 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.px-5 {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.px-6,
.px-8 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.py-0\.5 {
  padding-top: 0.125rem;
  padding-bottom: 0.125rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.py-1\.5 {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.pt-4 {
  padding-top: 1rem;
}

.pl-4 {
  padding-left: 1rem;
}

.pl-6 {
  padding-left: 1.5rem;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-base {
  font-size: 1rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.font-light {
  font-weight: 300;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.uppercase {
  text-transform: uppercase;
}

.tracking-wider {
  letter-spacing: 0.05em;
}

.leading-tight {
  line-height: 1.25;
}

.leading-7 {
  line-height: 1.75rem;
}

.underline {
  text-decoration: underline;
}

.relative {
  position: relative;
}

.fixed {
  position: fixed;
}

.overflow-x-auto {
  overflow-x: auto;
}

.overflow-y-scroll {
  overflow-y: scroll;
}

.cursor-pointer {
  cursor: pointer;
}

.pointer-events-none {
  pointer-events: none;
}

.min-w-full {
  min-width: 100%;
}

.max-w-lg {
  max-width: 32rem;
}

.max-w-2xl {
  max-width: 42rem;
}

.max-w-3xl {
  max-width: 48rem;
}

.max-w-\[550px\] {
  max-width: 550px;
}

.h-full {
  height: 100%;
}

.h-4 {
  height: 1rem;
}

.w-4 {
  width: 1rem;
}

.h-7 {
  height: 1.75rem;
}

.w-7 {
  width: 1.75rem;
}

.h-24 {
  height: 6rem;
}

.h-36 {
  height: 9rem;
}

.h-72 {
  height: 18rem;
}

.min-h-screen {
  min-height: 100vh;
}

.w-auto {
  width: auto;
}

.w-1\/6 {
  width: 16.666667%;
}

.divide-y > * + * {
  border-top: 1px solid var(--border);
}

.divide-gray-200 > * + * {
  border-color: var(--border);
}

.table-fixed {
  table-layout: fixed;
}

table {
  width: 100%;
  background: var(--card);
}

th {
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

td,
th {
  border-bottom: 1px solid var(--border);
}

.list-decimal {
  list-style-type: decimal;
}

.list-disc {
  list-style-type: disc;
}

.list-inside {
  list-style-position: inside;
}

.list-outside {
  list-style-position: outside;
}

.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 (min-width: 640px) {
  .sm\:p-4 {
    padding: 1rem;
  }

  .sm\:p-6,
  .sm\:p-7 {
    padding: 1.5rem;
  }

  .sm\:pb-32 {
    padding-bottom: 8rem;
  }

  .sm\:w-1\/3 {
    width: 33.333333%;
  }

  .sm\:flex-nowrap {
    flex-wrap: nowrap;
  }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .md\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .app-sidebar {
    transform: none;
  }

  .sidebar-backdrop,
  .sidebar-toggle,
  .mobile-brand {
    display: none;
  }

  .app-frame {
    padding-left: var(--sidebar-width);
  }

  .app-footer {
    left: var(--sidebar-width);
  }

  .lg\:ps-64 {
    padding-left: 0;
  }
}

@media (min-width: 1280px) {
  .xl\:grid-cols-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
