/* =========================================
   Modern SaaS Design System
   ========================================= */

:root {
  color-scheme: light;

  /* ---------- Color Palette ---------- */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Primary - vibrant indigo/violet */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;
  --primary-900: #312e81;

  /* Accent - emerald green */
  --accent-50: #ecfdf5;
  --accent-100: #d1fae5;
  --accent-200: #a7f3d0;
  --accent-300: #6ee7b7;
  --accent-400: #34d399;
  --accent-500: #10b981;
  --accent-600: #059669;
  --accent-700: #047857;

  /* Danger - rose/red */
  --danger-50: #fff1f2;
  --danger-100: #ffe4e6;
  --danger-200: #fecdd3;
  --danger-300: #fda4af;
  --danger-400: #fb7185;
  --danger-500: #f43f5e;
  --danger-600: #e11d48;
  --danger-700: #be123c;

  /* Warning - amber */
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  /* Surface & Layout */
  --bg: linear-gradient(180deg, #f8f9ff 0%, #fafaff 25%, #fbfcff 50%, #fafaff 75%, #f8f9ff 100%);
  --surface: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.85);
  --surface-overlay: rgba(255, 255, 255, 0.92);
  --border: rgba(148, 163, 184, 0.25);
  --border-hover: rgba(99, 102, 241, 0.4);
  --text: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-muted: var(--slate-500);

  /* Shadows (dramatic!) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.16), 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --shadow-primary: 0 8px 32px rgba(99, 102, 241, 0.25);
  --shadow-accent: 0 8px 32px rgba(16, 185, 129, 0.2);
  --shadow-danger: 0 8px 32px rgba(244, 63, 94, 0.2);

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

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --container: 1200px;
  --sidebar: 280px;

  /* Focus ring */
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.4);

  /* Legacy compat */
  --muted: var(--text-muted);
}

/* =========================================
   Reset & Base
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--slate-900);
  letter-spacing: -0.025em;
  margin: 0;
}

h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }

p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 24px 0;
}

/* =========================================
   Layout - App Shell
   ========================================= */

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal--open {
  display: flex;
}

.modal__content {
  background: white;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.modal__header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.modal__close:hover {
  color: var(--text);
}

.modal__body {
  padding: 24px 20px;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
}

.container {
  width: min(100% - 48px, var(--container));
  margin: 0 auto;
}

/* =========================================
   Sidebar - Glass Morphism
   ========================================= */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.97) 0%, rgba(248,250,252,0.95) 100%);
  backdrop-filter: blur(20px) saturate(1.8);
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.03);
  z-index: 10;
}

.sidebar__inner {
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar__brand {
  padding: 8px 12px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--slate-900);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand__logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 50%, var(--accent-500) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 16px;
  box-shadow: var(--shadow-primary);
}

.brand__dot {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 50%, var(--accent-500) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  position: relative;
}

.brand__dot::after {
  content: "✦";
  color: white;
  font-size: 18px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  flex: 1;
}

.sidebar__section {
  padding: 16px 12px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  position: relative;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.sidebar__link:hover {
  background: var(--slate-100);
  color: var(--slate-900);
  text-decoration: none;
  transform: translateX(3px);
}

.sidebar__link.is-active {
  background: linear-gradient(135deg, var(--primary-50) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--primary-700);
  font-weight: 600;
}

.sidebar__link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, var(--primary-500), var(--accent-500));
  box-shadow: 0 0 12px var(--primary-400);
}

.sidebar__icon {
  width: 24px;
  height: 24px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.sidebar__link:hover .sidebar__icon {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-600);
}

.sidebar__link.is-active .sidebar__icon {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar__badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 8px;
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  color: white;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.mobile-menu-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 10px;
  pointer-events: none;
}

