@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --radius: 0.625rem;
  --background: oklch(0.985 0.002 247.858);
  --foreground: oklch(0.129 0.042 264.695);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.129 0.042 264.695);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.129 0.042 264.695);
  --primary: oklch(0.511 0.262 276.966);
  --primary-foreground: oklch(0.984 0.003 247.858);
  --secondary: oklch(0.967 0.003 264.542);
  --secondary-foreground: oklch(0.208 0.042 265.755);
  --muted: oklch(0.967 0.003 264.542);
  --muted-foreground: oklch(0.554 0.046 257.417);
  --accent: oklch(0.967 0.003 264.542);
  --accent-foreground: oklch(0.208 0.042 265.755);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.984 0.003 247.858);
  --border: oklch(0.929 0.013 255.508);
  --input: oklch(0.929 0.013 255.508);
  --ring: oklch(0.511 0.262 276.966);
  --success: oklch(0.627 0.194 149.214);
  --warn: oklch(0.666 0.179 58.318);
}

html.dark {
  --background: oklch(0.129 0.042 264.695);
  --foreground: oklch(0.984 0.003 247.858);
  --card: oklch(0.208 0.042 265.755);
  --card-foreground: oklch(0.984 0.003 247.858);
  --popover: oklch(0.208 0.042 265.755);
  --popover-foreground: oklch(0.984 0.003 247.858);
  --primary: oklch(0.511 0.262 276.966);
  --primary-foreground: oklch(0.984 0.003 247.858);
  --secondary: oklch(0.279 0.041 260.031);
  --secondary-foreground: oklch(0.984 0.003 247.858);
  --muted: oklch(0.279 0.041 260.031);
  --muted-foreground: oklch(0.704 0.04 256.788);
  --accent: oklch(0.279 0.041 260.031);
  --accent-foreground: oklch(0.984 0.003 247.858);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.984 0.003 247.858);
  --border: oklch(0.372 0.044 257.287);
  --input: oklch(0.372 0.044 257.287);
  --ring: oklch(0.511 0.262 276.966);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: oklch(0.55 0.02 264 / 0.35) transparent;
}
html.dark .scrollbar-thin {
  scrollbar-color: oklch(0.45 0.02 264 / 0.45) transparent;
}
.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: oklch(0.45 0.02 264 / 0.45);
  border-radius: 9999px;
}

/* App shell */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--background);
}
.app-sidebar {
  display: flex;
  flex-direction: column;
  width: 14rem;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--card);
}
.app-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  padding: 0 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
}
.app-sidebar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  font-weight: 700;
  font-size: 1rem;
}
.app-sidebar-brand .accent { color: var(--primary); }
.app-sidebar-close,
.app-sidebar-toggle { display: none; }
.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(2px);
}
.app-sidebar-backdrop:not([hidden]) { display: block; }
.app-sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem;
}
.nav-group { margin-bottom: 1rem; }
.nav-group:last-child { margin-bottom: 0; }
.nav-label {
  margin-bottom: 0.25rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: var(--accent);
  color: var(--foreground);
}
.nav-link.active {
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--foreground);
  font-weight: 500;
}
.nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.app-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.app-topbar {
  z-index: 10;
  display: flex;
  height: 3.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  padding: 0 1.5rem;
}
.app-topbar-start {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}
.app-topbar-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-topbar-user {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.app-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 1.5rem;
}

/* Buttons */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.ui-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ui-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.ui-btn-primary:hover:not(:disabled) {
  filter: brightness(0.95);
}
.ui-btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}
.ui-btn-outline:hover:not(:disabled) {
  background: var(--accent);
}
.ui-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--foreground);
}
.ui-btn-ghost:hover:not(:disabled) {
  background: var(--accent);
}
.ui-btn-destructive:not(.ui-btn-outline):not(.ui-btn-ghost) {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
.ui-btn-outline.ui-btn-destructive {
  background: transparent;
  border-color: var(--border);
  color: var(--destructive);
}
.ui-btn-outline.ui-btn-destructive:hover:not(:disabled) {
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
  color: var(--destructive);
}
.ui-btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
}
.ui-btn-lg { height: 3rem; padding: 0 1.25rem; font-size: 0.875rem; }
.ui-btn-full { width: 100%; }

