@font-face {
  font-display: swap;
  font-family: "HandelsbankenSans";
  font-style: normal;
  font-weight: 400;
  src: url("https://www.handelsbanken.se/sv/sepu/fonts/jedi/base/kit/HandelsbankenSansTable-Regular.woff2")
    format("woff2");
}

@font-face {
  font-display: swap;
  font-family: "HandelsbankenSans";
  font-style: normal;
  font-weight: 600;
  src: url("https://www.handelsbanken.se/sv/sepu/fonts/jedi/base/kit/HandelsbankenSansTable-Medium.woff2")
    format("woff2");
}

@font-face {
  font-display: swap;
  font-family: "HandelsbankenSans";
  font-style: normal;
  font-weight: 700;
  src: url("https://www.handelsbanken.se/sv/sepu/fonts/jedi/base/kit/HandelsbankenSansTable-Bold.woff2")
    format("woff2");
}

:root {
  --bg: #f4f8fb;
  --bg-alt: #eaf4f7;
  --panel: #ffffff;
  --line: #c4e2eb;
  --line-soft: #dedede;
  --text: #043b62;
  --muted: #486378;
  --accent: #005fa5;
  --accent-2: #017ab2;
  --accent-dark: #043b62;
  --danger: #c83d2a;
  --success: #007b45;
  --shadow: 0 12px 30px rgba(4, 59, 98, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "HandelsbankenSans", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(165deg, var(--bg), var(--bg-alt));
  color: var(--text);
  min-height: 100vh;
}

body:not(.logged-in) {
  overflow: hidden;
}

.container {
  width: min(1200px, calc(100% - 2rem));
  margin: 1.4rem auto 2rem;
  display: grid;
  gap: 1rem;
}

body:not(.logged-in) .container {
  width: min(640px, calc(100% - 2rem));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  align-content: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.hero {
  padding: 1.1rem 1.2rem;
  border-top: 4px solid var(--accent);
  position: relative;
  overflow: hidden;
}

.brand-row {
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
}

.brand-logo {
  display: block;
  max-width: min(100%, 420px);
  width: auto;
  height: 4.75rem;
  object-fit: contain;
}

.brand-extra-image {
  display: block;
  position: absolute;
  right: 1rem;
  top: 0.45rem;
  width: min(48vw, 360px);
  height: auto;
  object-fit: contain;
  object-position: right center;
  opacity: 0.92;
  z-index: 0;
  pointer-events: none;
}

.hero > *:not(.brand-extra-image) {
  position: relative;
  z-index: 1;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  font-weight: 700;
  max-width: 30ch;
}

h2 {
  font-size: 1.02rem;
  font-weight: 700;
}

h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
}

.intro {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 75ch;
}

.session-bar {
  margin-top: 0.85rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.65rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  position: relative;
}

.session-tools {
  display: flex;
  width: 100%;
  margin-left: 0;
  gap: 0.65rem;
  align-items: flex-end;
  justify-content: space-between;
}

.session-account-row {
  display: flex;
  align-items: flex-end;
  gap: 0.58rem;
  min-width: 0;
  flex: 1;
}

.account-switcher {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
  min-width: min(24rem, 68vw);
  flex: 1;
}

.account-switcher-label {
  font-size: 0.8rem;
}

#accountSelect {
  min-width: 15rem;
  padding: 0.48rem 0.55rem;
}

.report-shortcut-btn {
  align-self: flex-end;
  min-width: 7.35rem;
  padding: 0.52rem 0.72rem;
  border-color: #9fc5d9;
  background: linear-gradient(180deg, #f8fcff, #eef6fb);
  color: var(--accent-dark);
  white-space: nowrap;
}

.report-shortcut-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #fefefe, #e7f2fa);
  transform: none;
}

.report-shortcut-btn:disabled,
.report-shortcut-btn:disabled:hover {
  border-color: #c7d2db;
  background: #edf2f6;
  color: #8593a0;
  cursor: not-allowed;
  transform: none;
}

.session-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-color: #9ec3d8;
  background: linear-gradient(180deg, #f8fcff, #eef6fb);
  color: var(--accent-dark);
  white-space: nowrap;
  padding: 0.52rem 0.72rem;
}

.session-menu-toggle:hover {
  background: linear-gradient(180deg, #fefefe, #e7f2fa);
  transform: none;
}

.session-menu-toggle-icon {
  display: inline-grid;
  gap: 3px;
}

.session-menu-toggle-icon span {
  display: block;
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-2);
}