.sidebar__hint {
  padding: 16px 12px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

.sidebar__link--logout {
  color: var(--danger-600);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar__link--logout:hover {
  background: var(--danger-50);
  color: var(--danger-700);
  transform: translateX(3px);
}

.sidebar__link--logout .sidebar__icon {
  background: rgba(244, 63, 94, 0.06);
}

.sidebar__link--logout:hover .sidebar__icon {
  background: rgba(244, 63, 94, 0.12);
  color: var(--danger-600);
}

/* =========================================
   Main Content Area
   ========================================= */
.app-main {
  min-width: 0;
  background: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar__org {
  font-weight: 700;
  font-size: 15px;
  color: var(--slate-800);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__org::before {
  content: "";
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, var(--accent-400), var(--accent-500));
  border-radius: var(--radius-full);
  box-shadow: 0 0 12px var(--accent-400);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Icon Button */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 18px;
}

.icon-btn:hover {
  background: var(--slate-50);
  border-color: var(--border-hover);
  color: var(--primary-600);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* User Chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-chip:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.user-chip__avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.user-chip__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--slate-800);
}

.content {
  padding: 36px 0 80px;
}

/* =========================================
   Page Header - Hero Style
   ========================================= */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 36px;
}

.page-header__title {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-header__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--primary-700);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.page-header__eyebrow::before {
  content: "◆";
  font-size: 8px;
  opacity: 0.7;
}

.page-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--slate-700) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header__meta {
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-header__meta::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--slate-400);
  border-radius: var(--radius-full);
}

/* =========================================
   Cards - Glassmorphism & Depth
   ========================================= */
.card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card--hover:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.card--gradient {
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.95) 100%);
}

.card--primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-color: var(--primary-600);
  color: white;
}

.card--primary .muted,
.card--primary .stat-label,
.card--primary .text-muted {
  color: rgba(255,255,255,0.85);
}

.card__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card__header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__header-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.card__body {
  padding: 24px;
}

.card__body--compact {
  padding: 18px 22px;
}

.card__footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
}

/* =========================================
   Section Headers
   ========================================= */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 18px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, var(--primary-500), var(--accent-500));
  border-radius: var(--radius-full);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

/* =========================================
   Stats - Dashboard Style
   ========================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.stat-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.stat-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

.stat {
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, var(--primary-100), transparent);
  border-radius: 0 0 0 100%;
  opacity: 0.5;
  transition: all var(--transition-base);
}

.stat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.stat:hover::before {
  opacity: 0.8;
  width: 120px;
  height: 120px;
}

.stat--primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-color: var(--primary-600);
  color: white;
  box-shadow: var(--shadow-primary);
}

.stat--primary::before {
  background: linear-gradient(135deg, rgba(255,255,255,0.25), transparent);
}

.stat--accent {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  border-color: var(--accent-600);
  color: white;
  box-shadow: var(--shadow-accent);
}

.stat--danger {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  border-color: var(--danger-600);
  color: white;
  box-shadow: var(--shadow-danger);
}

.stat__icon {
  width: 52px;
  height: 52px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 18px;
}

.stat--primary .stat__icon,
.stat--accent .stat__icon,
.stat--danger .stat__icon {
  background: rgba(255,255,255,0.2);
}

.stat-label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-number {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-title {
  font-size: 18px;
  font-weight: 700;
}

.stat-value {
  font-weight: 700;
  font-size: 15px;
}

.stat-value--heavy {
  font-weight: 800;
}

.stat__trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
}

.stat__trend--up {
  background: var(--accent-100);
  color: var(--accent-700);
}

.stat__trend--down {
  background: var(--danger-100);
  color: var(--danger-700);
}

/* =========================================
   Buttons - Premium Feel
   ========================================= */
.btn,
button,
input[type="submit"],
input[type="button"] {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn:active,
button:active {
  transform: translateY(0);
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
input[type="submit"].btn-primary {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  border-color: var(--primary-600);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.4);
  transform: translateY(-3px);
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--slate-50) 0%, var(--surface) 100%);
  border-color: var(--primary-200);
  color: var(--primary-700);
}

.btn-secondary:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--slate-100);
  border-color: transparent;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-500) 0%, var(--danger-600) 100%);
  border-color: var(--danger-600);
  color: white;
  box-shadow: var(--shadow-danger);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-600) 0%, var(--danger-700) 100%);
  box-shadow: 0 12px 40px rgba(244, 63, 94, 0.35);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%);
  border-color: var(--accent-600);
  color: white;
  box-shadow: var(--shadow-accent);
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-700) 100%);
  box-shadow: 0 12px 40px rgba(16, 185, 129, 0.35);
}

