/* ===================================
   CSS VARIABLES
   =================================== */

:root {
  /* Primary Colors */
  --color-primary: #8b5cf6;
  --color-primary-hover: #7c3aed;
  --color-primary-50: rgba(139, 92, 246, 0.05);
  --color-primary-100: rgba(139, 92, 246, 0.1);
  --color-primary-200: rgba(139, 92, 246, 0.2);

  /* Semantic Colors */
  --color-success: #10b981;
  --color-success-50: rgba(16, 185, 129, 0.05);
  --color-success-100: rgba(16, 185, 129, 0.1);

  --color-warning: #f59e0b;
  --color-warning-50: rgba(245, 158, 11, 0.05);
  --color-warning-100: rgba(245, 158, 11, 0.1);

  --color-error: #ef4444;
  --color-error-50: rgba(239, 68, 68, 0.05);
  --color-error-100: rgba(239, 68, 68, 0.1);

  --color-info: #3b82f6;
  --color-info-50: rgba(59, 130, 246, 0.05);
  --color-info-100: rgba(59, 130, 246, 0.1);

  /* Text Colors */
  --color-text: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;

  /* Background Colors */
  --color-background: #ffffff;
  --color-surface: #f8fafc;
  --color-surface-hover: #f1f5f9;

  /* Border Colors */
  --color-border: #e2e8f0;

  /* Typography */
  --font-primary: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.75rem;
  --text-4xl: 2rem;

  /* Font Weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-base: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
  --header-height: 64px;

  /* Transitions */
  --transition: 0.2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
  --color-text: #ffffff;
  --color-text-secondary: #c0c0c0;
  --color-text-muted: #838383;
  --color-background: #111214;
  --color-surface: #1f1f1f;
  --color-surface-hover: #262626;
  --color-border: #2d2d2d;
}

/* ===================================
   RESET & BASE STYLES
   =================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.6;
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

.active > .material-symbols-rounded {
  color: var(--color-primary);
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

* {
  scrollbar-color: var(--color-text-muted) transparent;
}

/* ===================================
   BUTTON COMPONENTS
   =================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary.danger {
  color: var(--color-error);
  border-color: var(--color-error-100);
}

.btn-secondary.danger:hover {
  background: var(--color-error-100);
}

/* ===================================
   DASHBOARD LAYOUT
   =================================== */

.dashboard-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.dashboard-sidebar {
  width: var(--sidebar-width);
  background: var(--color-background);
  display: flex;
  flex-direction: column;
  position: sticky;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 1000;
  transition: var(--transition);
}

.dashboard-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.dashboard-brand {
  padding: var(--space-md) calc(var(--space-lg) - 2px);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  height: var(--header-height);
}

.dashboard-sidebar-toggle {
  display: flex;
  align-items: center;
  color: var(--color-text);
  padding: var(--space-sm);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.dashboard-sidebar-toggle:hover {
  background: var(--color-surface-hover);
}

.dashboard-sidebar .logo {
  font-size: var(--text-lg);
  white-space: nowrap;
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  transition: var(--transition);
}

.dashboard-sidebar.collapsed .logo {
  opacity: 0;
  pointer-events: none;
}

.dashboard-nav {
  flex: 1;
  padding: var(--space-md) var(--space-xs);
}

.dashboard-nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dashboard-nav-item {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  border-radius: var(--radius-lg);
  margin: 2px var(--space-sm);
  transition: var(--transition);
  cursor: pointer;
}

.dashboard-nav-item .nav-icon {
  color: var(--color-text-secondary);
  margin-right: var(--space-base);
  font-size: var(--text-2xl);
  flex-shrink: 0;
}

.dashboard-nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.dashboard-nav-item.active {
  background: var(--color-surface-hover);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

.dashboard-sidebar .nav-label {
  transition: var(--transition);
}

.dashboard-sidebar.collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: var(--space-md);
}

.sidebar-back-button {
  width: 100%;
  justify-content: flex-start;
}

.dashboard-sidebar.collapsed .sidebar-back-button .btn-label {
  opacity: 0;
  pointer-events: none;
}

.dashboard-sidebar.collapsed .sidebar-back-button {
  padding-left: 12px;
}

.dashboard-sidebar-overlay {
  opacity: 0;
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  transition: var(--transition);
}

/* Main Content */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.dashboard-header {
  height: var(--header-height);
  background: var(--color-background);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
}

.dashboard-header-content {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.dashboard-header .dashboard-sidebar-toggle {
  display: none;
}

.dashboard-header-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

/* Search Container */
.search-container {
  display: flex;
  align-items: center;
  max-width: 500px;
  width: 100%;
  margin: 0 var(--space-2xl);
  position: relative;
}

.search-icon {
  position: absolute;
  left: 16px;
  z-index: 10;
  pointer-events: none;
  color: var(--color-text-secondary);
}

input.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-2xl);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: var(--transition);
  height: 44px;
  font-family: var(--font-primary);
}

input.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

