/* ==========================================================================
   CardVault - Premium B2B SaaS Design System
   Indigo/Violet gradient identity, Inter typography, 8px spacing
   ========================================================================== */

/* ==========================================================================
   01. RESET & CUSTOM PROPERTIES
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand Colors (HSL) */
  --primary: 238 76% 58%;
  --primary-foreground: 0 0% 100%;
  --secondary: 220 14% 96%;
  --secondary-foreground: 224 71% 4%;
  --muted: 220 14% 96%;
  --muted-foreground: 220 9% 46%;
  --accent: 220 14% 96%;
  --accent-foreground: 224 71% 4%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --success: 160 84% 39%;
  --success-fg: 0 0% 100%;
  --warning: 43 96% 56%;
  --warning-fg: 0 0% 9%;
  --background: 0 0% 98%;
  --foreground: 224 71% 4%;
  --card: 0 0% 100%;
  --card-foreground: 224 71% 4%;
  --border: 220 13% 91%;
  --input: 220 13% 91%;
  --ring: 238 76% 58%;

  /* Gradient */
  --gradient-from: 238 76% 58%;
  --gradient-to: 280 68% 60%;

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 4rem;
  --bottom-nav-height: 3.75rem;
  --content-max: 1400px;

  /* Shadows (layered) */
  --shadow-xs: 0 1px 2px hsl(var(--foreground) / 0.03);
  --shadow-sm: 0 1px 3px hsl(var(--foreground) / 0.04), 0 1px 2px hsl(var(--foreground) / 0.03);
  --shadow-md: 0 4px 6px hsl(var(--foreground) / 0.04), 0 2px 4px hsl(var(--foreground) / 0.03);
  --shadow-lg: 0 10px 15px hsl(var(--foreground) / 0.06), 0 4px 6px hsl(var(--foreground) / 0.04);
  --shadow-xl: 0 20px 25px hsl(var(--foreground) / 0.08), 0 8px 10px hsl(var(--foreground) / 0.04);
  --shadow-card: 0 1px 3px hsl(var(--foreground) / 0.04), 0 0 0 1px hsl(var(--border));
  --shadow-card-hover: 0 8px 25px hsl(var(--primary) / 0.1), 0 0 0 1px hsl(var(--primary) / 0.15);

  /* Spacing (8px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ==========================================================================
   02. TYPOGRAPHY & BASE ELEMENTS
   ========================================================================== */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: hsl(var(--ring));
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

a:hover {
  color: hsl(var(--primary));
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  line-height: inherit;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: hsl(var(--foreground));
  letter-spacing: -0.01em;
}

.text-muted {
  color: hsl(var(--muted-foreground));
}

.small {
  font-size: 0.8125rem;
}

.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;
}

/* ==========================================================================
   03. ICON SYSTEM
   ========================================================================== */

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  font-size: 1.125rem;
  flex-shrink: 0;
  vertical-align: middle;
}

.icon svg {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-sm { font-size: 0.875rem; }
.icon-md { font-size: 1.25rem; }
.icon-lg { font-size: 1.5rem; }
.icon-xl { font-size: 2rem; }

/* ==========================================================================
   04. LAYOUT PRIMITIVES
   ========================================================================== */

.main-content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8);
  animation: fade-in var(--duration-normal) var(--ease-out);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}

.index-layout {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
}

/* ==========================================================================
   05. NAVIGATION (Header, Sidebar, Bottom Nav)
   ========================================================================== */

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: hsl(var(--card) / 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  height: var(--header-height);
  transition: box-shadow var(--duration-normal) ease;
}

.app-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  opacity: 0.6;
}

.app-header.header--scrolled {
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--space-4);
}