.btn--lg {
  padding: 15px 30px;
  font-size: 15px;
  border-radius: var(--radius-lg);
}

.btn--sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn--icon {
  padding: 11px;
}

.btn__icon {
  font-size: 18px;
  line-height: 1;
}

/* =========================================
   Badges - Vivid Status
   ========================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.badge--lg {
  padding: 8px 18px;
  font-size: 13px;
}

.badge--lg::before {
  width: 8px;
  height: 8px;
}

.badge--sm {
  padding: 2px 8px;
  font-size: 11px;
}

.badge--sm::before {
  width: 5px;
  height: 5px;
}

/* Status Badges */
.badge--draft {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-200);
}
.badge--draft::before {
  background: var(--slate-400);
}

.badge--submitted,
.badge--pending,
.badge--proposing {
  background: linear-gradient(135deg, var(--primary-50), rgba(99, 102, 241, 0.12));
  color: var(--primary-700);
  border-color: var(--primary-200);
}
.badge--submitted::before,
.badge--pending::before,
.badge--proposing::before {
  background: var(--primary-500);
  box-shadow: 0 0 10px var(--primary-400);
  animation: pulse-badge 2s ease-in-out infinite;
}

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

.badge--approved,
.badge--active,
.badge--success {
  background: linear-gradient(135deg, var(--accent-50), rgba(16, 185, 129, 0.12));
  color: var(--accent-700);
  border-color: var(--accent-200);
}
.badge--approved::before,
.badge--active::before,
.badge--success::before {
  background: var(--accent-500);
}

.badge--estimating {
  background: linear-gradient(135deg, var(--warning-50), rgba(245, 158, 11, 0.12));
  color: var(--warning-600);
  border-color: var(--warning-400);
}
.badge--estimating::before {
  background: var(--warning-500);
}

.badge--rejected,
.badge--suspended,
.badge--error {
  background: linear-gradient(135deg, var(--danger-50), rgba(244, 63, 94, 0.12));
  color: var(--danger-700);
  border-color: var(--danger-200);
}
.badge--rejected::before,
.badge--suspended::before,
.badge--error::before {
  background: var(--danger-500);
}

.badge--approved-with-changes {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 152, 0, 0.08));
  color: #e65100;
  border-color: #ffb74d;
}
.badge--approved-with-changes::before {
  background: #ff9800;
}

.badge--closed {
  background: var(--slate-100);
  color: var(--slate-600);
  border-color: var(--slate-300);
}
.badge--closed::before {
  background: var(--slate-500);
}

.badge--onboarding {
  background: linear-gradient(135deg, var(--slate-50), var(--slate-100));
  color: var(--slate-600);
  border-color: var(--slate-200);
}
.badge--onboarding::before {
  background: var(--slate-400);
}

/* Phase Badges - 21 Stages */
.badge--info_waiting {
  background: linear-gradient(135deg, var(--slate-50), var(--slate-100));
  color: var(--slate-600);
  border-color: var(--slate-200);
}
.badge--info_waiting::before {
  background: var(--slate-400);
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge--property_proposing {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(139, 92, 246, 0.06));
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.3);
}
.badge--property_proposing::before {
  background: #8b5cf6;
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge--before_application {
  background: linear-gradient(135deg, var(--primary-50), rgba(99, 102, 241, 0.12));
  color: var(--primary-700);
  border-color: var(--primary-200);
}
.badge--before_application::before {
  background: var(--primary-500);
  box-shadow: 0 0 10px var(--primary-400);
}

.badge--application_completed {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(6, 182, 212, 0.06));
  color: #0891b2;
  border-color: rgba(6, 182, 212, 0.3);
}
.badge--application_completed::before {
  background: #06b6d4;
}

.badge--guarantee_screening {
  background: linear-gradient(135deg, var(--warning-50), rgba(245, 158, 11, 0.12));
  color: var(--warning-600);
  border-color: var(--warning-400);
}
.badge--guarantee_screening::before {
  background: var(--warning-500);
}