.session-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 59, 98, 0.26);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 24;
}

.session-menu-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(24rem, 92vw);
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  border-left: 1px solid #cbdce7;
  box-shadow: -18px 0 36px rgba(4, 59, 98, 0.22);
  transform: translateX(104%);
  transition: transform 260ms ease;
  pointer-events: none;
  z-index: 25;
  display: flex;
  flex-direction: column;
}

.session-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 1rem 1rem 0.78rem;
  border-bottom: 1px solid #d6e4ed;
}

.session-menu-user {
  border-bottom: 1px solid #d6e4ed;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #f6fbff, #edf6fc);
  display: grid;
  gap: 0.22rem;
}

.session-menu-user-label {
  margin: 0;
  font-size: 0.8rem;
}

.session-menu-user-name {
  margin: 0;
  color: #0f4967;
  font-size: 1.08rem;
}

.session-menu-user-type {
  margin: 0;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  background: rgba(1, 122, 178, 0.12);
  color: #015f8f;
  font-size: 0.72rem;
  font-weight: 700;
}

.session-menu-title {
  margin: 0;
  font-size: 1.92rem;
  line-height: 1;
  color: var(--accent-dark);
}

.session-menu-close {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #5f7483;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.34rem;
  line-height: 1;
}

.session-menu-close:hover {
  background: #eff5f9;
  transform: none;
}

.session-menu-list {
  display: grid;
  overflow-y: auto;
}

.session-menu-item {
  border: 0;
  border-bottom: 1px solid #d8e5ec;
  border-radius: 0;
  background: #ffffff;
  color: var(--accent-dark);
  text-align: left;
  font-weight: 600;
  padding: 0.94rem 1rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.session-menu-item::after {
  content: "\203A";
  color: #5b8198;
  font-size: 1.1rem;
  line-height: 1;
}

.session-menu-item:hover {
  background: #edf6fb;
  transform: none;
}

.session-menu-item:disabled {
  color: #8fa2af;
  background: #f7fbfd;
  cursor: not-allowed;
}

.session-menu-item:disabled::after {
  color: #9fb1bd;
}

body.session-menu-open {
  overflow: hidden;
}

body.session-menu-open .session-menu-overlay {
  opacity: 1;
  pointer-events: auto;
}

body.session-menu-open .session-menu-panel {
  transform: translateX(0);
  pointer-events: auto;
}

.danger-ghost {
  border-color: #e7b6ae;
  color: #9c2f22;
}

.danger-ghost:hover {
  background: #fff4f2;
}

#appContent {
  display: grid;
  gap: 1rem;
}

.app-tabs {
  padding: 0.2rem 0.8rem 0;
}

.tabs-list {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.tab-link {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0.78rem 0.74rem 0.62rem;
  background: transparent;
  color: #5d7180;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.1;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  scroll-snap-align: start;
}

.tab-link:hover {
  background: #f2f8fc;
  color: var(--accent-dark);
  transform: none;
}

.tab-link:active {
  transform: none;
}

.tab-link:focus {
  outline: 2px solid rgba(0, 95, 165, 0.34);
  outline-offset: 2px;
}

.tab-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: #ffffff;
}

.tab-panel {
  animation: fadeIn 220ms ease;
}

.tab-panel[hidden] {
  display: none !important;
}

.upload-top,
.summary-header,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

.upload-top {
  align-items: center;
}

.summary-action-btn {
  white-space: nowrap;
}

.summary-action-btn-small {
  padding: 0.35rem 0.56rem;
  border-radius: 0.5rem;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.1;
}

