/* ============================================================
   Arrowhead Deck & Pools — Commission Portal
   Comprehensive Dark-Theme Stylesheet
   ============================================================ */

/* ----- CSS Custom Properties ----- */
:root {
  /* Core palette */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-light: rgba(245, 158, 11, 0.15);
  --border: #334155;
  --border-light: #475569;

  /* Status colors */
  --status-pending: #f59e0b;
  --status-approved: #22c55e;
  --status-hold: #ef4444;
  --status-paid: #3b82f6;
  --status-pending-bg: rgba(245, 158, 11, 0.12);
  --status-approved-bg: rgba(34, 197, 94, 0.12);
  --status-hold-bg: rgba(239, 68, 68, 0.12);
  --status-paid-bg: rgba(59, 130, 246, 0.12);

  /* Buttons */
  --btn-primary: #f59e0b;
  --btn-primary-hover: #d97706;
  --btn-primary-text: #0f172a;
  --btn-danger: #ef4444;
  --btn-danger-hover: #dc2626;
  --btn-success: #22c55e;
  --btn-success-hover: #16a34a;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sm: 0.8125rem;
  --font-base: 0.9375rem;
  --font-lg: 1.125rem;
  --font-xl: 1.5rem;
  --font-2xl: 2rem;

  /* Layout */
  --nav-height: 60px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --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 30px rgba(0, 0, 0, 0.5);
  --transition: 200ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--accent-hover);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ----- Focus Utility ----- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================================
   NAVIGATION BAR
   ============================================================ */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 var(--space-xl);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  white-space: nowrap;
}

.brand-icon {
  color: var(--accent);
  font-size: var(--font-xl);
}

.brand-text {
  font-size: var(--font-lg);
  color: var(--text-primary);
}

.brand-separator {
  color: var(--text-muted);
  font-weight: 300;
}

.brand-portal {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.nav-menu li a,
.nav-menu li button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: var(--font-family);
}

.nav-menu li a:hover,
.nav-menu li button:hover,
.nav-menu li a.active,
.nav-menu li button.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-menu li a.active {
  color: var(--accent);
}

/* Hamburger toggle (mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle.open .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-top: var(--nav-height);
  padding: var(--space-xl);
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  min-height: calc(100vh - var(--nav-height));
}

/* ============================================================
   LOGIN FORM
   ============================================================ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  text-align: center;
  font-size: var(--font-xl);
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.login-card .login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  margin-bottom: var(--space-xl);
}

.login-card .brand-logo {
  text-align: center;
  font-size: var(--font-2xl);
  color: var(--accent);
  margin-bottom: var(--space-md);
}

/* ============================================================
   FORMS — General
   ============================================================ */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: var(--font-base);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

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

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-tertiary);
}