/* Form fields */
.ui-field { display: grid; gap: 0.5rem; }
.ui-label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}
.ui-input,
.ui-textarea,
.ui-select {
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: transparent;
  color: var(--foreground);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.ui-input,
.ui-select {
  height: 2.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}
.ui-input::placeholder,
.ui-textarea::placeholder { color: var(--muted-foreground); }
.ui-input:focus,
.ui-textarea:focus,
.ui-select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}
.ui-input:disabled,
.ui-textarea:disabled,
.ui-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ui-input-lg { height: 3rem; font-size: 1rem; }
.ui-textarea {
  min-height: 3.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  resize: vertical;
}
.ui-input-wrap { position: relative; }
.ui-input-wrap.has-icon .ui-input { padding-left: 2.25rem; }
.ui-input-wrap.has-icon-right .ui-input { padding-right: 2.5rem; }
.ui-input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
  display: flex;
}
.ui-input-icon .nav-icon { width: 1rem; height: 1rem; }
.ui-input-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0;
  display: flex;
}
.ui-input-toggle:hover { color: var(--foreground); }

.ui-select-wrap { position: relative; }
.ui-select {
  appearance: none;
  padding-right: 2rem;
  cursor: pointer;
}
.ui-select-chevron {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted-foreground);
  opacity: 0.5;
}
.ui-select-chevron .nav-icon { width: 1rem; height: 1rem; }

