/* ==========================================================================
   PartyParart — Unified Design System
   Shared across Event App, Partner Portal, Admin Platform
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   2. Design Tokens (CSS Custom Properties)
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --surface: #FAF9F7;
  --surface-card: #FFFFFF;
  --surface-sidebar: #1E2422;

  /* Borders */
  --border: #E2DED8;
  --border-light: #EDEAE5;

  /* Text */
  --text: #1A1A1A;
  --text-secondary: #6B6560;
  --text-on-dark: #FFFFFF;
  --text-sidebar: #A8A49E;
  --text-sidebar-hover: #D4D0CB;

  /* Semantic */
  --success: #3D8B3D;
  --success-light: #E8F5E8;
  --warning: #C4922D;
  --warning-light: #FDF6E8;
  --error: #C14B4B;
  --error-light: #FDE8E8;

  /* Default accent — event green */
  --accent: #6B8F5E;
  --accent-dark: #4D6E42;
  --accent-light: #E8F0E4;

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --space-3xl: 64px;

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Shadows — 3-tier elevation scale */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.15);

  /* Layout */
  --sidebar-width: 260px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   3. Area-Specific Accent Overrides
   -------------------------------------------------------------------------- */
html[data-area="event"] {
  --accent: #6B8F5E;
  --accent-dark: #4D6E42;
  --accent-light: #E8F0E4;
}

html[data-area="partner"] {
  --accent: #B8923D;
  --accent-dark: #96752D;
  --accent-light: #F5EDD8;
}

html[data-area="admin"] {
  --accent: #7C6DAF;
  --accent-dark: #5E5189;
  --accent-light: #EEEAF5;
}

/* --------------------------------------------------------------------------
   4. Base Typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
}

h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
}

h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
}

h3 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
}

h4 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   5. Sidebar Shell
   -------------------------------------------------------------------------- */
.ds-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: transform 0.3s var(--ease-out);
}

.ds-sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

/* Sidebar header */
.ds-sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ds-sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.ds-sidebar-logo img {
  width: 32px;
  height: 32px;
}

.ds-sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-on-dark);
}

.ds-sidebar-subtitle {
  font-size: 11px;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-xs);
}

/* Sidebar navigation */
.ds-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-md);
}

.ds-sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.ds-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.ds-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.ds-nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sidebar);
  padding: var(--space-md) var(--space-sm) var(--space-xs);
}

.ds-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  font-size: 14px;
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
  position: relative;
}

.ds-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ds-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-sidebar-hover);
}

.ds-nav-link.active {
  background: var(--accent);
  color: var(--text-on-dark);
}

.ds-nav-link.premium {
  opacity: 0.5;
  cursor: not-allowed;
}

.ds-nav-link.premium:hover {
  background: transparent;
  color: var(--text-sidebar);
}

.ds-nav-link-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ds-nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: var(--text-on-dark);
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ds-nav-link.active .ds-nav-badge {
  background: rgba(255, 255, 255, 0.25);
}

/* Sidebar divider */
.ds-sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: var(--space-sm) var(--space-md);
}

/* Sidebar footer */
.ds-sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ds-sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.ds-sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sidebar-hover);
  flex-shrink: 0;
}

.ds-sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.ds-sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-on-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-sidebar-user-email {
  font-size: 11px;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-sidebar-hover);
}

.ds-sidebar-upgrade {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
  background: var(--accent);
  color: var(--text-on-dark);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
}

.ds-sidebar-upgrade:hover {
  background: var(--accent-dark);
}

/* Logout link */
.ds-nav-link-logout {
  color: var(--text-sidebar);
}

.ds-nav-link-logout:hover {
  background: rgba(193, 75, 75, 0.15);
  color: var(--error);
}

/* --------------------------------------------------------------------------
   6. Layout
   -------------------------------------------------------------------------- */
.ds-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ds-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.ds-content {
  flex: 1;
  padding: 40px;
  max-width: 1400px;
  width: 100%;
}

.ds-footer {
  padding: var(--space-lg) 40px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   7. Components — Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-dark);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.btn-danger {
  background: var(--error);
  color: var(--text-on-dark);
  border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #A83E3E;
  border-color: #A83E3E;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--text);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   7. Components — Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  /* Default card body — no extra padding when inside .card */
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}

/* --------------------------------------------------------------------------
   7. Components — Forms
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B6560' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-row > .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.form-error {
  font-size: 12px;
  color: var(--error);
  margin-top: var(--space-xs);
}

/* Validation states */
.form-group.has-error .form-input,
.form-group.has-error .form-select,
.form-group.has-error .form-textarea {
  border-color: var(--error);
}

.form-group.has-error .form-input:focus,
.form-group.has-error .form-select:focus,
.form-group.has-error .form-textarea:focus {
  box-shadow: 0 0 0 3px var(--error-light);
}