/* CSS-only Logo Mark */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: hsl(var(--foreground));
  font-weight: 800;
  font-size: 1.125rem;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.logo-mark {
  position: relative;
  width: 1.75rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.logo-mark::before,
.logo-mark::after {
  content: "";
  position: absolute;
  width: 1.375rem;
  height: 0.875rem;
  border-radius: 3px;
  border: 2px solid transparent;
}

.logo-mark::before {
  top: 0;
  left: 0;
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  opacity: 0.9;
}

.logo-mark::after {
  bottom: 0;
  right: 0;
  background: linear-gradient(135deg, hsl(var(--gradient-to)), hsl(var(--gradient-from)));
  opacity: 0.6;
}

.logo-text-full {
  display: inline;
}

.logo-text-short {
  display: none;
}

/* Header Search */
.header-search {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}

.header-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.header-search-wrap .icon {
  position: absolute;
  left: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  pointer-events: none;
}

.header-search input {
  width: 320px;
  padding: 0.5rem 3.5rem 0.5rem 2.5rem;
  border-radius: var(--radius-full);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  transition: all var(--duration-normal) var(--ease-out);
  outline: none;
}

.header-search input::placeholder {
  color: hsl(var(--muted-foreground));
}

.header-search input:focus {
  background: hsl(var(--card));
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
  width: 380px;
}

.search-shortcut {
  position: absolute;
  right: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

/* Header Nav */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--duration-fast) ease;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.nav-link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-link.active {
  color: hsl(var(--primary));
  font-weight: 600;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -0.5rem;
  left: 50%;
  transform: translateX(-50%) scaleX(1);
  width: 1.5rem;
  height: 2px;
  background: hsl(var(--primary));
  border-radius: 1px;
  animation: scale-in var(--duration-normal) var(--ease-out);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  color: hsl(var(--primary-foreground));
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}

.nav-btn:hover {
  opacity: 0.9;
  color: hsl(var(--primary-foreground));
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

/* User Menu */
.user-menu {
  position: relative;
  margin-left: var(--space-1);
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: hsl(var(--foreground));
  transition: all var(--duration-fast) ease;
  cursor: pointer;
}

.user-menu-btn:hover {
  border-color: hsl(var(--border));
}

.user-menu.open .user-menu-btn {
  border-color: hsl(var(--primary) / 0.3);
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0.15), hsl(var(--gradient-to) / 0.15));
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-menu-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-chevron {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  transition: transform var(--duration-fast) ease;
}

.user-menu.open .user-menu-chevron {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 220px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 300;
  padding: var(--space-2);
  display: none;
  animation: slide-down var(--duration-fast) var(--ease-out);
}

.user-dropdown.open,
.user-menu.open .user-dropdown {
  display: block;
}

.user-dropdown-info {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: var(--space-2);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: background var(--duration-fast) ease;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.user-dropdown-item .icon {
  color: hsl(var(--muted-foreground));
  font-size: 1rem;
}

.user-dropdown-item--danger {
  color: hsl(var(--destructive));
}

.user-dropdown-item--danger .icon {
  color: hsl(var(--destructive));
}

.user-dropdown-form {
  border-top: 1px solid hsl(var(--border));
  margin-top: var(--space-1);
  padding-top: var(--space-1);
}

/* --- Admin Sidebar --- */
.layout-admin {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, hsl(var(--card)), hsl(0 0% 99%));
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
}

.sidebar-header .logo {
  font-size: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  gap: var(--space-1);
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav-group {
  margin-top: var(--space-3);
}

.sidebar-nav-group:first-child {
  margin-top: 0;
}

.sidebar-nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.625rem var(--space-3);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 400;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
  position: relative;
}

.sidebar-nav-item .icon {
  font-size: 1.125rem;
  flex-shrink: 0;
}

.sidebar-nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.sidebar-nav-item.active {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  font-weight: 600;
}

.sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.25rem;
  background: hsl(var(--primary));
  border-radius: 0 2px 2px 0;
}

.sidebar-nav-item .badge-count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.sidebar-user {
  border-top: 1px solid hsl(var(--border));
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.sidebar-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0.15), hsl(var(--gradient-to) / 0.15));
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  transition: all var(--duration-fast) ease;
  flex-shrink: 0;
}

.sidebar-user-logout:hover {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.sidebar-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  background: hsl(var(--background));
}

.sidebar-content .main-content {
  max-width: calc(var(--content-max) - var(--sidebar-width));
  padding: var(--space-8);
  margin: 0 auto;
}

/* Sidebar mobile backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: hsl(var(--foreground) / 0.5);
  z-index: 40;
  backdrop-filter: blur(4px);
}

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

/* Mobile top bar for admin layout */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: hsl(var(--card) / 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid hsl(var(--border));
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
}

.mobile-topbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  opacity: 0.4;
}

.mobile-topbar__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: none;
  color: hsl(var(--foreground));
  border-radius: var(--radius);
  cursor: pointer;
}

.mobile-topbar__toggle:hover {
  background: hsl(var(--accent));
}