.ui-datepicker { position: relative; }
.ui-datepicker-input-wrap { position: relative; display: flex; align-items: center; }
.ui-datepicker-input-wrap .ui-input {
  padding-right: 4.25rem;
  cursor: pointer;
}
.ui-datepicker-clear {
  position: absolute;
  right: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ui-datepicker-clear:hover:not(:disabled) {
  background: color-mix(in oklch, var(--destructive) 12%, transparent);
  color: var(--destructive);
}
.ui-datepicker-clear:disabled { cursor: default; }
.ui-datepicker-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.ui-datepicker-icon .nav-icon { width: 1rem; height: 1rem; }
.ui-field-hint {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.flatpickr-calendar {
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border);
  font-family: inherit;
  background: var(--popover);
  color: var(--popover-foreground);
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.flatpickr-day.selected:hover { filter: brightness(0.95); }
.flatpickr-time input { font-family: inherit; }
.flatpickr-months .flatpickr-month { color: var(--primary); }
.dark .flatpickr-calendar {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}
.dark .flatpickr-day { color: var(--foreground); }
.dark .flatpickr-day.flatpickr-disabled,
.dark .flatpickr-day.prevMonthDay,
.dark .flatpickr-day.nextMonthDay { color: var(--muted-foreground); }

/* legacy alias */
.ui-datepicker-wrap { position: relative; }

.ui-checkbox {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.ui-checkbox input { width: 1rem; height: 1rem; accent-color: var(--primary); }

/* Dropdown menu */
.ui-dropdown { position: relative; display: inline-flex; }
.ui-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 50;
  min-width: 8rem;
  display: none;
  padding: 0.25rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.ui-dropdown.open .ui-dropdown-menu { display: block; }
.ui-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.ui-dropdown-item:hover,
.ui-dropdown-item:focus {
  background: var(--accent);
  outline: none;
}
.ui-dropdown-item.destructive { color: var(--destructive); }
.ui-dropdown-item .nav-icon { width: 1rem; height: 1rem; }
.ui-dropdown-sep {
  height: 1px;
  margin: 0.25rem -0.25rem;
  background: var(--border);
}
.ui-dropdown-label {
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.ui-dropdown-hint {
  border-top: 1px solid var(--border);
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.ui-dropdown-item .check-slot {
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cards & panels */
.ui-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.ui-card-body { padding: 1.25rem; }
.ui-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.ui-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* Page header */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.page-header p {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Stats */
.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.5rem;
}
.stat-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 1rem;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.stat-value {
  margin-top: 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
}

/* Table */
.table-wrap { overflow-x: auto; }
.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.ui-table th,
.ui-table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.ui-table th {
  color: var(--muted-foreground);
  font-weight: 600;
}
.ui-table .text-right { text-align: right; }
.row-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.row-actions form { margin: 0; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge-success {
  background: color-mix(in oklch, var(--success) 20%, transparent);
  color: var(--success);
}
.badge-warn {
  background: color-mix(in oklch, var(--warn) 20%, transparent);
  color: var(--warn);
}
.badge-muted {
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge-destructive {
  background: color-mix(in oklch, var(--destructive) 20%, transparent);
  color: var(--destructive);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-success {
  background: color-mix(in oklch, var(--success) 15%, transparent);
  color: var(--success);
}
.alert-error {
  background: color-mix(in oklch, var(--destructive) 15%, transparent);
  color: var(--destructive);
}

.muted { color: var(--muted-foreground); }
.text-right { text-align: right; }
.form-grid { display: grid; gap: 1rem; max-width: 40rem; }
.form-grid-wide { max-width: none; }
.stack { display: grid; gap: 1rem; }
.form-actions { margin-top: 0.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.link-danger {
  border: 0;
  background: none;
  color: var(--destructive);
  cursor: pointer;
  padding: 0;
  font-size: 0.875rem;
  text-decoration: underline;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}
.pagination a { color: var(--primary); text-decoration: none; }
.pagination a:hover { text-decoration: underline; }

/* Chart */
.chart-bars {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  align-items: end;
  height: 140px;
  margin-top: 1rem;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.chart-label {
  font-size: 0.55rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* Login page */
.login-page {
  position: relative;
  display: flex;
  min-height: 100vh;
  background: var(--background);
}
.login-brand {
  position: relative;
  display: none;
  width: 42%;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 3rem 2.5rem;
}
@media (min-width: 1024px) {
  .login-brand { display: flex; }
}
.login-brand-glow {
  pointer-events: none;
  position: absolute;
  right: -5rem;
  top: 33%;
  width: 16rem;
  height: 16rem;
  border-radius: 9999px;
  background: rgb(255 255 255 / 0.08);
  filter: blur(48px);
}
.login-brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}
.login-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background: rgb(255 255 255 / 0.15);
}
.login-brand-icon .nav-icon { width: 1.25rem; height: 1.25rem; }
.login-brand-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.025em; }
.login-brand-sub { font-size: 0.75rem; opacity: 0.7; margin-top: 0.125rem; }
.login-brand-content { position: relative; max-width: 24rem; }
.login-brand-content h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.025em;
  margin: 0;
}
.login-brand-content p {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  opacity: 0.75;
}
.login-features {
  list-style: none;
  padding: 0;
  margin: 2.5rem 0 0;
  display: grid;
  gap: 0.75rem;
}
.login-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.login-features .nav-icon { opacity: 0.8; }
.login-brand-footer {
  position: relative;
  font-size: 0.75rem;
  opacity: 0.5;
}
.login-main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
}
.login-main-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, oklch(0.511 0.262 276.966 / 0.06), transparent 55%);
}
html.dark .login-main-glow {
  background: radial-gradient(ellipse at top right, oklch(0.511 0.262 276.966 / 0.12), transparent 55%);
}
.login-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1.5rem 1.5rem 0;
}
@media (min-width: 640px) {
  .login-header { padding: 1.5rem 2.5rem 0; }
}
.login-body {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
@media (min-width: 640px) {
  .login-body { padding: 2.5rem; }
}
.login-form-wrap { width: 100%; max-width: 26.25rem; }
.login-mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
@media (min-width: 1024px) {
  .login-mobile-brand { display: none; }
}
.login-mobile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--primary) 20%, transparent);
}
.login-intro { margin-bottom: 2rem; }
.login-intro h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.login-intro p {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}
.login-card {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
@media (min-width: 640px) {
  .login-card { padding: 2rem; }
}
.login-footer-note {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.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: 768px) {
  body.sidebar-open { overflow: hidden; }

  .app-sidebar-toggle,
  .app-sidebar-close { display: inline-flex; }

  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: min(18rem, 88vw);
    height: 100%;
    max-height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgb(0 0 0 / 0.18);
  }

  .app-topbar {
    padding: 0 0.75rem;
  }
  .app-topbar-user { display: none; }
  .app-content {
    padding: 1rem;
  }

  .page-header h2 { font-size: 1.25rem; }
  .page-header .ui-btn {
    width: 100%;
    justify-content: center;
  }

  .ui-card-header {
    flex-direction: column;
    align-items: stretch;
  }
  .ui-card-header .ui-btn {
    width: 100%;
    justify-content: center;
  }

  .data-grid-header {
    flex-direction: column;
    align-items: stretch;
  }
  .data-grid-search-wrap {
    max-width: none;
    width: 100%;
  }
  .data-grid-body {
    padding: 0 0.75rem;
  }
  .data-grid-header,
  .data-grid-pagination {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .data-grid-table {
    font-size: 0.8125rem;
  }
  .data-grid-table th,
  .data-grid-table td {
    padding: 0.625rem 0.375rem;
  }

  .row-actions {
    gap: 0.375rem;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .ui-field,
  .filter-bar .filter-select {
    min-width: 0;
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-value { font-size: 1.25rem; }

  .chart-bars {
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }
  .chart-label { font-size: 0.625rem; }

  .ui-dialog-backdrop {
    padding: 0.5rem;
    align-items: flex-end;
  }
  .ui-dialog {
    max-height: 92dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .settings-actions .ui-btn {
    width: 100%;
    justify-content: center;
  }

  .ui-dropdown-menu {
    right: 0;
    left: auto;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* —— DataGrid —— */
.data-grid { overflow: hidden; }
.data-grid-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 0;
}
.data-grid-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.data-grid-search-wrap {
  position: relative;
  width: 100%;
  max-width: 16rem;
}
.data-grid-search {
  padding-right: 2.25rem;
}
.data-grid-search-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
  display: flex;
}
.data-grid-body { padding: 0 1.25rem; }
.data-grid-pagination {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
@media (min-width: 640px) {
  .data-grid-pagination {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.data-grid-range {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.data-grid-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.data-grid-page-label {
  min-width: 4rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.ui-table tbody tr[hidden] { display: none; }
.ui-table tbody tr:hover td { background: color-mix(in oklch, var(--accent) 50%, transparent); }
.text-right, .ui-table .text-right { text-align: right; }

/* —— Dialog —— */
body.dialog-open { overflow: hidden; }
.ui-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(2px);
}
.ui-dialog-backdrop[hidden] { display: none !important; }
.ui-dialog {
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}
.ui-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0;
}
.ui-dialog-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.ui-dialog-desc { margin: 0.35rem 0 0; font-size: 0.875rem; color: var(--muted-foreground); }
.ui-dialog-form { padding: 1rem 1.25rem 1.25rem; }
.ui-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* —— Form stack —— */
.form-stack { display: grid; gap: 1.25rem; }
.form-card { margin-bottom: 1.5rem; }
.form-section-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}
.form-section-desc {
  margin: -0.5rem 0 1rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.form-row-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .form-row-2 { grid-template-columns: 1fr; } }
.ui-radio-group { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.ui-radio-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--muted-foreground);
}
.ui-radio-item.is-checked,
.ui-radio-item:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary) 5%, transparent);
  color: var(--foreground);
  font-weight: 500;
}
.ui-radio-item input { accent-color: var(--primary); }
.ui-checkbox-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  cursor: pointer;
  font-size: 0.875rem;
}
.ui-checkbox-card:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary) 5%, transparent);
}
.ui-checkbox-card input { accent-color: var(--primary); width: 1rem; height: 1rem; }