.badge--owner_screening {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.12), rgba(249, 115, 22, 0.06));
  color: #ea580c;
  border-color: rgba(249, 115, 22, 0.3);
}
.badge--owner_screening::before {
  background: #f97316;
}

.badge--screening_approved {
  background: linear-gradient(135deg, rgba(132, 204, 22, 0.12), rgba(132, 204, 22, 0.06));
  color: #65a30d;
  border-color: rgba(132, 204, 22, 0.3);
}
.badge--screening_approved::before {
  background: #84cc16;
}

.badge--move_in_date_confirmed {
  background: linear-gradient(135deg, var(--accent-50), rgba(16, 185, 129, 0.12));
  color: var(--accent-700);
  border-color: var(--accent-200);
}
.badge--move_in_date_confirmed::before {
  background: var(--accent-500);
}

.badge--invoice_creating {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(139, 92, 246, 0.06));
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.3);
}
.badge--invoice_creating::before {
  background: #8b5cf6;
}

.badge--invoice_payment_waiting {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(168, 85, 247, 0.06));
  color: #9333ea;
  border-color: rgba(168, 85, 247, 0.3);
}
.badge--invoice_payment_waiting::before {
  background: #a855f7;
}

.badge--customer_payment_completed {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.12), rgba(236, 72, 153, 0.06));
  color: #db2777;
  border-color: rgba(236, 72, 153, 0.3);
}
.badge--customer_payment_completed::before {
  background: #ec4899;
}

.badge--contract_creating {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(99, 102, 241, 0.06));
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.3);
}
.badge--contract_creating::before {
  background: #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.badge--contract_sending_to_customer {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(14, 165, 233, 0.06));
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.3);
}
.badge--contract_sending_to_customer::before {
  background: #0ea5e9;
}

.badge--schedule_response_waiting {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.12), rgba(20, 184, 166, 0.06));
  color: #0f766e;
  border-color: rgba(20, 184, 166, 0.3);
}
.badge--schedule_response_waiting::before {
  background: #14b8a6;
}

.badge--schedule_confirmed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.06));
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}
.badge--schedule_confirmed::before {
  background: #10b981;
}

.badge--contract_return_waiting {
  background: linear-gradient(135deg, var(--warning-50), rgba(245, 158, 11, 0.12));
  color: var(--warning-600);
  border-color: var(--warning-400);
}
.badge--contract_return_waiting::before {
  background: var(--warning-500);
}

.badge--documents_sending_to_agency {
  background: linear-gradient(135deg, var(--primary-50), rgba(99, 102, 241, 0.12));
  color: var(--primary-700);
  border-color: var(--primary-200);
}
.badge--documents_sending_to_agency::before {
  background: var(--primary-500);
}

.badge--key_delivery {
  background: linear-gradient(135deg, rgba(132, 204, 22, 0.12), rgba(132, 204, 22, 0.06));
  color: #65a30d;
  border-color: rgba(132, 204, 22, 0.3);
}
.badge--key_delivery::before {
  background: #84cc16;
}

.badge--key_receipt_return_waiting {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12), rgba(234, 179, 8, 0.06));
  color: #a16207;
  border-color: rgba(234, 179, 8, 0.3);
}
.badge--key_receipt_return_waiting::before {
  background: #eab308;
}

.badge--contract_completed {
  background: linear-gradient(135deg, var(--accent-50), rgba(16, 185, 129, 0.12));
  color: var(--accent-700);
  border-color: var(--accent-200);
}
.badge--contract_completed::before {
  background: var(--accent-500);
}

.badge--contract_cancelled {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.06));
  color: #991b1b;
  border-color: #fecaca;
}
.badge--contract_cancelled::before {
  background: #ef4444;
}

/* Type Badges */
.badge--type-proposal {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(99, 102, 241, 0.06));
  color: var(--primary-700);
  border-color: var(--primary-200);
}
.badge--type-proposal::before {
  background: var(--primary-500);
}

.badge--type-estimate {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.06));
  color: var(--accent-700);
  border-color: var(--accent-200);
}
.badge--type-estimate::before {
  background: var(--accent-500);
}

.badge--type-estimate-yellow {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.06));
  color: #92400e;
  border-color: #fcd34d;
}
.badge--type-estimate-yellow::before {
  background: #f59e0b;
}