.mobile-topbar .logo {
  font-size: 0.9375rem;
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: hsl(var(--card) / 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid hsl(var(--border) / 0.5);
  display: none;
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  font-size: 0.625rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color var(--duration-fast) ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}

.bottom-nav-item .icon {
  font-size: 1.25rem;
  transition: transform var(--duration-fast) var(--ease-out);
}

.bottom-nav-item.active {
  color: hsl(var(--primary));
}

.bottom-nav-item.active .icon {
  transform: scale(1.15);
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

/* ==========================================================================
   06. BUTTONS & LINKS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  text-decoration: none;
  white-space: nowrap;
  min-height: 2.375rem;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn .icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.btn--primary {
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn--primary:hover {
  opacity: 0.9;
  color: hsl(var(--primary-foreground));
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

.btn--secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn--secondary:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn--danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}

.btn--danger:hover {
  opacity: 0.9;
  color: hsl(var(--destructive-foreground));
}

.btn--ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: transparent;
}

.btn--ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn--outline {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.btn--outline:hover {
  background: hsl(var(--accent));
}

.btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 2rem;
  border-radius: var(--radius-sm);
}

.btn--sm .icon { font-size: 0.875rem; }

.btn--lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  min-height: 2.75rem;
}

.btn--full { width: 100%; }

.btn--icon {
  padding: 0.5rem;
  min-height: unset;
  width: 2.375rem;
  height: 2.375rem;
}

.btn--icon.btn--sm {
  width: 2rem;
  height: 2rem;
  padding: 0.375rem;
}

.btn--flex { flex: 1; justify-content: center; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: var(--space-5);
  transition: color var(--duration-fast) ease;
}

.back-link:hover {
  color: hsl(var(--foreground));
}

.back-link .icon {
  font-size: 1rem;
  transition: transform var(--duration-fast) ease;
}

.back-link:hover .icon {
  transform: translateX(-2px);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), 0 4px 20px hsl(var(--primary) / 0.3);
  z-index: 90;
  transition: all var(--duration-normal) var(--ease-out);
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl), 0 8px 30px hsl(var(--primary) / 0.4);
  color: hsl(var(--primary-foreground));
}

.fab .icon { font-size: 1.375rem; }

/* ==========================================================================
   07. FORMS & INPUTS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.form-label .icon {
  font-size: 0.9375rem;
  color: hsl(var(--muted-foreground));
}

.form-label .required {
  color: hsl(var(--destructive));
  font-weight: 400;
}

.form-input {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-lg);
  transition: all var(--duration-fast) ease;
  outline: none;
  min-height: 2.5rem;
}

.form-input::placeholder {
  color: hsl(var(--muted-foreground) / 0.6);
}

.form-input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 4px hsl(var(--ring) / 0.1);
  transform: scale(1.005);
}

.form-input:disabled {
  opacity: 0.6;
  background: hsl(var(--muted));
  cursor: not-allowed;
}

.form-input--error { border-color: hsl(var(--destructive)); }
.form-input--error:focus { box-shadow: 0 0 0 4px hsl(var(--destructive) / 0.1); }

.form-error {
  font-size: 0.75rem;
  color: hsl(var(--destructive));
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.form-row {
  display: flex;
  gap: var(--space-4);
}

.form-row > .form-group { flex: 1; }

.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-lg);
  transition: all var(--duration-fast) ease;
  outline: none;
  resize: vertical;
  min-height: 6rem;
}

.form-textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 4px hsl(var(--ring) / 0.1);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-3);
}

.form-actions--right { justify-content: flex-end; }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.125rem;
  accent-color: hsl(var(--primary));
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.45;
}

/* Input with icon */
.input-icon-wrap { position: relative; }

.input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
  z-index: 1;
  display: flex;
  align-items: center;
}

.input-with-icon,
.input-icon-wrap .form-input {
  padding-left: 2.75rem;
}

/* Form card with gradient top border */
.form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-8);
  position: relative;
}

.form-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.form-card .form-group + .form-group {
  margin-top: var(--space-4);
}

/* Settings card */
.settings-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-8);
  max-width: 600px;
  position: relative;
}

.settings-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.settings-card .form-group + .form-group {
  margin-top: var(--space-4);
}

/* Role select */
.role-select {
  display: flex;
  gap: var(--space-2);
}

.role-select__option {
  flex: 1;
  cursor: pointer;
}

.role-select__option input[type="radio"] {
  display: none;
}

.role-select__label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem var(--space-4);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--card));
  transition: all var(--duration-fast);
}

.role-select__option input[type="radio"]:checked + .role-select__label {
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  font-weight: 600;
}

/* ==========================================================================
   08. CARDS (card-tile, data-card, stat-card)
   ========================================================================== */

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.card-tile {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}

.card-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: hsl(var(--success));
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  z-index: 2;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.card-tile:hover {
  box-shadow: var(--shadow-card-hover);
  transform: scale(1.02);
  color: inherit;
}

.card-tile:hover::before {
  opacity: 1;
}

.card-tile__img {
  aspect-ratio: 16 / 10;
  background: hsl(var(--muted));
  overflow: hidden;
  position: relative;
}

.card-tile__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.card-tile:hover .card-tile__img img {
  transform: scale(1.04);
}

/* Shimmer skeleton for loading images */
.card-tile__img::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--muted-foreground) / 0.06) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.card-tile__img:not(:has(img)) .card-tile__placeholder ~ *::before {
  opacity: 1;
}

.card-tile__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: hsl(var(--muted-foreground) / 0.4);
}

.card-tile__body {
  padding: var(--space-3);
}

.card-tile__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-1);
}

.card-tile__meta {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Confidence badge */
.confidence-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
  background: hsl(var(--card) / 0.85);
  color: hsl(var(--foreground));
  z-index: 2;
  border: 1px solid hsl(var(--border) / 0.5);
}

.confidence-badge.confidence--high,
.confidence-badge--high {
  background: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
  border-color: hsl(var(--success) / 0.3);
}

.confidence-badge.confidence--mid,
.confidence-badge--medium {
  background: hsl(var(--warning) / 0.15);
  color: hsl(var(--warning-fg));
  border-color: hsl(var(--warning) / 0.3);
}

.confidence-badge.confidence--low,
.confidence-badge--low {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.3);
}

.source-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  backdrop-filter: blur(8px);
  background: hsl(var(--card) / 0.85);
  color: hsl(var(--muted-foreground));
  z-index: 2;
  border: 1px solid hsl(var(--border) / 0.5);
}

/* Stat card */
.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: box-shadow var(--duration-fast) ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
}

.stat-card__info {
  display: flex;
  flex-direction: column;
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 800;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.stat-card__label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  min-height: 300px;
}

