/*
 Author: abhik pramanik
 Change Date: 2026-10-04
 Change details: Missing-route (404) card uses the dashboard palette.
   500 error screen tokens remain unchanged. Prior: 500 error screen
   tokens and layout (dashboard chrome, not 404). Prior: Dashboard Source
   column; history Source / Payment method /
   Credit/Debit columns. Prior: Expense History restyle to match overview.
 Purpose: Dashboard overview + Expense History + 500 + Page not found styles.
 Inputs: tokens.css custom properties; .dash-page scoped palette
 Outputs: overview cards, charts, recent table, history cards, 500, 404
*/

.dash-page {
  --dash-bg: #f8fafc;
  --dash-card: #ffffff;
  --dash-text: #111827;
  --dash-muted: #64748b;
  --dash-border: #eef1f4;
  --dash-blue: #2563eb;
  --dash-blue-2: #3b82f6;
  --dash-blue-3: #60a5fa;
  --dash-blue-4: #dbeafe;
  --dash-ok: #10b981;
  --dash-warn: #f59e0b;
  --dash-bad: #ef4444;
  --dash-shadow: 0 1px 2px rgba(15, 23, 42, 0.03), 0 10px 28px rgba(15, 23, 42, 0.035);
  --dash-hover: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.05);
  --dash-skel: #eef2f7;
  --dash-radius: 18px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--dash-bg);
  color: var(--dash-text);
  animation: welcome-fade-in 200ms ease-out;
}

html[data-theme="dark"] .dash-page {
  --dash-bg: #0b1220;
  --dash-card: #111827;
  --dash-text: #f8fafc;
  --dash-muted: #94a3b8;
  --dash-border: rgba(255, 255, 255, 0.08);
  --dash-blue: #3b82f6;
  --dash-blue-2: #60a5fa;
  --dash-blue-3: #93c5fd;
  --dash-blue-4: rgba(59, 130, 246, 0.18);
  --dash-ok: #34d399;
  --dash-warn: #fbbf24;
  --dash-bad: #f87171;
  --dash-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 28px rgba(0, 0, 0, 0.22);
  --dash-hover: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 32px rgba(0, 0, 0, 0.28);
  --dash-skel: #1e293b;
  --dash-radius: 18px;
}

.dash-sticky {
  position: sticky;
  top: 0;
  z-index: 16;
  background: var(--dash-bg);
}

.dash-sticky .dash-header {
  position: relative;
}

.dash-page .dash-header {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 32px clamp(24px, 4vw, 48px) 4px;
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  gap: 24px;
}

.dash-page .dash-logo {
  width: 28px;
  height: 28px;
}

.dash-page .dash-product {
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: -0.02em;
  color: var(--dash-text);
}

.dash-page .dash-user {
  gap: 8px;
}

.dash-back {
  border: none;
  background: transparent;
  color: var(--dash-blue);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 180ms ease;
}

.dash-back:hover {
  color: var(--dash-blue-2);
}

.theme-toggle--compact {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.dash-month {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--dash-border);
  border-radius: 999px;
  background: var(--dash-card);
  color: var(--dash-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 550;
}

.dash-page .dash-gmail {
  min-width: 0;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 550;
  background: var(--dash-card);
  color: var(--dash-muted);
  border: 1px solid var(--dash-border);
  box-shadow: none;
}

.dash-page .dash-gmail:hover:not(:disabled) {
  border-color: var(--dash-blue);
}

.dash-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dash-profile-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
}

.dash-page .dash-username {
  color: var(--dash-text);
  font-size: 0.84rem;
  font-weight: 550;
  max-width: min(28vw, 220px);
}

.dash-logout-link {
  border: none;
  background: transparent;
  color: var(--dash-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  transition: color 180ms ease;
}

.dash-logout-link:hover:not(:disabled) {
  color: var(--dash-blue);
}

.dash-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--dash-blue-4);
  color: var(--dash-blue);
  font-size: 0.72rem;
  font-weight: 650;
  flex: 0 0 auto;
}

.dash-main--overview {
  align-items: stretch;
  justify-content: flex-start;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 16px clamp(24px, 4vw, 48px) 56px;
  gap: 22px;
}

.dash-main--overview .auth-alert {
  max-width: none;
  width: 100%;
}

.dash-hello {
  padding-top: 12px;
}