/* =========================================
   Forms - Refined Inputs
   ========================================= */
form { margin: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 4px;
}

.field > label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-left: 12px;
  padding-bottom: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-left: 12px;
  padding-bottom: 6px;
}

.field > label::before,
.field-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--primary-400), var(--primary-600));
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.field > label::after,
.field-label::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  width: 210px;
  height: 1px;
  background: linear-gradient(90deg, var(--primary-500) 0%, var(--primary-300) 40%, transparent 100%);
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.15);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="tel"],
textarea,
select {
  width: 100%;
  max-width: 210px;
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
}

textarea,
select {
  max-width: 100%;
}

/* ログイン・登録フォーム用 - 入力ボックスを幅いっぱいに */
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="tel"] {
  max-width: 100%;
}

/* チェックボックスエリア - クリック範囲拡大用 */
.checkbox-area:hover {
  background: var(--slate-50);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--slate-400);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-500);
  box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input[type="file"] {
  padding: 14px 18px;
  background: var(--slate-50);
  border-style: dashed;
  border-width: 2px;
  cursor: pointer;
}

input[type="file"]:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
}

.help {
  font-size: 13px;
  color: var(--text-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 24px;
}

.actions--tight { margin-top: 0; }

/* =========================================
   Tables - Modern Data Display
   ========================================= */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  text-align: left;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--slate-50);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: all var(--transition-fast);
}

tbody tr[data-controller="clickable-row"] {
  cursor: pointer;
}

tbody tr:hover {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.05), transparent);
}

tbody tr[data-controller="clickable-row"]:hover {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.02));
}

tbody tr:hover td:first-child {
  box-shadow: inset 4px 0 0 var(--primary-500);
}

/* =========================================
   Lists - Interactive Items
   ========================================= */
.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.list-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateX(6px);
}

.list-item__icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.list-item__content {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-weight: 600;
  color: var(--slate-900);
  margin-bottom: 2px;
}

.list-item__meta {
  font-size: 13px;
  color: var(--text-muted);
}

.list-item__action {
  flex-shrink: 0;
}

/* =========================================
   Flash Messages
   ========================================= */
.flash {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.flash__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-weight: 500;
}

.flash__item::before {
  font-size: 22px;
  flex-shrink: 0;
}

.flash__item--notice {
  background: linear-gradient(135deg, var(--accent-50), rgba(16, 185, 129, 0.08));
  border-color: var(--accent-200);
  color: var(--accent-800);
}

.flash__item--notice::before {
  content: "✓";
  color: var(--accent-600);
}

.flash__item--alert {
  background: linear-gradient(135deg, var(--danger-50), rgba(244, 63, 94, 0.08));
  border-color: var(--danger-200);
  color: var(--danger-800);
}

.flash__item--alert::before {
  content: "!";
  color: var(--danger-600);
}

/* =========================================
   Utilities
   ========================================= */
.stack > * + * { margin-top: 18px; }
.stack--sm > * + * { margin-top: 12px; }
.stack--lg > * + * { margin-top: 26px; }

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary-600); }
.text-accent { color: var(--accent-600); }
.text-danger { color: var(--danger-600); }

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

.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

.maxw-180 { max-width: 180px; }

code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  background: linear-gradient(135deg, var(--slate-100), var(--slate-50));
  border: 1px solid var(--slate-200);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  color: var(--primary-700);
}

/* =========================================
   Empty States
   ========================================= */
.empty-state {
  text-align: center;
  padding: 56px 28px;
}

.empty-state__icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--slate-100), var(--slate-50));
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 24px;
}