.empty-state .icon {
  font-size: 3rem;
  color: hsl(var(--muted-foreground) / 0.3);
  margin-bottom: var(--space-5);
}

.empty-state__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: var(--space-2);
}

.empty-state__desc {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 360px;
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

/* ==========================================================================
   09. TABLES
   ========================================================================== */

.table-wrap {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  background: hsl(var(--card));
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid hsl(var(--border));
  background: hsl(var(--secondary) / 0.5);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  font-size: 0.875rem;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

/* Row striping */
.table tbody tr:nth-child(even) td {
  background: hsl(var(--muted) / 0.3);
}

.table tbody tr:hover td {
  background: hsl(var(--accent) / 0.5);
}

/* ==========================================================================
   10. BADGES (role, status, plan, confidence)
   ========================================================================== */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge--admin, .role-badge--super_admin {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.role-badge--manager, .role-badge--company_admin {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.role-badge--user, .role-badge--employee {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-dot--active {
  background: hsl(var(--success));
  box-shadow: 0 0 0 2px hsl(var(--success) / 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot--inactive {
  background: hsl(var(--muted-foreground) / 0.3);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.plan-badge--free { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.plan-badge--pro { background: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.plan-badge--enterprise { background: hsl(var(--warning) / 0.12); color: hsl(var(--warning-fg)); }

/* Confidence inline */
.confidence-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.confidence-inline.confidence--high { background: hsl(var(--success) / 0.1); color: hsl(var(--success)); }
.confidence-inline.confidence--mid { background: hsl(var(--warning) / 0.1); color: hsl(43 96% 40%); }
.confidence-inline.confidence--low { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }

/* ==========================================================================
   11. ALERTS & FLASH MESSAGES
   ========================================================================== */

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-lg);
  animation: slide-down var(--duration-normal) var(--ease-out);
  position: relative;
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

.flash .icon {
  flex-shrink: 0;
  font-size: 1.125rem;
  margin-top: 0.0625rem;
}

.flash--success { border-left: 3px solid hsl(var(--success)); }
.flash--success .icon { color: hsl(var(--success)); }
.flash--error { border-left: 3px solid hsl(var(--destructive)); }
.flash--error .icon { color: hsl(var(--destructive)); }
.flash--warning { border-left: 3px solid hsl(var(--warning)); }
.flash--warning .icon { color: hsl(var(--warning)); }
.flash--info { border-left: 3px solid hsl(var(--primary)); }
.flash--info .icon { color: hsl(var(--primary)); }

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-6);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.alert--success { background: hsl(var(--success) / 0.08); color: hsl(var(--success)); border: 1px solid hsl(var(--success) / 0.2); }
.alert--error { background: hsl(var(--destructive) / 0.08); color: hsl(var(--destructive)); border: 1px solid hsl(var(--destructive) / 0.2); }
.alert--info, .alert--warning { background: hsl(var(--warning) / 0.08); color: hsl(43 96% 35%); border: 1px solid hsl(var(--warning) / 0.2); }

/* ==========================================================================
   12. PAGINATION
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-6) 0;
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: all var(--duration-fast) ease;
  border: 1px solid transparent;
}

.pagination__link:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.pagination__link.active,
.pagination__link--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  font-weight: 600;
}

.pagination__dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

/* ==========================================================================
   13. MISC (avatar, tag, divider, empty-state, section-card)
   ========================================================================== */

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0.1), hsl(var(--gradient-to) / 0.1));
  color: hsl(var(--primary));
  font-weight: 700;
  flex-shrink: 0;
}

.avatar--sm { width: 1.75rem; height: 1.75rem; font-size: 0.625rem; }
.avatar--md { width: 2.25rem; height: 2.25rem; font-size: 0.75rem; }
.avatar--lg { width: 3rem; height: 3rem; font-size: 1rem; }

.divider, hr.divider {
  border: none;
  height: 1px;
  background: hsl(var(--border));
  margin: var(--space-6) 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: var(--space-4);
  margin-top: var(--space-2);
}

.section-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 500;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.text-danger { color: hsl(var(--destructive)); }

/* ==========================================================================
   14. AUTH PAGES
   ========================================================================== */

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

.auth-brand-panel {
  flex: 1;
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: white;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 50%, hsl(280 68% 60% / 0.3) 0%, transparent 50%),
              radial-gradient(circle at 70% 30%, hsl(238 76% 70% / 0.2) 0%, transparent 50%);
}

.auth-brand-logo {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.auth-brand-logo .logo-mark {
  width: 2.5rem;
  height: 1.75rem;
}

.auth-brand-logo .logo-mark::before,
.auth-brand-logo .logo-mark::after {
  background: white;
}

.auth-brand-logo .logo-mark::before { opacity: 0.9; }
.auth-brand-logo .logo-mark::after { opacity: 0.5; }

.auth-brand-title {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-brand-tagline {
  position: relative;
  z-index: 1;
  font-size: 1rem;
  opacity: 0.8;
  margin-top: var(--space-2);
}

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: hsl(var(--background));
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: none;
}

.auth-logo-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto var(--space-6);
  background: linear-gradient(135deg, hsl(var(--gradient-from) / 0.1), hsl(var(--gradient-to) / 0.1));
  border-radius: var(--radius-full);
  color: hsl(var(--primary));
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: var(--space-2);
  color: hsl(var(--foreground));
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.875rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-form .form-input {
  border-radius: var(--radius-lg);
  min-height: 2.75rem;
  font-size: 0.9375rem;
}

.auth-form .btn--primary {
  min-height: 2.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-6);
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.auth-link {
  color: hsl(var(--primary));
  font-weight: 600;
  transition: color var(--duration-fast) ease;
}

.auth-link:hover {
  color: hsl(var(--gradient-to));
  text-decoration: underline;
}

/* ==========================================================================
   15. CARDS INDEX PAGE
   ========================================================================== */

.page-index {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
}

.index-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
}

.index-main {
  flex: 1;
  min-width: 0;
}

/* Sidebar sections */
.sidebar-section {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.sidebar-section__title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: hsl(var(--foreground));
}

.sidebar-stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-stats .stat-card {
  padding: var(--space-3);
  border: none;
  background: hsl(var(--muted) / 0.5);
}

.sidebar-filter-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-filter-item {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: all var(--duration-fast) ease;
}

.sidebar-filter-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.sidebar-filter-item.active {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  font-weight: 600;
}

/* Search */
.search-form { margin-bottom: var(--space-4); }

.search-bar {
  display: flex;
  align-items: center;
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  overflow: hidden;
  transition: border-color var(--duration-fast) ease;
  position: relative;
}

.search-bar:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

.search-bar__icon {
  position: absolute;
  left: var(--space-3);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.search-bar__input {
  flex: 1;
  border: none;
  padding: 0.625rem var(--space-4) 0.625rem 2.5rem;
  font-size: 0.875rem;
  background: transparent;
  outline: none;
  color: hsl(var(--foreground));
  min-height: 2.5rem;
}

.search-bar__input::placeholder {
  color: hsl(var(--muted-foreground) / 0.6);
}

.search-bar__btn {
  padding: var(--space-2) var(--space-4);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--duration-fast) ease;
  white-space: nowrap;
}

.search-bar__btn:hover { opacity: 0.9; }

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  margin-bottom: var(--space-4);
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.3125rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.chip--active, .chip.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

/* Result count */
.result-count {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: var(--space-4);
}

.result-query {
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* Mobile stats */
.mobile-stats {
  display: none;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.mobile-stats__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  white-space: nowrap;
  font-size: 0.8rem;
}

.mobile-stats__value { font-weight: 700; }
.mobile-stats__label { color: hsl(var(--muted-foreground)); }

.mobile-chips {
  display: none;
  margin-bottom: var(--space-4);
  overflow-x: auto;
  -webkit-mask-image: linear-gradient(90deg, black 90%, transparent 100%);
  mask-image: linear-gradient(90deg, black 90%, transparent 100%);
}

/* View mode toggle */
.view-toggle {
  display: inline-flex;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.view-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  transition: all var(--duration-fast) ease;
  cursor: pointer;
  border: none;
  background: transparent;
}

.view-toggle__btn.active {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   16. CARD SHOW PAGE
   ========================================================================== */

.page-show .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}

.show-image { position: relative; }

.card-image-wrap {
  border-radius: var(--radius-xl);
  border: 1px solid hsl(var(--border));
  overflow: hidden;
  background: hsl(var(--muted));
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  box-shadow: var(--shadow-md);
}

.card-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

.card-image-wrap.zoomed img {
  cursor: zoom-out;
  transform: scale(1.5);
  transition: transform var(--duration-slow) var(--ease-out);
}

.card-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.image-meta {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}

.image-meta__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* AI raw data */
.ai-raw-data {
  margin-top: var(--space-3);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}

.ai-raw-data summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ai-raw-data__content {
  margin-top: var(--space-3);
  font-size: 0.7rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  background: hsl(var(--muted));
  padding: var(--space-3);
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.6;
}

/* Contact card */
.contact-card {
  background: hsl(var(--card));
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border));
  padding: var(--space-6);
  position: relative;
}

.contact-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.contact-card__name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--space-1); }
.contact-card__title { color: hsl(var(--muted-foreground)); font-size: 0.9rem; margin-bottom: var(--space-1); }
.contact-card__company { display: flex; align-items: center; gap: var(--space-2); font-size: 0.95rem; margin-bottom: var(--space-5); }
.contact-card__company .icon { color: hsl(var(--muted-foreground)); }

.contact-fields {
  display: flex;
  flex-direction: column;
}

.field-row {
  display: flex;
  align-items: flex-start;
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid hsl(var(--border) / 0.5);
  gap: var(--space-3);
  transition: background var(--duration-fast) ease;
  border-radius: var(--radius);
}

.field-row:last-child { border-bottom: none; }
.field-row:hover { background: hsl(var(--accent) / 0.3); }

.field-row__icon { color: hsl(var(--muted-foreground)); flex-shrink: 0; margin-top: 0.125rem; }
.field-row__content { flex: 1; min-width: 0; }
.field-row__label { font-size: 0.7rem; color: hsl(var(--muted-foreground)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.field-row__value { font-size: 0.9rem; margin-top: 0.125rem; word-break: break-all; }
.field-row__link { color: hsl(var(--primary)); text-decoration: none; }
.field-row__link:hover { text-decoration: underline; }

/* Desktop/mobile actions */
.desktop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.sticky-actions {
  display: none;
}

/* ==========================================================================
   17. CARD CREATE PAGE
   ========================================================================== */

.page-create .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}

/* Segment tabs */
.segment-tabs {
  display: flex;
  background: hsl(var(--muted));
  border-radius: var(--radius-lg);
  padding: 0.25rem;
  margin-bottom: var(--space-6);
}

.segment-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem var(--space-4);
  border: none;
  background: transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all var(--duration-fast);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.segment-tab.active {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Camera */
.camera-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: hsl(var(--foreground));
  aspect-ratio: 16 / 10;
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.camera-corners {
  position: absolute;
  inset: 10%;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: rgba(255,255,255,0.8);
  border-style: solid;
}

.corner--tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; animation: corner-pulse 2s ease-in-out infinite; }
.corner--tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; animation: corner-pulse 2s ease-in-out 0.5s infinite; }
.corner--bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; animation: corner-pulse 2s ease-in-out 1s infinite; }
.corner--br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; animation: corner-pulse 2s ease-in-out 1.5s infinite; }