.upload-info-box {
  margin-top: 0.55rem;
  border: 1px solid #bdd7e7;
  border-left: 4px solid #0a8dca;
  border-radius: 0.72rem;
  background: linear-gradient(180deg, #f7fcff, #eef8fd);
  padding: 0.72rem 0.8rem;
  display: grid;
  gap: 0.45rem;
}

.upload-info-box p {
  margin: 0;
  color: #305467;
  font-size: 0.86rem;
  line-height: 1.42;
}

.upload-guide-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid #0b85bd;
  background: linear-gradient(180deg, #20a6e0, #0179b1);
  color: #ffffff;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(1, 121, 177, 0.28);
  cursor: pointer;
}

.upload-guide-btn:hover {
  background: linear-gradient(180deg, #38b4ea, #0083bd);
}

.upload-guide-btn:focus-visible {
  outline: 3px solid rgba(1, 121, 177, 0.35);
  outline-offset: 2px;
}

.forecast-range-controls {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
}

.forecast-range-controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.forecast-range-controls input {
  min-width: 10.6rem;
}

.forecast-quick-range {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.forecast-quick-btn {
  padding: 0.44rem 0.62rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.forecast-quick-btn.is-active {
  background: #e8f3fa;
  border-color: #9ec7de;
}

.forecast-range-meta {
  margin: 0.45rem 0 0;
}

.statement-panel {
  display: grid;
  gap: 0.72rem;
}

.statement-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
}

.statement-controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

#statementSearchInput {
  min-width: 18rem;
}

#pendingSearchInput {
  min-width: 18rem;
}

.category-rules-search-row {
  display: grid;
  gap: 0.25rem;
}

.category-rules-search-row label {
  color: var(--muted);
  font-size: 0.8rem;
}

#categoryRulesSearchInput {
  max-width: 26rem;
}

.unmapped-search-row {
  display: grid;
  gap: 0.25rem;
}

.unmapped-search-row label {
  color: var(--muted);
  font-size: 0.8rem;
}

#unmappedSearchInput {
  max-width: 26rem;
}

.statement-table-wrap {
  margin-top: 0;
}

.file-info {
  margin: 0.6rem 0 0;
}

.upload-grid {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.upload-grid[hidden] {
  display: none !important;
}

.mixed-upload-box {
  margin-top: 0.6rem;
}

.drop-zone-large {
  min-height: 9.4rem;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 1.25rem 1rem;
}

.create-report-wrap {
  margin-top: 0.82rem;
  display: flex;
  justify-content: flex-end;
}

#createReportBtn {
  min-width: 12.5rem;
  background: linear-gradient(180deg, #0185c5, #0068a8);
}

#createReportBtn:hover {
  background: linear-gradient(180deg, #1592ce, #005f9a);
}

#createReportBtn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.upload-box {
  border: 1px solid var(--line);
  border-radius: 0.82rem;
  background: #f8fcfe;
  padding: 0.78rem;
}

.upload-box h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--accent-dark);
}

.drop-zone {
  margin-top: 0.55rem;
  border: 2px dashed #7db7d6;
  border-radius: 0.82rem;
  background: #ffffff;
  padding: 1rem 0.95rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
  position: relative;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: #f5fbff;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: #eaf4f7;
  box-shadow: inset 0 0 0 1px rgba(0, 95, 165, 0.22);
}

.drop-zone.is-disabled {
  opacity: 0.58;
  pointer-events: none;
}

.drop-zone-title {
  margin: 0;
  font-weight: 700;
  color: var(--accent-dark);
}

.drop-zone-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.file-input-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.muted {
  color: var(--muted);
}

.error {
  margin: 0.52rem 0 0;
  color: var(--danger);
  font-weight: 600;
}

.auth-panel {
  animation: fadeIn 260ms ease;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  display: grid;
  gap: 0.9rem;
  text-align: center;
}

.auth-form {
  max-width: none;
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  text-align: center;
}

.auth-logo {
  width: min(24rem, 78vw);
  height: auto;
}

.auth-brand-text {
  margin: 0;
}

.auth-cta-row {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.auth-cta-row button {
  min-width: 10.5rem;
}

.auth-modal-card {
  width: min(470px, 96vw);
  max-height: none;
  overflow: visible;
  align-self: center;
}

.auth-modal-card .auth-actions button {
  width: 100%;
}

body:not(.logged-in) #sessionBar,
body:not(.logged-in) #appContent,
body:not(.logged-in) #reportLoadingOverlay {
  display: none !important;
}

body:not(.logged-in) .hero {
  display: none !important;
}

body.logged-in #authPanel,
body.logged-in #authLoginModal,
body.logged-in #authRegisterModal {
  display: none !important;
}

#currentUserProfileLabel {
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.1rem 0.44rem;
  border-radius: 999px;
  background: rgba(1, 122, 178, 0.12);
  color: #015f8f;
  font-size: 0.72rem;
  font-weight: 700;
}

.auth-actions {
  display: flex;
  gap: 0.55rem;
}

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

.stats-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 0.8rem;
  padding: 0.8rem;
}

.stat.highlight {
  border-color: rgba(0, 95, 165, 0.45);
  background: rgba(1, 122, 178, 0.09);
}

.stat.highlight-soft {
  border-color: rgba(1, 122, 178, 0.34);
  background: rgba(234, 244, 247, 0.95);
}