input.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-close {
  position: absolute;
  right: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.search-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.search-close.show {
  display: flex;
}

.mobile-search-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-text-secondary);
  transition: var(--transition);
}

.mobile-search-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-avatar-small {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  overflow: hidden;
}

.user-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.user-avatar-small .material-symbols-rounded {
  font-size: var(--text-lg);
}

/* Content Area */
.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  border-top-left-radius: var(--radius-xl);
  background: var(--color-surface);
}

/* Views */
.dashboard-view {
  display: none;
}

.dashboard-view.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-link {
  cursor: pointer;
}

.stat-card-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-100), var(--shadow-md);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.stat-card-title {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
}

.stat-card-icon.primary {
  background: var(--color-primary-100);
  color: var(--color-primary);
}

.stat-card-icon.success {
  background: var(--color-success-100);
  color: var(--color-success);
}

.stat-card-icon.warning {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.stat-card-icon.info {
  background: var(--color-info-100);
  color: var(--color-info);
}

.stat-card-value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.stat-card-change {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
}

.stat-card-change.positive {
  color: var(--color-success);
}

.stat-card-change.negative {
  color: var(--color-error);
}

/* Chart Cards */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.chart-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
}

.chart-card-header {
  margin-bottom: var(--space-lg);
}

.chart-card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.chart-card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.chart-container {
  position: relative;
  height: 300px;
}

/* Table Styles */
.dashboard-table-container {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

.dashboard-table-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-table-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.task-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
}

.dashboard-table thead {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.dashboard-table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dashboard-table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.dashboard-table tbody tr:last-child td {
  border-bottom: none;
}

.dashboard-table tbody tr:hover {
  background: var(--color-surface-hover);
}

.project-title-cell {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 300px;
}

.project-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--color-primary-100);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-info {
  flex: 1;
  min-width: 0;
}

.project-title-text {
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: 2px;
}

.project-meta-text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.status-badge {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
}

.status-badge.success {
  background: var(--color-success-100);
  color: var(--color-success);
}