.dash-hello-title {
  margin: 0;
  font-size: clamp(1.85rem, 2.5vw, 2.125rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--dash-text);
  line-height: 1.12;
}

.dash-hello-accent {
  color: var(--dash-blue);
}

.dash-hello-sub {
  margin: 6px 0 0;
  color: var(--dash-muted);
  font-size: 0.875rem;
  font-weight: 400;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.kpi-card,
.chart-card,
.recent-card {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow);
}

.kpi-card {
  padding: 22px 24px 20px;
}

.kpi-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

.kpi-card-icon {
  width: 15px;
  height: 15px;
  color: var(--dash-muted);
  opacity: 0.85;
}

.kpi-card-label {
  color: var(--dash-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.kpi-card-value {
  margin: 0;
  font-size: clamp(1.4rem, 1.7vw, 1.7rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  color: var(--dash-text);
  line-height: 1.1;
}

.kpi-card-cents {
  font-size: 0.58em;
  font-weight: 550;
  letter-spacing: -0.02em;
  margin-left: 1px;
  opacity: 0.72;
}

.kpi-card-value--accent {
  color: var(--dash-blue);
}

.kpi-card-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 450;
  color: var(--dash-muted);
}

.kpi-card-hint--ok {
  color: var(--dash-ok);
}

.kpi-card-hint--bad {
  color: var(--dash-bad);
}

.kpi-card-hint--accent {
  color: var(--dash-muted);
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.chart-card,
.recent-card {
  padding: 22px 24px 20px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.chart-card-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dash-text);
}

.chart-card-meta,
.recent-all {
  color: var(--dash-muted);
  font-size: 0.75rem;
  font-weight: 450;
}

.recent-all {
  border: none;
  background: transparent;
  color: var(--dash-blue);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  cursor: pointer;
  padding: 0;
  transition: color 180ms ease;
}

.recent-all:hover {
  color: var(--dash-blue-2);
}

.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 340px;
  padding: 8px 0 12px;
}

.donut-svg {
  width: min(100%, 400px);
  height: auto;
  max-height: 400px;
  display: block;
}

.trend-svg {
  width: 100%;
  height: auto;
  min-height: 280px;
  flex: 1;
  display: block;
}

.donut-label {
  fill: #ffffff;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.trend-grid {
  stroke: var(--dash-border);
  stroke-width: 1;
  opacity: 0.85;
}

.trend-axis {
  fill: var(--dash-muted);
  font-size: 10px;
}

.trend-line {
  stroke: var(--dash-blue);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot {
  fill: var(--dash-card);
  stroke: var(--dash-blue);
  stroke-width: 1.75;
}

.chart-empty {
  margin: 48px 12px;
  text-align: center;
  color: var(--dash-muted);
  font-size: 0.9rem;
}

.chart-empty--table {
  margin: 28px 8px 16px;
}

.recent-scroll {
  overflow-x: auto;
}

.recent-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.recent-table th,
.recent-table td {
  padding: 18px 12px;
  text-align: left;
  border-bottom: 1px solid var(--dash-border);
  font-size: 0.875rem;
}

.recent-table th {
  color: var(--dash-muted);
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--dash-border);
}

.recent-table tbody tr {
  transition: background-color 180ms ease;
}

.recent-table tbody tr:hover {
  background: color-mix(in srgb, var(--dash-bg) 70%, transparent);
}

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

.recent-date {
  color: var(--dash-muted);
  white-space: nowrap;
  width: 16%;
  font-weight: 400;
}

.recent-cat {
  width: 22%;
  white-space: nowrap;
  font-weight: 450;
  color: var(--dash-text);
}

.recent-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
}

.recent-desc {
  font-weight: 550;
  color: var(--dash-text);
}

.recent-src {
  color: var(--dash-muted);
  font-weight: 450;
  overflow-wrap: anywhere;
}

.recent-amt {
  text-align: right;
  font-weight: 550;
  white-space: nowrap;
}

.dash-skel {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--dash-skel) 0%,
    color-mix(in srgb, var(--dash-skel) 60%, #fff) 50%,
    var(--dash-skel) 100%
  );
  background-size: 200% 100%;
  animation: dash-skel 1.2s ease-in-out infinite;
}

.dash-skel--sm {
  height: 12px;
  width: 42%;
  margin-bottom: 18px;
}

