/*
 * Dashboard report composition
 * Final presentation layer for the reference-led finance workspace.
 */

:root {
  --report-bg: #f7f9fd;
  --report-panel: rgba(255, 255, 255, .96);
  --report-panel-soft: #f8faff;
  --report-line: #dfe6f1;
  --report-line-soft: #edf1f7;
  --report-ink: #081126;
  --report-muted: #65748f;
  --report-blue: #3159f5;
  --report-violet: #6338f2;
  --report-green: #0cba70;
  --report-red: #f3263c;
  --report-orange: #ff6811;
}

body,
.dashboard-shell,
.main {
  background:
    radial-gradient(circle at 66% 6%, rgba(84, 112, 255, .045), transparent 24rem),
    var(--report-bg);
}

.dashboard-shell {
  --assistant-rail-width: 440px;
}

.assistant-resizer {
  display: none;
}

@media (min-width: 1440px) {
  .dashboard-shell:has(.assistant-rail) {
    grid-template-columns: 224px minmax(0, 1fr) var(--assistant-rail-width);
  }

  .dashboard-shell.sidebar-collapsed:has(.assistant-rail) {
    grid-template-columns: 76px minmax(0, 1fr) var(--assistant-rail-width);
  }

  .assistant-rail:not(.collapsed) .assistant-resizer {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 12;
    display: flex;
    width: 12px;
    height: 100%;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    touch-action: none;
  }

  .assistant-resizer::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    content: "";
    background: #4265f5;
    opacity: 0;
    transition: opacity .16s ease;
  }

  .assistant-resizer span {
    width: 4px;
    height: 48px;
    border-radius: 999px;
    background: #c7d1e2;
    box-shadow: 0 2px 8px rgba(35, 58, 105, .12);
    opacity: .58;
    transition: width .16s ease, background .16s ease, opacity .16s ease, box-shadow .16s ease;
  }

  .assistant-resizer:hover::before,
  .assistant-resizer:focus-visible::before,
  .assistant-resizer.is-active::before {
    opacity: .72;
  }

  .assistant-resizer:hover span,
  .assistant-resizer:focus-visible span,
  .assistant-resizer.is-active span {
    width: 5px;
    background: #4265f5;
    box-shadow: 0 4px 14px rgba(49, 89, 245, .28);
    opacity: 1;
  }

  .assistant-resizer:focus-visible {
    outline: 2px solid rgba(49, 89, 245, .36);
    outline-offset: -2px;
  }
}

body.is-resizing-copilot,
body.is-resizing-copilot * {
  cursor: col-resize !important;
  user-select: none !important;
}

:root[data-theme="dark"] .assistant-resizer span {
  background: #34445d;
  box-shadow: 0 2px 9px rgba(0, 0, 0, .28);
}

:root[data-theme="dark"] .assistant-resizer:hover span,
:root[data-theme="dark"] .assistant-resizer:focus-visible span,
:root[data-theme="dark"] .assistant-resizer.is-active span {
  background: #6f8dff;
  box-shadow: 0 4px 16px rgba(70, 102, 245, .35);
}

.main {
  padding: 22px 24px 18px;
}

.topbar {
  margin-bottom: 18px;
}

.headline h1 {
  font-size: clamp(22px, 1.55vw, 28px);
  letter-spacing: -.045em;
}

.headline-wave {
  display: inline-block;
  margin-left: 2px;
  font-size: .86em;
  transform-origin: 70% 70%;
  animation: report-wave 2.8s ease-in-out 1;
}

@keyframes report-wave {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(12deg); }
  20%, 40% { transform: rotate(-7deg); }
}

