/* ============================================
   Personal Financial Allocation - Global Styles
   Version: 1.0.0
   ============================================ */

:root {
  --primary: #5f8d7e;
  --primary-dark: #4a7063;
  --primary-light: #a7c4a0;
  --secondary: #a7c4a0;
  --background: #f8f9fa;
  --surface: #ffffff;
  --surface-alt: #f1f3f5;
  --border: #e9ecef;
  --accent: #f4a261;
  --warning: #ffd166;
  --success: #52b788;
  --danger: #e76f51;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --primary: #6fa898;
  --primary-dark: #5f8d7e;
  --primary-light: #8fc4b4;
  --secondary: #7fa898;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-alt: #334155;
  --border: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(71, 85, 105, 0.4);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: -webkit-fill-available;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--background);
  transition:
    background var(--transition),
    color var(--transition);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

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

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

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

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

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
}

@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--surface-alt);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

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

/* ============================================
   Skeleton Loader
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-alt) 25%,
    var(--border) 50%,
    var(--surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  z-index: 99998;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  min-width: 300px;
  max-width: 400px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  border-left: 4px solid var(--primary);
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.toast.success {
  border-left-color: var(--success);
}
.toast.success .toast-icon {
  background: rgba(82, 183, 136, 0.15);
  color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.error .toast-icon {
  background: rgba(231, 111, 81, 0.15);
  color: var(--danger);
}
.toast.warning {
  border-left-color: var(--warning);
}
.toast.warning .toast-icon {
  background: rgba(255, 209, 102, 0.2);
  color: #d4a017;
}
.toast.info {
  border-left-color: var(--primary);
}
.toast.info .toast-icon {
  background: rgba(95, 141, 126, 0.15);
  color: var(--primary);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

.toast-message {
  color: var(--text-secondary);
  font-size: 13px;
}

.toast-close {
  opacity: 0.5;
  font-size: 18px;
  line-height: 1;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

/* ============================================
   Layout - App Shell
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  z-index: 100;
  transition: transform var(--transition);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}

.sidebar-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
  border-radius: inherit;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}

.nav-item:hover::before {
  opacity: 0.05;
}

.nav-item.active {
  background: rgba(95, 141, 126, 0.12);
  color: var(--primary);
}

.nav-item.active::before {
  opacity: 0.1;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.nav-item span {
  z-index: 1;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  margin-bottom: 10px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

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

.user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.icon-btn.logout:hover {
  background: rgba(231, 111, 81, 0.1);
  color: var(--danger);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: calc(28px + env(safe-area-inset-left, 0px));
  padding-right: calc(28px + env(safe-area-inset-right, 0px));
  height: calc(64px + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input {
  position: relative;
}

.search-input input {
  width: 240px;
  height: 38px;
  padding: 0 14px 0 40px;
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.search-input input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(95, 141, 126, 0.12);
}

.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--primary);
  color: white;
  transform: rotate(15deg);
}

.page-content {
  flex: 1;
  padding: 28px;
  padding-left: calc(28px + env(safe-area-inset-left, 0px));
  padding-right: calc(28px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
  overflow: hidden;
}

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

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition:
    width 0.4s,
    height 0.4s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(95, 141, 126, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(95, 141, 126, 0.35);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #d45a3d;
}

.btn-warning {
  background: var(--warning);
  color: #7a5d00;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(95, 141, 126, 0.05);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-link {
  color: var(--primary);
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.form-control:hover {
  border-color: var(--text-muted);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(95, 141, 126, 0.12);
  background: var(--surface);
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--surface-alt);
  cursor: not-allowed;
  opacity: 0.7;
}

textarea.form-control {
  height: auto;
  padding: 12px 14px;
  min-height: 100px;
  resize: vertical;
}

select.form-control {
  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='%236C757D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

.form-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input-group-text {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.input-group .form-control {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.form-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.form-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  border-radius: 24px;
  transition: all var(--transition-fast);
}

.form-switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.form-switch input:checked + .form-switch-slider {
  background-color: var(--primary);
}

.form-switch input:checked + .form-switch-slider::before {
  transform: translateX(20px);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-success {
  background: rgba(82, 183, 136, 0.15);
  color: var(--success);
}

.badge-danger {
  background: rgba(231, 111, 81, 0.12);
  color: var(--danger);
}

.badge-warning {
  background: rgba(255, 209, 102, 0.25);
  color: #d4a017;
}

.badge-info {
  background: rgba(95, 141, 126, 0.12);
  color: var(--primary);
}

.badge-secondary {
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.badge-sage {
  background: rgba(95, 141, 126, 0.15);
  color: var(--primary);
}

.badge-orange {
  background: rgba(244, 162, 97, 0.15);
  color: var(--accent);
}

.badge-yellow {
  background: rgba(255, 209, 102, 0.25);
  color: #c49417;
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--surface-alt);
}

.table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.table th:hover {
  background: var(--border);
}

.table th.sort-asc::after {
  content: " ↑";
  color: var(--primary);
}

.table th.sort-desc::after {
  content: " ↓";
  color: var(--primary);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--surface-alt);
}

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

.table-empty {
  padding: 60px 20px;
  text-align: center;
}

.table-empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: var(--surface-alt);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.table-empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

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

/* ============================================
   Progress Bar
   ============================================ */