.dash-skel--lg {
  height: 28px;
  width: 58%;
  margin-bottom: 12px;
}

.dash-skel--xs {
  height: 10px;
  width: 34%;
}

.dash-skel--donut {
  width: min(280px, 70%);
  height: 280px;
  border-radius: 50%;
  margin: 24px auto;
}

.dash-skel--trend {
  height: 240px;
  margin: 16px 0 8px;
}

.dash-skel--row {
  height: 20px;
  margin: 18px 0;
}

@keyframes dash-skel {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dash-back,
  .recent-all,
  .dash-logout-link,
  .recent-table tbody tr {
    transition: none;
  }

  .dash-skel {
    animation: none;
  }
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .chart-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .dash-page .dash-header {
    padding: 16px 16px 8px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .dash-page .dash-brand {
    width: 100%;
  }

  .dash-page .dash-user {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    row-gap: 8px;
  }

  .theme-toggle--compact,
  .dash-month {
    order: 1;
  }

  .dash-profile {
    order: 2;
    margin-left: auto;
  }

  .dash-page .dash-gmail {
    order: 3;
    flex: 1 1 100%;
  }

  .dash-page .dash-username {
    max-width: 42vw;
  }

  .dash-main--overview {
    padding: 8px 16px 32px;
    gap: 16px;
  }

  .theme-toggle--compact,
  .dash-month,
  .dash-page .dash-gmail,
  .dash-avatar {
    min-height: 44px;
  }

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

  .dash-avatar {
    width: 40px;
    height: 40px;
  }

  .recent-table {
    min-width: 0;
  }

  .recent-table thead {
    display: none;
  }

  .recent-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--dash-border);
  }

  .recent-table td {
    border: none;
    padding: 0;
  }

  .recent-date {
    order: 1;
  }

  .recent-amt {
    order: 2;
    text-align: right;
  }

  .recent-cat {
    order: 3;
  }

  .recent-desc {
    order: 4;
    text-align: right;
  }

  .recent-src {
    order: 5;
    grid-column: 1 / -1;
    text-align: left;
  }
}

.dash-main--history {
  align-items: stretch;
  justify-content: flex-start;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 16px clamp(24px, 4vw, 48px) 56px;
  gap: 18px;
}

.hist-hello {
  padding-top: 8px;
}

.hist-hello-count {
  color: var(--dash-muted);
}

.hist-filter-card,
.hist-table-card,
.hist-bulk,
.hist-error {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: 16px;
  box-shadow: var(--dash-shadow);
}

.hist-filter-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 16px 20px;
}

.hist-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hist-filter-label {
  color: var(--dash-muted);
  font-size: 0.78rem;
  font-weight: 550;
}

.hist-filter-input,
.hist-search {
  min-height: 44px;
  height: 44px;
  width: 200px;
  max-width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--dash-border);
  border-radius: 12px;
  background: var(--dash-card);
  color: var(--dash-text);
  font: inherit;
  font-size: 0.9rem;
  color-scheme: inherit;
}

.hist-filter-input:focus,
.hist-search:focus,
.stmt-editor-input:focus {
  outline: 2px solid color-mix(in srgb, var(--dash-blue) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--dash-blue);
}

.hist-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hist-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.hist-btn--primary {
  background: var(--dash-blue);
  color: #fff;
  border-color: var(--dash-blue);
  box-shadow: none;
}

.hist-btn--primary:hover:not(:disabled) {
  background: var(--dash-blue-2);
}

.hist-btn--secondary,
.hist-btn--ghost {
  background: var(--dash-card);
  color: var(--dash-text);
  border-color: var(--dash-border);
}

.hist-btn--ghost {
  background: transparent;
}

.hist-btn--secondary:hover:not(:disabled),
.hist-btn--ghost:hover:not(:disabled) {
  border-color: var(--dash-blue);
  color: var(--dash-blue);
}

.hist-btn--danger {
  background: var(--dash-bad);
  color: #fff;
  border-color: var(--dash-bad);
}

.hist-btn--danger:hover:not(:disabled) {
  filter: brightness(0.95);
}

.hist-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hist-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-color: color-mix(in srgb, var(--dash-bad) 35%, var(--dash-border));
}

.hist-error-text {
  margin: 0;
  color: var(--dash-text);
  font-size: 0.9rem;
}

.hist-error-retry {
  flex: 0 0 auto;
}