.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-5);
  background: linear-gradient(to top, hsl(var(--foreground) / 0.6), transparent);
}

.btn-capture {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-full);
  background: hsl(var(--primary-foreground));
  border: 4px solid hsl(var(--primary-foreground) / 0.5);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-capture:hover { transform: scale(1.05); }
.btn-capture:active { transform: scale(0.95); }

.btn-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-full);
  background: hsl(var(--foreground) / 0.4);
  backdrop-filter: blur(4px);
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  border: none;
}

.btn-icon:hover { background: hsl(var(--foreground) / 0.6); }

.camera-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  background: hsl(var(--muted));
  border-radius: var(--radius-xl);
  border: 2px dashed hsl(var(--border));
}

.camera-start .icon {
  color: hsl(var(--muted-foreground) / 0.4);
  margin-bottom: var(--space-4);
}

.camera-start p {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed hsl(var(--border));
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  background: hsl(var(--card));
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.04);
}

.upload-zone:hover {
  border-style: solid;
  animation: border-rotate 4s linear infinite;
}

.upload-zone .icon {
  font-size: 2.5rem;
  color: hsl(var(--muted-foreground) / 0.4);
  margin-bottom: var(--space-4);
}

.upload-zone__title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.upload-zone__sub {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

/* Preview */
.preview-container { text-align: center; }

.preview-img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}

