:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --neutral: #64748b;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-700: #334155;
  --dark: #0f172a;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius-md: 0.75rem;
  --radius-xl: 1rem;
  --transition: 150ms ease;
}

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

body {
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: #f8fafc;
  color: var(--dark);
  line-height: 1.6;
}

/* -------------------- Layout -------------------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, 280px) minmax(0, 1fr);
}

.app-shell__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 20;
}

.drawer {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  color: #e2e8f0;
  padding: 1.5rem 1rem;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand-mark {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: white;
}
.brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
}
.brand-subtitle {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Sidebar */
.sidebar-summary {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 1rem;
  margin-bottom: 2rem;
}
.sidebar-summary-label {
  font-size: 0.7rem;
  color: #94a3b8;
}
.sidebar-summary-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
  margin-top: 4px;
}

.nav-group {
  margin-bottom: 1.5rem;
}
.nav-group-title {
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  color: #cbd5e1;
  transition: var(--transition);
}
.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.nav-link.active {
  background: rgba(79,70,229,0.2);
  color: white;
  border-right: 3px solid var(--primary);
}

/* Main content */
.main-content {
  padding: 1.5rem;
  min-width: 0;
  overflow-x: hidden;
}
.app-header {
  margin-bottom: 1.5rem;
}
.app-toolbar {
  background: white;
  border-radius: 1rem;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.menu-toggle {
  display: none;
  background: white;
  border: none;
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.page-kicker {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.75rem;
}
.page-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
}
.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.status-pill {
  background: var(--gray-100);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral);
}
.quick-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.inline-form {
  display: inline;
}

.mobile-quick-actions {
  display: none;
}

.mobile-quick-actions-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--gray-700);
}

.mobile-quick-actions-grid {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.mobile-quick-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: max-content;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: white;
  color: var(--dark);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.mobile-quick-action-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Stack and Grid */
.stack-xl {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.grid {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* Metric Cards */
.metric-card {
  position: relative;
  min-width: 0;
  padding: 1rem;
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}
.metric-card.tone-success::before { background: var(--success); }
.metric-card.tone-danger::before { background: var(--danger); }
.metric-card.tone-warning::before { background: var(--warning); }
.metric-card.tone-info::before { background: var(--info); }
.metric-card.tone-neutral::before { background: var(--neutral); }
.metric-label {
  font-size: 0.75rem;
  color: var(--neutral);
  text-transform: uppercase;
}
.metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}
.metric-note {
  font-size: 0.7rem;
  color: var(--neutral);
  margin-top: 0.5rem;
}

/* Dashboard Hero */
.dashboard-hero-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-eyebrow {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}
.hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 0.25rem;
}
.hero-subtitle {
  color: var(--neutral);
  margin-top: 0.25rem;
}
.hero-note {
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-top: 0.5rem;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard-overview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.finance-overview-head {
  margin-bottom: 0;
}

.finance-overview-head .muted {
  max-width: 72rem;
}

.finance-metric-grid {
  gap: 1rem;
}

.finance-advanced-metrics {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow-sm);
  padding: 0.85rem;
}

.finance-advanced-metrics summary {
  cursor: pointer;
  color: var(--gray-700);
  font-weight: 800;
}

.finance-metric-grid-advanced {
  margin-top: 0.85rem;
}

/* Sections */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 800;
}
.section-actions {
  display: flex;
  gap: 0.5rem;
}
.compact-actions {
  gap: 0.4rem;
}