.hist-summary {
  margin: 0;
  color: var(--dash-muted);
  font-size: 0.82rem;
  font-weight: 450;
}

.hist-summary-sep {
  color: var(--dash-border);
}

.hist-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.hist-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.hist-bulk-label {
  font-size: 0.88rem;
  font-weight: 550;
  color: var(--dash-text);
}

.hist-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hist-table-card {
  padding: 18px 20px 12px;
  overflow: hidden;
  min-width: 0;
}

.hist-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  min-height: 44px;
}

.hist-table-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dash-text);
}

.hist-search {
  width: min(280px, 100%);
  height: 42px;
  min-height: 42px;
}

.hist-table-scroll {
  overflow-x: hidden;
}

.hist-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 0;
}

.hist-table th,
.hist-table td {
  padding: 18px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--dash-border);
  font-size: 0.875rem;
  color: var(--dash-text);
}

.hist-table th {
  color: var(--dash-muted);
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 10px;
  padding-bottom: 12px;
  background: var(--dash-card);
}

.hist-table th:nth-child(1),
.hist-table td:nth-child(1) {
  width: 22%;
}

.hist-table th:nth-child(2),
.hist-table td:nth-child(2) {
  width: 11%;
}

.hist-table th:nth-child(3),
.hist-table td:nth-child(3) {
  width: 10%;
  white-space: nowrap;
}

.hist-table th:nth-child(4),
.hist-table td:nth-child(4) {
  width: 7%;
}

.hist-table th:nth-child(5),
.hist-table td:nth-child(5) {
  width: 10%;
}

.hist-table th:nth-child(6),
.hist-table td:nth-child(6) {
  width: 7%;
}

.hist-table th:nth-child(7),
.hist-table td:nth-child(7),
.hist-table th:nth-child(8),
.hist-table td:nth-child(8),
.hist-table th:nth-child(9),
.hist-table td:nth-child(9) {
  width: 11%;
}

.hist-cell-amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 550;
  white-space: nowrap;
}

.hist-cell-date,
.hist-cell-cur,
.hist-cell-qty {
  color: var(--dash-muted);
  font-size: 0.8rem;
}

.hist-cell-src,
.hist-cell-pay,
.hist-cell-dc {
  color: var(--dash-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hist-sort {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0;
}

.hist-th-name {
  align-items: center;
}

.hist-row {
  transition: background-color 160ms ease;
}

.hist-row:hover {
  background: color-mix(in srgb, var(--dash-bg) 70%, transparent);
}

.hist-row--selected {
  background: color-mix(in srgb, var(--dash-blue) 7%, var(--dash-card));
}

.hist-row--selected:hover {
  background: color-mix(in srgb, var(--dash-blue) 10%, var(--dash-card));
}

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

.hist-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--dash-text);
}

.hist-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.stmt-cell-edit {
  cursor: pointer;
}

.stmt-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.stmt-editor-input {
  min-height: 44px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.stmt-save {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.stmt-new-type {
  width: auto;
  min-width: 44px;
  padding: 8px 14px;
  white-space: nowrap;
  background: var(--dash-card);
  color: var(--dash-text);
  border: 1px solid var(--dash-border);
  box-shadow: none;
}

.stmt-new-type:hover:not(:disabled) {
  background: color-mix(in srgb, var(--dash-blue) 12%, var(--dash-card));
  color: var(--dash-text);
  border-color: var(--dash-blue);
}

.stmt-new-type:disabled {
  background: var(--dash-skel);
  color: var(--dash-muted);
  border-color: var(--dash-border);
  opacity: 0.72;
  cursor: not-allowed;
}

.stmt-name-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
}

.stmt-name-text {
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 550;
  line-height: 1.35;
}

.stmt-cell-name .stmt-editor {
  flex: 1 1 auto;
  min-width: 0;
}

.stmt-row-check {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--dash-blue);
  cursor: pointer;
}

.stmt-delete {
  width: auto;
  min-width: 96px;
}

.hist-empty,
.hist-search-empty {
  padding: 36px 16px 28px;
  text-align: center;
}

.hist-empty-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 600;
}

.hist-empty-copy,
.hist-empty-hint {
  margin: 0;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  color: var(--dash-muted);
  font-size: 0.9rem;
}

.hist-empty-hint {
  margin-top: 10px;
  color: var(--dash-blue);
}