.form-group.has-success .form-input,
.form-group.has-success .form-select,
.form-group.has-success .form-textarea {
  border-color: var(--success);
}

.form-group.has-success .form-input:focus,
.form-group.has-success .form-select:focus,
.form-group.has-success .form-textarea:focus {
  box-shadow: 0 0 0 3px var(--success-light);
}

/* --------------------------------------------------------------------------
   7. Components — Tables
   -------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-align: left;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text);
  vertical-align: middle;
}

tr:hover td {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   7. Components — Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-error {
  background: var(--error-light);
  color: var(--error);
}

.badge-neutral {
  background: var(--border-light);
  color: var(--text-secondary);
}

.badge-pro {
  background: var(--warning);
  color: var(--text-on-dark);
}

/* --------------------------------------------------------------------------
   7. Components — Modals
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(10px);
  transition: transform 0.3s var(--ease-out);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.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-light);
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   7. Components — Flash Messages
   -------------------------------------------------------------------------- */
.flash-message {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.flash-message svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.flash-message.success,
.flash-success,
.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(61, 139, 61, 0.2);
}

.flash-message.error,
.flash-error,
.alert-error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid rgba(193, 75, 75, 0.2);
}

.flash-message.warning,
.flash-warning,
.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid rgba(196, 146, 45, 0.2);
}

/* Flash aliases — ensure standalone classes get base styling */
.flash-success,
.flash-error,
.flash-warning,
.alert-success,
.alert-error,
.alert-warning {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--space-md);
}

/* --------------------------------------------------------------------------
   7. Components — Stats
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--border-light);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
  margin-top: var(--space-xs);
}

.stat-change.positive {
  color: var(--success);
}

.stat-change.negative {
  color: var(--error);
}

/* --------------------------------------------------------------------------
   7. Components — Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.pagination a:hover {
  background: var(--surface);
  color: var(--text);
}

.pagination .active a,
.pagination .active span {
  background: var(--accent);
  color: var(--text-on-dark);
}

.pagination .disabled a,
.pagination .disabled span {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   7. Components — Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.empty-state svg,
.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--border);
  margin: 0 auto var(--space-md);
}

.empty-state-icon {
  font-size: 48px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   7. Components — Page Header
   -------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* --------------------------------------------------------------------------
   7. Components — Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1.5px solid var(--border-light);
  margin-bottom: var(--space-xl);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   8. Mobile Responsive
   -------------------------------------------------------------------------- */
.ds-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ds-sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.ds-mobile-toggle {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 101;
  width: 44px;
  height: 44px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ds-mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  position: relative;
}

.ds-mobile-toggle span::before,
.ds-mobile-toggle span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--text);
}

.ds-mobile-toggle span::before {
  top: -6px;
}

.ds-mobile-toggle span::after {
  top: 6px;
}

/* 1024px — Sidebar collapses */
@media (max-width: 1024px) {
  .ds-sidebar {
    transform: translateX(-100%);
  }

  .ds-sidebar.open {
    transform: translateX(0);
  }

  .ds-mobile-toggle {
    display: flex;
  }

  .ds-main {
    margin-left: 0;
  }

  .ds-content {
    padding-top: 72px;
  }
}

/* 768px — Reduced padding, stacked layout */
@media (max-width: 768px) {
  .ds-content {
    padding: 72px var(--space-lg) var(--space-lg);
  }

  .ds-footer {
    padding: var(--space-md) var(--space-lg);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .modal-content {
    width: 95%;
  }
}

/* 640px — Compact mode */
@media (max-width: 640px) {
  .ds-content {
    padding: 64px var(--space-md) var(--space-md);
  }

  .ds-footer {
    padding: var(--space-md);
  }

  .page-title {
    font-size: 22px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .btn {
    padding: 8px 16px;
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --------------------------------------------------------------------------
   9. Utilities
   -------------------------------------------------------------------------- */

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text colors */
.text-primary { color: var(--text); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

/* Spacing — margins */
.mt-0 { margin-top: 0; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Flex helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.flex-1 { flex: 1; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --------------------------------------------------------------------------
   10. Print Styles
   -------------------------------------------------------------------------- */
@media print {
  .ds-sidebar,
  .ds-mobile-toggle,
  .ds-sidebar-overlay,
  .ds-footer {
    display: none !important;
  }

  .ds-main {
    margin-left: 0 !important;
  }

  .ds-content {
    padding: 0 !important;
    max-width: 100% !important;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .btn {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   14. Accessibility
   -------------------------------------------------------------------------- */

/* Focus indicators for keyboard navigation */
.btn:focus-visible,
.ds-nav-link:focus-visible,
.ds-nav-link-logout:focus-visible,
.tab:focus-visible,
.modal-close:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 0.75rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--surface-card);
  color: var(--text);
  z-index: 9999;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