.status-badge.warning {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.status-badge.planned {
  background: var(--color-info-100);
  color: var(--color-info);
}

.status-badge.underway {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.status-badge.completed {
  background: var(--color-success-100);
  color: var(--color-success);
}

.status-badge.reserved {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.status-badge.sold {
  background: var(--color-success-100);
  color: var(--color-success);
}

/* Task Filter Buttons */
.task-filter-group {
  display: flex;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2px;
}

.task-filter-btn {
  padding: var(--space-xs) var(--space-base);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.task-filter-btn:hover {
  color: var(--color-text);
}

.task-filter-btn.active {
  background: var(--color-background);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* Task List */
.task-list {
  list-style: none;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  transition: var(--transition);
}

.task-item:last-child {
  border-bottom: none;
}

.task-item:hover {
  background: var(--color-surface-hover);
}

.task-checkbox {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: transparent;
  background: var(--color-background);
}

.task-checkbox:hover {
  border-color: var(--color-primary);
}

.task-checkbox.checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.task-checkbox .material-symbols-rounded {
  font-size: 16px;
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.task-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-meta-item .material-symbols-rounded {
  font-size: 14px;
}

.priority-badge {
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
}

.priority-badge.low {
  background: var(--color-info-100);
  color: var(--color-info);
}

.priority-badge.medium {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.priority-badge.high {
  background: var(--color-error-100);
  color: var(--color-error);
}

.task-customer-tag {
  background: var(--color-primary-100);
  color: var(--color-primary);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
}

.table-section-header.warning {
  background: var(--color-warning-50);
  border-bottom: 1px solid var(--color-warning-100);
}

.table-section-header.warning .dashboard-table-title {
  color: var(--color-warning);
}

.table-section-header.success {
  background: var(--color-success-50);
  border-bottom: 1px solid var(--color-success-100);
}

.table-section-header.success .dashboard-table-title {
  color: var(--color-success);
}

/* Haul Detail Modal */
.haul-detail-modal {
  max-width: 640px;
}

.haul-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.haul-detail-summary-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-sm);
  text-align: center;
}

.haul-detail-summary-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: 2px;
}

.haul-detail-summary-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.haul-detail-section {
  margin-bottom: var(--space-lg);
}

.haul-detail-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.haul-detail-section-header h4 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.haul-detail-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.haul-mini-list {
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.haul-mini-list:empty {
  display: none;
}

.haul-mini-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.haul-mini-list-item:last-child {
  border-bottom: none;
}

.haul-mini-list-item-amount {
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.haul-mini-list-item-amount.income {
  color: var(--color-success);
}

.haul-mini-list-item-amount.expense {
  color: var(--color-error);
}

.haul-mini-form {
  display: flex;
  gap: var(--space-sm);
}

.haul-mini-form input[type="text"] {
  flex: 2;
}

.haul-mini-form input[type="number"] {
  flex: 1;
  min-width: 90px;
}

@media (max-width: 480px) {
  .haul-detail-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .haul-mini-form {
    flex-wrap: wrap;
  }

  .haul-mini-form input {
    flex: 1 1 100%;
  }

  .haul-mini-form button {
    flex: 1 1 100%;
  }
}

/* Notes */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
}

.note-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: var(--transition);
}

.note-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
}

.note-card-title {
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  word-break: break-word;
}

.note-card-content {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  max-height: 160px;
  overflow-y: auto;
}

.note-card-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.note-card-actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* Form Elements */
.form-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.backfill-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  position: relative;
}

.backfill-row-remove {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

textarea.form-input {
  height: auto;
  resize: vertical;
  padding: var(--space-sm) var(--space-md);
}

select.form-input {
  height: 44px;
  cursor: pointer;
}

/* Payment status badges */
.status-badge.pending {
  background: var(--color-warning-100);
  color: var(--color-warning);
}

.status-badge.partial {
  background: var(--color-info-100);
  color: var(--color-info);
}

/* Row action buttons */
.row-actions {
  display: flex;
  gap: var(--space-xs);
  justify-content: flex-end;
}

.row-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: var(--transition);
}

.row-action-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.row-action-btn.danger:hover {
  background: var(--color-error-100);
  color: var(--color-error);
}

.row-action-btn .material-symbols-rounded {
  font-size: var(--text-lg);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  padding: var(--space-md);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--color-background);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

.modal-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: var(--color-primary-50);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
}

.empty-state-icon .material-symbols-rounded {
  font-size: var(--text-4xl);
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.empty-state-description {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablet and Mobile */
@media (max-width: 1024px) {
  .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100%;
    z-index: 1000;
    width: var(--sidebar-width);
    transition: left 0.3s ease;
  }

  .dashboard-sidebar.collapsed {
    left: 0;
  }

  .dashboard-sidebar.collapsed :is(.logo, .nav-label, .nav-icon, .dashboard-nav-title, .sidebar-back-button .btn-label) {
    opacity: 1;
    pointer-events: auto;
  }

  .dashboard-sidebar.collapsed .sidebar-back-button {
    padding-left: var(--space-md);
  }

  .dashboard-header {
    padding: 0 var(--space-md);
  }

  .dashboard-brand {
    gap: var(--space-sm);
  }

  .dashboard-header .dashboard-sidebar-toggle {
    display: flex;
  }

  /* Search responsive styles */
  .search-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: var(--header-height);
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    z-index: 1001;
    margin: 0;
    padding: 0 var(--space-md);
    display: none;
    align-items: center;
    gap: var(--space-sm);
  }

  .search-container.mobile-active {
    display: flex;
  }

  .search-container .search-close {
    display: flex;
    position: static;
    transform: none;
    height: 44px;
    width: 44px;
    background: var(--color-surface-hover);
  }

  .search-icon {
    left: 30px;
  }

  .mobile-search-btn {
    display: flex;
  }

  /* Sidebar Overlay Mobile Behavior */
  .dashboard-sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100%;
    z-index: 1000;
    width: var(--sidebar-width);
    transition: left 0.3s ease;
  }

  .dashboard-sidebar.collapsed {
    left: 0;
    width: var(--sidebar-width);
  }

  .dashboard-content {
    padding: var(--space-md);
    border-top-left-radius: 0;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .dashboard-header {
    padding: 0 var(--space-md);
  }

  .dashboard-content {
    padding: var(--space-base);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-table-container {
    overflow-x: auto;
  }
}

/* Responsive table -> stacked cards (Customers/Overview tables) */
@media (max-width: 640px) {
  .dashboard-table thead {
    display: none;
  }

  .dashboard-table,
  .dashboard-table tbody,
  .dashboard-table tr {
    display: block;
    width: 100%;
  }

  .dashboard-table tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  .dashboard-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .dashboard-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-xs) 0;
    border: none;
    text-align: right;
    font-size: var(--text-sm);
  }

  .dashboard-table td[data-label]::before {
    content: attr(data-label);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    text-align: left;
  }

  .dashboard-table td.cell-primary {
    display: block;
    text-align: left;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
  }

  .dashboard-table td.cell-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-sm);
    margin-top: var(--space-xs);
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .stat-card {
    padding: var(--space-md);
  }

  .stat-card-header {
    margin-bottom: var(--space-sm);
  }

  .stat-card-title {
    font-size: var(--text-xs);
  }

  .stat-card-icon {
    width: 32px;
    height: 32px;
    font-size: var(--text-base);
  }

  .stat-card-value {
    font-size: var(--text-2xl);
  }

  .stat-card-change {
    font-size: var(--text-xs);
    flex-wrap: wrap;
  }

  .dashboard-table-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .dashboard-table-header > .btn {
    width: 100%;
    justify-content: center;
  }

  .task-toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .task-toolbar-actions > .btn {
    width: 100%;
    justify-content: center;
  }

  .task-filter-group {
    flex: 1;
  }

  .task-filter-btn {
    flex: 1;
    text-align: center;
  }
}

/* Focus Styles */
*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}