.preview-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}

.file-preview {
  text-align: center;
  margin-bottom: var(--space-4);
}

/* Processing overlay */
.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--foreground) / 0.3);
  backdrop-filter: blur(8px);
}

.processing-box {
  background: hsl(var(--card));
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  text-align: center;
  box-shadow: var(--shadow-xl);
  max-width: 320px;
  width: calc(100% - 2rem);
}

.processing-spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-5);
}

.processing-text {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

/* Create sidebar instructions */
.create-sidebar .instructions-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: sticky;
  top: calc(var(--header-height) + var(--space-4));
}

.instructions-card h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.instructions-steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.instructions-steps li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.instructions-steps li .icon { color: hsl(var(--primary)); flex-shrink: 0; }

.instructions-info { margin-bottom: var(--space-4); }
.instructions-info h4 { font-size: 0.8rem; font-weight: 600; color: hsl(var(--foreground)); margin-bottom: var(--space-2); }
.instructions-info p, .instructions-info li { font-size: 0.8rem; color: hsl(var(--muted-foreground)); line-height: 1.5; }
.instructions-info ul { padding-left: var(--space-4); }

/* ==========================================================================
   18. CARD EDIT PAGE
   ========================================================================== */

.page-edit .two-col {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: var(--space-8);
  align-items: start;
}

.edit-image__card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.edit-image__card img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: hsl(var(--muted));
}

.edit-form-wrap .form-group + .form-group {
  margin-top: var(--space-4);
}

.edit-form-wrap .form-row + .form-row,
.edit-form-wrap .form-row + .form-group,
.edit-form-wrap .form-group + .form-row {
  margin-top: var(--space-4);
}

/* ==========================================================================
   19. MANAGE PAGES (employees, settings)
   ========================================================================== */

.page-admin {
  max-width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: var(--space-1);
}

/* Mobile data cards */
.data-card-list {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.data-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.data-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.data-card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  text-decoration: none;
}

.data-card__body {
  display: flex;
  flex-direction: column;
}

.data-card__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid hsl(var(--border) / 0.4);
  font-size: 0.8125rem;
  gap: var(--space-2);
}

.data-card__row:last-of-type { border-bottom: none; }

.data-card__label { color: hsl(var(--muted-foreground)); flex-shrink: 0; font-size: 0.75rem; }
.data-card__value { color: hsl(var(--foreground)); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.data-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  margin-top: var(--space-2);
  border-top: 1px solid hsl(var(--border));
  font-size: 0.85rem;
}