.empty-state__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.empty-state__description {
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* =========================================
   Footer
   ========================================= */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 56px;
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
  .container {
    width: min(100% - 28px, var(--container));
  }

  .content {
    padding: 24px 0 48px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar__nav {
    flex-direction: column;
    padding: 12px 8px;
    gap: 4px;
  }

  .sidebar__link {
    white-space: normal;
    word-break: break-word;
  }

  .sidebar__hint {
    display: none;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat-grid--2 {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* =========================================
   Animations
   ========================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.animate-fadeIn {
  animation: fadeIn 0.35s ease-out forwards;
}

.animate-slideIn {
  animation: slideIn 0.35s ease-out forwards;
}

.animate-scaleIn {
  animation: scaleIn 0.25s ease-out forwards;
}

/* Staggered animations for cards */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }

/* =========================================
   Skeleton Loading
   ========================================= */
.skeleton {
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* =========================================
   Print Styles
   ========================================= */
@media print {
  .sidebar,
  .topbar,
  .actions {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* =========================================
   Form Row (horizontal field layout)
   ========================================= */
.form-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.form-row > .field {
  min-width: 200px;
}

/* =========================================
   Field Required Indicator
   ========================================= */
.field-required {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--danger-600);
  background: var(--danger-50);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* =========================================
   Alerts / Notices
   ========================================= */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}

.alert--info {
  background: var(--primary-50);
  color: var(--primary-800);
  border: 1px solid var(--primary-200);
}

.alert--success {
  background: var(--accent-50);
  color: var(--accent-700);
  border: 1px solid var(--accent-200);
}

.alert--warning {
  background: var(--warning-50);
  color: var(--warning-600);
  border: 1px solid var(--warning-400);
}

.alert--danger {
  background: var(--danger-50);
  color: var(--danger-700);
  border: 1px solid var(--danger-200);
}

/* =========================================
   Code & Pre elements
   ========================================= */
code {
  font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--slate-100);
  color: var(--primary-700);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

pre {
  font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
  background: var(--slate-800);
  color: var(--slate-100);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* =========================================
   Tooltip (simple CSS)
   ========================================= */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--slate-800);
  color: white;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
  z-index: 1000;
  pointer-events: none;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px);
}

/* =========================================
   Dropdown Menu (simple)
   ========================================= */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition-fast);
  z-index: 100;
}

.dropdown:focus-within .dropdown__menu,
.dropdown:hover .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

.dropdown__item {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.dropdown__item:hover {
  background: var(--slate-50);
  color: var(--primary-600);
}

/* =========================================
   File Upload Styling
   ========================================= */
input[type="file"] {
  padding: 0.75rem 1rem;
  background: var(--slate-50);
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
}

input[type="file"]:hover {
  border-color: var(--primary-400);
  background: var(--primary-50);
}

input[type="file"]:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: var(--ring);
}

input[type="file"]::file-selector-button {
  background: var(--primary-500);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  margin-right: 1rem;
  transition: var(--transition-fast);
}

input[type="file"]::file-selector-button:hover {
  background: var(--primary-600);
}

/* =========================================
   Pulse Animation for Live Data
   ========================================= */
.pulse-live {
  position: relative;
}

.pulse-live::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  background: var(--accent-500);
  border-radius: 50%;
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* =========================================
   Accordion
   ========================================= */
.hidden {
  display: none !important;
}

.rotated {
  transform: rotate(90deg);
}

/* =========================================
   Responsive Improvements
   ========================================= */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-header .actions {
    width: 100%;
    justify-content: flex-start;
  }
}

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

/* =========================================
   Comprehensive Mobile Responsive Design
   ========================================= */

/* Tablet & Below (768px) */
@media (max-width: 768px) {
  /* Layout */
  :root {
    --sidebar: 100%;
  }

  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100% !important;
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.is-open {
    left: 0;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 1rem !important;
  }

  /* Typography */
  .page-title {
    font-size: 24px !important;
  }

  h1 {
    font-size: 28px !important;
  }

  h2 {
    font-size: 22px !important;
  }

  h3 {
    font-size: 18px !important;
  }

  /* Cards */
  .card {
    padding: 20px !important;
    margin: 12px 0 !important;
  }

  .card__header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  /* Tables */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* Forms */
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .field-group {
    flex-direction: column;
  }

  .field {
    width: 100% !important;
  }

  .input,
  .select,
  .textarea {
    font-size: 16px !important; /* Prevent zoom on iOS */
  }

  /* Buttons */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }

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

  .btn {
    padding: 14px 20px !important;
  }

  /* Navigation */
  .topbar {
    padding: 12px !important;
  }

  .topbar__actions {
    gap: 8px !important;
  }

  /* Modals */
  .modal__content {
    width: 95% !important;
    max-width: none !important;
    margin: 20px auto !important;
  }

  /* Stats Grid */
  .stats {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Action Bars */
  .actions {
    flex-direction: column;
    width: 100%;
  }

  .actions .btn {
    width: 100%;
  }

  /* Search Bars */
  .search-bar {
    flex-direction: column;
    gap: 12px;
  }

  .search-bar input {
    width: 100%;
  }

  /* Badges & Pills */
  .badge,
  .pill {
    font-size: 12px !important;
    padding: 4px 10px !important;
  }

  /* Spacing */
  .page-header {
    padding: 20px 0 !important;
  }

  .section {
    padding: 20px 0 !important;
  }

  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }

  /* Show mobile-only elements */
  .mobile-only {
    display: block !important;
  }
}