.summary-grid {
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.metric-card.balance {
  position: relative;
  min-height: 170px;
  overflow: hidden;
  padding: 20px 18px 14px;
  color: var(--report-ink);
  border: 1px solid var(--report-line);
  border-top: 1px solid var(--report-line);
  border-radius: 15px;
  background: linear-gradient(150deg, rgba(255,255,255,.99), rgba(248,250,255,.96));
  box-shadow: 0 8px 26px rgba(35, 55, 94, .055), inset 0 1px 0 rgba(255,255,255,.9);
}

.metric-card::before,
.metric-card.balance::before,
.metric-card.income::before,
.metric-card.expense::before,
.metric-card.saving::before,
.metric-card.saving.is-negative::before {
  display: none;
}

.metric-card.balance {
  color: var(--report-ink);
  border-color: #f2d9df;
  background: linear-gradient(145deg, #fff 0%, #fff9fa 68%, #fff2f4 100%);
  box-shadow: 0 8px 28px rgba(207, 47, 78, .07), inset 0 1px 0 rgba(255,255,255,.95);
}

.metric-card.income {
  border-color: #d6ebe2;
  background: linear-gradient(145deg, #fff 0%, #f8fffb 68%, #f0fbf6 100%);
}

.metric-card.expense {
  border-color: #f0dfd0;
  background: linear-gradient(145deg, #fff 0%, #fffbf7 68%, #fff5ec 100%);
}

.metric-card.saving {
  border-color: #dbe1f2;
  border-top-color: #dbe1f2;
  background: linear-gradient(145deg, #fff 0%, #f8faff 68%, #f1f4ff 100%);
}

.metric-card.balance { border-top-color: #f2d9df; }
.metric-card.income { border-top-color: #d6ebe2; }
.metric-card.expense { border-top-color: #f0dfd0; }

.metric-card:hover,
.metric-card.balance:hover {
  border-color: #cfd9e8;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(32, 51, 88, .09), inset 0 1px 0 #fff;
}

.metric-card-main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 14px;
}

.metric-copy {
  min-width: 0;
}

.metric-card .metric-icon,
.metric-card.balance .metric-icon {
  position: static;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff7185, #f71945);
  box-shadow: 0 10px 20px rgba(244, 31, 69, .26), inset 0 1px 0 rgba(255,255,255,.45);
}

.metric-card.income .metric-icon {
  color: #fff;
  background: linear-gradient(145deg, #21d889, #05aa61);
  box-shadow: 0 10px 20px rgba(12, 186, 112, .22), inset 0 1px 0 rgba(255,255,255,.42);
}

.metric-card.expense .metric-icon {
  color: #fff;
  background: linear-gradient(145deg, #ff8c25, #ff5700);
  box-shadow: 0 10px 20px rgba(255, 104, 17, .22), inset 0 1px 0 rgba(255,255,255,.42);
}

.metric-card.saving .metric-icon,
.metric-card.saving.is-negative .metric-icon {
  color: #fff;
  background: linear-gradient(145deg, #4d7cff, #253fe8);
  box-shadow: 0 10px 20px rgba(49, 89, 245, .23), inset 0 1px 0 rgba(255,255,255,.42);
}

.metric-icon svg {
  width: 27px;
  height: 27px;
  stroke-width: 1.9;
}

.metric-card label,
.metric-card.balance label {
  display: block;
  margin: 2px 0 6px;
  color: #18223a;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.metric-card h2,
.metric-card.balance h2 {
  margin: 0;
  color: var(--report-ink);
  font-size: clamp(22px, 1.55vw, 27px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.035em;
  white-space: nowrap;
  text-shadow: none;
}

.metric-card.balance h2,
.metric-card.expense h2,
.metric-card.is-negative h2 {
  color: var(--report-red);
}

.metric-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 9px;
  color: var(--report-muted);
  font-size: 9px;
  white-space: nowrap;
}

.metric-trend svg {
  width: 11px;
  height: 11px;
  stroke-width: 2.5;
}

.metric-trend b {
  font-size: 10px;
}

.metric-trend small {
  color: #3e4b65;
  font-size: 9px;
}

.metric-trend.positive { color: var(--report-green); }
.metric-trend.negative { color: var(--report-red); }

.metric-direction {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
}

.metric-direction svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.metric-direction.positive {
  color: var(--report-green);
  background: #e6f8ef;
}

.metric-direction.negative {
  color: var(--report-red);
  background: #ffeaed;
}

.metric-card .sparkline {
  right: 18px;
  bottom: 9px;
  left: 18px;
  z-index: 1;
  height: 42px;
  opacity: 1;
}

.metric-card .sparkline polyline {
  stroke-width: 2;
  filter: drop-shadow(0 3px 4px rgba(24, 45, 82, .1));
}

.panel {
  box-sizing: border-box;
  border-color: var(--report-line);
  border-radius: 14px;
  background: var(--report-panel);
  box-shadow: 0 7px 24px rgba(36, 55, 91, .05), inset 0 1px 0 rgba(255,255,255,.9);
}

.panel:hover {
  border-color: #d4ddea;
  box-shadow: 0 11px 29px rgba(36, 55, 91, .075), inset 0 1px 0 rgba(255,255,255,.95);
}

.panel-head h3,
.panel h3 {
  color: var(--report-ink);
  font-size: 14px;
  font-weight: 800;
}

.budget-panel {
  align-items: stretch;
  background:
    radial-gradient(circle at 72% 65%, rgba(99,56,242,.09), transparent 42%),
    linear-gradient(145deg, #fff, #fbfaff);
}

.budget-panel .panel-head {
  width: 100%;
}

.panel-menu {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0 0 5px;
  color: #34425c;
  border: 1px solid var(--report-line);
  border-radius: 50%;
  background: rgba(255,255,255,.88);
  box-shadow: 0 3px 9px rgba(30,47,80,.08);
  font-size: 13px;
  letter-spacing: 1px;
}

.budget-ring {
  width: 120px;
  height: 120px;
  margin: 0 auto 8px;
  padding: 10px;
  background: conic-gradient(from 18deg, #7357ff 0, #263fe8 var(--budget), #e7e8f5 0);
  box-shadow: 0 9px 22px rgba(70, 66, 220, .13), inset 0 0 0 1px rgba(83,72,232,.08);
}

.budget-ring::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  top: 7px;
  right: 40px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #9a8aff;
  box-shadow: 0 3px 9px rgba(80,61,210,.28);
}

.budget-ring .inner {
  background: rgba(255,255,255,.96);
}

.spending-panel {
  padding-bottom: 10px;
}

.spending-report {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 120px;
}

.spending-donut {
  display: grid;
  width: 110px;
  height: 110px;
  place-items: center;
  padding: 12px;
  border-radius: 50%;
  background: var(--segments);
  box-shadow: 0 7px 20px rgba(40,61,106,.08);
}

.spending-donut > div {
  display: grid;
  width: 100%;
  height: 100%;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(218,225,238,.8);
}

.spending-donut b {
  color: var(--report-ink);
  font-size: 15px;
  letter-spacing: -.03em;
}

.spending-donut span {
  margin-top: 2px;
  color: var(--report-muted);
  font-size: 9px;
}

.category-legend {
  display: grid;
  gap: 7px;
}

.category-line {
  display: grid;
  grid-template-columns: 20px minmax(52px, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: #253149;
  font-size: 10px;
}

.category-line > i {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  color: #fff;
  border-radius: 6px;
  background: var(--tone);
}

.category-line > i svg {
  width: 11px;
  height: 11px;
  stroke-width: 2.1;
}

.category-line label {
  min-width: 0;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.category-line b {
  color: #35415a;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.category-line b small {
  color: #79869d;
  font-size: 8px;
  font-weight: 550;
}

.panel-footer-link {
  color: #2947df;
}

.transactions-panel {
  overflow: hidden;
}

.transactions tbody tr {
  transition: background .15s ease;
}

.transactions tbody tr:hover td {
  background: #f7f9fe;
}

.assistant-rail {
  background:
    radial-gradient(circle at 62% 38%, rgba(91,89,255,.035), transparent 22rem),
    #fff;
}

.assistant-rail-header {
  min-height: 86px;
}

.assistant-alert {
  border-color: #d9ddff;
  background: linear-gradient(145deg, #fafaff, #f5f6ff);
}

.large-chart,
.budget-panel {
  min-height: 237px;
}

.spending-panel,
.financial-health,
.insights-panel {
  min-height: 226px;
}

.insight-list {
  gap: 6px;
}

.insight-item {
  min-height: 38px;
  padding-block: 5px;
}

@media (min-width: 721px) {
  .sidebar .nav button {
    color: #40516e;
    border: 0;
  }

  .sidebar .nav button:hover:not(.active) {
    color: #20365b;
    background: #f3f6fb;
  }

  .sidebar .nav {
    gap: 3px;
  }

  .sidebar .nav button {
    min-height: 39px;
  }

  .sidebar .nav button svg {
    width: 17px;
    height: 17px;
  }

  .nav-label {
    margin-top: 17px;
  }

  .sidebar-promo {
    display: none;
  }

  .theme-switch {
    bottom: 141px;
  }

  .sidebar .profile-card {
    bottom: 54px;
  }
}

@media (min-width: 1280px) and (min-height: 920px) {
  .sidebar-promo {
    display: block;
    bottom: 203px;
  }

  .sidebar-promo img {
    height: 218px;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: top;
  }
}

:root[data-theme="dark"] {
  --report-bg: #050d19;
  --report-panel: rgba(10, 21, 35, .96);
  --report-panel-soft: #0d1a2b;
  --report-line: #233146;
  --report-line-soft: #18263a;
  --report-ink: #f2f5fb;
  --report-muted: #91a0b7;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .dashboard-shell,
:root[data-theme="dark"] .main {
  background:
    radial-gradient(circle at 68% 8%, rgba(49,89,245,.06), transparent 27rem),
    var(--report-bg);
}

:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .metric-card.balance {
  color: var(--report-ink);
  border-color: var(--report-line);
  background: linear-gradient(150deg, #0c1726 0%, #091320 100%);
  box-shadow: 0 8px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.025);
}

:root[data-theme="dark"] .metric-card.balance {
  border-color: #3a2939;
  background: linear-gradient(145deg, #101825, #16131e);
}

:root[data-theme="dark"] .metric-card.income {
  border-color: #1e3a34;
  background: linear-gradient(145deg, #0c1726, #0a1b19);
}

:root[data-theme="dark"] .metric-card.expense {
  border-color: #3a3028;
  background: linear-gradient(145deg, #0c1726, #1b1511);
}

:root[data-theme="dark"] .metric-card.saving {
  border-color: #263451;
  background: linear-gradient(145deg, #0c1726, #0d152a);
}

:root[data-theme="dark"] .metric-card label,
:root[data-theme="dark"] .metric-card.balance label,
:root[data-theme="dark"] .metric-trend small {
  color: #c6d0df;
}

:root[data-theme="dark"] .metric-card h2,
:root[data-theme="dark"] .metric-card.balance h2 {
  color: #f3f6fb;
}

:root[data-theme="dark"] .metric-card.balance h2,
:root[data-theme="dark"] .metric-card.expense h2,
:root[data-theme="dark"] .metric-card.is-negative h2 {
  color: #ff6677;
}

:root[data-theme="dark"] .metric-direction.positive {
  color: #34d990;
  background: rgba(12,186,112,.13);
}

:root[data-theme="dark"] .metric-direction.negative {
  color: #ff6677;
  background: rgba(243,38,60,.14);
}

:root[data-theme="dark"] .metric-card .metric-icon,
:root[data-theme="dark"] .metric-card.balance .metric-icon,
:root[data-theme="dark"] .metric-card.income .metric-icon,
:root[data-theme="dark"] .metric-card.expense .metric-icon,
:root[data-theme="dark"] .metric-card.saving .metric-icon,
:root[data-theme="dark"] .metric-card.saving.is-negative .metric-icon {
  color: #fff;
  border-radius: 50%;
}

:root[data-theme="dark"] .metric-card.balance .metric-icon {
  background: linear-gradient(145deg, #ff667c, #df183f);
  box-shadow: 0 10px 22px rgba(225,24,63,.22), inset 0 1px 0 rgba(255,255,255,.28);
}

:root[data-theme="dark"] .metric-card.income .metric-icon {
  background: linear-gradient(145deg, #19ce81, #058f55);
  box-shadow: 0 10px 22px rgba(5,143,85,.2), inset 0 1px 0 rgba(255,255,255,.25);
}

:root[data-theme="dark"] .metric-card.expense .metric-icon {
  background: linear-gradient(145deg, #ff8a23, #e74c00);
  box-shadow: 0 10px 22px rgba(231,76,0,.2), inset 0 1px 0 rgba(255,255,255,.25);
}

:root[data-theme="dark"] .metric-card.saving .metric-icon,
:root[data-theme="dark"] .metric-card.saving.is-negative .metric-icon {
  background: linear-gradient(145deg, #4d77ff, #263ad3);
  box-shadow: 0 10px 22px rgba(38,58,211,.22), inset 0 1px 0 rgba(255,255,255,.25);
}

:root[data-theme="dark"] .panel {
  border-color: var(--report-line);
  background: linear-gradient(155deg, #0c1726, #08121e);
  box-shadow: 0 8px 28px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.02);
}

:root[data-theme="dark"] .panel:hover {
  border-color: #304159;
  box-shadow: 0 12px 34px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.03);
}

:root[data-theme="dark"] .panel-head h3,
:root[data-theme="dark"] .panel h3,
:root[data-theme="dark"] .spending-donut b {
  color: var(--report-ink);
}

:root[data-theme="dark"] .budget-panel {
  background:
    radial-gradient(circle at 72% 65%, rgba(99,56,242,.12), transparent 44%),
    linear-gradient(145deg, #0c1726, #0b1424);
}

:root[data-theme="dark"] .panel-menu {
  color: #cbd5e4;
  border-color: #29384e;
  background: #101d2e;
}

:root[data-theme="dark"] .budget-ring {
  background: conic-gradient(from 18deg, #7b61ff 0, #3249f0 var(--budget), #263248 0);
  box-shadow: 0 10px 25px rgba(43,45,180,.18);
}

:root[data-theme="dark"] .budget-ring .inner,
:root[data-theme="dark"] .spending-donut > div {
  background: #0b1725;
}

:root[data-theme="dark"] .budget-ring::after {
  border-color: #c9c7ff;
  background: #8f7cff;
}

:root[data-theme="dark"] .spending-donut > div {
  box-shadow: inset 0 0 0 1px #253349;
}

:root[data-theme="dark"] .spending-donut span,
:root[data-theme="dark"] .category-line b small {
  color: #8493aa;
}

:root[data-theme="dark"] .category-line,
:root[data-theme="dark"] .category-line b {
  color: #cbd5e4;
}

:root[data-theme="dark"] .transactions tbody tr:hover td {
  background: #101d2e;
}

:root[data-theme="dark"] .assistant-rail {
  background:
    radial-gradient(circle at 55% 38%, rgba(78,80,238,.07), transparent 21rem),
    #07111d;
}

:root[data-theme="dark"] .sidebar .nav button {
  color: #aebbd0;
}

:root[data-theme="dark"] .sidebar .nav button:hover:not(.active) {
  color: #f2f6ff;
  background: rgba(255,255,255,.055);
}

@media (max-width: 1350px) {
  .metric-card-main {
    grid-template-columns: 48px minmax(0, 1fr) 27px;
    gap: 10px;
  }

  .metric-card .metric-icon,
  .metric-card.balance .metric-icon {
    width: 48px;
    height: 48px;
  }

  .metric-icon svg {
    width: 23px;
    height: 23px;
  }

  .metric-trend small {
    display: none;
  }

  .spending-report {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .spending-donut {
    width: 104px;
    height: 104px;
  }
}

@media (max-width: 1080px) {
  .metric-card,
  .metric-card.balance {
    min-height: 156px;
  }
}

@media (max-width: 720px) {
  .ai-modal .ai-chat {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  .ai-modal .ai-chat-scroll {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  .ai-modal .ai-chat-scroll .ai-chat-messages {
    overflow: visible !important;
    max-height: none !important;
  }

  .ai-modal .assistant-rail-form,
  .ai-modal .ai-chat-form {
    margin-top: auto !important;
    padding-bottom: max(4px, env(safe-area-inset-bottom)) !important;
  }

  .main {
    padding: 28px 14px 96px;
  }

  .sidebar .nav {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .sidebar .nav::-webkit-scrollbar {
    display: none;
  }

  .headline h1 {
    font-size: 25px;
  }

  .summary-grid {
    gap: 12px;
  }

  .metric-card,
  .metric-card.balance {
    min-height: 158px;
    padding: 17px 15px 12px;
  }

  .metric-card-main {
    grid-template-columns: 48px minmax(0, 1fr) 28px;
  }

  .metric-card .metric-icon,
  .metric-card.balance .metric-icon {
    width: 48px;
    height: 48px;
  }

  .metric-trend small {
    display: inline;
  }

  .spending-report {
    grid-template-columns: 124px minmax(0, 1fr);
  }

  .spending-donut {
    width: 118px;
    height: 118px;
  }

  .budget-ring {
    width: 126px;
    height: 126px;
  }
}

@media (max-width: 420px) {
  .headline h1 {
    font-size: 23px;
  }

  .metric-card-main {
    grid-template-columns: 44px minmax(0, 1fr) 26px;
    gap: 9px;
  }

  .metric-card .metric-icon,
  .metric-card.balance .metric-icon {
    width: 44px;
    height: 44px;
  }

  .metric-card h2,
  .metric-card.balance h2 {
    font-size: 21px;
  }

  .metric-trend small {
    display: none;
  }

  .spending-report {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .category-legend {
    width: 100%;
  }
}

/* Mobile app shell — reference-matched light and dark dashboard. */
.mobile-dashboard-header,
.mobile-menu-backdrop,
.mobile-finance-composer,
.mobile-bottom-nav,
.mobile-budget-link,
.mobile-transaction-meta,
.tx-title > i {
  display: none;
}

@media (max-width: 720px) {
  :root {
    --mobile-bg: #ffffff;
    --mobile-surface: #ffffff;
    --mobile-surface-soft: #f8faff;
    --mobile-line: #e1e7f0;
    --mobile-ink: #0a1020;
    --mobile-muted: #536078;
  }

  html,
  body {
    min-width: 320px;
    background: var(--mobile-bg);
  }

  body {
    padding: 0;
  }

  .dashboard-shell,
  .main {
    background: var(--mobile-bg);
  }

  .dashboard-shell {
    display: block;
    min-height: 100dvh;
  }

  .main {
    width: 100%;
    padding: 0 16px calc(164px + env(safe-area-inset-bottom));
  }

  .topbar,
  .assistant-rail,
  .floating-ai {
    display: none !important;
  }

  /* Off-canvas desktop navigation behind the mobile menu button. */
  .dashboard-shell .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 110;
    display: flex;
    width: min(82vw, 310px);
    height: 100dvh;
    flex-direction: column;
    padding: max(22px, env(safe-area-inset-top)) 16px 18px;
    overflow-y: auto;
    border-right: 1px solid var(--mobile-line);
    background: rgba(255,255,255,.98);
    box-shadow: 24px 0 60px rgba(20,38,76,.2);
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform .24s ease, visibility .24s ease;
  }

  .dashboard-shell.mobile-menu-open .sidebar {
    visibility: visible;
    transform: translateX(0);
  }

  .dashboard-shell .sidebar .brand {
    display: flex;
    min-height: 52px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
  }

  .dashboard-shell .sidebar .brand strong,
  .dashboard-shell .sidebar .brand span,
  .dashboard-shell .sidebar .nav span,
  .dashboard-shell .sidebar .pill-new,
  .dashboard-shell .sidebar .profile-card {
    display: flex;
  }

  .dashboard-shell .sidebar .brand strong {
    display: block;
    color: #15213a;
  }

  .dashboard-shell .sidebar .nav {
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 0;
    overflow: visible;
  }

  .dashboard-shell .sidebar .nav button {
    min-width: 0;
    min-height: 46px;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 14px;
    color: #15213a;
    background: transparent;
    border-color: transparent;
  }

  .dashboard-shell .sidebar .nav button svg {
    color: #29456f;
    stroke: currentColor;
  }

  .dashboard-shell .sidebar .nav button.active {
    color: #fff;
    background: linear-gradient(135deg, #3158f6, #5540e8);
    border-color: transparent;
  }

  .dashboard-shell .sidebar .nav button.active svg {
    color: #fff;
  }

  .dashboard-shell .sidebar .theme-switch {
    position: relative;
    inset: auto;
    width: 118px;
    min-height: 38px;
    align-self: center;
    margin-top: auto;
    padding: 4px;
    gap: 2px;
    border-radius: 20px;
  }

  .dashboard-shell .sidebar .theme-switch button {
    width: 52px;
    height: 30px;
    padding: 0;
  }

  .dashboard-shell .sidebar .theme-switch button span {
    display: none;
  }

  .dashboard-shell .sidebar .profile-card {
    position: relative;
    inset: auto;
    width: 100%;
    margin-top: 10px;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: block;
    border: 0;
    background: rgba(5,12,27,.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  /* A dialog owns the viewport; persistent controls must never cover it. */
  body.dashboard-modal-open .mobile-finance-composer,
  body.dashboard-modal-open .mobile-bottom-nav {
    display: none !important;
  }

  .mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile status, menu, greeting, and quick actions. */
  .mobile-dashboard-header {
    display: block;
    padding: 4px 4px 2px;
    color: var(--mobile-ink);
  }

  .mobile-statusbar,
  .mobile-quickbar,
  .mobile-device-status,
  .mobile-signal {
    display: flex;
    align-items: center;
  }

  /* The dashboard is rendered edge-to-edge in the app shell; the simulated
     phone status strip only consumes valuable report space on mobile. */
  .mobile-statusbar {
    display: none;
  }

  .mobile-statusbar {
    min-height: 20px;
    justify-content: space-between;
    padding: 0 7px;
  }

  .mobile-statusbar > b {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.02em;
  }

  .mobile-device-status {
    gap: 9px;
  }

  .mobile-signal {
    height: 14px;
    align-items: flex-end;
    gap: 2px;
  }

  .mobile-signal em {
    width: 3px;
    border-radius: 2px;
    background: currentColor;
  }

  .mobile-signal em:nth-child(1) { height: 5px; }
  .mobile-signal em:nth-child(2) { height: 8px; }
  .mobile-signal em:nth-child(3) { height: 11px; }
  .mobile-signal em:nth-child(4) { height: 14px; }

  .mobile-wifi {
    position: relative;
    width: 17px;
    height: 12px;
    overflow: hidden;
    border-top: 3px solid currentColor;
    border-radius: 50% 50% 0 0;
  }

  .mobile-wifi::before,
  .mobile-wifi::after {
    position: absolute;
    left: 50%;
    content: "";
    transform: translateX(-50%);
  }

  .mobile-wifi::before {
    top: 3px;
    width: 9px;
    height: 6px;
    border-top: 2px solid currentColor;
    border-radius: 50% 50% 0 0;
  }

  .mobile-wifi::after {
    bottom: 0;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
  }

  .mobile-battery {
    position: relative;
    width: 23px;
    height: 11px;
    border: 2px solid currentColor;
    border-radius: 3px;
  }

  .mobile-battery::before {
    position: absolute;
    inset: 1px;
    content: "";
    border-radius: 1px;
    background: currentColor;
  }

  .mobile-battery::after {
    position: absolute;
    top: 2px;
    right: -4px;
    width: 2px;
    height: 5px;
    content: "";
    border-radius: 0 2px 2px 0;
    background: currentColor;
  }

  .mobile-quickbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
    margin: -4px -4px 12px -4px;
  }

  .mobile-brand-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  }

  .mobile-brand-title img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 50%;
  }

  .mobile-brand-title span {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .mobile-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-menu-button,
  .mobile-notice-button,
  .mobile-copilot-button {
    display: grid;
    place-items: center;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    background: #ffffff;
    cursor: pointer;
  }

  .mobile-menu-button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    transition: transform .18s ease, background .18s ease;
  }

  .mobile-menu-button:active {
    transform: scale(.94);
    background: #f1f5f9;
  }

  .mobile-menu-button svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
    color: #334155;
  }

  .mobile-notice-button {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    transition: transform .18s ease, background .18s ease;
  }

  .mobile-notice-button:active {
    transform: scale(.94);
    background: #f1f5f9;
  }

  .mobile-notice-button svg {
    width: 20px;
    height: 20px;
    color: #334155;
  }

  .mobile-notice-button b {
    position: absolute;
    top: 2px;
    right: 2px;
    display: grid;
    width: 17px;
    height: 17px;
    place-items: center;
    border: 2px solid #ffffff;
    border-radius: 50%;
    color: #ffffff;
    background: #ef4444;
    font-size: 9px;
    font-weight: 800;
    box-shadow: 0 0 8px rgba(239, 68, 68, .5);
  }

  .mobile-copilot-button {
    width: 40px;
    height: 40px;
    overflow: hidden;
    border-radius: 12px;
    border-color: #bfdbfe;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.15);
    transition: transform .18s ease;
  }

  .mobile-copilot-button:active {
    transform: scale(.94);
  }

  .mobile-copilot-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.15);
  }

  :root[data-theme="dark"] .mobile-quickbar {
    background: rgba(15, 23, 42, 0.94);
    border-bottom-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  }

  :root[data-theme="dark"] .mobile-brand-title {
    background: rgba(15, 23, 42, 0.85);
    border-color: #334155;
  }

  :root[data-theme="dark"] .mobile-brand-title span {
    background: linear-gradient(135deg, #f8fafc 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  :root[data-theme="dark"] .mobile-menu-button,
  :root[data-theme="dark"] .mobile-notice-button {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
  }

  :root[data-theme="dark"] .mobile-menu-button svg,
  :root[data-theme="dark"] .mobile-notice-button svg {
    color: #cbd5e1;
  }

  :root[data-theme="dark"] .mobile-notice-button b {
    border-color: #1e293b;
  }

  :root[data-theme="dark"] .mobile-copilot-button {
    background: #1e293b;
    border-color: #3b82f6;
  }

  .mobile-greeting {
    padding: 1px 2px 0;
  }

  .mobile-greeting h1 {
    margin: 0;
    color: var(--mobile-ink);
    font-size: clamp(23px, 6.4vw, 27px);
    font-weight: 820;
    letter-spacing: -.045em;
    line-height: 1.04;
  }

  .mobile-greeting h1 span {
    display: inline-block;
    margin-left: 3px;
    font-size: .9em;
  }

  .mobile-greeting p {
    margin: 4px 0 12px;
    color: var(--mobile-muted);
    font-size: 12.5px;
  }

  /* Dense 2x2 metric composition. */
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
  }

  .metric-card,
  .metric-card.balance {
    min-height: 108px;
    padding: 11px 9px 8px;
    overflow: hidden;
    border: 1px solid var(--mobile-line);
    border-radius: 12px;
    background: var(--mobile-surface);
    box-shadow: 0 5px 18px rgba(22,39,78,.045);
  }

  .metric-card::before,
  .metric-card.balance::before {
    display: none;
  }

  .metric-card-main {
    grid-template-columns: 40px minmax(0, 1fr) 24px;
    gap: 7px;
  }

  .metric-card .metric-icon,
  .metric-card.balance .metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }

  .metric-icon svg {
    width: 21px;
    height: 21px;
  }

  .metric-card label,
  .metric-card.balance label {
    color: var(--mobile-ink);
    font-size: 10px;
    font-weight: 720;
    letter-spacing: 0;
    text-transform: none;
  }

  .metric-card h2,
  .metric-card.balance h2 {
    margin-top: 3px;
    color: var(--mobile-ink);
    font-size: clamp(17px, 4.8vw, 21px);
    font-weight: 800;
    text-shadow: none;
  }

  .metric-trend {
    gap: 2px;
    margin-top: 4px;
    white-space: nowrap;
  }

  .metric-trend svg {
    width: 11px;
    height: 11px;
  }

  .metric-trend b {
    font-size: 9px;
  }

  .metric-trend small {
    display: inline;
    color: var(--mobile-muted);
    font-size: 8px;
  }

  .metric-direction {
    width: 24px;
    height: 24px;
  }

  .metric-direction svg {
    width: 15px;
    height: 15px;
  }

  .metric-card .sparkline {
    right: 9px;
    bottom: 7px;
    left: 9px;
    height: 26px;
  }

  /* Two-column report layout matching the mobile references. */
  .content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .content-grid .panel {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--mobile-line);
    border-radius: 12px;
    background: var(--mobile-surface);
    box-shadow: 0 5px 18px rgba(22,39,78,.04);
  }

  .content-grid .panel:hover,
  .metric-card:hover {
    transform: none;
  }

  .panel-head {
    margin-bottom: 7px;
  }

  .panel-head h3,
  .panel h3 {
    color: var(--mobile-ink);
    font-size: 13px;
    font-weight: 780;
  }

  .large-chart {
    grid-column: 1 / -1 !important;
    order: 1;
    height: 136px;
    min-height: 136px;
    padding: 8px 10px 6px !important;
    overflow: hidden;
  }

  .large-chart .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    gap: 8px;
  }

  .large-chart .panel-head h3 {
    width: auto;
    flex: 0 0 auto;
    text-align: left;
  }

  .large-chart .chart-tools {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    margin-left: auto;
  }

  .chart-tools,
  .legend {
    gap: 7px;
  }

  .legend span {
    gap: 3px;
    font-size: 8px;
  }

  .legend i {
    width: 10px;
  }

  .period-select {
    min-height: 28px;
    padding: 0 24px 0 8px;
    font-size: 9px;
  }

  .income-expense-chart {
    height: 88px;
    margin-top: 0;
  }

  .income-expense-chart svg {
    height: 70px;
  }

  .chart-y-axis,
  .chart-x-axis {
    font-size: 8px;
  }

  .spending-panel {
    grid-column: 1;
    order: 2;
    min-height: 172px;
    height: auto;
    padding: 10px !important;
  }

  .budget-panel {
    grid-column: 2;
    order: 3;
    min-height: 172px;
    height: auto;
    padding: 10px !important;
    display: flex;
    flex-direction: column;
  }

  .financial-health {
    display: none;
  }

  .spending-report {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }

  .spending-donut {
    width: 78px;
    height: 78px;
    padding: 6px;
  }

  .spending-donut > div {
    width: 100%;
    height: 100%;
    padding: 2px;
  }

  .spending-donut b {
    font-size: 10px;
    line-height: 1.1;
  }

  .spending-donut span {
    font-size: 7.5px;
    margin-top: 1px;
  }

  .category-legend {
    gap: 3px;
  }

  .category-line {
    grid-template-columns: 17px minmax(0, 1fr) auto;
    gap: 4px;
    font-size: 8.5px;
  }

  .category-line > i {
    width: 17px;
    height: 17px;
    border-radius: 4px;
  }

  .category-line > i svg {
    width: 10px;
    height: 10px;
  }

  .category-line b {
    font-size: 0;
  }

  .category-line b small {
    color: var(--mobile-ink);
    font-size: 8.5px;
  }

  .category-paren {
    display: none;
  }

  .spending-panel .panel-footer-link,
  .mobile-budget-link {
    display: flex;
    min-height: 22px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid var(--mobile-line);
    color: #3658f5;
    font-size: 9px;
  }

  .mobile-budget-link svg {
    width: 12px;
    height: 12px;
  }

  .budget-panel .panel-head {
    width: 100%;
  }

  .budget-panel .panel-menu {
    display: none;
  }

  .budget-ring {
    width: 68px;
    height: 68px;
    margin: 0 auto 3px;
    flex: 0 0 68px;
  }

  .budget-ring::after {
    display: none;
  }

  .budget-ring .inner {
    inset: 8px;
  }

  .budget-ring b {
    font-size: 16px;
  }

  .budget-ring span {
    font-size: 9px;
  }

  .budget-total,
  .budget-over {
    font-size: 9px;
  }

  .budget-over {
    margin-bottom: 3px;
  }

  .insights-panel {
    grid-column: 1;
    order: 4;
    height: 148px;
    min-height: 148px;
    overflow: hidden;
    padding: 7px !important;
  }

  .transactions-panel {
    grid-column: 2;
    order: 5;
    height: 148px;
    min-height: 148px;
    overflow: hidden;
    padding: 7px !important;
  }

  .insight-list {
    gap: 3px;
  }

  .insight-item {
    grid-template-columns: 25px minmax(0, 1fr) 12px;
    min-height: 27px;
    gap: 5px;
    padding: 2px 5px;
    border-radius: 8px;
  }

  .insight-item > i {
    width: 23px;
    height: 23px;
    border-radius: 7px;
  }

  .insight-item > i svg,
  .insight-item > svg {
    width: 12px;
    height: 12px;
  }

  .insight-item b {
    overflow: hidden;
    font-size: 8.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .insights-panel > .panel-footer-link {
    display: none;
  }

  .transactions-panel .panel-head {
    margin-bottom: 2px;
    flex-wrap: nowrap;
  }

  .transactions-panel .panel-head h3 {
    font-size: 12px;
    white-space: nowrap;
  }

  .transactions-panel .panel-link {
    color: #3658f5;
    font-size: 8.5px;
  }

  .transactions-wrap {
    overflow: visible;
  }

  .transactions,
  .transactions tbody {
    display: block;
    width: 100%;
  }

  .transactions thead,
  .transactions td {
    display: none;
  }

  .transactions tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    height: 29px;
    min-height: 29px;
    padding: 0 !important;
    border-bottom: 1px solid var(--mobile-line);
    background: transparent !important;
  }

  .transactions tbody tr:last-child {
    border-bottom: 0;
  }

  .transactions td:nth-child(2),
  .transactions td:nth-child(5) {
    display: block;
    padding: 0;
    border: 0;
  }

  .transactions td:nth-child(5) {
    color: #f3263c;
    font-size: 9px;
    font-weight: 750;
    white-space: nowrap;
  }

  .tx-title {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .tx-title > i {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 7px;
    color: var(--tone);
    background: var(--tone-bg);
  }

  .tx-title > i svg {
    width: 13px;
    height: 13px;
  }

  .tx-title b {
    display: block;
    overflow: hidden;
    color: var(--mobile-ink);
    font-size: 8.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-transaction-meta {
    display: block;
    margin-top: 1px;
    overflow: hidden;
    color: var(--mobile-muted);
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Persistent Finance Copilot composer and five-item bottom nav. */
  .mobile-finance-composer,
  .mobile-bottom-nav {
    position: fixed;
    right: 16px;
    left: 16px;
    z-index: 80;
    display: grid;
    border: 1px solid var(--mobile-line);
    background: rgba(255,255,255,.95);
    box-shadow: 0 12px 35px rgba(24,42,86,.12);
    backdrop-filter: blur(18px);
  }

  body.finance-copilot-open .mobile-finance-composer,
  body.finance-copilot-open .mobile-bottom-nav {
    display: none !important;
  }

  .mobile-finance-composer {
    bottom: calc(74px + env(safe-area-inset-bottom));
    grid-template-columns: 45px minmax(0, 1fr) 40px 40px;
    min-height: 56px;
    align-items: center;
    gap: 5px;
    padding: 6px;
    border-radius: 22px;
  }

  .mobile-composer-bot {
    width: 43px;
    height: 43px;
    overflow: hidden;
    border: 0;
    border-radius: 13px;
    background: transparent;
  }

  .mobile-composer-bot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.2);
  }

  .mobile-finance-composer textarea {
    width: 100%;
    height: 42px;
    min-height: 42px;
    padding: 11px 5px;
    border: 0;
    outline: 0;
    color: var(--mobile-ink);
    background: transparent;
    font: inherit;
    font-size: 13px;
    line-height: 20px;
    resize: none;
  }

  .mobile-finance-composer textarea::placeholder {
    color: #7d8aa0;
  }

  .mobile-composer-action {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid #d9ece6;
    border-radius: 50%;
    color: #07b96e;
    background: transparent;
  }

  .mobile-composer-action svg {
    width: 20px;
    height: 20px;
  }

  .mobile-bottom-nav {
    bottom: calc(8px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 64px;
    align-items: center;
    padding: 4px 5px;
    border-radius: 14px;
  }

  .mobile-bottom-nav button {
    display: flex;
    min-width: 0;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 0;
    color: #5f6980;
    background: transparent;
    font-size: 9px;
  }

  .mobile-bottom-nav button svg {
    width: 21px;
    height: 21px;
  }

  .mobile-bottom-nav button.active {
    color: #4149f4;
  }

  .mobile-bottom-nav .mobile-add-button {
    width: 54px;
    height: 54px;
    min-height: 54px;
    justify-self: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #6678ff 0%, #4d3cf4 55%, #3930d7 100%);
    box-shadow: 0 10px 24px rgba(65,63,241,.34), 0 0 0 4px rgba(99,102,241,.1);
    transition: transform .18s ease, box-shadow .18s ease;
    transform: translateY(-7px);
  }

  .mobile-bottom-nav .mobile-add-button:active {
    transform: translateY(-7px) scale(.94);
    box-shadow: 0 6px 16px rgba(65,63,241,.3), 0 0 0 3px rgba(99,102,241,.08);
  }

  .mobile-bottom-nav .mobile-add-button svg {
    width: 27px;
    height: 27px;
  }

  /* Dark mobile theme. */
  :root[data-theme="dark"] {
    --mobile-bg: #030a16;
    --mobile-surface: #071321;
    --mobile-surface-soft: #0a1727;
    --mobile-line: #1a2b40;
    --mobile-ink: #f4f7fc;
    --mobile-muted: #aab5c7;
  }

  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .dashboard-shell,
  :root[data-theme="dark"] .main {
    background:
      radial-gradient(circle at 84% 83%, rgba(55,55,220,.16), transparent 18rem),
      linear-gradient(180deg, #020713 0%, #030a16 62%, #071226 100%);
  }

  :root[data-theme="dark"] .dashboard-shell .sidebar {
    border-color: var(--mobile-line);
    background: rgba(5,14,26,.98);
  }

  :root[data-theme="dark"] .mobile-menu-button,
  :root[data-theme="dark"] .mobile-notice-button,
  :root[data-theme="dark"] .mobile-copilot-button {
    color: var(--mobile-ink);
    border-color: var(--mobile-line);
    background: #071321;
  }

  :root[data-theme="dark"] .mobile-notice-button {
    border-color: transparent var(--mobile-line) transparent transparent;
  }

  :root[data-theme="dark"] .metric-card,
  :root[data-theme="dark"] .metric-card.balance,
  :root[data-theme="dark"] .content-grid .panel {
    border-color: var(--mobile-line);
    background: linear-gradient(145deg, #071321, #081729);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.018), 0 8px 24px rgba(0,0,0,.18);
  }

  :root[data-theme="dark"] .metric-card h2,
  :root[data-theme="dark"] .metric-card.balance h2,
  :root[data-theme="dark"] .metric-card label,
  :root[data-theme="dark"] .metric-card.balance label,
  :root[data-theme="dark"] .panel-head h3,
  :root[data-theme="dark"] .panel h3,
  :root[data-theme="dark"] .category-line b small,
  :root[data-theme="dark"] .tx-title b {
    color: var(--mobile-ink);
  }

  :root[data-theme="dark"] .large-chart {
    background: linear-gradient(145deg, #061321, #07182a);
  }

  :root[data-theme="dark"] .mobile-finance-composer,
  :root[data-theme="dark"] .mobile-bottom-nav {
    border-color: #21344e;
    background: rgba(5,16,30,.94);
    box-shadow: 0 14px 38px rgba(0,0,0,.34);
  }

  :root[data-theme="dark"] .mobile-finance-composer {
    border-color: #195d6a;
    box-shadow: -8px 0 28px rgba(5,190,120,.08), 8px 0 28px rgba(81,54,244,.12);
  }

  :root[data-theme="dark"] .mobile-composer-action {
    border-color: #28435a;
    color: #19c986;
  }

  :root[data-theme="dark"] .mobile-bottom-nav button {
    color: #b8c1d0;
  }

  :root[data-theme="dark"] .mobile-bottom-nav button.active {
    color: #6f72ff;
  }

  :root[data-theme="dark"] .transactions tbody tr {
    border-color: var(--mobile-line);
  }

  :root[data-theme="dark"] .mobile-transaction-meta,
  :root[data-theme="dark"] .metric-trend small {
    color: var(--mobile-muted);
  }
}

@media (max-width: 370px) {
  .main {
    padding-inline: 10px;
  }

  .mobile-finance-composer,
  .mobile-bottom-nav {
    right: 10px;
    left: 10px;
  }

  .mobile-greeting h1 {
    font-size: 23px;
  }

  .metric-card-main {
    grid-template-columns: 36px minmax(0, 1fr) 22px;
    gap: 5px;
  }

  .metric-card .metric-icon,
  .metric-card.balance .metric-icon {
    width: 36px;
    height: 36px;
  }

  .metric-card h2,
  .metric-card.balance h2 {
    font-size: 16px;
  }

  .metric-trend small {
    display: none;
  }
}

/* Mobile light reference lock: flat green finance UI */
@media (max-width:720px){
  :root[data-theme="light"]{
    --mobile-bg:#f7fbfa;
    --mobile-surface:#fefefe;
    --mobile-surface-soft:#eff7f3;
    --mobile-line:#e3eeea;
    --mobile-ink:#11293c;
    --mobile-muted:#617386;
  }
  :root[data-theme="light"] body,
  :root[data-theme="light"] .dashboard-shell,
  :root[data-theme="light"] .main{
    background:#f7fbfa!important;
  }
  :root[data-theme="light"] .mobile-dashboard-header{
    background:linear-gradient(180deg,#f8fcfa 0%,#eff9f4 100%)!important;
  }
  :root[data-theme="light"] .mobile-quickbar{
    border-bottom-color:#e5eeea!important;
    background:#fcfdfd!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="light"] .mobile-brand-title{
    border-color:#e1ebe7!important;
    background:#fff!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="light"] .mobile-brand-title span{
    color:#11293c!important;
    background:none!important;
    -webkit-background-clip:border-box!important;
    -webkit-text-fill-color:#11293c!important;
  }
  :root[data-theme="light"] .mobile-brand-title img,
  :root[data-theme="light"] .mobile-copilot-button img,
  :root[data-theme="light"] .mobile-composer-bot img{
    filter:hue-rotate(-68deg) saturate(1.35) brightness(1.06)!important;
  }
  :root[data-theme="light"] .mobile-menu-button,
  :root[data-theme="light"] .mobile-notice-button{
    color:#294557!important;
    border-color:#e1ebe7!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .mobile-notice-button b{
    box-shadow:none!important;
  }
  :root[data-theme="light"] .mobile-copilot-button{
    border-color:#d5eadf!important;
    background:#eaf6f0!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .metric-card,
  :root[data-theme="light"] .metric-card.balance,
  :root[data-theme="light"] .content-grid .panel{
    color:#11293c!important;
    border-color:#e3eeea!important;
    background:#fefefe!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .metric-card .metric-icon,
  :root[data-theme="light"] .metric-card.balance .metric-icon{
    color:#fff!important;
    border:1px solid #12a968!important;
    background:linear-gradient(145deg,#50d39b,#019a56)!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .metric-card.saving .metric-icon,
  :root[data-theme="light"] .metric-card.saving.is-negative .metric-icon,
  :root[data-theme="light"] .metric-card.saving:not(.is-negative) .metric-icon{
    color:#078a4c!important;
    border-color:#d9eee3!important;
    background:#e5f4ea!important;
  }
  :root[data-theme="light"] .metric-card h2,
  :root[data-theme="light"] .metric-card.balance h2,
  :root[data-theme="light"] .metric-card.expense h2,
  :root[data-theme="light"] .metric-card.saving h2,
  :root[data-theme="light"] .metric-card.is-negative h2,
  :root[data-theme="light"] .metric-card label,
  :root[data-theme="light"] .metric-card.balance label{
    color:#11293c!important;
  }
  :root[data-theme="light"] .metric-direction{
    color:#019a56!important;
    border-color:transparent!important;
    background:#e7f5ee!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .spending-report{
    grid-template-columns:58px minmax(0,1fr)!important;
    gap:5px!important;
  }
  :root[data-theme="light"] .spending-donut{
    width:58px!important;
    height:58px!important;
  }
  :root[data-theme="light"] .spending-donut>div{
    inset:9px!important;
  }
  :root[data-theme="light"] .category-line{
    grid-template-columns:15px minmax(0,1fr) auto!important;
    gap:3px!important;
    font-size:8px!important;
  }
  :root[data-theme="light"] .category-line>i{
    width:15px!important;
    height:15px!important;
  }
  :root[data-theme="light"] .category-line label{
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }
  :root[data-theme="light"] .spending-panel .panel-footer-link,
  :root[data-theme="light"] .mobile-budget-link,
  :root[data-theme="light"] .transactions-panel .panel-link{
    color:#019a56!important;
  }
  :root[data-theme="light"] .mobile-finance-composer,
  :root[data-theme="light"] .mobile-bottom-nav{
    border-color:#dfeae5!important;
    background:#fff!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="light"] .mobile-composer-action{
    color:#019a56!important;
    border-color:#d8ebe1!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .mobile-bottom-nav button{
    color:#52687a!important;
  }
  :root[data-theme="light"] .mobile-bottom-nav button.active{
    color:#019a56!important;
  }
  :root[data-theme="light"] .mobile-bottom-nav .mobile-add-button{
    color:#fff!important;
    background:linear-gradient(145deg,#05ae65,#018c50)!important;
    box-shadow:none!important;
  }
}

/* Mobile dialogs must own the entire viewport, including the sticky quickbar. */
@media (max-width:720px){
  body.dashboard-modal-open{
    overflow:hidden!important;
    touch-action:none;
  }
  body.dashboard-modal-open .modal-backdrop,
  .modal-backdrop{
    z-index:1000!important;
  }
  .modal-backdrop .modal{
    position:relative;
    z-index:1;
  }
  body.dashboard-modal-open .mobile-quickbar{
    pointer-events:none!important;
  }
}

/* Mobile dark reference lock: flat black-teal finance UI */
@media (max-width:720px){
  :root[data-theme="dark"]{
    --mobile-bg:#010a0f;
    --mobile-surface:#050f15;
    --mobile-surface-soft:#07141a;
    --mobile-line:#1a2c31;
    --mobile-ink:#f3f7f5;
    --mobile-muted:#91a29b;
  }
  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .dashboard-shell,
  :root[data-theme="dark"] .main{
    color:#e9f1ed!important;
    background:#010a0f!important;
  }
  :root[data-theme="dark"] .mobile-dashboard-header{
    color:#f3f7f5!important;
    background:linear-gradient(180deg,#031017 0%,#020c12 100%)!important;
  }
  :root[data-theme="dark"] .mobile-greeting h1{
    color:#f3f7f5!important;
    text-shadow:none!important;
  }
  :root[data-theme="dark"] .mobile-greeting p{
    color:#9baca5!important;
  }
  :root[data-theme="dark"] .mobile-quickbar{
    border-bottom-color:#17282e!important;
    background:#020c12!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="dark"] .mobile-brand-title{
    border-color:#1b3036!important;
    background:#061218!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="dark"] .mobile-brand-title span{
    color:#f3f7f5!important;
    background:none!important;
    -webkit-background-clip:border-box!important;
    -webkit-text-fill-color:#f3f7f5!important;
  }
  :root[data-theme="dark"] .mobile-brand-title img,
  :root[data-theme="dark"] .mobile-copilot-button img,
  :root[data-theme="dark"] .mobile-composer-bot img{
    filter:hue-rotate(-68deg) saturate(1.45) brightness(1.14)!important;
  }
  :root[data-theme="dark"] .mobile-menu-button,
  :root[data-theme="dark"] .mobile-notice-button{
    color:#dce8e2!important;
    border-color:#1b3036!important;
    background:#061218!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .mobile-menu-button svg,
  :root[data-theme="dark"] .mobile-notice-button svg{
    color:#b9c9c2!important;
  }
  :root[data-theme="dark"] .mobile-notice-button b{
    border-color:#061218!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .mobile-copilot-button{
    border-color:#174938!important;
    background:#09261d!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .metric-card,
  :root[data-theme="dark"] .metric-card.balance,
  :root[data-theme="dark"] .content-grid .panel{
    color:#e9f1ed!important;
    border-color:#1a2c31!important;
    background:linear-gradient(145deg,#061116,#040e14)!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .metric-card .metric-icon,
  :root[data-theme="dark"] .metric-card.balance .metric-icon{
    color:#effff7!important;
    border:1px solid #0ba75f!important;
    background:linear-gradient(145deg,#18b86e,#078d50 58%,#045f39)!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .metric-card.saving .metric-icon,
  :root[data-theme="dark"] .metric-card.saving.is-negative .metric-icon,
  :root[data-theme="dark"] .metric-card.saving:not(.is-negative) .metric-icon{
    color:#75efad!important;
    border-color:#174d39!important;
    background:#0e3528!important;
  }
  :root[data-theme="dark"] .metric-card h2,
  :root[data-theme="dark"] .metric-card.balance h2,
  :root[data-theme="dark"] .metric-card.expense h2,
  :root[data-theme="dark"] .metric-card.saving h2,
  :root[data-theme="dark"] .metric-card.is-negative h2,
  :root[data-theme="dark"] .metric-card label,
  :root[data-theme="dark"] .metric-card.balance label{
    color:#f3f7f5!important;
  }
  :root[data-theme="dark"] .metric-direction{
    color:#70edac!important;
    border-color:#1c4437!important;
    background:#0b271f!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .large-chart{
    background:linear-gradient(145deg,#061116,#040e14)!important;
  }
  :root[data-theme="dark"] .period-select{
    color:#e8f0ec!important;
    border-color:#1b3036!important;
    background:#07141a!important;
  }
  :root[data-theme="dark"] .spending-panel .panel-footer-link,
  :root[data-theme="dark"] .mobile-budget-link,
  :root[data-theme="dark"] .transactions-panel .panel-link{
    color:#25e486!important;
  }
  :root[data-theme="dark"] .insight-item{
    color:#e8f0ec!important;
    border-color:#1b3036!important;
    background:#07141a!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .insight-item>i,
  :root[data-theme="dark"] .status-dot{
    background:color-mix(in srgb,var(--tone) 16%,#07141a)!important;
    border-color:color-mix(in srgb,var(--tone) 28%,#162a2e)!important;
  }
  :root[data-theme="dark"] .transactions tbody tr{
    border-color:#1a2c31!important;
    background:transparent!important;
  }
  :root[data-theme="dark"] .mobile-finance-composer,
  :root[data-theme="dark"] .mobile-bottom-nav{
    border-color:#1b3036!important;
    background:#051219!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  :root[data-theme="dark"] .mobile-finance-composer textarea{
    color:#e9f1ed!important;
  }
  :root[data-theme="dark"] .mobile-finance-composer textarea::placeholder{
    color:#91a29b!important;
  }
  :root[data-theme="dark"] .mobile-composer-action{
    color:#25e486!important;
    border-color:#1c4437!important;
    background:#07141a!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .mobile-bottom-nav button{
    color:#a9bbb3!important;
  }
  :root[data-theme="dark"] .mobile-bottom-nav button.active{
    color:#25e486!important;
  }
  :root[data-theme="dark"] .mobile-bottom-nav .mobile-add-button{
    color:#fff!important;
    background:linear-gradient(145deg,#05ae65,#018c50)!important;
    box-shadow:none!important;
  }
}

/* User-selectable compact density. The default layout remains unchanged. */
@media (min-width: 721px) {
  :root[data-density="compact"] .content-grid { gap:10px; }
  :root[data-density="compact"] .content-grid .panel,
  :root[data-density="compact"] .transactions-panel { padding:12px 14px; }
  :root[data-density="compact"] .summary-grid { gap:10px; }
  :root[data-density="compact"] .metric-card,
  :root[data-density="compact"] .metric-card.balance {
    min-height:138px;
    padding:13px 14px 10px;
  }
  :root[data-density="compact"] .transactions th,
  :root[data-density="compact"] .transactions td {
    padding-top:7px;
    padding-bottom:7px;
  }
  :root[data-density="compact"] .insight-list,
  :root[data-density="compact"] .category-legend { gap:5px; }
}

/* Mobile Copilot: keep every non-semantic state in the mint/emerald system. */
@media (max-width: 720px) {
  :root[data-theme="light"] .modal.ai-modal {
    color:#17382a!important;
    border-color:#cfe4d9!important;
    background:#fbfdfc!important;
    box-shadow:0 18px 48px rgba(20,63,42,.16)!important;
  }
  :root[data-theme="light"] .ai-modal .modal-top h2 { color:#102d21!important; }
  :root[data-theme="light"] .ai-modal .modal-top p,
  :root[data-theme="light"] .ai-modal .assistant-rail-form > small { color:#668074!important; }
  :root[data-theme="light"] .ai-modal .modal-close {
    color:#315b48!important;
    background:#edf7f1!important;
  }
  :root[data-theme="light"] .ai-modal .modal-close:hover {
    color:#057843!important;
    background:#dff3e8!important;
  }
  :root[data-theme="light"] .ai-modal .comet-badge-modal {
    color:#315b48!important;
    border-color:#d7e8df!important;
    background:#f6fbf8!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-online { color:#48695a!important; }
  :root[data-theme="light"] .ai-modal .assistant-online i { background:#08a85f!important; }
  :root[data-theme="light"] .ai-modal .assistant-alert {
    color:#17382a!important;
    border-color:#d5e9df!important;
    background:#edf8f2!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-alert-icon {
    color:#078c4f!important;
    background:#dff5e9!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-alert > div > b { color:#17382a!important; }
  :root[data-theme="light"] .ai-modal .assistant-alert > div > span { color:#60776c!important; }
  :root[data-theme="light"] .ai-modal .assistant-alert-actions button {
    color:#087e49!important;
    border-color:#cfe5da!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-alert-actions button:hover {
    color:#056f3f!important;
    border-color:#a9d8c0!important;
    background:#f2faf6!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-day { color:#658075!important; }
  :root[data-theme="light"] .ai-modal .assistant-day::before,
  :root[data-theme="light"] .ai-modal .assistant-day::after { background:#dce9e2!important; }
  :root[data-theme="light"] .ai-modal .assistant-day span { background:#fbfdfc!important; }
  :root[data-theme="light"] .ai-modal .ai-message.user {
    color:#fff!important;
    border:1px solid #07894d!important;
    background:#079a56!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .ai-message.user .ai-message-label,
  :root[data-theme="light"] .ai-modal .ai-message.user small { color:#d9f7e8!important; }
  :root[data-theme="light"] .ai-modal .ai-message.assistant {
    color:#29493a!important;
    border-color:#dce9e2!important;
    background:#f4faf7!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .ai-message.assistant .ai-message-label { color:#087e49!important; }
  :root[data-theme="light"] .ai-modal .ai-message.assistant .ai-message-body,
  :root[data-theme="light"] .ai-modal .copilot-summary .ai-message-body,
  :root[data-theme="light"] .ai-modal .copilot-summary ul { color:#385749!important; }
  :root[data-theme="light"] .ai-modal .copilot-summary .ai-message-body > b,
  :root[data-theme="light"] .ai-modal .ai-heading { color:#17382a!important; }
  :root[data-theme="light"] .ai-modal .ai-message-body code {
    color:#096c40!important;
    background:#dff3e8!important;
  }
  :root[data-theme="light"] .ai-modal .ai-typing { color:#315b48!important; }
  :root[data-theme="light"] .ai-modal .ai-typing i { background:#08a85f!important; }
  :root[data-theme="light"] .ai-modal .ai-bot-avatar { background:#dff5e9!important; }
  :root[data-theme="light"] .ai-modal .ai-meta-tag {
    color:#477061!important;
    border-color:#d4e7dd!important;
    background:#edf7f2!important;
  }
  :root[data-theme="light"] .ai-modal .ai-message-footer { border-top-color:#dce9e2!important; }
  :root[data-theme="light"] .ai-modal .ai-action-btn,
  :root[data-theme="light"] .ai-modal .ai-rate-btn {
    color:#426354!important;
    border-color:#d5e7de!important;
    background:#fff!important;
  }
  :root[data-theme="light"] .ai-modal .ai-action-btn svg { color:#078c4f!important; }
  :root[data-theme="light"] .ai-modal .ai-action-btn:hover,
  :root[data-theme="light"] .ai-modal .ai-rate-btn:hover,
  :root[data-theme="light"] .ai-modal .ai-rate-btn.active {
    color:#067542!important;
    border-color:#add9c3!important;
    background:#e5f6ed!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-integration-cta {
    border-color:#d5e9df!important;
    background:#edf8f2!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-integration-cta strong { color:#17382a!important; }
  :root[data-theme="light"] .ai-modal .assistant-integration-cta span,
  :root[data-theme="light"] .ai-modal .assistant-integration-dismiss { color:#60796d!important; }
  :root[data-theme="light"] .ai-modal .assistant-integration-cta a {
    color:#244b39!important;
    border-color:#cfe5da!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-integration-cta a:hover {
    border-color:#a9d8c0!important;
    background:#f5fbf8!important;
  }
  :root[data-theme="light"] .ai-modal .copilot-compose {
    border-color:#cfe5da!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .copilot-compose:focus-within {
    border-color:#74c99d!important;
    box-shadow:0 0 0 3px rgba(8,168,95,.1)!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-rail-form textarea { color:#17382a!important; }
  :root[data-theme="light"] .ai-modal .assistant-rail-form textarea::placeholder { color:#728b80!important; }
  :root[data-theme="light"] .ai-modal .compose-clip { color:#078c4f!important; }
  :root[data-theme="light"] .ai-modal .assistant-send {
    color:#fff!important;
    background:#08a85f!important;
    box-shadow:none!important;
  }
  :root[data-theme="light"] .ai-modal .assistant-send:hover:not(:disabled) { background:#078c4f!important; }

  :root[data-theme="dark"] .modal.ai-modal {
    color:#dcebe4!important;
    border-color:#1c3b2f!important;
    background:#07150f!important;
    box-shadow:0 18px 52px rgba(0,0,0,.42)!important;
  }
  :root[data-theme="dark"] .ai-modal .modal-top h2 { color:#eff9f4!important; }
  :root[data-theme="dark"] .ai-modal .modal-top p,
  :root[data-theme="dark"] .ai-modal .assistant-rail-form > small { color:#8fa99c!important; }
  :root[data-theme="dark"] .ai-modal .modal-close {
    color:#b9d0c4!important;
    background:#10271d!important;
  }
  :root[data-theme="dark"] .ai-modal .comet-badge-modal,
  :root[data-theme="dark"] .ai-modal .assistant-alert,
  :root[data-theme="dark"] .ai-modal .assistant-integration-cta {
    color:#dcebe4!important;
    border-color:#1b3b2e!important;
    background:#0b2117!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .ai-modal .assistant-alert-icon,
  :root[data-theme="dark"] .ai-modal .ai-bot-avatar {
    color:#42e894!important;
    background:#103b28!important;
  }
  :root[data-theme="dark"] .ai-modal .assistant-alert > div > b,
  :root[data-theme="dark"] .ai-modal .assistant-integration-cta strong { color:#eff9f4!important; }
  :root[data-theme="dark"] .ai-modal .assistant-alert > div > span,
  :root[data-theme="dark"] .ai-modal .assistant-integration-cta span { color:#94aa9f!important; }
  :root[data-theme="dark"] .ai-modal .assistant-alert-actions button,
  :root[data-theme="dark"] .ai-modal .assistant-integration-cta a {
    color:#dcebe4!important;
    border-color:#24503d!important;
    background:#081a12!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .ai-modal .assistant-day { color:#8ca398!important; }
  :root[data-theme="dark"] .ai-modal .assistant-day::before,
  :root[data-theme="dark"] .ai-modal .assistant-day::after { background:#1b382c!important; }
  :root[data-theme="dark"] .ai-modal .assistant-day span { background:#07150f!important; }
  :root[data-theme="dark"] .ai-modal .ai-message.user {
    color:#e5faef!important;
    border:1px solid #176941!important;
    background:#0a5534!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .ai-modal .ai-message.user .ai-message-label,
  :root[data-theme="dark"] .ai-modal .ai-message.user small { color:#b7efd1!important; }
  :root[data-theme="dark"] .ai-modal .ai-message.assistant {
    color:#d5e5dd!important;
    border-color:#1d3b30!important;
    background:#091b13!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .ai-modal .ai-message.assistant .ai-message-label,
  :root[data-theme="dark"] .ai-modal .ai-typing { color:#74e9aa!important; }
  :root[data-theme="dark"] .ai-modal .ai-typing i { background:#2bd77f!important; }
  :root[data-theme="dark"] .ai-modal .copilot-summary .ai-message-body,
  :root[data-theme="dark"] .ai-modal .copilot-summary ul { color:#bfd2c8!important; }
  :root[data-theme="dark"] .ai-modal .copilot-summary .ai-message-body > b,
  :root[data-theme="dark"] .ai-modal .ai-heading { color:#eff9f4!important; }
  :root[data-theme="dark"] .ai-modal .ai-meta-tag,
  :root[data-theme="dark"] .ai-modal .ai-action-btn,
  :root[data-theme="dark"] .ai-modal .ai-rate-btn {
    color:#bad0c5!important;
    border-color:#234438!important;
    background:#10271d!important;
  }
  :root[data-theme="dark"] .ai-modal .ai-rate-btn.active { border-color:#287e54!important;background:#103b28!important; }
  :root[data-theme="dark"] .ai-modal .copilot-compose {
    border-color:#24503d!important;
    background:#081a12!important;
    box-shadow:none!important;
  }
  :root[data-theme="dark"] .ai-modal .copilot-compose:focus-within {
    border-color:#2b9862!important;
    box-shadow:0 0 0 3px rgba(43,215,127,.1)!important;
  }
  :root[data-theme="dark"] .ai-modal .assistant-rail-form textarea { color:#e6f2ec!important; }
  :root[data-theme="dark"] .ai-modal .assistant-rail-form textarea::placeholder { color:#839c90!important; }
  :root[data-theme="dark"] .ai-modal .compose-clip { color:#42e894!important; }
  :root[data-theme="dark"] .ai-modal .assistant-send {
    color:#fff!important;
    background:#079a56!important;
    box-shadow:none!important;
  }
}

/* Mobile header simplification: greeting + signed profile, theme in bottom nav. */
@media (max-width: 720px) {
  .mobile-statusbar,
  .mobile-quickbar { display:none!important; }

  .mobile-dashboard-header {
    padding:6px 4px 2px!important;
  }

  .mobile-greeting {
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:start;
    gap:12px;
    padding:8px 6px 4px!important;
  }

  .mobile-greeting-copy { min-width:0; }

  .mobile-greeting p {
    margin-bottom:8px!important;
  }

  .mobile-profile-button {
    display:grid;
    width:46px;
    height:46px;
    place-items:center;
    padding:3px;
    overflow:hidden;
    border:1px solid #cfe5da;
    border-radius:50%;
    background:#fff;
    box-shadow:none;
    cursor:pointer;
  }

  .mobile-profile-button img {
    width:100%;
    height:100%;
    object-fit:cover;
    border-radius:50%;
  }

  .mobile-profile-button:focus-visible {
    outline:3px solid rgba(8,168,95,.18);
    outline-offset:2px;
  }

  .mobile-bottom-nav [data-mobile-theme-toggle] {
    color:#52687a!important;
  }

  .mobile-bottom-nav [data-mobile-theme-toggle][aria-pressed="true"] {
    color:#019a56!important;
  }

  :root[data-theme="dark"] .mobile-profile-button {
    border-color:#28503f;
    background:#0a1c14;
  }

  :root[data-theme="dark"] .mobile-bottom-nav [data-mobile-theme-toggle] {
    color:#a9bbb3!important;
  }

  :root[data-theme="dark"] .mobile-bottom-nav [data-mobile-theme-toggle][aria-pressed="true"] {
    color:#25e486!important;
  }
}

/* Canonical app mark: preserve the supplied artwork without legacy recoloring. */
img[src$="money-copilot-app-logo.png"] {
  object-fit:contain!important;
  filter:none!important;
  mix-blend-mode:normal!important;
}

.sidebar .brand img[src$="money-copilot-app-logo.png"],
.copilot-logo img[src$="money-copilot-app-logo.png"],
.floating-ai img[src$="money-copilot-app-logo.png"],
.mobile-composer-bot img[src$="money-copilot-app-logo.png"],
.ai-bot-avatar img[src$="money-copilot-app-logo.png"] {
  transform:none!important;
}

/* Mint month picker: replaces the platform-native blue calendar UI. */
.month-picker {
  position:relative;
  width:140px;
  height:43px;
  z-index:35;
}

.month-picker-trigger {
  display:flex;
  width:100%;
  height:100%;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:0 13px;
  color:#10261d;
  border:1px solid #cfe5da;
  border-radius:9px;
  background:#fff;
  box-shadow:none;
  font:700 11px/1 Inter,sans-serif;
  cursor:pointer;
}

.month-picker-trigger svg {
  width:16px;
  height:16px;
  flex:0 0 16px;
  color:#078f50;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.month-picker-trigger:hover,
.month-picker.open .month-picker-trigger,
.month-picker-trigger:focus-visible {
  border-color:#46c990;
  box-shadow:0 0 0 3px rgba(12,183,105,.11);
  outline:0;
}

.month-picker-popover {
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  width:258px;
  padding:12px;
  overflow:hidden;
  color:#10261d;
  border:1px solid #b9ddcc;
  border-radius:13px;
  background:#fbfffd;
  box-shadow:0 18px 42px rgba(18,76,51,.15);
}

.month-picker-popover[hidden] { display:none!important; }

.month-picker-year {
  display:grid;
  grid-template-columns:34px 1fr 34px;
  align-items:center;
  margin-bottom:9px;
  padding-bottom:10px;
  border-bottom:1px solid #dceee5;
  text-align:center;
}

.month-picker-year strong { font-size:13px; }

.month-picker-year button {
  display:grid;
  width:32px;
  height:32px;
  place-items:center;
  padding:0;
  color:#078f50;
  border:1px solid transparent;
  border-radius:8px;
  background:transparent;
  font:700 22px/1 Inter,sans-serif;
  cursor:pointer;
}

.month-picker-year button:hover,
.month-picker-year button:focus-visible {
  border-color:#bde8d3;
  background:#e8f8f0;
  outline:0;
}

.month-picker-grid {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:7px;
}

.month-picker-option {
  min-height:36px;
  padding:0;
  color:#26473a;
  border:1px solid transparent;
  border-radius:8px;
  background:transparent;
  font:600 12px/1 Inter,sans-serif;
  cursor:pointer;
}

.month-picker-option:hover,
.month-picker-option:focus-visible {
  color:#057744;
  border-color:#bde8d3;
  background:#eaf9f2;
  outline:0;
}

.month-picker-option.selected {
  color:#fff;
  border-color:#049754;
  background:#08a85f;
  box-shadow:none;
}

.month-picker-footer {
  display:flex;
  justify-content:space-between;
  gap:8px;
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid #dceee5;
}

.month-picker-footer button {
  padding:6px 7px;
  color:#078f50;
  border:0;
  border-radius:7px;
  background:transparent;
  font:700 11px/1 Inter,sans-serif;
  cursor:pointer;
}

.month-picker-footer button:hover,
.month-picker-footer button:focus-visible {
  background:#e8f8f0;
  outline:0;
}

:root[data-theme="dark"] .month-picker-trigger {
  color:#e8f5ee;
  border-color:#214335;
  background:#071812;
}

:root[data-theme="dark"] .month-picker-popover {
  color:#edf9f2;
  border-color:#28513f;
  background:#081b13;
  box-shadow:0 20px 46px rgba(0,0,0,.36);
}

:root[data-theme="dark"] .month-picker-year,
:root[data-theme="dark"] .month-picker-footer { border-color:#1c3b2e; }
:root[data-theme="dark"] .month-picker-year button,
:root[data-theme="dark"] .month-picker-footer button { color:#43e99a; }
:root[data-theme="dark"] .month-picker-year button:hover,
:root[data-theme="dark"] .month-picker-year button:focus-visible,
:root[data-theme="dark"] .month-picker-footer button:hover,
:root[data-theme="dark"] .month-picker-footer button:focus-visible { background:#103727; }
:root[data-theme="dark"] .month-picker-option { color:#c4dbd0; }
:root[data-theme="dark"] .month-picker-option:hover,
:root[data-theme="dark"] .month-picker-option:focus-visible {
  color:#7bf0b1;
  border-color:#285c45;
  background:#103727;
}
:root[data-theme="dark"] .month-picker-option.selected {
  color:#03120b;
  border-color:#26dc83;
  background:#36e38c;
}

/* Mobile Copilot bubbles should size to their content, not fill the chat viewport. */
@media (max-width: 720px) {
  .ai-modal .ai-chat-scroll .assistant-rail-messages {
    flex:0 0 auto!important;
    width:100%;
    height:auto!important;
    min-height:0!important;
    align-content:start!important;
    grid-auto-rows:max-content!important;
    overflow:visible!important;
  }

  .ai-modal .assistant-rail-messages .ai-message {
    height:auto!important;
    min-height:0!important;
    align-self:start!important;
  }

  .ai-modal .assistant-rail-messages .ai-message.user {
    justify-self:end!important;
  }

  .ai-modal .assistant-rail-messages .ai-message-body {
    min-height:0!important;
  }
}

/* Money Copilot identity in the chat modal title. */
.ai-modal .modal-heading { min-width:0; }

.ai-modal .modal-title-row {
  display:flex;
  align-items:center;
  gap:8px;
}

.ai-modal .modal-title-logo {
  display:block;
  width:30px;
  height:30px;
  flex:0 0 30px;
  object-fit:contain;
  filter:none!important;
}

.ai-modal .modal-title-row h2 { margin-bottom:0; }
.ai-modal .modal-heading > p { margin-top:3px; }

@media (max-width: 720px) {
  .ai-modal .modal-title-row { gap:6px; }
  .ai-modal .modal-title-logo {
    width:26px;
    height:26px;
    flex-basis:26px;
  }
}

/* Secure MCP client connection panel. */
.connections-modal { width:min(720px,100%); }

.mcp-connect-card {
  padding:17px;
  color:#18382a;
  border:1px solid #cce6da;
  border-radius:15px;
  background:linear-gradient(145deg,#f5fcf8,#edf9f3);
}

.mcp-connect-head,
.mcp-connect-identity,
.mcp-credential-status,
.mcp-endpoint-field,
.mcp-auth-row,
.mcp-client-heading {
  display:flex;
  align-items:center;
}

.mcp-connect-head { justify-content:space-between;gap:14px;padding-bottom:13px;border-bottom:1px solid #d9ebe2; }
.mcp-connect-identity { gap:10px;min-width:0; }
.mcp-connect-identity > img { width:42px;height:42px;flex:0 0 42px;object-fit:contain;border-radius:11px;background:#fff; }
.mcp-connect-identity span { display:grid;gap:2px;min-width:0; }
.mcp-connect-identity b { color:#102d21;font-size:14px; }
.mcp-connect-identity small { color:#647e72;font-size:10px; }

.mcp-ready { display:inline-flex;align-items:center;gap:6px;padding:5px 9px;color:#087a47;border:1px solid #b9dfcc;border-radius:999px;background:#e5f8ee;font-size:10px;font-weight:800; }
.mcp-ready i,
.mcp-credential-status > i { width:8px;height:8px;flex:0 0 8px;border-radius:50%;background:#0ab866; }

.mcp-credential-status { gap:9px;padding:13px 1px; }
.mcp-credential-status span { display:grid;gap:2px; }
.mcp-credential-status b { color:#087844;font-size:11px; }
.mcp-credential-status small { color:#647d71;font-size:10px; }

.mcp-endpoint-field {
  justify-content:space-between;
  gap:12px;
  padding:11px 12px;
  border:1px solid #d1e6dc;
  border-radius:10px;
  background:#fff;
}
.mcp-endpoint-field > span { display:grid;gap:4px;min-width:0; }
.mcp-endpoint-field small { color:#71877c;font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.05em; }
.mcp-endpoint-field code { overflow:hidden;color:#163d2c;font:650 11px/1.3 ui-monospace,SFMono-Regular,Consolas,monospace;text-overflow:ellipsis;white-space:nowrap; }
.mcp-endpoint-field button { display:inline-flex;min-height:34px;align-items:center;gap:6px;padding:0 10px;color:#087d48;border:1px solid #c6e4d5;border-radius:8px;background:#effaf4;font-size:10px;font-weight:800;cursor:pointer; }
.mcp-endpoint-field button:hover,
.mcp-endpoint-field button.copied { border-color:#8ed0ae;background:#e2f7ec; }
.mcp-endpoint-field button svg { width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8; }

.mcp-auth-row { justify-content:space-between;gap:12px;padding:12px 2px 2px;color:#587165;font-size:10px; }
.mcp-auth-row span { display:inline-flex;align-items:center;gap:7px; }
.mcp-auth-row svg { width:14px;height:14px;fill:none;stroke:#079653;stroke-width:1.8; }
.mcp-auth-row b { color:#153c2b; }
.mcp-security-note { margin:10px 0 0!important;padding:9px 10px;color:#4f6d5e!important;border-radius:8px;background:rgba(255,255,255,.6);font-size:10px!important;line-height:1.45!important; }

.mcp-client-section { margin-top:16px; }
.mcp-client-heading { justify-content:space-between;gap:12px;margin-bottom:10px; }
.mcp-client-heading h3 { margin:0;color:#112f22;font-size:14px; }
.mcp-client-heading p { margin:2px 0 0;color:#71877c;font-size:10px; }
.mcp-client-heading > span { padding:5px 8px;color:#087c47;border-radius:999px;background:#e6f7ee;font-size:9px;font-weight:800; }

.mcp-client-grid { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px; }
.mcp-client-grid button {
  display:grid;
  grid-template-columns:32px minmax(0,1fr) 15px;
  align-items:center;
  gap:8px;
  min-height:58px;
  padding:9px;
  color:#244739;
  border:1px solid #d8e8e0;
  border-radius:11px;
  background:#fff;
  text-align:left;
  cursor:pointer;
}
.mcp-client-grid button:hover { border-color:#a8d8c0;background:#f6fcf9; }
.mcp-client-grid button.active { color:#087c47;border-color:#62c895;background:#effaf4; }
.mcp-client-grid img { width:30px;height:30px;object-fit:contain; }
.mcp-client-grid button > span { display:grid;gap:2px;min-width:0; }
.mcp-client-grid b { font-size:11px; }
.mcp-client-grid small { overflow:hidden;color:#71877c;font-size:9px;text-overflow:ellipsis;white-space:nowrap; }
.mcp-client-grid svg { width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8; }

.mcp-client-guide { margin-top:10px;padding:13px 14px;color:#365849;border:1px solid #d6e9df;border-radius:11px;background:#f7fcf9; }
.mcp-client-guide[hidden] { display:none!important; }
.mcp-client-guide > strong { color:#133928;font-size:12px; }
.mcp-client-guide ol { margin:9px 0 8px;padding-left:19px;font-size:10px;line-height:1.55; }
.mcp-client-guide li + li { margin-top:4px; }
.mcp-client-guide > small { color:#6c8277;font-size:9px;line-height:1.45; }

:root[data-theme="dark"] .mcp-connect-card { color:#d8ebe1;border-color:#1d4534;background:linear-gradient(145deg,#081a12,#0b2118); }
:root[data-theme="dark"] .mcp-connect-head { border-color:#1c3d30; }
:root[data-theme="dark"] .mcp-connect-identity > img { background:#f7fffb; }
:root[data-theme="dark"] .mcp-connect-identity b,
:root[data-theme="dark"] .mcp-client-heading h3 { color:#edf9f3; }
:root[data-theme="dark"] .mcp-connect-identity small,
:root[data-theme="dark"] .mcp-credential-status small,
:root[data-theme="dark"] .mcp-client-heading p { color:#8ea79b; }
:root[data-theme="dark"] .mcp-ready { color:#77efad;border-color:#245b42;background:#103624; }
:root[data-theme="dark"] .mcp-credential-status b { color:#65e9a1; }
:root[data-theme="dark"] .mcp-endpoint-field { border-color:#224637;background:#07170f; }
:root[data-theme="dark"] .mcp-endpoint-field small { color:#7f9b8d; }
:root[data-theme="dark"] .mcp-endpoint-field code,
:root[data-theme="dark"] .mcp-auth-row b { color:#d9eee3; }
:root[data-theme="dark"] .mcp-endpoint-field button { color:#75edac;border-color:#285841;background:#102d20; }
:root[data-theme="dark"] .mcp-auth-row { color:#91a99d; }
:root[data-theme="dark"] .mcp-security-note { color:#9bb0a5!important;background:rgba(255,255,255,.035); }
:root[data-theme="dark"] .mcp-client-heading > span { color:#72eba9;background:#103624; }
:root[data-theme="dark"] .mcp-client-grid button { color:#c9ddd3;border-color:#1f4033;background:#081811; }
:root[data-theme="dark"] .mcp-client-grid button:hover { border-color:#2d684c;background:#0d261a; }
:root[data-theme="dark"] .mcp-client-grid button.active { color:#78efaf;border-color:#278d5b;background:#103624; }
:root[data-theme="dark"] .mcp-client-grid small { color:#89a095; }
:root[data-theme="dark"] .mcp-client-guide { color:#b5cabf;border-color:#1f4334;background:#091c13; }
:root[data-theme="dark"] .mcp-client-guide > strong { color:#e6f5ed; }
:root[data-theme="dark"] .mcp-client-guide > small { color:#879e92; }

@media (max-width:720px) {
  .connections-modal { padding-inline:11px!important; }
  .mcp-connect-card { padding:13px; }
  .mcp-connect-identity > img { width:36px;height:36px;flex-basis:36px; }
  .mcp-endpoint-field { align-items:stretch; }
  .mcp-endpoint-field code { max-width:210px; }
  .mcp-client-grid { grid-template-columns:1fr;gap:7px; }
  .mcp-client-grid button { min-height:52px;grid-template-columns:30px minmax(0,1fr) 15px;padding:8px 10px; }
  .mcp-client-grid img { width:28px;height:28px; }
  .mcp-client-guide { padding:11px 12px; }
}

/* Integration promo buttons open the dashboard connection panel. */
.assistant-integration-cta nav button {
  display:flex;
  min-width:0;
  min-height:40px;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:6px 8px;
  color:#193f2e;
  border:1px solid #d5e8de;
  border-radius:9px;
  background:#fff;
  box-shadow:none;
  font:750 10px/1 Inter,sans-serif;
  cursor:pointer;
}
.assistant-integration-cta nav button:hover {
  color:#087d48;
  border-color:#a9d8c0;
  background:#f4fbf7;
  transform:translateY(-1px);
}
.assistant-integration-cta nav button img { width:18px;height:18px;flex:0 0 18px;object-fit:contain; }
:root[data-theme="dark"] .assistant-integration-cta nav button { color:#e5f3ec;border-color:#234536;background:#081811; }
:root[data-theme="dark"] .assistant-integration-cta nav button:hover { color:#74edab;border-color:#347151;background:#0d281b; }
