:root {
  --surface: #ffffff;
  --surface-muted: #f5f7fb;
  --line: #d9e0ea;
  --text: #1c2430;
  --muted: #64748b;
  --primary: #0d6efd;
  --success: #198754;
  --danger: #dc3545;
  --warning: #f59f00;
}

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  background: var(--surface-muted);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
  text-decoration: none;
}

.btn {
  border-radius: 6px;
  font-weight: 600;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.2);
}

.app-shell {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: 264px;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.app-content {
  min-height: 100vh;
  margin-left: 264px;
}

.sidebar-header,
.topbar-inner {
  display: flex;
  align-items: center;
}

.sidebar-header {
  justify-content: space-between;
  min-height: 42px;
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
}

.sidebar-brand:hover,
.sidebar-brand:focus {
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.sidebar-close,
.sidebar-toggle {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.sidebar-company {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.sidebar-company span,
.sidebar-section {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-company strong {
  color: var(--text);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.sidebar-nav {
  display: grid;
  gap: 0.25rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
  scrollbar-width: thin;
}

.sidebar-section {
  padding: 0.9rem 0.75rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 42px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
}

.sidebar-link:hover,
.sidebar-link:focus,
.sidebar-link.active {
  background: #eef5ff;
  color: var(--primary);
}

.sidebar-link.active {
  font-weight: 800;
}

.sidebar-group {
  display: block;
}

.sidebar-group-title {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  user-select: none;
}

.sidebar-group-title::-webkit-details-marker {
  display: none;
}

.sidebar-group-title > span {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-group-title > span > i {
  width: 20px;
  text-align: center;
}

.sidebar-group-title:hover,
.sidebar-group-title:focus,
.sidebar-group-title.active {
  background: #f8fafc;
  color: var(--text);
}

.sidebar-group-chevron {
  font-size: 0.75rem;
  transition: transform 0.18s ease;
}

.sidebar-group[open] .sidebar-group-chevron {
  transform: rotate(180deg);
}

.sidebar-group-links {
  display: grid;
  gap: 0.15rem;
  padding: 0.2rem 0 0.35rem 0.75rem;
}

.sidebar-group-links .sidebar-link {
  min-height: 38px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.925rem;
}

.sidebar-backdrop {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  min-height: 64px;
  gap: 0.75rem;
  padding: 0 1.5rem;
}

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
}

.topbar-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link {
  color: var(--muted);
  font-weight: 600;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--primary);
}

.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 260px;
  padding: 0.25rem 0.6rem 0.25rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.2;
  cursor: pointer;
}

.user-menu-toggle:hover,
.user-menu-toggle[aria-expanded="true"] {
  border-color: var(--primary);
}

.user-avatar {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.user-menu-label {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.user-menu-label strong,
.user-menu-label small {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-label strong {
  font-size: 0.88rem;
  font-weight: 700;
}

.user-menu-label small {
  color: var(--muted);
  font-size: 0.72rem;
}

.user-menu-caret {
  color: var(--muted);
  font-size: 0.65rem;
}

.user-menu-panel {
  min-width: 250px;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem 0.6rem;
}

.user-menu-header > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.user-menu-header strong,
.user-menu-header small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-header strong {
  font-size: 0.85rem;
}

.user-menu-header small {
  color: var(--muted);
  font-size: 0.75rem;
}

.user-menu-panel .dropdown-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  border-radius: 6px;
  background: none;
  font-weight: 600;
  text-align: left;
}

.user-menu-panel form {
  margin: 0;
}

.app-main {
  padding: 1.5rem 0 2.5rem;
}

.dashboard-shell {
  display: grid;
  gap: 1rem;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-heading h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0;
}

.page-heading p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  position: relative;
  min-height: 118px;
  padding: 1rem;
  overflow: hidden;
}

.metric-link {
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric-link:hover,
.metric-link:focus {
  color: var(--text);
  border-color: rgba(13, 110, 253, 0.45);
  transform: translateY(-1px);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 0.55rem;
  font-size: clamp(1.25rem, 1.8vw, 1.75rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-weight: 700;
}

.metric-card i {
  position: absolute;
  right: 1rem;
  bottom: 0.85rem;
  color: rgba(13, 110, 253, 0.18);
  font-size: 2rem;
}

.metric-card.income i {
  color: rgba(25, 135, 84, 0.2);
}

.metric-card.expense i {
  color: rgba(220, 53, 69, 0.2);
}

.metric-card.net i {
  color: rgba(245, 159, 0, 0.24);
}

.metric-grid.compact .metric-card {
  min-height: 96px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 1rem;
}

.dashboard-grid.lower {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  padding: 1rem;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.chart-panel {
  min-height: 320px;
}

.table {
  --bs-table-bg: transparent;
}

.table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.table td {
  vertical-align: middle;
}

.list-stack {
  display: grid;
  gap: 0.65rem;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 800;
}

.compact-balance {
  min-width: min(100%, 260px);
  min-height: 82px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.report-card {
  display: grid;
  min-height: 170px;
  align-content: start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.report-card:hover,
.report-card:focus {
  border-color: rgba(13, 110, 253, 0.45);
  color: var(--text);
}

.report-card i {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(13, 110, 253, 0.1);
  color: var(--primary);
}

.report-card strong {
  font-size: 1.05rem;
}

.report-card span {
  color: var(--muted);
}

.due-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.due-item strong,
.due-item span {
  display: block;
}

.due-item span,
.empty-state {
  color: var(--muted);
}

.empty-state {
  padding: 1rem;
  text-align: center;
}

.empty-state p {
  margin: 0.35rem 0 0;
}

.favorite-toggle {
  padding: 0;
  margin-right: 0.35rem;
  color: #94a3b8;
  vertical-align: baseline;
}

.favorite-toggle.is-favorite,
.favorite-toggle:hover {
  color: #f59f00;
}

.quick-account-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.65rem;
}

.quick-account {
  display: grid;
  gap: 0.25rem;
  min-height: 92px;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
}

.quick-account:hover,
.quick-account:focus {
  color: var(--text);
  border-color: rgba(13, 110, 253, 0.45);
}

.quick-account span,
.quick-account small {
  color: var(--muted);
}

.mobile-action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.mobile-action-bar .btn {
  min-height: 46px;
}

.timeline {
  display: grid;
  gap: 0.75rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 0.75rem;
  position: relative;
}

.timeline-date {
  color: var(--muted);
  font-weight: 800;
}

.timeline-content {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #fff;
}

.timeline-item.is-overdue .timeline-content {
  border-left-color: var(--warning);
  background: #fff8e1;
}

.timeline-content p {
  margin: 0.35rem 0;
}

.timeline-content small {
  color: var(--muted);
}

.modal-loading {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.command-search {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.command-search .form-control {
  border: 0;
  box-shadow: none;
  font-size: 1.05rem;
  padding-left: 0;
}

.command-results {
  max-height: min(70vh, 620px);
  overflow: auto;
  padding: 0.5rem;
}

.command-empty {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.command-list {
  display: grid;
  gap: 0.35rem;
}

.command-palette-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.command-palette-item:hover,
.command-palette-item.is-active {
  background: #f3f7ff;
  border-color: rgba(13, 110, 253, 0.25);
}

.command-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(13, 110, 253, 0.1);
  color: var(--primary);
}

.command-text {
  display: grid;
  gap: 0.15rem;
}

.command-text span {
  color: var(--muted);
  font-size: 0.9rem;
}

.command-inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.finora-fab {
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
}

.finora-fab-main {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 5px 14px rgba(13, 110, 253, 0.22);
}

.finora-fab-main:hover,
.finora-fab-main:focus-visible {
  background: #0b5ed7;
}

.finora-fab-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  display: none;
  min-width: 230px;
  padding: 0.45rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

.finora-fab.is-open .finora-fab-menu {
  display: grid;
  gap: 0.25rem;
}

.finora-fab-menu a,
.finora-fab-menu button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-weight: 700;
  text-align: left;
}

.finora-fab-menu a:hover,
.finora-fab-menu button:hover {
  background: #f3f7ff;
  color: var(--primary);
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

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

  .dashboard-grid,
  .dashboard-grid.lower {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 20px 0 42px rgba(15, 23, 42, 0.18);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.34);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .app-content {
    margin-left: 0;
  }

  .topbar-inner {
    padding: 0 1rem;
  }
}

@media (max-width: 767.98px) {
  .app-main {
    padding-top: 1rem;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-actions {
    width: 100%;
  }

  .quick-actions .btn {
    flex: 1 1 180px;
  }

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

  .due-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .due-item .text-end {
    width: 100%;
    text-align: left !important;
  }

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

  .table-responsive {
    overflow: visible;
  }

  .table thead {
    display: none;
  }

  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    padding: 0.35rem 0;
    text-align: right !important;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
    text-align: left;
  }

  .table td .btn-group {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .command-palette-item {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .command-inline-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

}