.stat .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat .value {
  margin: 0.35rem 0 0;
  font-weight: 700;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  color: var(--accent-dark);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.stat-pair-list {
  margin-top: 0.34rem;
  display: grid;
  gap: 0.46rem;
}

.stat-pair-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.18rem;
  border-top: 1px dashed #d4e4ec;
  padding-top: 0.42rem;
}

.stat-pair-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.stat-pair-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.79rem;
}

.stat-pair-row .value {
  display: block;
  width: 100%;
  margin: 0;
  font-size: clamp(0.96rem, 1.35vw, 1.08rem);
  text-align: right;
}

.status-text {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.account-balance-caption {
  margin: 0.44rem 0 0;
  font-size: 0.76rem;
}

.account-balance-breakdown {
  margin-top: 0.28rem;
  display: grid;
  gap: 0.24rem;
}

.account-balance-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px dashed #d4e4ec;
  padding-top: 0.24rem;
}

.account-balance-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.account-balance-name {
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 600;
}

.account-balance-value {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.account-balance-value.positive {
  color: var(--success);
}

.account-balance-value.negative {
  color: var(--danger);
}

.forecast-chart-card {
  margin-top: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.82rem;
  background: #ffffff;
  padding: 0.82rem;
}

.chart-head {
  align-items: center;
}

.chart-legend {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.95rem;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
}

.legend-line {
  width: 1rem;
  height: 0;
  border-top: 2px solid #2f86b8;
  border-radius: 999px;
  display: inline-block;
}

.legend-line.trend {
  border-top-color: #2f86b8;
  border-top-style: dashed;
}

.legend-dot.balance {
  background: #017ab2;
}

.legend-dot.income {
  background: #017ab2;
}

.legend-dot.expense {
  background: #c83d2a;
}

.forecast-chart {
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: linear-gradient(180deg, #ffffff, #f8fcff);
  padding: 0.4rem;
  min-height: 220px;
}

.category-trend-wrap {
  margin-top: 0.62rem;
  max-height: 360px;
}

.table-wrap.category-trend-wrap {
  max-height: none;
  overflow: visible;
}

.cost-change {
  font-weight: 700;
}

.cost-up {
  color: var(--danger);
}

.cost-down {
  color: var(--success);
}

.cost-flat {
  color: var(--muted);
}

.cost-new {
  color: #9a4b00;
}

.trend-mini-wrap {
  display: grid;
  gap: 0.12rem;
  min-width: 180px;
}

.trend-mini-svg {
  width: 180px;
  height: 34px;
  display: block;
}

.trend-mini-zero {
  stroke: #c7dce8;
  stroke-width: 1;
}

.trend-mini-line {
  fill: none;
  stroke: #017ab2;
  stroke-width: 1.6;
}

.trend-mini-marker {
  fill: #017ab2;
  stroke: #ffffff;
  stroke-width: 1;
}

.trend-mini-labels {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.22rem;
  font-size: 0.64rem;
  line-height: 1.1;
  white-space: nowrap;
  color: #5f7586;
}

.trend-mini-label.up {
  color: #9f3020;
}

.trend-mini-label.down {
  color: #16694a;
}

.trend-mini-label.flat {
  color: #5f7586;
}

.trend-mini-sep {
  color: #8ca6b7;
}

.chart-empty {
  margin: 0;
  padding: 0.5rem;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: #d8e8f0;
  stroke-width: 1;
}

.chart-axis-line {
  stroke: #8db3c8;
  stroke-width: 1.2;
}

.chart-axis-text {
  fill: #5f7586;
  font-size: 12px;
}

.chart-axis-year {
  font-size: 10px;
}

.chart-expense-area {
  fill: rgba(200, 61, 42, 0.12);
}

.chart-expense-line {
  fill: none;
  stroke: #c83d2a;
  stroke-width: 2;
}

.chart-balance-line {
  fill: none;
  stroke: #017ab2;
  stroke-width: 2.4;
}

.chart-bar-income {
  fill: rgba(1, 122, 178, 0.82);
}

.chart-bar-expense {
  fill: rgba(200, 61, 42, 0.78);
}

.chart-trend-line {
  fill: none;
  stroke: #2f86b8;
  stroke-width: 2.2;
  stroke-dasharray: 6 5;
}

.chart-trend-marker {
  fill: #2f86b8;
  stroke: #ffffff;
  stroke-width: 1.5;
}

.chart-peak {
  fill: #c83d2a;
  stroke: #ffffff;
  stroke-width: 1.5;
}

.value.positive {
  color: var(--success);
}

.value.negative {
  color: var(--danger);
}

.full-width {
  grid-column: span 6;
}

.table-wrap {
  margin-top: 0.8rem;
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

th,
td {
  padding: 0.62rem 0.65rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #eaf4f7;
  z-index: 1;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  color: var(--accent-dark);
}

tbody tr:hover td {
  background: rgba(1, 122, 178, 0.08);
}

.align-right {
  text-align: right;
}

.month-row td {
  background: rgba(0, 95, 165, 0.1);
  color: var(--accent-dark);
  font-weight: 700;
}

.external-form {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.65rem;
}

.external-form label {
  display: grid;
  gap: 0.26rem;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 0.56rem;
  padding: 0.55rem 0.6rem;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(0, 95, 165, 0.34);
  outline-offset: 1px;
}

button {
  border: 1px solid transparent;
  border-radius: 0.6rem;
  padding: 0.62rem 0.82rem;
  cursor: pointer;
  font-weight: 700;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #ffffff;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #0074be, #00518f);
}

button:active {
  transform: translateY(0);
}

.ghost {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--accent-dark);
}

.ghost:hover {
  background: #f3f9fc;
}

.external-actions {
  margin-top: 0.8rem;
}

.payments-layout {
  margin-top: 0.4rem;
  display: grid;
  gap: 0.85rem;
}

.payments-split {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr 1fr;
}

.payments-block {
  border: 1px solid var(--line);
  border-radius: 0.82rem;
  background: #f9fcfe;
  padding: 0.8rem;
}

.payments-head {
  align-items: baseline;
}

.payments-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent-dark);
}