/* Mobile Portrait (480px) */
@media (max-width: 480px) {
  /* Layout */
  .main-content {
    padding: 12px !important;
  }

  /* Typography */
  .page-title {
    font-size: 20px !important;
  }

  h1 {
    font-size: 24px !important;
  }

  h2 {
    font-size: 20px !important;
  }

  h3 {
    font-size: 16px !important;
  }

  body {
    font-size: 14px !important;
  }

  /* Cards */
  .card {
    padding: 16px !important;
    border-radius: 8px !important;
  }

  /* Buttons */
  .btn {
    padding: 12px 16px !important;
    font-size: 14px !important;
  }

  .btn-sm {
    padding: 8px 12px !important;
    font-size: 12px !important;
  }

  /* Forms */
  .input,
  .select,
  .textarea {
    padding: 12px !important;
  }

  label {
    font-size: 14px !important;
  }

  /* Navigation */
  .sidebar__link {
    padding: 12px 16px !important;
    font-size: 14px !important;
  }

  .sidebar__icon {
    width: 18px !important;
    height: 18px !important;
  }

  /* Stats */
  .stat__value {
    font-size: 24px !important;
  }

  .stat__label {
    font-size: 12px !important;
  }

  /* Tables */
  table {
    font-size: 13px !important;
  }

  th,
  td {
    padding: 10px 8px !important;
  }

  /* Modals */
  .modal__content {
    padding: 20px !important;
  }

  .modal__header h2 {
    font-size: 18px !important;
  }

  /* File Upload */
  .file-upload {
    padding: 20px !important;
  }

  /* Avatar */
  .avatar {
    width: 32px !important;
    height: 32px !important;
  }

  .avatar-lg {
    width: 48px !important;
    height: 48px !important;
  }
}

/* Small Mobile (360px) */
@media (max-width: 360px) {
  .page-title {
    font-size: 18px !important;
  }

  h1 {
    font-size: 22px !important;
  }

  .card {
    padding: 12px !important;
  }

  .btn {
    padding: 10px 14px !important;
    font-size: 13px !important;
  }
}

/* Tablet Landscape (1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  table {
    font-size: 14px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets */
  .btn,
  .sidebar__link,
  a,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover states on touch devices */
  .btn:hover,
  .card:hover {
    transform: none !important;
  }

  /* Larger checkboxes and radios */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}

/* Landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    width: 280px !important;
  }

  .main-content {
    margin-left: 280px !important;
  }
}

/* Print styles */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .actions,
  .mobile-menu {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    width: 100% !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  body {
    font-size: 12pt;
  }
}
/* =========================================
   Pagination (Pagy)
   ========================================= */
.pagy-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.pagy-nav a,
.pagy-nav span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagy-nav a {
  color: var(--text);
  background: var(--slate-50);
  border: 1px solid var(--border);
}

.pagy-nav a:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  color: var(--primary-700);
}

.pagy-nav span.current {
  background: var(--primary-600);
  color: white;
  border: 1px solid var(--primary-700);
  font-weight: 600;
}

.pagy-nav span.disabled {
  color: var(--text-muted);
  background: var(--slate-100);
  border: 1px solid var(--border);
  opacity: 0.5;
  cursor: not-allowed;
}

.pagy-nav .gap {
  color: var(--text-muted);
  padding: 0 8px;
}