/* ==========================================================================
   20. ADMIN DASHBOARD
   ========================================================================== */

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.admin-stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: box-shadow var(--duration-fast) ease;
  position: relative;
  overflow: hidden;
}

.admin-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  opacity: 0.7;
}

.admin-stat-card:hover {
  box-shadow: var(--shadow-md);
}

.admin-stat-card__icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.admin-stat-card__content { flex: 1; min-width: 0; }

.admin-stat-card__value {
  font-size: 1.75rem;
  font-weight: 800;
  color: hsl(var(--foreground));
  line-height: 1.1;
  margin-bottom: 0.125rem;
}

.admin-stat-card__label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.admin-stat-card__sub {
  font-size: 0.6875rem;
  margin-top: var(--space-1);
}

/* Admin nav cards */
.admin-nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.admin-nav-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: hsl(var(--foreground));
  transition: all var(--duration-fast) ease;
}

.admin-nav-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--foreground));
}

.admin-nav-card .icon:first-child {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: hsl(var(--muted));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
}

.admin-nav-card div { flex: 1; min-width: 0; }
.admin-nav-card div strong { font-size: 0.875rem; display: block; }
.admin-nav-card div span { font-size: 0.75rem; }

.nav-arrow {
  margin-left: auto;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
  transition: transform var(--duration-fast) ease;
}

.admin-nav-card:hover .nav-arrow {
  transform: translateX(3px);
}

/* ==========================================================================
   21. ERROR PAGE
   ========================================================================== */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: var(--space-8);
}

.error-page .icon {
  color: hsl(var(--muted-foreground) / 0.3);
  margin-bottom: var(--space-4);
}

.error-code {
  font-size: 8rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, hsl(var(--gradient-from)), hsl(var(--gradient-to)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-2);
}

.error-message {
  font-size: 1.125rem;
  color: hsl(var(--muted-foreground));
  max-width: 400px;
  margin-bottom: var(--space-8);
  line-height: 1.6;
}

/* ==========================================================================
   22. UTILITIES
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-3); }
.gap-lg { gap: var(--space-6); }
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
.mb-3 { margin-bottom: var(--space-6); }
.hidden { display: none; }
.block { display: block; }
.inline-flex { display: inline-flex; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.border { border: 1px solid hsl(var(--border)); }
.bg-card { background: hsl(var(--card)); }
.bg-muted { background: hsl(var(--muted)); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Spin animation */
.spin { animation: spin 1s linear infinite; }

/* Create mode container */
.create-mode { }

/* ==========================================================================
   23. ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { transform: translateX(-50%) scaleX(0); }
  to { transform: translateX(-50%) scaleX(1); }
}

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px hsl(var(--success) / 0.2); }
  50% { box-shadow: 0 0 0 4px hsl(var(--success) / 0.1); }
}

@keyframes corner-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

@keyframes flash-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes drawer-open {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--muted-foreground) / 0.08) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* Spinner */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.spinner--sm { width: 1rem; height: 1rem; border-width: 1.5px; }
.spinner--lg { width: 2rem; height: 2rem; border-width: 3px; }

/* ==========================================================================
   24. RESPONSIVE - TABLET (640px - 768px)
   ========================================================================== */