.settings-panel {
  display: grid;
  gap: 0.85rem;
}

.admin-panel {
  display: grid;
  gap: 0.85rem;
}

.admin-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.1rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.admin-tag.yes {
  background: rgba(0, 106, 160, 0.14);
  color: #005a8d;
}

.admin-tag.no {
  background: rgba(110, 128, 141, 0.14);
  color: #4f6472;
}

.guide-panel {
  display: grid;
  gap: 0.8rem;
}

.guide-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

.guide-card {
  border: 1px solid var(--line);
  border-radius: 0.76rem;
  background: #f9fcff;
  padding: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

.guide-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.guide-image {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.62rem;
  background: #ffffff;
}

.category-detail-row {
  cursor: pointer;
}

.category-detail-row td:first-child {
  font-weight: 700;
  color: var(--accent-dark);
}

.category-detail-link {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.category-detail-link:hover {
  transform: none;
  color: var(--accent);
  text-decoration: underline;
}

.rule-category-editor {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.rule-category-editor input {
  min-width: 11rem;
}

.rule-category-editor select {
  min-width: 11rem;
}

.common-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.55rem;
  border: 1px solid #cde3ef;
  border-radius: 999px;
  background: #f7fcff;
  color: #355469;
  font-size: 0.76rem;
  font-weight: 600;
}

.category-rule-form {
  display: grid;
  gap: 0.62rem;
  grid-template-columns: 1.3fr 1fr auto;
  align-items: end;
}

.unmapped-bulk-form {
  grid-template-columns: 1fr auto auto;
}

.category-combo-label {
  min-width: 18rem;
}

.category-combo {
  position: relative;
}

.category-combo input {
  width: 100%;
  padding-right: 2.25rem;
}

.category-combo.is-open input {
  border-color: #8fbad0;
}

.combo-toggle {
  position: absolute;
  top: 50%;
  right: 0.26rem;
  transform: translateY(-50%);
  width: 1.72rem;
  height: 1.72rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: #4f6a7b;
  font-size: 0.98rem;
  line-height: 1;
  font-weight: 700;
}

.combo-toggle:hover {
  transform: translateY(-50%);
  background: #eef6fb;
  border-color: #c9deea;
}

.combo-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.combo-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  z-index: 40;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0.62rem;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(9, 40, 64, 0.12);
  padding: 0.28rem;
}

.combo-option {
  width: 100%;
  text-align: left;
  background: #ffffff;
  color: var(--accent-dark);
  border: 1px solid transparent;
  border-radius: 0.46rem;
  padding: 0.42rem 0.5rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.combo-option:hover {
  transform: none;
  background: #eaf4f9;
  border-color: #bfd8e6;
}

.combo-empty {
  margin: 0;
  padding: 0.5rem 0.55rem;
  font-size: 0.79rem;
}

.custom-category-field {
  margin-top: -0.12rem;
}

.category-rule-form .custom-category-field {
  grid-column: 2 / 3;
}

.unmapped-bulk-form .custom-category-field {
  grid-column: 1 / -1;
  margin-top: -0.05rem;
}

.checkbox-col {
  width: 2.4rem;
  text-align: center;
}

.checkbox-col input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.category-rule-form label {
  display: grid;
  gap: 0.26rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.settings-message {
  margin: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 40, 67, 0.28);
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 20;
}

.report-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 44;
  display: grid;
  place-items: center;
  background: rgba(4, 40, 67, 0.52);
  padding: 1rem;
}

.report-loading-overlay[hidden] {
  display: none !important;
}

.report-loading-card {
  width: min(26rem, 94vw);
  background: #ffffff;
  border: 1px solid #c1d8e7;
  border-radius: 1rem;
  box-shadow: 0 24px 58px rgba(3, 37, 61, 0.32);
  padding: 1rem 1rem 1.1rem;
  display: grid;
  justify-items: center;
  gap: 0.72rem;
}

.report-loading-title {
  margin: 0;
  text-align: center;
  color: #0b456d;
  font-weight: 700;
  font-size: 1rem;
}

.pump-loader {
  position: relative;
  width: 11.4rem;
  height: 7.5rem;
}

.pump-ring {
  position: absolute;
  inset: 0.4rem 1.6rem 1.2rem;
  border: 2px solid rgba(1, 122, 178, 0.22);
  border-radius: 999px;
  animation: pump-ring-pulse 1s ease-in-out infinite;
}

.pump-head {
  position: absolute;
  left: calc(50% - 0.48rem);
  top: 2.45rem;
  width: 0.96rem;
  height: 0.96rem;
  border-radius: 50%;
  background: #0c4f77;
}

.pump-body {
  position: absolute;
  left: calc(50% - 0.16rem);
  top: 3.32rem;
  width: 0.32rem;
  height: 2.22rem;
  border-radius: 0.2rem;
  background: #0c4f77;
}

.pump-arm {
  position: absolute;
  top: 3.52rem;
  width: 2.22rem;
  height: 0.28rem;
  border-radius: 0.28rem;
  background: #0c4f77;
}

.pump-arm-left {
  left: calc(50% - 2.18rem);
  transform-origin: 2rem 0.14rem;
  animation: pump-arm-left 0.9s ease-in-out infinite;
}

.pump-arm-right {
  left: calc(50% - 0.05rem);
  transform-origin: 0.2rem 0.14rem;
  animation: pump-arm-right 0.9s ease-in-out infinite;
}

.pump-leg {
  position: absolute;
  top: 5.38rem;
  width: 1.85rem;
  height: 0.3rem;
  border-radius: 0.28rem;
  background: #0c4f77;
}

.pump-leg-left {
  left: calc(50% - 1.74rem);
  transform: rotate(26deg);
}

.pump-leg-right {
  left: calc(50% - 0.1rem);
  transform: rotate(-26deg);
}

.pump-bar {
  position: absolute;
  left: calc(50% - 2.6rem);
  top: 1.42rem;
  width: 5.2rem;
  height: 0.3rem;
  border-radius: 0.2rem;
  background: #0a6ea5;
  animation: pump-bar-lift 0.9s ease-in-out infinite;
}

.pump-plate {
  position: absolute;
  top: 1.1rem;
  width: 0.86rem;
  height: 0.86rem;
  border-radius: 0.16rem;
  background: #0a6ea5;
  animation: pump-bar-lift 0.9s ease-in-out infinite;
}

.pump-plate-left {
  left: calc(50% - 3.12rem);
}

.pump-plate-right {
  left: calc(50% + 2.26rem);
}

body.report-loading-open {
  overflow: hidden;
}

@keyframes pump-arm-left {
  0% {
    transform: rotate(-20deg);
  }
  50% {
    transform: rotate(-64deg);
  }
  100% {
    transform: rotate(-20deg);
  }
}

@keyframes pump-arm-right {
  0% {
    transform: rotate(20deg);
  }
  50% {
    transform: rotate(64deg);
  }
  100% {
    transform: rotate(20deg);
  }
}

@keyframes pump-bar-lift {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.72rem);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes pump-ring-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.4;
  }
  50% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(0.96);
    opacity: 0.4;
  }
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(520px, 96vw);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: 0;
  align-self: start;
  overflow: auto;
  will-change: transform;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: 0 22px 60px rgba(4, 59, 98, 0.25);
  padding: 1rem;
  display: grid;
  gap: 0.7rem;
}