/* —— Upload —— */
.ui-upload { margin: 0.5rem 0; }
.ui-upload-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.ui-upload-step {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
.ui-upload-label { font-size: 0.875rem; font-weight: 600; }
.ui-upload-hint { font-size: 0.8rem; color: var(--muted-foreground); margin: 0 0 0.75rem; }
.ui-upload-status {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
}
.ui-upload-status[data-tone="ok"] {
  background: color-mix(in oklch, var(--success) 15%, transparent);
  color: var(--success);
}
.ui-upload-dropzone {
  border: 1.5px dashed var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.ui-upload-dropzone.dragover {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary) 8%, transparent);
}
.ui-upload-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--muted-foreground);
}
.ui-upload-pick strong { color: var(--foreground); font-size: 0.875rem; }
.ui-upload-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  margin-bottom: 0.25rem;
}
.ui-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}
.ui-upload-preview {
  margin-bottom: 0.75rem;
  text-align: center;
}
.ui-upload-preview img {
  max-height: 12rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.5rem;
}
.ui-upload-preview.hidden, .hidden { display: none !important; }

/* —— Sweeter sidebar —— */
.app-sidebar {
  background: linear-gradient(180deg, var(--card) 0%, color-mix(in oklch, var(--card) 92%, var(--primary)) 100%);
}
.app-sidebar-brand {
  background: color-mix(in oklch, var(--primary) 6%, transparent);
  letter-spacing: -0.02em;
}
.nav-link.active {
  box-shadow: inset 3px 0 0 var(--primary);
  border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
}