.hist-skel {
  padding: 8px 4px 16px;
}

.hist-skel-row {
  height: 18px;
  margin: 22px 0;
}

.hist-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 0 4px;
}

.hist-pager-meta {
  color: var(--dash-muted);
  font-size: 0.8rem;
}

.hist-mobile {
  display: none;
}

.hist-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.hist-modal {
  width: min(100%, 420px);
  padding: 24px 22px 18px;
  border-radius: 16px;
  border: 1px solid var(--dash-border);
  background: var(--dash-card);
  box-shadow: var(--dash-hover);
  color: var(--dash-text);
}

.hist-modal-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 650;
}

.hist-modal-copy {
  margin: 0 0 20px;
  color: var(--dash-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hist-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hist-mcard {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--dash-border);
}

.hist-mcard--selected {
  background: color-mix(in srgb, var(--dash-blue) 7%, transparent);
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
  border-radius: 12px;
}

.hist-mcard-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.hist-mcard-name {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--dash-text);
  font: inherit;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.hist-mcard-meta,
.hist-mcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: 26px;
}

.hist-mcard-cat {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.hist-mcard-date,
.hist-mcard-qty {
  color: var(--dash-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.hist-mcard-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}

.hist-mcard-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-left: 26px;
  color: var(--dash-muted);
  font-size: 0.8rem;
}

@media (max-width: 1100px) {
  .hist-cell-cur,
  .hist-cell-qty,
  .hist-table th:nth-child(4),
  .hist-table td:nth-child(4),
  .hist-table th:nth-child(6),
  .hist-table td:nth-child(6) {
    display: none;
  }

  .hist-table th:nth-child(1),
  .hist-table td:nth-child(1) {
    width: 26%;
  }

  .hist-table th:nth-child(2),
  .hist-table td:nth-child(2) {
    width: 14%;
  }

  .hist-table th:nth-child(3),
  .hist-table td:nth-child(3) {
    width: 12%;
  }

  .hist-table th:nth-child(5),
  .hist-table td:nth-child(5) {
    width: 12%;
  }

  .hist-table th:nth-child(7),
  .hist-table td:nth-child(7),
  .hist-table th:nth-child(8),
  .hist-table td:nth-child(8),
  .hist-table th:nth-child(9),
  .hist-table td:nth-child(9) {
    width: 12%;
  }
}

@media (max-width: 720px) {
  .dash-main--history {
    padding: 8px 16px 32px;
    gap: 14px;
  }

  .hist-filter-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 14px 14px;
  }

  .hist-filter-input {
    width: 100%;
  }

  .hist-filter-actions {
    grid-column: 1 / -1;
  }

  .hist-filter-actions .hist-btn {
    flex: 1;
  }

  .hist-table-head {
    align-items: stretch;
  }

  .hist-search {
    width: 100%;
  }

  .hist-table-scroll {
    display: none;
  }

  .hist-mobile {
    display: block;
  }

  .hist-pager {
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hist-btn,
  .hist-row {
    transition: none;
  }
}

/* 500 / Internal Server Error — dashboard chrome, not a 404 page */
.error-500-page {
  --err-bg: #f8fafc;
  --err-card: #ffffff;
  --err-text: #111827;
  --err-muted: #64748b;
  --err-border: #e5e7eb;
  --err-blue: #2563eb;
  --err-blue-h: #1d4ed8;
  --err-dot: #ef4444;
  background: var(--err-bg);
  color: var(--err-text);
}

html[data-theme="dark"] .error-500-page {
  --err-bg: #0b1220;
  --err-card: #111827;
  --err-text: #f8fafc;
  --err-muted: #94a3b8;
  --err-border: rgba(255, 255, 255, 0.08);
  --err-blue: #3b82f6;
  --err-blue-h: #2563eb;
  --err-dot: #ef4444;
}

.error-500-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px clamp(16px, 4vw, 48px) 56px;
}

.error-500-card {
  width: min(100%, 560px);
  padding: clamp(28px, 4vw, 40px) clamp(24px, 4vw, 36px);
  border-radius: 18px;
  background: var(--err-card);
  border: 1px solid var(--err-border);
  box-shadow: var(--dash-shadow);
  text-align: center;
}

.error-500-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.error-500-mark .dash-logo {
  width: 40px;
  height: 40px;
}