.form-control.is-error {
  border-color: var(--status-hold);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-error {
  font-size: var(--font-sm);
  color: var(--status-hold);
  margin-top: var(--space-xs);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-size: var(--font-sm);
  font-weight: 600;
  font-family: var(--font-family);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary (Amber) */
.btn-primary {
  color: var(--btn-primary-text);
  background: var(--btn-primary);
  border-color: var(--btn-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Danger (Red) */
.btn-danger {
  color: #fff;
  background: var(--btn-danger);
  border-color: var(--btn-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--btn-danger-hover);
  border-color: var(--btn-danger-hover);
}

.btn-danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* Success (Green) */
.btn-success {
  color: #fff;
  background: var(--btn-success);
  border-color: var(--btn-success);
}

.btn-success:hover:not(:disabled) {
  background: var(--btn-success-hover);
  border-color: var(--btn-success-hover);
}

.btn-success:focus-visible {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

/* Ghost / Outline */
.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.btn-ghost:focus-visible {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

/* Icon-only button */
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* Small variant */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* Block (full-width) */
.btn-block {
  width: 100%;
}

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* ============================================================
   CARDS — General
   ============================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-header h2,
.card-header h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.kpi-card {
  flex: 1 1 220px;
  max-width: calc(25% - var(--space-lg));
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-light);
}

.kpi-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-change {
  font-size: var(--font-sm);
  font-weight: 500;
}

.kpi-change.positive {
  color: var(--status-approved);
}

.kpi-change.negative {
  color: var(--status-hold);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.filter-bar .form-control {
  width: auto;
  min-width: 160px;
  flex: 0 1 auto;
}

.filter-bar .filter-search {
  flex: 1 1 200px;
  min-width: 200px;
}

/* Filter pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: default;
  transition: background var(--transition);
}

.pill .pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: color var(--transition), background var(--transition);
}

.pill .pill-remove:hover {
  color: var(--status-hold);
  background: rgba(239, 68, 68, 0.15);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-pending {
  color: var(--status-pending);
  background: var(--status-pending-bg);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-approved {
  color: var(--status-approved);
  background: var(--status-approved-bg);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-hold {
  color: var(--status-hold);
  background: var(--status-hold-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-paid {
  color: var(--status-paid);
  background: var(--status-paid-bg);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ============================================================
   COMMISSION TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
}

.commission-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: var(--font-sm);
}

.commission-table thead {
  background: var(--bg-tertiary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.commission-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  user-select: none;
}

.commission-table th.sortable {
  cursor: pointer;
  transition: color var(--transition);
}

.commission-table th.sortable:hover {
  color: var(--text-primary);
}

.commission-table th.sortable::after {
  content: '\2195';
  margin-left: var(--space-xs);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.commission-table th.sort-asc::after {
  content: '\2191';
  color: var(--accent);
}

.commission-table th.sort-desc::after {
  content: '\2193';
  color: var(--accent);
}

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

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

.commission-table tbody tr:hover {
  background: rgba(245, 158, 11, 0.04);
}

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

.commission-table .cell-amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
}

.commission-table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.commission-table .cell-actions .btn {
  margin-left: var(--space-xs);
}

/* Empty state */
.table-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.table-empty p {
  margin-top: var(--space-sm);
  font-size: var(--font-sm);
}

/* Pagination row */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.table-pagination .pagination-buttons {
  display: flex;
  gap: var(--space-xs);
}

/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  padding: var(--space-lg);
  animation: fadeIn 200ms ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp 250ms ease;
}

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

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1.25rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

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

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

/* ============================================================
   OVERRIDE FORM
   ============================================================ */
.override-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.override-form .form-group:last-of-type {
  margin-bottom: 0;
}

.override-form .override-amount {
  font-size: var(--font-lg);
  font-weight: 600;
}

/* ============================================================
   TOAST / NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-md));
  right: var(--space-lg);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  max-width: 420px;
  width: 100%;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: slideInRight 300ms ease;
  transition: opacity 300ms ease, transform 300ms ease;
}

.toast.toast-leaving {
  opacity: 0;
  transform: translateX(100%);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: var(--font-sm);
  color: var(--text-primary);
}

.toast-message {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 1rem;
  transition: color var(--transition);
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast.toast-success {
  border-left: 3px solid var(--status-approved);
}

.toast.toast-error {
  border-left: 3px solid var(--status-hold);
}

.toast.toast-warning {
  border-left: 3px solid var(--status-pending);
}

.toast.toast-info {
  border-left: 3px solid var(--status-paid);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.section-header h1 {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.section-header .section-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ============================================================
   LOADING / SPINNER
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  gap: var(--space-md);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--status-approved); }
.text-danger { color: var(--status-hold); }
.text-sm { font-size: var(--font-sm); }
.font-bold { font-weight: 700; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none !important; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

/* ============================================================
   RESPONSIVE — Tablet (768px)
   ============================================================ */
@media (max-width: 768px) {
  .nav-bar {
    padding: 0 var(--space-md);
  }

  .brand-separator,
  .brand-portal {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-sm);
    box-shadow: var(--shadow-md);
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-menu li a,
  .nav-menu li button {
    width: 100%;
    justify-content: flex-start;
    padding: var(--space-md);
  }

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

  .kpi-card {
    max-width: calc(50% - var(--space-lg) / 2);
  }

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

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-control {
    width: 100%;
    min-width: unset;
  }

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

  .section-header .section-actions {
    width: 100%;
  }

  .section-header .section-actions .btn {
    flex: 1;
  }

  .table-pagination {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    max-width: unset;
  }

  .modal-card {
    max-width: 100%;
    margin: var(--space-md);
  }
}

/* ============================================================
   RESPONSIVE — Mobile (480px)
   ============================================================ */
@media (max-width: 480px) {
  :root {
    --font-base: 0.875rem;
    --font-lg: 1rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
  }

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

  .kpi-row {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .kpi-card {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  .login-card {
    padding: var(--space-lg);
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }

  .commission-table th,
  .commission-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .modal-overlay {
    padding: var(--space-sm);
    align-items: flex-end;
  }

  .modal-card {
    margin: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 85vh;
  }

  .toast-container {
    left: var(--space-sm);
    right: var(--space-sm);
  }

  .filter-pills {
    gap: var(--space-xs);
  }

  .pill {
    font-size: 0.6875rem;
    padding: 0.2rem 0.5rem;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .nav-bar,
  .toast-container,
  .modal-overlay,
  .filter-bar,
  .btn {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .main-content {
    margin-top: 0;
    padding: 0;
  }

  .card,
  .kpi-card,
  .table-wrapper {
    border: 1px solid #ccc;
    box-shadow: none;
    background: #fff;
  }

  .commission-table th {
    background: #f0f0f0;
  }
}

/* ----- Inline Table Controls ----- */
.inline-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.3rem;
  font-size: 0.78rem;
  max-width: 140px;
  cursor: pointer;
}
.inline-select:focus {
  border-color: var(--accent);
  outline: none;
}
.inline-input {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
}
.inline-input:focus {
  border-color: var(--accent);
  outline: none;
}
.inline-input::placeholder {
  color: var(--text-muted);
}

/* ----- Summary Cards Grid ----- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}
.summary-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  text-align: center;
}
.summary-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.summary-card .value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ----- Dashboard Table Enhancements ----- */
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrap th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.table-wrap td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.85rem;
}
.table-wrap tbody tr {
  transition: background 0.15s ease;
}
.table-wrap tbody tr:hover {
  background: rgba(245, 158, 11, 0.04);
}
@media (max-width: 1200px) {
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