.confirm-modal-card {
  width: min(460px, 96vw);
}

.category-detail-modal-card {
  width: min(1180px, 98vw);
  max-height: calc(100vh - 1.4rem);
  max-height: calc(100dvh - 1.4rem);
  overflow-y: auto;
  gap: 0.8rem;
}

.guide-modal-card {
  width: min(980px, 97vw);
  max-height: calc(100vh - 1.6rem);
  max-height: calc(100dvh - 1.6rem);
  padding: 1.2rem 1.15rem;
  gap: 0.95rem;
}

.external-payments-modal-card {
  width: min(1080px, 97vw);
  max-height: calc(100vh - 1.5rem);
  max-height: calc(100dvh - 1.5rem);
  overflow-y: auto;
}

.guide-modal-card .modal-header {
  position: sticky;
  top: 0;
  z-index: 4;
  margin: -1.2rem -1.15rem 0;
  padding: 1rem 1.15rem 0.82rem;
  border-bottom: 1px solid #d6e4ed;
  background: #ffffff;
}

.guide-popup-lead {
  margin: 0;
}

.guide-info-box {
  border: 1px solid #bdd7e7;
  border-left: 4px solid #0a8dca;
  border-radius: 0.72rem;
  background: linear-gradient(180deg, #f7fcff, #eef8fd);
  padding: 0.72rem 0.8rem;
  display: grid;
  gap: 0.45rem;
}

.guide-info-box p {
  margin: 0;
  color: #305467;
  font-size: 0.86rem;
  line-height: 1.42;
}

.guide-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.guide-popup-step {
  border: 1px solid #c8dbe8;
  border-radius: 0.82rem;
  background: linear-gradient(180deg, #fbfdff, #f2f8fc);
  padding: 0.72rem;
  display: grid;
  gap: 0.55rem;
}

.guide-popup-step h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.guide-step-number {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #0595d6, #006ba6);
  box-shadow: 0 5px 14px rgba(0, 107, 166, 0.26);
  flex-shrink: 0;
}

.guide-popup-image {
  width: 100%;
  max-height: 16rem;
  object-fit: cover;
  border: 1px solid #c8dbe8;
  border-radius: 0.62rem;
  background: #ffffff;
  cursor: zoom-in;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.guide-popup-image:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 18px rgba(4, 59, 98, 0.18);
}

.guide-image-modal-card {
  width: min(1220px, 98vw);
  max-height: calc(100vh - 1.2rem);
  max-height: calc(100dvh - 1.2rem);
  padding: 1rem;
  gap: 0.7rem;
}

.guide-image-stage {
  border: 1px solid #c8dbe8;
  border-radius: 0.72rem;
  background: #ffffff;
  min-height: 50vh;
  max-height: calc(100vh - 7.5rem);
  max-height: calc(100dvh - 7.5rem);
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 0.6rem;
}

.guide-image-zoomed {
  width: min(100%, 1120px);
  height: auto;
  object-fit: contain;
  border-radius: 0.4rem;
}

.category-detail-controls {
  margin-top: 0;
}

.category-detail-kpis {
  display: grid;
  gap: 0.62rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.category-detail-chart-card {
  margin-top: 0;
}

.category-detail-chart {
  min-height: 360px;
}

.category-detail-list-card {
  margin-top: 0;
}

.category-detail-transactions-wrap {
  margin-top: 0.5rem;
  max-height: 320px;
  overflow: auto;
}

.category-detail-list-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: center;
}

.facts-card {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #f8fcff;
  padding: 0.7rem 0.75rem;
}

.facts-card h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent-dark);
}