.progress {
  height: 8px;
  background: var(--surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.success {
  background: linear-gradient(90deg, var(--success), #80deaa);
}

.progress-bar.warning {
  background: linear-gradient(90deg, var(--warning), #ffe08a);
}

.progress-bar.danger {
  background: linear-gradient(90deg, var(--danger), #f6a788);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99997;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  padding: 20px;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-lg {
  max-width: 720px;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* ============================================
   Floating Action Button
   ============================================ */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  right: calc(28px + env(safe-area-inset-right, 0px));
  width: 56px;
  height: 56px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(95, 141, 126, 0.4);
  z-index: 99;
  transition: all var(--transition);
}

.fab:hover {
  transform: translateY(-3px) rotate(90deg);
  box-shadow: 0 12px 32px rgba(95, 141, 126, 0.5);
}

/* ============================================
   Chips / Tags
   ============================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: rgba(95, 141, 126, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}

.empty-state-illustration {
  width: 160px;
  height: 160px;
  margin: 0 auto 24px;
  background: var(--surface-alt);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.empty-state-illustration::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(95, 141, 126, 0.1), transparent);
}

.empty-state-illustration svg {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state-desc {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto 24px;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  flex-wrap: wrap;
  gap: 12px;
}

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

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   Filter Bar
   ============================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-bar .form-control {
  height: 40px;
  width: auto;
  min-width: 160px;
}

.filter-bar .spacer {
  flex: 1;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   Tooltips
   ============================================ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 12px;
  background: var(--text-primary);
  color: var(--background);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  z-index: 100;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Action Buttons (Table)
   ============================================ */
.action-btns {
  display: flex;
  gap: 4px;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.action-btn.edit:hover {
  background: rgba(95, 141, 126, 0.12);
  color: var(--primary);
}

.action-btn.delete:hover {
  background: rgba(231, 111, 81, 0.12);
  color: var(--danger);
}

/* ============================================
   Divider
   ============================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  margin: 20px 0;
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================
   Alert
   ============================================ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-success {
  background: rgba(82, 183, 136, 0.1);
  border: 1px solid rgba(82, 183, 136, 0.3);
  color: var(--success);
}

.alert-danger {
  background: rgba(231, 111, 81, 0.08);
  border: 1px solid rgba(231, 111, 81, 0.25);
  color: var(--danger);
}

.alert-warning {
  background: rgba(255, 209, 102, 0.15);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: #a17d00;
}

.alert-info {
  background: rgba(95, 141, 126, 0.1);
  border: 1px solid rgba(95, 141, 126, 0.25);
  color: var(--primary);
}

/* ============================================
   Switches & Toggles
   ============================================ */
.toggle-group {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   Version Popup
   ============================================ */
.version-popup .modal-body {
  text-align: center;
  padding: 32px 24px;
}

.version-badge {
  display: inline-flex;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.version-popup h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.version-date {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.changelog-title {
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.changelog-list {
  text-align: left;
  list-style: none;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.changelog-list li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.changelog-list li::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .search-input input {
    width: 180px;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
  }

  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 16px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0 16px;
    height: 58px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    height: calc(58px + env(safe-area-inset-top, 0px));
  }

  .menu-toggle {
    min-width: 48px;
    min-height: 48px;
  }

  .search-input {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-control {
    height: 48px;
    min-height: 48px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .filter-bar {
    padding: 12px;
  }

  .filter-bar .form-control {
    min-width: 140px;
    flex: 1;
  }

  .card-body {
    padding: 16px;
  }

  .card-header {
    padding: 16px;
  }

  .btn {
    min-height: 48px;
    padding: 10px 18px;
    font-size: 14px;
  }

  .fab {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
  }

  .toast {
    min-width: auto;
    width: 100%;
    max-width: none;
  }

  .toast-container {
    left: 0;
    right: 0;
    top: 0;
    top: calc(12px + env(safe-area-inset-top, 0px));
    padding: 0 12px;
  }

  .modal-overlay {
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal {
    max-height: none;
    height: auto;
    min-height: 50%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%) scale(1);
    transition: transform var(--transition);
    max-width: 100%;
  }

  .modal-overlay.show .modal {
    transform: translateY(0) scale(1);
  }

  .modal-body {
    padding: 20px 16px;
    max-height: 60vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .card-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .action-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 16px;
  }

  .btn {
    min-height: 48px;
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 15px;
  }

  .form-switch {
    width: 52px;
    height: 30px;
  }

  .form-switch-slider::before {
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
  }

  .form-switch input:checked + .form-switch-slider::before {
    transform: translateX(22px);
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .sidebar,
  .topbar,
  .fab,
  .filter-bar,
  .pagination,
  .toast-container,
  .loading-screen,
  .action-btns {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .page-content {
    padding: 0;
  }

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

  body {
    background: white;
    color: black;
  }
}

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

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

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

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

.animate-fade-up {
  animation: fadeInUp 0.5s ease forwards;
}

.animate-bounce-in {
  animation: bounceIn 0.5s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-delay-1 {
  animation-delay: 0.1s;
  opacity: 0;
}
.animate-delay-2 {
  animation-delay: 0.2s;
  opacity: 0;
}
.animate-delay-3 {
  animation-delay: 0.3s;
  opacity: 0;
}
.animate-delay-4 {
  animation-delay: 0.4s;
  opacity: 0;
}

/* ============================================
   Color Picker
   ============================================ */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.color-option {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: var(--text-primary);
  box-shadow: var(--shadow-md);
}

.color-option.selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Confirmation Dialog
   ============================================ */
.confirm-dialog {
  text-align: center;
  padding: 16px 0;
}

.confirm-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(231, 111, 81, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--danger);
}

.confirm-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}