/* Legacy aliases (templates migrating to ui-* classes) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background: var(--accent); }
.panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.panel h3 { margin-top: 0; margin-bottom: 1rem; font-size: 1rem; font-weight: 600; }
.app-content table:not(.ui-table) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.app-content table:not(.ui-table) th,
.app-content table:not(.ui-table) td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.app-content table:not(.ui-table) th {
  color: var(--muted-foreground);
  font-weight: 600;
}
.app-content label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.875rem;
}
.app-content input:not(.ui-input),
.app-content select:not(.ui-select),
.app-content textarea:not(.ui-textarea) {
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: transparent;
  color: var(--foreground);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.app-content input:focus,
.app-content select:focus,
.app-content textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}

.ui-readonly { margin: 0; font-size: 0.9375rem; font-weight: 500; }
.ui-link { color: var(--primary); font-size: 0.875rem; text-decoration: none; }
.ui-link:hover { text-decoration: underline; }
.ui-btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; min-height: 2rem; }
.page-note { margin: -0.5rem 0 1rem; font-size: 0.875rem; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}
.filter-bar .ui-field { margin: 0; min-width: 10rem; flex: 1; }
.filter-bar .filter-select { min-width: 12rem; }

.settings-form {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2rem;
}
.settings-card { margin: 0; }
.settings-card .ui-card-desc,
.ui-card-desc { margin: 0.25rem 0 1rem; font-size: 0.875rem; color: var(--muted-foreground); }
.settings-subheading { margin: 0.5rem 0 0; font-size: 0.875rem; font-weight: 600; color: var(--muted-foreground); }
.field-hint { margin: -0.25rem 0 0; font-size: 0.8rem; color: var(--muted-foreground); }
.field-hint code { font-size: 0.85em; color: var(--foreground); }
.duration-preview {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: color-mix(in oklch, var(--muted) 30%, transparent);
}
.duration-preview-title { margin: 0 0 0.75rem; font-size: 0.875rem; font-weight: 600; }
.duration-preview-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.duration-chip {
  display: inline-flex;
  padding: 0.375rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--background);
  font-size: 0.875rem;
  font-weight: 500;
}
.checkbox-stack { gap: 0.75rem; }
.settings-actions { display: flex; justify-content: flex-start; padding-top: 0.5rem; }
.settings-readonly-note { text-align: center; font-size: 0.875rem; }
.qris-preview-wrap { margin-bottom: 1rem; }
.qris-preview-img {
  max-height: 12rem;
  width: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.5rem;
}
.page-header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.dashboard-card, .report-card { margin-bottom: 1rem; }
.opname-diff.has-diff { color: #d97706; font-weight: 600; }
.refund-form { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.ui-input-sm { height: 2rem; padding: 0.25rem 0.5rem; font-size: 0.8125rem; }