.facts-list {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

#confirmModalConfirmBtn.is-danger {
  background: linear-gradient(180deg, #d14a36, #b93625);
}

#confirmModalConfirmBtn.is-danger:hover {
  background: linear-gradient(180deg, #de523e, #b32f1f);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-drag-handle {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.modal-drag-handle:active {
  cursor: grabbing;
}

.modal-close-btn {
  min-width: 2rem;
  padding: 0.3rem 0.5rem;
  line-height: 1;
}

.modal-actions {
  display: flex;
  gap: 0.55rem;
}

.modal-account-section {
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.modal-account-list {
  display: grid;
  gap: 0.45rem;
}

.modal-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.68rem;
  background: #f8fcfe;
  padding: 0.48rem 0.55rem;
}

.modal-account-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.modal-account-name {
  font-weight: 700;
  color: var(--accent-dark);
}

.modal-account-current {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #015f8f;
  background: rgba(1, 122, 178, 0.13);
}

.modal-account-remove-btn {
  padding: 0.34rem 0.56rem;
  font-size: 0.77rem;
  white-space: nowrap;
}

.type-chip {
  display: inline-block;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.type-chip.income {
  background: rgba(0, 123, 69, 0.14);
  color: #005f35;
}

.type-chip.expense {
  background: rgba(200, 61, 42, 0.12);
  color: #a22f20;
}

.action-button {
  font-size: 0.78rem;
  padding: 0.34rem 0.5rem;
  border-radius: 0.5rem;
}

@media (max-width: 1020px) {
  .auth-cta-row {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-cta-row button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-detail-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .full-width {
    grid-column: span 3;
  }

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

  .create-report-wrap {
    justify-content: stretch;
  }

  #createReportBtn {
    width: 100%;
  }

  .payments-split {
    grid-template-columns: 1fr;
  }

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

  .guide-popup-grid {
    grid-template-columns: 1fr;
  }

  .guide-image-stage {
    min-height: 40vh;
    max-height: calc(100vh - 8.4rem);
    max-height: calc(100dvh - 8.4rem);
  }

  .summary-header {
    align-items: flex-start;
  }

  .category-rule-form {
    grid-template-columns: 1fr 1fr;
  }

  .category-rule-form button {
    grid-column: 1 / -1;
  }

  .unmapped-bulk-form {
    grid-template-columns: 1fr;
  }

  .category-combo-label {
    min-width: 0;
  }

  .custom-category-field {
    margin-top: 0;
  }

  .unmapped-bulk-form button {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .container {
    width: calc(100% - 1rem);
    margin-top: 1rem;
  }

  .brand-logo {
    height: 4.1rem;
  }

  .brand-extra-image {
    right: 0.55rem;
    width: min(58vw, 270px);
    height: auto;
  }

  .tab-link {
    padding: 0.7rem 0.55rem 0.58rem;
    font-size: 0.88rem;
  }

  .upload-guide-btn {
    width: 2.7rem;
    height: 2.7rem;
    font-size: 1.5rem;
  }

  .forecast-range-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .forecast-range-controls label,
  .forecast-range-controls input,
  .forecast-range-controls > button {
    width: 100%;
  }

  .forecast-range-controls > button,
  .forecast-quick-range {
    grid-column: 1 / -1;
  }

  .forecast-quick-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.38rem;
    width: 100%;
  }

  .forecast-quick-btn {
    width: 100%;
  }

  .statement-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .statement-controls label:first-child {
    grid-column: 1 / -1;
  }

  .statement-controls label,
  .statement-controls input,
  .statement-controls > button {
    width: 100%;
  }

  .statement-controls > button {
    grid-column: 1 / -1;
  }

  #statementSearchInput {
    min-width: 0;
  }

  #pendingSearchInput {
    min-width: 0;
  }

  #categoryRulesSearchInput {
    max-width: 100%;
    min-width: 0;
  }

  #unmappedSearchInput {
    max-width: 100%;
    min-width: 0;
  }

  .rule-category-editor {
    flex-direction: column;
    align-items: stretch;
  }

  .session-bar {
    align-items: stretch;
  }

  .session-tools {
    width: 100%;
    margin-left: 0;
    flex-direction: row;
    align-items: flex-end;
  }

  .session-account-row {
    flex: 1;
    min-width: 0;
  }

  .account-switcher {
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
  }

  #accountSelect {
    min-width: 0;
    width: 100%;
  }

  .report-shortcut-btn {
    min-width: 6.7rem;
  }

  .session-menu-toggle {
    justify-content: center;
  }

  .session-menu-panel {
    width: min(24rem, 96vw);
  }

  .session-menu-user {
    padding: 0.8rem 0.8rem;
  }

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

  .category-detail-kpis {
    grid-template-columns: 1fr;
  }

  .full-width {
    grid-column: span 2;
  }

  .panel {
    padding: 0.82rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  .category-rule-form {
    grid-template-columns: 1fr;
  }

  .category-combo-label {
    min-width: 0;
  }

  .category-rule-form .custom-category-field {
    grid-column: 1 / -1;
  }

  .settings-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}