/* Mini Cards */
.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.mini-card {
  background: var(--gray-100);
  padding: 0.75rem;
  border-radius: 0.75rem;
}
.mini-card-label {
  font-size: 0.7rem;
  color: var(--neutral);
}
.mini-card-value {
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: 0.2rem;
}
.mini-card-note {
  font-size: 0.65rem;
  color: var(--neutral);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--gray-200);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--gray-200);
}
th {
  background: var(--gray-100);
  font-weight: 600;
  font-size: 0.75rem;
}
tbody tr:hover td {
  background: #f1f5f9;
}
.empty-state {
  text-align: center;
  color: var(--neutral);
  padding: 2rem !important;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.empty-state-title {
  color: var(--dark);
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 0.45rem;
}
.empty-state-text {
  color: var(--gray-700);
  line-height: 1.8;
}
.empty-state-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.empty-state-hint {
  color: var(--neutral);
  font-size: 0.8rem;
  line-height: 1.7;
  margin-top: 0.75rem;
}
.empty-state .btn {
  justify-content: center;
}

.mobile-card-list {
  display: none;
}

.mobile-row-card {
  border: 1px solid var(--gray-200);
  border-radius: 0.75rem;
  background: white;
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.mobile-row-field {
  display: grid;
  grid-template-columns: minmax(6rem, 35%) 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--gray-200);
}

.mobile-row-field:last-child {
  border-bottom: 0;
}

.mobile-row-label {
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 700;
}

.mobile-row-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-row-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

/* Badges */
.badge {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-soft {
  background: rgba(79,70,229,0.1);
  color: var(--primary);
}
.badge-success {
  background: rgba(16,185,129,0.1);
  color: var(--success);
}
.badge-muted {
  background: var(--gray-200);
  color: var(--neutral);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: white;
  border-color: var(--gray-200);
  color: var(--dark);
}
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; }
.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.7rem;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field label {
  font-weight: 600;
  font-size: 0.8rem;
}
.field.has-error {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.22);
}
.field.has-error label {
  color: var(--danger);
}
.form-control, .form-select {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--gray-200);
  background: white;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
}
.form-error-summary {
  color: var(--danger);
  font-weight: 600;
}
.form-error-summary ul {
  margin: 0.25rem 1rem 0 0;
}
.field-error {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}
.help-text {
  color: var(--neutral);
  font-size: 0.76rem;
  line-height: 1.7;
}
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Flash Messages */
.messages-container {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.flash {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0;
}
.flash-success {
  background: rgba(16,185,129,0.1);
  border-right: 3px solid var(--success);
}
.flash-error {
  background: rgba(239,68,68,0.1);
  border-right: 3px solid var(--danger);
}
.flash-warning {
  background: rgba(245,158,11,0.1);
  border-right: 3px solid var(--warning);
}

/* Pagination */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.pagination-info {
  font-size: 0.8rem;
  color: var(--neutral);
}
.pagination-links {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.current-page {
  font-weight: 600;
  background: var(--gray-100);
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
}

/* Auth Pages */
.auth-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  padding: 1rem;
}
.auth-card {
  max-width: 480px;
  width: 100%;
}
.auth-form {
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .drawer {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 30;
    width: 280px;
    max-width: 86vw;
  }
  .drawer.open {
    transform: translateX(0);
  }
  .app-shell__backdrop.show {
    display: block;
  }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .main-content {
    width: 100%;
    padding: 1rem;
  }
  .app-toolbar {
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  .header-left,
  .header-actions {
    min-width: 0;
  }
  .grid-2, .grid-4, .form-grid {
    grid-template-columns: 1fr;
  }
  .grouped-form,
  .form-card form {
    padding-bottom: 5.25rem;
  }
  .mobile-sticky-form-actions {
    position: sticky;
    bottom: 0.75rem;
    z-index: 15;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: rgba(255,255,255,0.96);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    flex-wrap: wrap;
  }
  .mobile-sticky-form-actions .btn {
    min-height: 2.75rem;
    justify-content: center;
    flex: 1 1 9rem;
  }
  .dashboard-hero-inner {
    flex-direction: column;
  }
  .responsive-table-desktop {
    display: none;
  }
  .mobile-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: -0.5rem;
  }
  .mobile-quick-actions-grid {
    direction: rtl;
  }
  .mobile-card-list {
    display: grid;
    gap: 0.75rem;
  }
}

@media (max-width: 768px) {
  .mobile-row-field {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .mobile-row-actions .btn,
  .mobile-row-actions a {
    min-height: 2.5rem;
    align-items: center;
  }
}

/* --------------------------------------------------------------------------
   Wave 4 / Issue 24: Global UI utility polish
   These classes are intentionally small and generic. They are used by the
   financial/report pages added in Wave 3 and by common list/detail templates.
-------------------------------------------------------------------------- */

/* Typography utilities */
.muted { color: var(--neutral); }
.text-muted { color: var(--neutral); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.fw-bold { font-weight: 800; }
.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  direction: ltr;
  unicode-bidi: plaintext;
}
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

/* Missing report grids */
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.report-center-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.report-card-title {
  font-size: 1rem;
  line-height: 1.7;
  white-space: normal;
}

/* Metric/card tone polish */
.metric-card {
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(79,70,229,0.28);
}
.metric-card.tone-success { background: linear-gradient(180deg, rgba(16,185,129,0.07), white 52%); }
.metric-card.tone-danger { background: linear-gradient(180deg, rgba(239,68,68,0.07), white 52%); }
.metric-card.tone-warning { background: linear-gradient(180deg, rgba(245,158,11,0.08), white 52%); }
.metric-card.tone-info { background: linear-gradient(180deg, rgba(14,165,233,0.07), white 52%); }
.metric-card.tone-neutral { background: linear-gradient(180deg, rgba(100,116,139,0.06), white 52%); }

/* Borders used by integrity/wallet/report cards */
.border-success { border-color: rgba(16,185,129,0.36) !important; }
.border-danger { border-color: rgba(239,68,68,0.36) !important; }
.border-warning { border-color: rgba(245,158,11,0.40) !important; }
.border-info { border-color: rgba(14,165,233,0.36) !important; }
.border-neutral { border-color: var(--gray-200) !important; }

/* Badges/tone utilities */
.badge-success,
.badge-soft.tone-success {
  background: rgba(16,185,129,0.12);
  color: #047857;
}
.badge-danger,
.badge-soft.tone-danger {
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
}
.badge-warning,
.badge-soft.tone-warning {
  background: rgba(245,158,11,0.14);
  color: #92400e;
}
.badge-info,
.badge-soft.tone-info {
  background: rgba(14,165,233,0.12);
  color: #0369a1;
}
.badge-soft.tone-neutral {
  background: var(--gray-200);
  color: var(--neutral);
}

/* Buttons that reports already reference */
.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #059669; }
.btn-warning {
  background: var(--warning);
  color: #1f2937;
}
.btn-warning:hover { background: #d97706; color: white; }
.btn-info {
  background: var(--info);
  color: white;
}
.btn-info:hover { background: #0284c7; }

/* Reports and filter forms */
.filter-form {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: 1rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.form-group label,
.checkbox-label {
  color: var(--gray-700);
  font-size: 0.78rem;
  font-weight: 800;
}
.checkbox-group {
  justify-content: end;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.4rem;
  cursor: pointer;
}
.checkbox-label input { width: 1rem; height: 1rem; }

/* Informational definition lists used in report pages */
.info-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.info-list li,
.info-list .info-item {
  display: grid;
  grid-template-columns: minmax(10rem, 28%) 1fr;
  gap: 0.85rem;
  align-items: start;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #fff;
}
.info-list strong,
.info-list .info-label {
  color: var(--dark);
  font-weight: 800;
}
.info-list span,
.info-list .info-value {
  color: var(--gray-700);
  line-height: 1.8;
}

/* Alerts */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  padding: 0.8rem 1rem;
  margin: 0.75rem 0;
  line-height: 1.8;
}
.alert-success { background: rgba(16,185,129,0.10); border-color: rgba(16,185,129,0.32); color: #065f46; }
.alert-danger { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.32); color: #991b1b; }
.alert-warning { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.34); color: #78350f; }
.alert-info { background: rgba(14,165,233,0.10); border-color: rgba(14,165,233,0.32); color: #075985; }
.alert-neutral { background: var(--gray-100); border-color: var(--gray-200); color: var(--gray-700); }

/* Tables */
.table-wrap {
  background: white;
}
.table {
  min-width: 780px;
}
.table-striped tbody tr:nth-child(even) td {
  background: rgba(241,245,249,0.55);
}
.table th {
  white-space: nowrap;
  color: var(--gray-700);
}
.table td {
  vertical-align: middle;
}
.table td .btn,
.table td .badge {
  white-space: nowrap;
}
.row-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.row-actions .btn,
.section-actions .btn,
.hero-actions .btn {
  text-decoration: none;
}

/* Better focus for keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: 3px solid rgba(79,70,229,0.28);
  outline-offset: 2px;
}

/* Dashboard hero polish */
.dashboard-hero {
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(79,70,229,0.11), transparent 34%),
    linear-gradient(180deg, #ffffff, #fbfdff);
}
.hero-actions .btn {
  min-height: 2.25rem;
}

/* Responsive fixes */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr; }
  .section-head {
    align-items: flex-start;
  }
  .section-actions,
  .hero-actions,
  .row-actions,
  .form-actions {
    width: 100%;
  }
  .section-actions .btn,
  .hero-actions .btn,
  .row-actions .btn,
  .form-actions .btn {
    justify-content: center;
  }
  .info-list li,
  .info-list .info-item {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
  .filter-form .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .metric-value {
    font-size: 1.35rem;
  }
  .card {
    padding: 1rem;
  }
  .app-toolbar {
    padding: 0.75rem 1rem;
  }
  .header-actions .status-pill {
    width: 100%;
  }
  .btn {
    min-height: 2.45rem;
  }
}

/* --------------------------------------------------------------------------
   Wave 4 / Issue 25: Generic list/report readability and mobile cards
-------------------------------------------------------------------------- */
.list-page-card,
.report-generic-card {
  overflow: hidden;
}
.list-page-head {
  align-items: flex-start;
}
.list-page-actions {
  align-items: center;
  flex-wrap: wrap;
}
.list-search-form {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: min(100%, 28rem);
}
.list-search-form .form-control {
  min-width: 15rem;
  min-height: 2.35rem;
}
.list-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: -0.25rem 0 1rem;
}
.list-next-actions {
  margin-bottom: 1rem;
}
.object-list-table th:last-child,
.object-list-table td.actions-cell {
  width: 1%;
  white-space: nowrap;
}
.object-list-mobile,
.report-generic-mobile {
  margin-top: 0.5rem;
}
.mobile-row-card {
  position: relative;
}
.mobile-row-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 3px;
  border-radius: 999px;
  background: rgba(79,70,229,0.28);
}
.mobile-row-actions .row-actions {
  width: 100%;
}
.mobile-row-actions .btn,
.mobile-row-actions a.btn {
  justify-content: center;
}
.btn-light {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-light:hover {
  background: var(--gray-100);
}

@media (max-width: 1024px) {
  .list-page-actions,
  .list-search-form,
  .list-search-form .form-control,
  .list-page-actions > .btn {
    width: 100%;
  }
  .list-search-form .btn {
    flex: 1 1 8rem;
  }
}

@media print {
  .mobile-card-list {
    display: none !important;
  }
  .responsive-table-desktop {
    display: block !important;
  }
}

/* --------------------------------------------------------------------------
   Wave 4 / Issue 26: Responsive drawer must not cover content accidentally
   On narrow / half-width laptop windows the sidebar becomes an off-canvas menu.
   It is hidden by default, opens from the right in RTL, and the page content
   always keeps full width.
-------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .app-shell {
    display: block;
    grid-template-columns: 1fr !important;
    width: 100%;
    min-width: 0;
  }

  .drawer {
    position: fixed !important;
    inset-block: 0;
    inset-inline-start: auto;
    inset-inline-end: 0;
    width: min(82vw, 320px);
    max-width: 320px;
    height: 100dvh;
    z-index: 60;
    transform: translateX(105%);
    transition: transform 0.22s ease;
    box-shadow: -18px 0 40px rgba(15, 23, 42, 0.22);
  }

  .drawer.open {
    transform: translateX(0);
  }

  .app-shell__backdrop {
    z-index: 50;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
  }

  .app-shell__backdrop.show {
    display: block;
  }

  .main-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding-inline: 1rem;
    overflow-x: hidden;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.drawer-open {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .drawer {
    width: min(88vw, 300px);
  }
  .main-content {
    padding-inline: 0.75rem;
  }
}

/* Wave 4 Issue 26B: robust RTL off-canvas sidebar fix */
@media (max-width: 1180px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .app-shell {
    display: block !important;
    grid-template-columns: none !important;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
  }

  .main-content {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    margin: 0;
    padding: 1rem;
    overflow-x: hidden;
  }

  .drawer {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(320px, 86vw);
    max-width: 86vw;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(110%);
    transition: transform 220ms ease;
    z-index: 1000;
    box-shadow: -18px 0 48px rgba(15, 23, 42, 0.28);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .drawer.open {
    transform: translateX(0);
  }

  html[dir="ltr"] .drawer {
    right: auto;
    left: 0;
    transform: translateX(-110%);
    box-shadow: 18px 0 48px rgba(15, 23, 42, 0.28);
  }

  html[dir="ltr"] .drawer.open {
    transform: translateX(0);
  }

  .app-shell__backdrop {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(15, 23, 42, 0.42);
    z-index: 990;
    backdrop-filter: blur(2px);
  }

  .app-shell__backdrop.show {
    display: block;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .app-toolbar,
  .header-left,
  .header-actions,
  .quick-actions {
    max-width: 100%;
  }

  .table-wrap,
  .responsive-table-desktop,
  .card,
  .report-card,
  .dashboard-hero,
  .form-card {
    max-width: 100%;
  }
}

@media (max-width: 520px) {
  .main-content {
    padding: 0.75rem;
  }

  .app-toolbar {
    padding: 0.75rem;
  }

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

  .drawer {
    width: min(300px, 88vw);
    max-width: 88vw;
  }
}