@media (max-width: 1280px) {
  .index-sidebar { width: 220px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { display: none; }
  .sidebar-content { margin-left: 0; }
  .sidebar-content .main-content { max-width: 100%; padding: var(--space-6); }
  .bottom-nav { display: flex; }
  body { padding-bottom: var(--bottom-nav-height); }
  .index-sidebar { display: none; }
  .page-index { flex-direction: column; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-nav-cards { grid-template-columns: repeat(2, 1fr); }
  .page-show .two-col { grid-template-columns: 1fr 1fr; gap: var(--space-6); }
  .page-create .two-col { grid-template-columns: 1fr; }
  .create-sidebar { display: none; }
  .fab { bottom: calc(var(--bottom-nav-height) + var(--space-4)); right: var(--space-6); }
  .mobile-chips { display: block; }
}

/* ==========================================================================
   25. RESPONSIVE - PHONE (max 768px)
   ========================================================================== */

@media (max-width: 768px) {
  body { padding-bottom: var(--bottom-nav-height); }

  /* Admin sidebar */
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: 50;
  }
  .sidebar.open {
    transform: translateX(0);
    animation: drawer-open var(--duration-normal) var(--ease-out);
  }
  .sidebar-content { margin-left: 0; }
  .sidebar-content .main-content {
    max-width: 100%;
    padding: var(--space-4);
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px));
  }
  .mobile-topbar { display: flex; }
  .bottom-nav { display: flex; }

  /* Header */
  .header-search { display: none; }
  .header-inner { padding: 0 var(--space-4); }
  .user-menu-name { display: none; }
  .logo-text-full { display: none; }
  .logo-text-short { display: inline; }
  .nav-link-text { display: none; }
  .nav-btn-text { display: none; }
  .nav-link.active::after { display: none; }

  .main-content { padding: var(--space-5) var(--space-4); }

  /* Two-col -> single col */
  .two-col,
  .page-show .two-col,
  .page-create .two-col,
  .page-edit .two-col {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .card-image-wrap { position: static; }

  /* Index */
  .page-index { flex-direction: column; gap: 0; }
  .index-sidebar { display: none; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .card-tile__body { padding: var(--space-2) var(--space-3); }

  /* Search iOS zoom fix */
  .search-bar__input { font-size: 16px; }

  /* Mobile stats & chips */
  .mobile-stats { display: flex; }
  .mobile-chips { display: block; }

  /* Forms */
  .form-row { flex-direction: column; gap: var(--space-4); }

  /* Actions */
  .sticky-actions {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    background: hsl(var(--card) / 0.9);
    backdrop-filter: blur(16px);
    border-top: 1px solid hsl(var(--border));
    gap: var(--space-2);
    z-index: 100;
  }
  .sticky-actions .btn { flex: 1; }
  .desktop-actions { display: none; }
  .page-show { padding-bottom: 5rem; }
  .fab { display: none; }

  /* Tables -> cards */
  .table-wrap { display: none; }
  .data-card-list { display: flex; }

  /* Admin */
  .admin-stats { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .admin-nav-cards { grid-template-columns: 1fr; }
  .create-sidebar { display: none; }

  /* Page header */
  .page-header { margin-bottom: var(--space-4); }
  .page-title { font-size: 1.25rem; }

  /* Contact fields */
  .field-row { flex-direction: column; gap: var(--space-1); padding: var(--space-3) var(--space-2); }

  /* Search */
  .search-form { margin-bottom: var(--space-3); }
  .pagination { padding: var(--space-4) 0; }

  /* Camera edge-to-edge */
  .camera-container { border-radius: var(--radius-lg); }
  .camera-start { padding: var(--space-8) var(--space-4); }

  /* Auth: hide brand panel, full-screen form */
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: var(--space-6) var(--space-4); }
  .auth-logo-circle { display: flex; }
}

/* ==========================================================================
   26. RESPONSIVE - SMALL PHONE (max 480px)
   ========================================================================== */

@media (max-width: 480px) {
  .auth-card { padding: var(--space-6) var(--space-5); }
  .auth-title { font-size: 1.25rem; }
  .page-title { font-size: 1.25rem; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .card-tile__name { font-size: 0.8125rem; }
  .stat-card__value { font-size: 1.25rem; }
  .contact-card__name { font-size: 1.25rem; }
  .admin-stat-card { padding: var(--space-4); }
  .admin-stat-card__value { font-size: 1.375rem; }
  .main-content { padding: var(--space-4); }
  .error-code { font-size: 5rem; }
}

/* ==========================================================================
   27. RESPONSIVE - DESKTOP (min 1025px)
   ========================================================================== */

@media (min-width: 1025px) {
  .bottom-nav { display: none !important; }
  .logo-text-short { display: none; }
  .sticky-actions { display: none !important; }
  .data-card-list { display: none !important; }
  .table-wrap { display: block !important; }
  .main-content { padding: var(--space-8); }
  .mobile-stats { display: none !important; }
}

/* ==========================================================================
   28. TOUCH & POINTER
   ========================================================================== */

@media (hover: none) {
  .card-tile:hover { transform: none; box-shadow: none; }
  .card-tile:hover::before { opacity: 0; }
  .card-tile:hover .card-tile__img img { transform: none; }
  .card-tile:active { opacity: 0.85; }
  .btn:hover { opacity: 1; }
  .btn:active { opacity: 0.85; }
  .nav-link:hover { background: none; }
  .sidebar-nav-item:hover { background: none; }
  .admin-nav-card:hover { box-shadow: none; border-color: hsl(var(--border)); }
  .admin-nav-card:hover .nav-arrow { transform: none; }
  .field-row:hover { background: transparent; }
  .table tbody tr:hover td { background: transparent; }
}

@media (pointer: coarse) {
  .btn { min-height: 2.75rem; }
  .btn--sm { min-height: 2.375rem; }
  .nav-link { min-height: 2.75rem; padding: 0.625rem 0.75rem; }
  .pagination__link { min-width: 2.75rem; min-height: 2.75rem; }
  .chip { min-height: 2.25rem; padding: var(--space-2) var(--space-3); }
  .form-input, .form-textarea, select.form-input { min-height: 2.75rem; font-size: 1rem; }
  .sidebar-nav-item { min-height: 2.75rem; }
  .back-link { min-height: 2.75rem; display: inline-flex; align-items: center; }
  .bottom-nav-item { min-height: 52px; }
  .user-dropdown-item { min-height: 2.75rem; }
}

/* ==========================================================================
   29. SAFE AREA & PRINT
   ========================================================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  }
  .fab { bottom: calc(2rem + env(safe-area-inset-bottom)); }
  @media (max-width: 768px) {
    body { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)); }
  }
  @media (min-width: 769px) and (max-width: 1024px) {
    body { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)); }
  }
}

@media print {
  .app-header, .sidebar, .bottom-nav, .fab, .sticky-actions { display: none !important; }
  .sidebar-content { margin-left: 0 !important; }
  body { padding: 0 !important; background: white !important; }
  .main-content { padding: 0 !important; animation: none !important; }
  .card-tile { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