.error-500-arc {
  display: block;
  margin: 4px auto 0;
  color: var(--err-blue);
}

.error-500-arc-track {
  stroke: var(--err-border);
}

.error-500-arc-line,
.error-500-spark {
  stroke: var(--err-blue);
}

.error-500-spark-break {
  stroke: var(--err-muted);
}

.error-500-arc-dot {
  fill: var(--err-dot);
}

.error-500-code {
  margin: 8px 0 4px;
  font-size: clamp(72px, 12vw, 110px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--err-text);
}

.error-500-title {
  margin: 0 0 10px;
  font-size: clamp(28px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--err-text);
}

.error-500-body {
  margin: 0 auto 24px;
  max-width: 36em;
  font-size: clamp(14px, 1.4vw, 16px);
  line-height: 1.5;
  color: var(--err-muted);
}

.error-500-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.error-500-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.error-500-btn--primary {
  background: var(--err-blue);
  color: #fff;
  border-color: var(--err-blue);
}

.error-500-btn--primary:hover {
  background: var(--err-blue-h);
  border-color: var(--err-blue-h);
}

.error-500-btn--secondary {
  background: var(--err-card);
  color: var(--err-text);
  border-color: var(--err-border);
}

.error-500-btn--secondary:hover {
  border-color: var(--err-blue);
  color: var(--err-blue);
}

.error-500-btn--ghost {
  background: transparent;
  color: var(--err-muted);
  border-color: transparent;
  min-width: 100%;
}

.error-500-btn--ghost:hover {
  color: var(--err-blue);
}

.error-500-btn:focus-visible {
  outline: 2px solid var(--err-blue);
  outline-offset: 3px;
}

.error-500-ref {
  margin: 18px 0 0;
  font-size: 0.75rem;
  color: var(--err-muted);
}

@media (max-width: 720px) {
  .error-500-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .error-500-btn {
    width: 100%;
  }

  .error-500-btn--ghost {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .error-500-btn {
    transition: none;
  }
}

.analysis-not-found {
  position: relative;
  min-height: 100vh;
}

.not-found-page {
  min-height: 100vh;
}

.not-found-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 64px;
}

.not-found-main .auth-alert {
  max-width: 480px;
  width: 100%;
  margin: 0 0 12px;
}

.not-found-page--unauth .not-found-main {
  padding-top: 88px;
}

.not-found-card {
  width: min(100%, 480px);
  padding: 36px 28px 32px;
  text-align: center;
  background: var(--dash-card);
  border: 1px solid #e5e7eb;
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow);
}

html[data-theme="dark"] .not-found-card {
  border-color: var(--dash-border);
}

.not-found-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
}

.not-found-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 132px;
  margin: 0 auto 4px;
}

.not-found-ring {
  position: absolute;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--dash-blue) 22%, transparent);
  pointer-events: none;
}

.not-found-ring::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--dash-blue) 16%, transparent);
}

.not-found-line {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--dash-blue) 30%, transparent) 45%,
    transparent
  );
  pointer-events: none;
}

.not-found-code {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(4.5rem, 8vw, 6.875rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--dash-blue);
  background: linear-gradient(180deg, var(--dash-blue-2), var(--dash-blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.not-found-title {
  margin: 0 0 10px;
  font-size: clamp(1.75rem, 3vw, 2.125rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--dash-text);
}

.not-found-copy {
  margin: 0 auto 28px;
  max-width: 450px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--dash-muted);
}

.not-found-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.not-found-actions .hist-btn {
  min-width: 168px;
  text-decoration: none;
}

.not-found-actions .hist-btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.not-found-actions .hist-btn--primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.not-found-actions .hist-btn:focus-visible {
  outline: 2px solid var(--dash-blue);
  outline-offset: 3px;
}

html[data-theme="dark"] .not-found-actions .hist-btn--primary {
  background: #3b82f6;
  border-color: #3b82f6;
}

html[data-theme="dark"] .not-found-actions .hist-btn--primary:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
}

@media (max-width: 720px) {
  .not-found-code {
    font-size: clamp(4rem, 18vw, 4.5rem);
  }

  .not-found-title {
    font-size: clamp(1.625rem, 5vw, 1.875rem);
  }

  .not-found-card {
    padding: 28px 20px 24px;
  }

  .not-found-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .not-found-actions .hist-btn {
    width: 100%;
    min-width: 0;
  }
}
