:root {
  --expense: #d92d20;
  --income: #159947;
  --primary: #0e7c66;
  --primary-2: #0b5f95;
  --accent: #f59e0b;
  --bg: #f2f7f8;
  --surface: #ffffff;
  --surface-soft: #f7fbfc;
  --border: #d8e6ea;
  --text: #12242a;
  --muted: #5f747d;
  --shadow: 0 12px 30px rgba(13, 47, 61, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Tajawal", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(17, 140, 111, 0.14), transparent 60%),
    radial-gradient(900px 500px at 90% -20%, rgba(11, 95, 149, 0.12), transparent 55%),
    linear-gradient(180deg, #eef6f7 0%, #f5f9fa 28%, #f2f7f8 100%);
}

.container {
  width: min(1240px, 94%);
  margin: 20px auto 26px;
  padding-bottom: 110px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 1));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: #0d2b35;
}

.subtitle,
.hint {
  color: var(--muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  position: sticky;
  top: 10px;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 12px;
}

.brand-text {
  font-size: 1.36rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0f7fa;
  border: 1px solid #d2e3e9;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 600;
}

.avatar-btn {
  border: 0;
  background: transparent;
  padding: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
}

.avatar-btn:focus-visible {
  outline: 2px solid #2f88d8;
  outline-offset: 2px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #d8e3ea;
  background: #dbe7ec;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #d9e6eb;
  border-radius: 14px;
  box-shadow: 0 18px 34px rgba(7, 29, 38, 0.16);
  padding: 8px;
  z-index: 50;
}

.user-menu-item {
  width: 100%;
  text-align: start;
  border: 1px solid transparent;
  background: #f6fbfd;
  color: #12313b;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 6px;
}

.user-menu-item:last-child {
  margin-bottom: 0;
}

.user-menu-item:hover {
  background: #e9f4f8;
}

.user-menu-item.danger {
  background: #fff1ef;
  color: #c11f17;
  border-color: #ffd2cd;
}

.btn {
  border: 0;
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #ffffff;
  box-shadow: 0 9px 20px rgba(14, 124, 102, 0.28);
}

.btn.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.92;
}

.btn.is-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-start: 8px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #ffffff;
  border-radius: 50%;
  vertical-align: middle;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-ghost {
  background: #edf4f6;
  color: #12313b;
  border: 1px solid #d5e4e9;
}

.btn-outline {
  background: #ffffff;
  color: #0f3944;
  border: 1px solid #c8d9df;
}

.btn-google {
  background: #ffffff;
  border: 1px solid #d6dbe0;
}

.btn-microsoft {
  background: #edf3ff;
  border: 1px solid #ccd9fb;
}

.btn-apple {
  background: #101215;
  color: #ffffff;
}

.landing-card {
  margin-bottom: 14px;
  padding: 0;
  overflow: hidden;
}

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

.hero-grid > div {
  padding: 24px 22px 8px;
}

#landingTitle {
  font-size: clamp(1.6rem, 4.5vw, 2.7rem);
  line-height: 1.15;
  margin-bottom: 10px;
}

#landingSubtitle {
  font-size: 1.03rem;
  max-width: 780px;
  line-height: 1.65;
}

.landing-actions {
  margin-top: 16px;
}

.mobile-app-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid rgba(14, 124, 102, 0.14);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(14, 124, 102, 0.08), rgba(37, 99, 235, 0.08));
}

.mobile-app-kicker {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.8rem;
}

.mobile-app-card h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.mobile-store-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.store-button {
  min-width: 160px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.store-button small {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
}

.store-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 900;
}

.store-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.hero-image {
  width: 100%;
  max-width: none;
  display: block;
  height: min(56vh, 560px);
  object-fit: cover;
  border-top: 1px solid #d8e6ea;
  border-bottom: 1px solid #d8e6ea;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 22px;
}

.feature-box,
.how-card,
.comments-card {
  background: linear-gradient(180deg, #f9fcfd, #f5fafb);
  border: 1px solid #dbe9ed;
  border-radius: 14px;
}

.feature-box {
  padding: 14px;
}

.feature-box h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.feature-box p {
  line-height: 1.65;
}

.how-card {
  margin: 0 22px 12px;
  padding: 14px;
}

.how-card h3 {
  margin-bottom: 8px;
}

.how-card ol {
  margin: 0;
  padding-inline-start: 22px;
  line-height: 1.9;
}

.comments-card {
  margin: 0 22px 20px;
  padding: 14px;
}

.feedback-form {
  margin-top: 10px;
  display: grid;
  gap: 9px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: #1b3a44;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbdbe2;
  border-radius: 11px;
  padding: 10px 11px;
  font-family: inherit;
  font-size: 0.96rem;
  background: #ffffff;
  color: #162d34;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6ba8c7;
  box-shadow: 0 0 0 3px rgba(69, 145, 181, 0.18);
}

.auth-card {
  margin-bottom: 14px;
}

.auth-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.auth-tabs {
  display: inline-flex;
  gap: 8px;
  margin: 12px 0;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-inline-link {
  display: inline-flex;
  justify-content: flex-start;
  margin-top: 2px;
  color: #0b5f95;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.auth-inline-link:hover {
  text-decoration: underline;
}

.password-match-hint {
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 20px;
}

.password-match-hint.match-ok {
  color: #159947;
}

.password-match-hint.match-bad {
  color: #d92d20;
}

.password-checklist {
  margin: 0;
  padding-inline-start: 20px;
  display: grid;
  gap: 4px;
}

.rule-item {
  font-size: 0.88rem;
  font-weight: 700;
}

.rule-item::marker {
  content: "✗ ";
  color: #d92d20;
}

.rule-item.rule-ok {
  color: #159947;
}

.rule-item.rule-ok::marker {
  content: "✓ ";
  color: #159947;
}

.rule-item.rule-fail {
  color: #d92d20;
}

.social-divider {
  text-align: center;
  margin: 12px 0;
  color: #617883;
  font-weight: 700;
}

.social-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

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

.subscription-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  border: 1px solid #c8d7f3;
  background: #ecf2ff;
  color: #224083;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.9rem;
  font-weight: 700;
}

.widgets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 13px 0;
}

.widget {
  position: relative;
  overflow: hidden;
}

.widget::after {
  content: "";
  position: absolute;
  inset-inline-end: -30px;
  inset-block-start: -40px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  opacity: 0.1;
}

.widget.in::after {
  background: var(--income);
}

.widget.out::after {
  background: var(--expense);
}

.widget.net::after {
  background: #2f7fdc;
}

.widget strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.widget.in strong {
  color: var(--income);
}

.widget.out strong {
  color: var(--expense);
}

.widget.net strong {
  color: #2f7fdc;
}

.chart-card,
.filters-card,
.table-card,
.grid-2 {
  margin-top: 12px;
}

.savings-card {
  margin-top: 12px;
}

.savings-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.savings-item {
  border: 1px solid #d4e3e9;
  border-radius: 12px;
  padding: 10px;
  background: #f8fcfd;
}

.savings-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.savings-progress {
  height: 10px;
  border-radius: 999px;
  background: #e7eff3;
  overflow: hidden;
}

.savings-progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #159947, #0e7c66);
}

.savings-meta {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.savings-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.savings-actions input {
  width: 150px;
}

.savings-actions select {
  width: 190px;
  min-width: 150px;
}

.chart-card {
  height: 390px;
}

#cashFlowChart {
  height: 320px !important;
  max-height: 320px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.fx-box {
  grid-column: 1 / -1;
  border: 1px solid #d8e7ec;
  border-radius: 12px;
  padding: 10px;
  background: #f8fcfd;
}

.fx-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.fx-inline select {
  width: auto;
  min-width: 96px;
}

.fx-arrow {
  color: #46707d;
  font-weight: 800;
}

.admin-card {
  margin-top: 14px;
}

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

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-stat {
  border: 1px solid #d8e6ea;
  background: #f8fcfe;
  border-radius: 12px;
  padding: 12px;
}

.admin-stat span {
  color: #5d7580;
  display: block;
  margin-bottom: 6px;
}

.admin-stat strong {
  font-size: 1.2rem;
}

.admin-feedback h4 {
  margin-bottom: 10px;
}

.admin-feedback .table-wrap {
  overflow-x: hidden;
}

.admin-feedback table {
  table-layout: fixed;
}

.admin-feedback th,
.admin-feedback td {
  white-space: normal;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.admin-team {
  margin-bottom: 14px;
}

.admin-visitors-chart-wrap {
  border: 1px solid #d8e6ea;
  background: #f8fcfe;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.admin-visitors-chart-wrap h4 {
  margin-bottom: 8px;
}

#adminVisitorsChart {
  height: 280px !important;
  max-height: 280px;
}

.admin-team h4 {
  margin-bottom: 10px;
}

.admin-team-form {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.admin-invite-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.invite-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.invite-status.status-active {
  color: #0f6e46;
  background: #e6f8ef;
  border-color: #b9e8cd;
}

.invite-status.status-expired {
  color: #7f4b00;
  background: #fff6e5;
  border-color: #f3d7a3;
}

.invite-status.status-used {
  color: #1c4f91;
  background: #e9f1ff;
  border-color: #c8dafc;
}

.invite-status.status-canceled {
  color: #8f162b;
  background: #ffecef;
  border-color: #ffcbd3;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.admin-reply-box {
  min-width: 0;
}

.admin-reply-input {
  width: 100%;
  min-height: 68px;
  resize: vertical;
}

.admin-reply-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 8px;
  align-items: end;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #d8e7ec;
  border-radius: 13px;
  background: #fcfeff;
}

.table-card .table-wrap {
  overflow-x: hidden;
}

.tx-filter-notice {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border: 1px solid #b8dff2;
  background: #eef8fd;
  color: #0d3e57;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid #e4eef2;
  text-align: right;
  white-space: nowrap;
}

.table-card th,
.table-card td {
  white-space: normal;
  vertical-align: top;
}

.table-card td {
  word-break: break-word;
}

.table-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tx-col-select {
  width: 44px;
  text-align: center !important;
  white-space: nowrap !important;
}

#txSelectAll,
.tx-row-select {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.tx-note-preview {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tx-col-type,
.tx-col-amount,
.tx-col-currency,
.tx-col-date,
.tx-col-actions {
  white-space: nowrap !important;
}

.tx-col-category,
.tx-col-wallet,
.tx-col-source {
  white-space: nowrap;
}

.tx-col-note {
  min-width: 240px;
  max-width: 360px;
}

.tx-col-note .btn-sm {
  margin-top: 6px;
}

.badge {
  white-space: nowrap;
}

.tx-details {
  margin-top: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #d7e5eb;
  background: #f7fbfd;
  font-size: 0.9rem;
  line-height: 1.45;
}

html[data-theme="dark"] .tx-details {
  border-color: #2a4662;
  background: #0a1f34;
  color: #dbe9f4;
}

html[data-theme="dark"] .tx-details strong {
  color: #ffffff;
}

th {
  background: #eff6f8;
  font-weight: 800;
  color: #1e4753;
}

html[dir="ltr"] th,
html[dir="ltr"] td {
  text-align: left;
}

.empty-cell {
  text-align: center !important;
  color: #6e848d;
}

.badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.badge.in {
  background: #e6f8ee;
  color: var(--income);
}

.badge.out {
  background: #feeceb;
  color: var(--expense);
}

.amount.in {
  color: var(--income);
  font-weight: 800;
}

.amount.out {
  color: var(--expense);
  font-weight: 800;
}

.tx-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-radius: 9px;
  min-width: 64px;
}

.btn-del {
  color: #ffffff;
  border-color: #d92d20;
  background: #d92d20;
}

html[data-theme="dark"] .btn-del {
  color: #ffffff;
  border-color: #f04438;
  background: #f04438;
}

.plans-dialog,
.tx-dialog {
  border: 0;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(8, 29, 36, 0.28);
}

.permissions-dialog {
  width: min(760px, 95vw);
  border: 0;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 44px rgba(8, 29, 36, 0.3);
}

.permissions-dialog::backdrop {
  background: rgba(7, 14, 24, 0.58);
}

.permissions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.permissions-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.35fr 0.8fr auto;
  gap: 10px;
  align-items: end;
}

.permissions-list-wrap {
  margin-top: 14px;
  border: 1px solid #d8e6ea;
  border-radius: 12px;
  overflow: hidden;
}

.permissions-table {
  width: 100%;
  border-collapse: collapse;
}

.permissions-table th,
.permissions-table td {
  padding: 10px;
  border-bottom: 1px solid #e3edf1;
  text-align: start;
}

.role-chip {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.role-view {
  color: #1f5fa2;
  background: #e8f2fd;
}

.role-edit {
  color: #0f766e;
  background: #e5f8f4;
}

.role-admin {
  color: #8a2a12;
  background: #ffefe6;
}

.btn-remove-perm {
  border: 1px solid #ffd2cd;
  background: #fff2f0;
  color: #ca2a1f;
  border-radius: 9px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
}

.plans-dialog {
  max-width: 1120px;
  width: min(95vw, 1120px);
  padding: 16px;
}

.plans-dialog::backdrop,
.tx-dialog::backdrop {
  background: rgba(5, 20, 27, 0.5);
}

.plans-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  margin-top: 10px;
}

.plan-item {
  border-radius: 14px;
  border: 1px solid #d7e5eb;
  background: linear-gradient(180deg, #ffffff, #f5fbfd);
  color: #173742;
  padding: 14px;
}

.plan-item.featured {
  border-color: #c9922e;
  background: linear-gradient(180deg, #fff6df, #ffe8b3);
}

.plan-item ul {
  margin: 10px 0;
  padding-inline-start: 18px;
}

.plan-item li {
  margin: 7px 0;
  line-height: 1.5;
}

.plan-price {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 8px 0;
}

.tx-dialog {
  max-width: 760px;
  width: min(94vw, 760px);
}

.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.quick-add {
  position: fixed;
  left: 22px;
  bottom: 14px;
  border: 0;
  border-radius: 999px;
  padding: 12px 17px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #0e7c66, #0b5f95);
  box-shadow: 0 10px 24px rgba(14, 124, 102, 0.35);
  cursor: pointer;
  z-index: 30;
}

.dashboard-side-nav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 24;
  width: 168px;
  min-height: 100vh;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 112px 10px 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 12px 28px rgba(8, 35, 41, 0.12);
  backdrop-filter: blur(10px);
}

[dir="rtl"] .dashboard-side-nav {
  left: auto;
  right: 0;
}

#dashboardSection {
  padding-left: 168px;
}

[dir="rtl"] #dashboardSection {
  padding-left: 0;
  padding-right: 168px;
}

.side-nav-btn {
  width: 100%;
  border: 1px solid #d4e4e2;
  background: #f6fbfa;
  color: #123f46;
  border-radius: 8px;
  padding: 11px 12px;
  min-height: 52px;
  font-weight: 800;
  text-align: start;
  cursor: pointer;
}

html[data-theme="dark"] .dashboard-side-nav {
  background: rgba(18, 29, 40, 0.96);
  border-color: #2a3a4c;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .side-nav-btn {
  background: #162434;
  border-color: #2a3a4c;
  color: #e5eef5;
}

html[data-theme="dark"] .side-nav-btn:hover,
html[data-theme="dark"] .side-nav-btn:focus-visible,
html[data-theme="dark"] .side-nav-btn.is-active {
  border-color: #22b8a8;
  background: #0f9f8f;
  color: #ffffff;
}

.side-nav-btn:hover,
.side-nav-btn:focus-visible,
.side-nav-btn.is-active {
  border-color: #0f9f8f;
  background: #0f9f8f;
  color: #ffffff;
  outline: none;
}

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

@media (max-width: 1050px) {
  .plans-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 900px) {
  .container {
    width: min(100%, 95%);
    margin-top: 14px;
  }

  .topbar {
    position: static;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .brand-text {
    font-size: 1.12rem;
  }

  .hero-image {
    height: min(42vh, 340px);
  }

  .about-grid,
  .widgets-grid,
  .grid-2,
  .social-grid {
    grid-template-columns: 1fr;
  }

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

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

  .dashboard-head {
    flex-direction: column;
    align-items: stretch;
  }

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

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

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

  .admin-team-form {
    grid-template-columns: 1fr;
  }

  .admin-invite-link-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .plans-grid,
  .filters-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .quick-add {
    left: 12px;
    right: 12px;
    bottom: 10px;
    text-align: center;
  }

  .dashboard-side-nav {
    position: sticky;
    top: 8px;
    left: auto;
    right: auto;
    width: auto;
    min-height: auto;
    padding: 10px;
    border-radius: 10px;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    margin-bottom: 12px;
  }

  #dashboardSection,
  [dir="rtl"] #dashboardSection {
    padding-left: 0;
    padding-right: 0;
  }

  .side-nav-btn {
    white-space: nowrap;
    text-align: center;
  }
}

@media print {
  #quickAddBtn,
  .head-actions,
  .filters-card,
  .manage-card,
  .budget-card,
  .reconcile-card,
  .auth-card,
  .landing-card {
    display: none !important;
  }

  .container {
    width: 100%;
    margin: 0;
  }
}

html[data-theme="dark"] {
  --bg: #0f1720;
  --surface: #121d28;
  --surface-soft: #162434;
  --border: #2a3a4c;
  --text: #e5eef5;
  --muted: #9bb0be;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(17, 140, 111, 0.22), transparent 60%),
    radial-gradient(900px 500px at 90% -20%, rgba(11, 95, 149, 0.22), transparent 55%),
    linear-gradient(180deg, #0f1720 0%, #0c131c 100%);
  color: var(--text);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .feature-box,
html[data-theme="dark"] .how-card,
html[data-theme="dark"] .comments-card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .savings-item {
  background: linear-gradient(180deg, #152331, #111d2a);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .tx-dialog {
  background: linear-gradient(180deg, #152331, #0f1b27);
  color: #e5eef5;
  border: 1px solid #2a3a4c;
}

html[data-theme="dark"] .tx-dialog h3,
html[data-theme="dark"] .tx-dialog label,
html[data-theme="dark"] .tx-dialog span {
  color: #e7f0f8;
}

html[data-theme="dark"] .tx-dialog input::placeholder,
html[data-theme="dark"] .tx-dialog textarea::placeholder {
  color: #8ea3b4;
}

html[data-theme="dark"] .fx-box {
  background: #101b28;
  border-color: #294055;
}

html[data-theme="dark"] .fx-arrow {
  color: #93afc2;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] .brand-text,
html[data-theme="dark"] th {
  color: #e7f0f8;
}

html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .hint,
html[data-theme="dark"] .social-divider {
  color: var(--muted);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0e1721;
  color: #e5eef5;
  border-color: #314558;
}

html[data-theme="dark"] .btn-ghost {
  background: #1d2e3f;
  color: #d9e6f0;
  border-color: #31475c;
}

html[data-theme="dark"] .btn-ghost.btn-del {
  color: #ffffff;
  border-color: #f04438;
  background: #f04438;
}

html[data-theme="dark"] .btn-outline {
  background: #121d28;
  color: #dbe8f2;
  border-color: #33506a;
}

html[data-theme="dark"] .user-chip {
  background: #172635;
  border-color: #31485d;
  color: #dfeaf3;
}

html[data-theme="dark"] .user-menu {
  background: #0f1d2b;
  border-color: #31485d;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .user-menu-item {
  background: #15283a;
  border-color: #243f56;
  color: #dbeaf5;
}

html[data-theme="dark"] .user-menu-item:hover {
  background: #1a3349;
}

html[data-theme="dark"] .user-menu-item.danger {
  background: #3a1d24;
  border-color: #7d3340;
  color: #ffb7bd;
}

html[data-theme="dark"] .permissions-dialog {
  background: linear-gradient(180deg, #152331, #0f1b27);
  color: #e5eef5;
  border: 1px solid #2a3a4c;
}

html[data-theme="dark"] .permissions-list-wrap {
  border-color: #2f4357;
}

html[data-theme="dark"] .permissions-table th,
html[data-theme="dark"] .permissions-table td {
  border-bottom-color: #25384a;
}

html[data-theme="dark"] .btn-remove-perm {
  background: #4a222b;
  border-color: #8d3b4b;
  color: #ffc8ce;
}

html[data-theme="dark"] .admin-stat {
  background: #122232;
  border-color: #2b4157;
}

html[data-theme="dark"] .admin-stat span {
  color: #9bb2c3;
}

html[data-theme="dark"] .admin-team .check-inline {
  color: #dbe8f3;
}

html[data-theme="dark"] .admin-visitors-chart-wrap {
  background: #122232;
  border-color: #2b4157;
}

html[data-theme="dark"] .invite-status.status-active {
  color: #8de7bc;
  background: #153b2b;
  border-color: #2f6d50;
}

html[data-theme="dark"] .invite-status.status-expired {
  color: #ffd79a;
  background: #473313;
  border-color: #73542a;
}

html[data-theme="dark"] .invite-status.status-used {
  color: #b4d0ff;
  background: #1a3156;
  border-color: #365987;
}

html[data-theme="dark"] .invite-status.status-canceled {
  color: #ffb0bc;
  background: #4b1e2c;
  border-color: #834055;
}

html[data-theme="dark"] th {
  background: #1a2b3d;
  border-bottom-color: #2f4256;
}

html[data-theme="dark"] td {
  border-bottom-color: #27394b;
}

html[data-theme="dark"] .tx-filter-notice {
  border-color: #2f5673;
  background: #10283b;
  color: #b7d9f3;
}

html[data-theme="dark"] .plan-item {
  border: 1px solid #2c3746;
  background: linear-gradient(160deg, #101821, #121a2a);
  color: #f4f8fb;
}

html[data-theme="dark"] .plan-item.featured {
  border-color: #d39b2f;
  background: linear-gradient(160deg, #102437, #0f4a63);
}

.logo-sections {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.logo-section-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-section-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.logo-section-card h4 {
  margin: 0;
}

.logo-section-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.site-footer {
  margin: 18px 0 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.site-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.site-footer-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
}

html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .logo-section-card {
  background: linear-gradient(180deg, #152331, #111d2a);
  border-color: var(--border);
}

.ai-forecast-card {
  margin-bottom: 10px;
}

.ai-smart-input {
  margin: 8px 0 12px;
}

.ai-smart-input textarea {
  min-height: 76px;
  resize: vertical;
}

.ai-smart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

/* ============================================================
   AI Floating Action Button & Chat Overlay
   ============================================================ */

/* FAB Button */
.ai-fab {
  position: fixed;
  bottom: 88px;
  inset-inline-end: 28px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #0f766e 0%, #0891b2 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(8,145,178,0.45);
  transition: transform 0.2s, box-shadow 0.2s;
}
.ai-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(8,145,178,0.55);
}
.ai-fab.hidden { display: none !important; }

/* Overlay backdrop */
.ai-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  animation: fadeInOverlay 0.2s ease;
}
.ai-chat-overlay.hidden { display: none !important; }

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Chat panel */
.ai-chat-panel {
  background: var(--bg-card, #fff);
  border-radius: 20px;
  width: min(460px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.25s ease;
  overflow: hidden;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0f766e 0%, #0891b2 100%);
  color: #fff;
}
.ai-chat-title {
  font-weight: 700;
  font-size: 1rem;
}
.ai-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.ai-chat-close:hover { opacity: 1; }

/* Body */
.ai-chat-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Hint */
.ai-chat-hint {
  background: var(--bg-subtle, #f0fdfa);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--text-muted, #555);
  line-height: 1.5;
}
.ai-chat-hint p { margin: 0 0 4px; }

/* Input row */
.ai-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-chat-textarea {
  flex: 1;
  resize: vertical;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 0.93rem;
  font-family: inherit;
  background: var(--bg-input, #fff);
  color: var(--text, #1a202c);
  transition: border-color 0.15s;
  min-height: 60px;
}
.ai-chat-textarea:focus {
  outline: none;
  border-color: #0891b2;
}

/* Mic button */
.ai-mic-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border, #e2e8f0);
  background: var(--bg-card, #fff);
  color: var(--text, #374151);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ai-mic-btn:hover {
  background: #f0fdfa;
  border-color: #0f766e;
  color: #0f766e;
}
.ai-mic-btn.recording {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  animation: pulse-mic 1s infinite;
}
@keyframes pulse-mic {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Send button */
.ai-send-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
}

/* Mic status */
.ai-mic-status {
  font-size: 0.85rem;
  color: #ef4444;
  font-weight: 600;
  text-align: center;
}
.ai-mic-status.hidden { display: none; }

/* Loading spinner */
.ai-chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  font-size: 0.9rem;
  color: var(--text-muted, #555);
}
.ai-chat-loading.hidden { display: none; }
.ai-spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--border, #e2e8f0);
  border-top-color: #0891b2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.ai-chat-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.ai-chat-error.hidden { display: none; }

/* Result card */
.ai-result-card {
  background: var(--bg-subtle, #f0fdfa);
  border: 1.5px solid #99f6e4;
  border-radius: 14px;
  overflow: hidden;
}
.ai-result-card.hidden { display: none; }

.ai-result-header {
  background: #0f766e;
  color: #fff;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
}

.ai-result-grid {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(300px, 38vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ai-result-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.9rem;
}
.ai-result-label {
  min-width: 90px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  flex-shrink: 0;
}
.ai-result-value {
  color: var(--text, #1a202c);
  word-break: break-word;
}

.ai-result-row-multi {
  padding: 9px 0;
  border-bottom: 1px solid rgba(15, 118, 110, 0.16);
}

.ai-result-row-multi:last-child {
  border-bottom: 0;
}

.ai-result-row-multi small {
  color: var(--muted, #6b7280);
  line-height: 1.45;
}

.ai-result-actions {
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  border-top: 1px solid #99f6e4;
}

/* Upgrade wall */
.ai-upgrade-wall {
  padding: 32px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ai-upgrade-wall.hidden { display: none; }
.ai-upgrade-icon { font-size: 2.5rem; }
.ai-upgrade-wall p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text, #374151);
}

/* RTL support */
[dir="rtl"] .ai-fab {
  inset-inline-end: 28px;
  bottom: 88px;
}

.review-dialog {
  width: min(760px, 96vw);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(8, 29, 36, 0.28);
  padding: 16px;
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 16, 27, 0.45);
  z-index: 12000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
}

.tour-box {
  width: min(460px, 92vw);
  background: #ffffff;
  color: #0f172a;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(2, 8, 23, 0.25);
}

.tour-box h4 {
  margin: 0 0 8px;
}

.tour-box p {
  margin: 0 0 12px;
  line-height: 1.6;
}

.tour-button-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin: 0 0 14px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #0f9f8f;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 159, 143, 0.28);
}

.tour-target {
  position: relative !important;
  z-index: 12001 !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.45) !important;
  border-radius: 10px !important;
}

.review-grid .full {
  grid-column: 1 / -1;
}

/* Final sidebar/settings fixes */
body.app-mode .dashboard-side-nav {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

body.app-mode .side-nav-btn,
body.app-mode .side-user-btn,
body.app-mode .side-setting-btn {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

body.app-mode .side-nav-btn {
  flex-shrink: 0;
  white-space: normal;
  line-height: 1.25;
  overflow: hidden;
}

body.app-mode .side-nav-btn > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.app-mode .side-nav-btn:hover,
body.app-mode .side-nav-btn:focus-visible,
body.app-mode [dir="rtl"] .side-nav-btn:hover,
body.app-mode [dir="rtl"] .side-nav-btn:focus-visible {
  transform: none;
}

body.app-mode .side-nav-settings {
  flex: 0 0 auto;
  margin-top: auto;
  min-width: 0;
}

.side-settings-menu {
  display: grid;
  gap: 8px;
}

.side-settings-menu.hidden {
  display: none !important;
}

body.app-mode .quick-add {
  inset-inline-start: calc(var(--app-sidebar) + 20px);
}

body.app-mode[dir="rtl"] .quick-add,
[dir="rtl"] body.app-mode .quick-add {
  inset-inline-start: auto;
  inset-inline-end: calc(var(--app-sidebar) + 20px);
}

@media (max-width: 900px) {
  body.app-mode .quick-add,
  body.app-mode[dir="rtl"] .quick-add,
  [dir="rtl"] body.app-mode .quick-add {
    inset-inline-start: 18px;
    inset-inline-end: auto;
  }
}

/* Global dashboard redesign */
:root {
  --app-sidebar: 232px;
  --app-radius: 14px;
  --app-shadow-soft: 0 18px 46px rgba(11, 31, 43, 0.08);
  --app-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 44px rgba(15, 23, 42, 0.07);
}

body {
  background:
    linear-gradient(135deg, rgba(15, 159, 143, 0.08), transparent 28%),
    linear-gradient(225deg, rgba(11, 95, 149, 0.08), transparent 32%),
    #f6f8fb;
}

body.app-mode .container:has(#dashboardSection:not(.hidden)) {
  width: 100%;
  margin: 0;
  padding: 0 0 80px;
}

body.app-mode .container:has(#dashboardSection:not(.hidden)) > .topbar {
  display: none;
}

#dashboardSection {
  min-height: 100vh;
  padding-left: var(--app-sidebar);
}

[dir="rtl"] #dashboardSection {
  padding-left: 0;
  padding-right: var(--app-sidebar);
}

.dashboard-side-nav {
  width: var(--app-sidebar);
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-inline-end: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 10px 0 34px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(22px);
}

[dir="rtl"] .dashboard-side-nav {
  border-inline-end: 0;
  border-inline-start: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: -10px 0 34px rgba(15, 23, 42, 0.06);
}

.side-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 12px;
}

.side-nav-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: #eef8f6;
  border: 1px solid #d8ebe8;
}

.side-nav-brand strong {
  display: block;
  font-size: 1rem;
  letter-spacing: 0;
}

.side-nav-brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.side-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-bottom: 6px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #31434d;
  box-shadow: none;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.side-nav-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eef5f6;
  color: #0e7c66;
  font-weight: 900;
}

.side-nav-btn:hover,
.side-nav-btn:focus-visible {
  background: #eff7f8;
  color: #0b2f39;
  transform: translateX(2px);
}

[dir="rtl"] .side-nav-btn:hover,
[dir="rtl"] .side-nav-btn:focus-visible {
  transform: translateX(-2px);
}

.side-nav-btn.is-active {
  background: linear-gradient(135deg, #0e7c66, #0b5f95);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 14px 26px rgba(14, 124, 102, 0.24);
}

.side-nav-btn.is-active .side-nav-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.side-nav-settings {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 8px;
}

.side-user-btn,
.side-setting-btn {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: #f7fbfc;
  color: #253741;
  min-height: 42px;
  font-weight: 800;
  cursor: pointer;
}

.side-user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  text-align: start;
}

.side-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbe7ec;
}

.side-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side-setting-btn:hover,
.side-user-btn:hover {
  background: #eef7f8;
  border-color: #b9d8d6;
}

.side-setting-btn.full {
  grid-column: 1 / -1;
}

.app-command-bar,
.dashboard-head {
  position: sticky;
  top: 0;
  z-index: 21;
  margin: 0 0 18px;
  border-radius: 0 0 var(--app-radius) var(--app-radius);
  border-top: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
}

#dashboardSection > [data-dashboard-panel],
#dashboardSection > .widgets-grid {
  width: min(1180px, calc(100% - 36px));
  margin-left: auto;
  margin-right: auto;
}

.hero-insight-card {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  padding: 24px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(9, 86, 84, 0.96), rgba(11, 95, 149, 0.94)),
    #0b5f95;
  border: 0;
  box-shadow: 0 22px 54px rgba(11, 95, 149, 0.24);
}

.hero-insight-card h3,
.hero-insight-card .hint {
  color: #ffffff;
}

.hero-insight-card .hint {
  max-width: 760px;
  margin-top: 10px;
  opacity: 0.9;
  font-size: 1rem;
  line-height: 1.8;
}

.executive-widgets {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
  margin-bottom: 18px;
}

.widget {
  min-height: 136px;
  border-radius: var(--app-radius);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  box-shadow: var(--app-shadow-card);
}

.widget span {
  color: #657985;
  font-size: 0.86rem;
  font-weight: 800;
}

.widget strong {
  margin-top: 14px;
  font-size: clamp(1.5rem, 2.2vw, 2.1rem);
  letter-spacing: 0;
}

.widget.in {
  border-left: 4px solid #159947;
}

.widget.out {
  border-left: 4px solid #d92d20;
}

.widget.net {
  border-left: 4px solid #0b5f95;
}

[dir="rtl"] .widget.in,
[dir="rtl"] .widget.out,
[dir="rtl"] .widget.net {
  border-left-width: 1px;
  border-right-width: 4px;
}

.filters-card,
.table-card,
.savings-card,
.chart-card,
.period-summary-card,
.manage-card,
.budget-card,
.reconcile-card,
.fx-box {
  border-radius: var(--app-radius);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--app-shadow-card);
}

.filters-card {
  margin-bottom: 14px;
}

.filters-grid,
.inline-form {
  gap: 10px;
}

input,
select,
textarea {
  min-height: 42px;
  border-radius: 10px;
}

.btn {
  min-height: 40px;
  border-radius: 10px;
  letter-spacing: 0;
}

.btn-primary {
  background: linear-gradient(135deg, #0e7c66, #0b5f95);
  box-shadow: 0 10px 24px rgba(14, 124, 102, 0.24);
}

.table-wrap {
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f5f8fb;
  color: #43525d;
  font-size: 0.82rem;
  text-transform: none;
}

td {
  background: #ffffff;
}

tbody tr:hover td {
  background: #f8fcfd;
}

.quick-add,
.ai-fab {
  box-shadow: 0 18px 38px rgba(14, 124, 102, 0.26);
}

.ai-chat-overlay {
  align-items: center;
  justify-content: flex-end;
  padding: 18px;
  background: rgba(5, 13, 20, 0.38);
  backdrop-filter: blur(4px);
}

[dir="rtl"] .ai-chat-overlay {
  justify-content: flex-start;
}

.ai-chat-panel {
  width: min(480px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 36px));
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 28px 70px rgba(2, 8, 23, 0.28);
}

.ai-chat-header {
  background: linear-gradient(135deg, #073b3a, #0b5f95);
}

.ai-chat-hint,
.ai-result-card {
  border-radius: 12px;
}

.ai-chat-textarea {
  min-height: 88px;
}

.ai-agent-answer {
  line-height: 1.75;
  color: var(--text, #1a202c);
  white-space: pre-wrap;
}

.agent-tool-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.agent-tool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.08);
  color: #0d4f48;
}

html[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(15, 159, 143, 0.12), transparent 30%),
    linear-gradient(225deg, rgba(11, 95, 149, 0.12), transparent 32%),
    #0b1118;
}

html[data-theme="dark"] .dashboard-side-nav {
  background: rgba(13, 20, 29, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 10px 0 34px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .side-nav-logo,
html[data-theme="dark"] .side-nav-icon {
  background: #172536;
  border-color: #26384c;
}

html[data-theme="dark"] .side-nav-settings {
  border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .side-user-btn,
html[data-theme="dark"] .side-setting-btn {
  background: #172536;
  border-color: #26384c;
  color: #dbe7f0;
}

html[data-theme="dark"] .side-user-btn:hover,
html[data-theme="dark"] .side-setting-btn:hover {
  background: #203348;
}

html[data-theme="dark"] .agent-tool-item {
  background: rgba(34, 184, 168, 0.12);
  color: #baf3ec;
}

html[data-theme="dark"] .side-nav-brand span,
html[data-theme="dark"] .side-nav-btn {
  color: #aebdca;
}

html[data-theme="dark"] .side-nav-btn:hover,
html[data-theme="dark"] .side-nav-btn:focus-visible {
  background: #172536;
  color: #ffffff;
}

html[data-theme="dark"] .dashboard-head,
html[data-theme="dark"] .app-command-bar,
html[data-theme="dark"] .widget,
html[data-theme="dark"] .filters-card,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .savings-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .period-summary-card,
html[data-theme="dark"] .manage-card,
html[data-theme="dark"] .budget-card,
html[data-theme="dark"] .reconcile-card,
html[data-theme="dark"] .fx-box {
  background: rgba(18, 29, 40, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] td {
  background: #121d28;
}

html[data-theme="dark"] tbody tr:hover td,
html[data-theme="dark"] th {
  background: #172536;
}

@media (max-width: 900px) {
  #dashboardSection,
  [dir="rtl"] #dashboardSection {
    padding-left: 0;
    padding-right: 0;
  }

  .dashboard-side-nav {
    position: sticky;
    top: 0;
    bottom: auto;
    width: 100%;
    min-height: auto;
    padding: 10px;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    border-radius: 0;
  }

  .side-nav-brand {
    display: none;
  }

  .app-command-bar,
  .dashboard-head {
    position: static;
    border-radius: var(--app-radius);
  }

  .executive-widgets {
    grid-template-columns: 1fr;
  }
}

/* Final override: keep sidebar controls inside the panel */
body.app-mode .dashboard-side-nav {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

body.app-mode .side-nav-btn,
body.app-mode .side-user-btn,
body.app-mode .side-setting-btn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

body.app-mode .side-nav-btn {
  flex-shrink: 0;
  white-space: normal;
  line-height: 1.25;
  overflow: hidden;
  transform: none;
}

body.app-mode .side-nav-btn > span:last-child,
body.app-mode .side-user-btn > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.app-mode .side-nav-btn:hover,
body.app-mode .side-nav-btn:focus-visible,
html[dir="rtl"] body.app-mode .side-nav-btn:hover,
html[dir="rtl"] body.app-mode .side-nav-btn:focus-visible {
  transform: none;
}

body.app-mode .side-nav-settings {
  flex: 0 0 auto;
  margin-top: auto;
  min-width: 0;
}

body.app-mode .side-settings-menu {
  display: grid;
  gap: 8px;
}

body.app-mode .side-settings-menu.hidden {
  display: none !important;
}

body.app-mode .quick-add {
  inset-inline-start: calc(var(--app-sidebar) + 20px);
}

html[dir="rtl"] body.app-mode .quick-add {
  inset-inline-start: auto;
  inset-inline-end: calc(var(--app-sidebar) + 20px);
}

@media (max-width: 900px) {
  body.app-mode .quick-add,
  html[dir="rtl"] body.app-mode .quick-add {
    inset-inline-start: 18px;
    inset-inline-end: auto;
  }
}

/* =========================================================
   FinCtrl Premium SaaS Dashboard
   Final dashboard layer: grid shell, glassmorphism, refined
   typography, responsive cards, and AI glow action.
   ========================================================= */
:root {
  --premium-sidebar: 248px;
  --premium-gutter: 24px;
  --premium-radius: 18px;
  --primary-text: #eef7fb;
  --secondary-text: rgba(238, 247, 251, 0.68);
  --premium-muted: rgba(238, 247, 251, 0.58);
  --premium-line: rgba(255, 255, 255, 0.1);
  --premium-glass: rgba(255, 255, 255, 0.05);
  --premium-glass-strong: rgba(255, 255, 255, 0.08);
  --premium-shadow: 0 20px 70px rgba(0, 0, 0, 0.36);
  --premium-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.5);
  --premium-brand: #16b8a6;
  --premium-brand-2: #2877ff;
  --premium-danger: #ff5c7a;
  --premium-success: #38e18f;
}

body.app-mode {
  font-family: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  color: var(--primary-text);
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 184, 166, 0.24), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(40, 119, 255, 0.2), transparent 32%),
    linear-gradient(135deg, #07111c 0%, #0b1524 45%, #080d16 100%);
  min-height: 100vh;
}

body.app-mode .container {
  width: 100%;
  margin: 0;
  padding: 0;
}

body.app-mode .finctrl-dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--premium-sidebar) minmax(0, 1fr);
  gap: 0;
  padding: 0 var(--premium-gutter) 112px 0;
}

html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
  grid-template-columns: minmax(0, 1fr) var(--premium-sidebar);
  padding: 0 0 112px var(--premium-gutter);
}

body.app-mode .dashboard-side-nav {
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--premium-sidebar);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 0;
  border-bottom: 0;
  border-inline-start: 0;
  box-shadow: 18px 0 50px rgba(0, 0, 0, 0.24);
  z-index: 30;
}

html[dir="rtl"] body.app-mode .dashboard-side-nav {
  grid-column: 2;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.1);
  border-inline-end: 0;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.24);
}

body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav) {
  grid-column: 2;
  width: min(1240px, calc(100% - 24px));
  margin-inline: auto;
}

html[dir="rtl"] body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav) {
  grid-column: 1;
}

body.app-mode .side-nav-brand {
  min-height: 74px;
  padding: 10px;
  margin: 0 0 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

body.app-mode .side-nav-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(22, 184, 166, 0.1);
  border: 1px solid rgba(22, 184, 166, 0.2);
}

body.app-mode .side-nav-brand strong {
  color: var(--primary-text);
  font-size: 1.02rem;
}

body.app-mode .side-nav-brand span {
  color: var(--secondary-text);
  font-size: 0.78rem;
}

body.app-mode .side-nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--secondary-text);
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

body.app-mode .side-nav-btn::before {
  content: "";
  position: absolute;
  inset-block: 10px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 99px;
  background: transparent;
  transition: background 0.22s ease, box-shadow 0.22s ease;
}

html[dir="rtl"] body.app-mode .side-nav-btn::before {
  inset-inline-start: auto;
  inset-inline-end: 0;
}

body.app-mode .side-nav-btn:hover,
body.app-mode .side-nav-btn:focus-visible {
  color: var(--primary-text);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
  outline: none;
}

body.app-mode .side-nav-btn.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(22, 184, 166, 0.82), rgba(40, 119, 255, 0.62));
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 34px rgba(22, 184, 166, 0.24);
}

body.app-mode .side-nav-btn.is-active::before {
  background: #ffffff;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.72);
}

body.app-mode .side-nav-icon {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #9ff8ee;
  background: rgba(22, 184, 166, 0.12);
  border: 1px solid rgba(22, 184, 166, 0.18);
}

body.app-mode .side-nav-btn > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.app-mode .side-nav-settings {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.app-mode .side-setting-btn,
body.app-mode .side-user-btn {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--primary-text);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(15px);
  font-weight: 800;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

body.app-mode .side-setting-btn:hover,
body.app-mode .side-user-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(22, 184, 166, 0.36);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
}

body.app-mode .dashboard-head {
  margin-top: 18px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border-radius: var(--premium-radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--premium-shadow);
}

body.app-mode .dashboard-head h2 {
  color: var(--primary-text);
  font-size: clamp(1.35rem, 2.2vw, 2.15rem);
  letter-spacing: 0;
}

body.app-mode .dashboard-head .subtitle,
body.app-mode .subscription-badge {
  color: var(--secondary-text);
}

body.app-mode .head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

body.app-mode .card,
body.app-mode .filters-card,
body.app-mode .table-card,
body.app-mode .savings-card,
body.app-mode .chart-card,
body.app-mode .period-summary-card,
body.app-mode .manage-card,
body.app-mode .budget-card,
body.app-mode .reconcile-card,
body.app-mode .fx-box,
body.app-mode .widget {
  color: var(--primary-text);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--premium-radius);
  box-shadow: var(--premium-shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

body.app-mode .card:hover,
body.app-mode .widget:hover,
body.app-mode .filters-card:hover,
body.app-mode .table-card:hover,
body.app-mode .savings-card:hover,
body.app-mode .chart-card:hover,
body.app-mode .period-summary-card:hover,
body.app-mode .manage-card:hover,
body.app-mode .budget-card:hover,
body.app-mode .reconcile-card:hover,
body.app-mode .fx-box:hover {
  transform: translateY(-5px);
  box-shadow: var(--premium-shadow-hover);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

body.app-mode .hero-insight-card {
  min-height: 168px;
  padding: 26px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(22, 184, 166, 0.28), rgba(40, 119, 255, 0.18)),
    rgba(255, 255, 255, 0.05);
}

body.app-mode .hero-insight-card::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  inset-inline-end: -70px;
  top: -84px;
  background: radial-gradient(circle, rgba(22, 184, 166, 0.45), transparent 62%);
  pointer-events: none;
}

body.app-mode .hero-insight-card h3 {
  color: var(--primary-text);
  font-size: 1.2rem;
}

body.app-mode .hero-insight-card .hint {
  max-width: 760px;
  margin-top: 10px;
  color: var(--secondary-text);
  line-height: 1.75;
}

body.app-mode .executive-widgets {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 0;
  margin-bottom: 20px;
}

body.app-mode .widget {
  min-height: 142px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

body.app-mode .widget span {
  color: var(--premium-muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

body.app-mode .widget strong {
  margin-top: 12px;
  color: var(--primary-text);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0;
}

body.app-mode .widget.in strong {
  color: var(--premium-success);
}

body.app-mode .widget.out strong {
  color: var(--premium-danger);
}

body.app-mode .widget.net strong {
  color: #78a7ff;
}

body.app-mode .filters-grid,
body.app-mode .inline-form {
  display: grid;
  gap: 12px;
}

body.app-mode .filters-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
}

body.app-mode label span,
body.app-mode .ai-result-label,
body.app-mode .hint,
body.app-mode .subtitle {
  color: var(--secondary-text);
}

body.app-mode input,
body.app-mode select,
body.app-mode textarea {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-text);
  outline: none;
}

body.app-mode input:focus,
body.app-mode select:focus,
body.app-mode textarea:focus {
  border-color: rgba(22, 184, 166, 0.62);
  box-shadow: 0 0 0 3px rgba(22, 184, 166, 0.12);
}

body.app-mode .btn {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

body.app-mode .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

body.app-mode .btn-primary,
body.app-mode .quick-add {
  background: linear-gradient(135deg, var(--premium-brand), var(--premium-brand-2));
  border-color: rgba(255, 255, 255, 0.16);
}

body.app-mode .btn-ghost,
body.app-mode .btn-outline {
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-text);
}

body.app-mode .table-wrap {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  overflow: auto;
}

body.app-mode table {
  border-collapse: separate;
  border-spacing: 0;
}

body.app-mode th {
  background: rgba(255, 255, 255, 0.07);
  color: var(--secondary-text);
  font-size: 0.78rem;
  font-weight: 900;
}

body.app-mode td {
  background: transparent;
  color: var(--primary-text);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

body.app-mode tbody tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

@keyframes finctrlAiGlow {
  0% {
    box-shadow: 0 0 0 rgba(22, 184, 166, 0), 0 18px 38px rgba(22, 184, 166, 0.28);
  }
  50% {
    box-shadow: 0 0 28px rgba(22, 184, 166, 0.62), 0 18px 44px rgba(40, 119, 255, 0.36);
  }
  100% {
    box-shadow: 0 0 0 rgba(22, 184, 166, 0), 0 18px 38px rgba(22, 184, 166, 0.28);
  }
}

body.app-mode .ai-fab {
  border-radius: 16px;
  background: linear-gradient(135deg, #0bfff0, #2877ff);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  animation: finctrlAiGlow 2.4s ease-in-out infinite;
}

body.app-mode .ai-fab:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 52px rgba(22, 184, 166, 0.5);
}

body.app-mode .quick-add {
  border-radius: 16px;
  padding: 13px 18px;
}

@media (max-width: 1100px) {
  body.app-mode .filters-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 900px) {
  body.app-mode .finctrl-dashboard-shell,
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
    display: block;
    padding: 0 14px 110px;
  }

  body.app-mode .dashboard-side-nav,
  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    position: sticky;
    top: 0;
    width: calc(100% + 28px);
    height: auto;
    min-height: auto;
    margin-inline: -14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    border-inline: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  body.app-mode .side-nav-brand,
  body.app-mode .side-nav-settings {
    display: none;
  }

  body.app-mode .side-nav-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 142px;
    white-space: nowrap;
  }

  body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav),
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav) {
    width: 100%;
    margin-inline: 0;
  }

  body.app-mode .dashboard-head {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  body.app-mode .executive-widgets,
  body.app-mode .filters-grid {
    grid-template-columns: 1fr;
  }
}

/* Emergency layout correction: keep dashboard content visible beside the fixed sidebar. */
body.app-mode .finctrl-dashboard-shell {
  display: block;
  min-height: 100vh;
  padding: 0 var(--premium-gutter) 112px calc(var(--premium-sidebar) + var(--premium-gutter));
}

html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
  padding: 0 calc(var(--premium-sidebar) + var(--premium-gutter)) 112px var(--premium-gutter);
}

body.app-mode .dashboard-side-nav {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  inset-inline-end: auto;
  left: 0;
  right: auto;
  height: 100vh;
}

html[dir="rtl"] body.app-mode .dashboard-side-nav {
  inset-inline-start: auto;
  inset-inline-end: 0;
  left: auto;
  right: 0;
}

body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav) {
  width: min(1240px, 100%);
  margin-inline: auto;
}

body.app-mode .finctrl-dashboard-shell > [data-dashboard-panel]:not(.panel-hidden),
body.app-mode .finctrl-dashboard-shell > .widgets-grid:not(.panel-hidden),
body.app-mode .finctrl-dashboard-shell > .grid-2:not(.panel-hidden) {
  margin-top: 18px;
}

body.app-mode .finctrl-dashboard-shell > .widgets-grid:not(.panel-hidden),
body.app-mode .finctrl-dashboard-shell > .grid-2:not(.panel-hidden) {
  display: grid;
}

body.app-mode .finctrl-dashboard-shell > [data-dashboard-panel].panel-hidden {
  display: none !important;
}

body.app-mode .dashboard-user-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

body.app-mode .dashboard-user-avatar {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  object-fit: cover;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

body.app-mode .dashboard-user-name {
  display: block;
  margin-top: 4px;
  color: var(--primary-text);
  font-size: 0.95rem;
}

body.app-mode .settings-panel-card {
  display: block;
}

body.app-mode .settings-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

body.app-mode .settings-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
}

body.app-mode .settings-action-card {
  min-height: 118px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-text);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

body.app-mode .settings-action-card:hover {
  transform: translateY(-5px);
  border-color: rgba(22, 184, 166, 0.36);
  box-shadow: var(--premium-shadow-hover);
}

html[dir="rtl"] body.app-mode .dashboard-head,
html[dir="rtl"] body.app-mode .settings-panel-card,
html[dir="rtl"] body.app-mode .card,
html[dir="rtl"] body.app-mode .filters-card,
html[dir="rtl"] body.app-mode .table-card {
  direction: rtl;
}

@media (max-width: 900px) {
  body.app-mode .finctrl-dashboard-shell,
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
    display: block;
    padding: 0 14px 110px;
  }

  body.app-mode .dashboard-side-nav,
  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    position: sticky;
    inset: auto;
    left: auto;
    right: auto;
    top: 0;
    height: auto;
  }

  body.app-mode .settings-actions-grid {
    grid-template-columns: 1fr;
  }
}

/* Premium light theme refinements */
html[data-theme="light"] body.app-mode {
  --primary-text: #1A202C;
  --secondary-text: #718096;
  --premium-muted: #718096;
  --premium-line: #E2E8F0;
  --premium-glass: #FFFFFF;
  --premium-glass-strong: #FFFFFF;
  --premium-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --premium-shadow-hover: 0 14px 32px rgba(15, 23, 42, 0.10);
  --premium-success: #087348;
  --premium-danger: #B42318;
  color: var(--primary-text);
  background:
    radial-gradient(circle at 12% 8%, rgba(14, 124, 102, 0.10), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(37, 99, 235, 0.08), transparent 32%),
    #F4F7F6;
}

html[data-theme="light"] body.app-mode .dashboard-side-nav {
  background: rgba(255, 255, 255, 0.86);
  border-color: #E2E8F0;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.08);
}

html[dir="rtl"][data-theme="light"] body.app-mode .dashboard-side-nav {
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] body.app-mode .card,
html[data-theme="light"] body.app-mode .filters-card,
html[data-theme="light"] body.app-mode .table-card,
html[data-theme="light"] body.app-mode .savings-card,
html[data-theme="light"] body.app-mode .chart-card,
html[data-theme="light"] body.app-mode .period-summary-card,
html[data-theme="light"] body.app-mode .manage-card,
html[data-theme="light"] body.app-mode .budget-card,
html[data-theme="light"] body.app-mode .reconcile-card,
html[data-theme="light"] body.app-mode .fx-box,
html[data-theme="light"] body.app-mode .widget,
html[data-theme="light"] body.app-mode .settings-action-card {
  color: var(--primary-text);
  background: #FFFFFF;
  border-color: #E2E8F0;
  box-shadow: var(--premium-shadow);
  backdrop-filter: none;
}

html[data-theme="light"] body.app-mode .card:hover,
html[data-theme="light"] body.app-mode .widget:hover,
html[data-theme="light"] body.app-mode .filters-card:hover,
html[data-theme="light"] body.app-mode .table-card:hover,
html[data-theme="light"] body.app-mode .chart-card:hover,
html[data-theme="light"] body.app-mode .settings-action-card:hover {
  background: #FFFFFF;
  border-color: #CBD5E0;
  box-shadow: var(--premium-shadow-hover);
}

html[data-theme="light"] body.app-mode .dashboard-head,
html[data-theme="light"] body.app-mode .app-command-bar {
  background: rgba(255, 255, 255, 0.92);
  border-color: #E2E8F0;
}

html[data-theme="light"] body.app-mode .hero-insight-card {
  background:
    linear-gradient(135deg, rgba(14, 124, 102, 0.10), rgba(37, 99, 235, 0.08)),
    #FFFFFF;
}

html[data-theme="light"] body.app-mode .side-nav-brand,
html[data-theme="light"] body.app-mode .side-nav-icon,
html[data-theme="light"] body.app-mode .side-nav-logo,
html[data-theme="light"] body.app-mode .side-nav-btn,
html[data-theme="light"] body.app-mode .side-setting-btn,
html[data-theme="light"] body.app-mode .side-user-btn {
  color: #2D3748;
  background: rgba(248, 250, 252, 0.92);
  border-color: #E2E8F0;
}

html[data-theme="light"] body.app-mode .side-nav-btn:hover,
html[data-theme="light"] body.app-mode .side-nav-btn:focus-visible {
  color: #1A202C;
  background: #EEF7F5;
}

html[data-theme="light"] body.app-mode .side-nav-btn.is-active {
  color: #FFFFFF;
  background: linear-gradient(135deg, #0E7C66, #2563EB);
}

html[data-theme="light"] body.app-mode input,
html[data-theme="light"] body.app-mode select,
html[data-theme="light"] body.app-mode textarea {
  color: #1A202C;
  background: #F8FAFC;
  border-color: #CBD5E0;
}

html[data-theme="light"] body.app-mode .btn-ghost,
html[data-theme="light"] body.app-mode .btn-outline {
  color: #2D3748;
  background: #F8FAFC;
  border-color: #CBD5E0;
}

html[data-theme="light"] body.app-mode .table-wrap {
  background: #FFFFFF;
  border-color: #E2E8F0;
}

html[data-theme="light"] body.app-mode th {
  color: #718096;
  background: #F9FAFB;
}

html[data-theme="light"] body.app-mode td {
  color: #2D3748;
  border-bottom-color: #EDF2F7;
}

html[data-theme="light"] body.app-mode tbody tr:hover td {
  background: #F8FAFC;
}

html[data-theme="light"] body.app-mode .widget.in strong {
  color: #087348;
}

html[data-theme="light"] body.app-mode .widget.out strong {
  color: #B42318;
}

html[data-theme="light"] body.app-mode .widget.net strong {
  color: #1D4ED8;
}

body.app-mode .ai-forecast-state {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

body.app-mode .ai-forecast-icon {
  flex: 0 0 auto;
  color: #E74C3C;
  font-size: 1.1rem;
  line-height: 1.7;
}

body.app-mode .ai-forecast-state.is-error .hint {
  color: #E74C3C;
}

body.app-mode .ai-retry-btn {
  margin-top: 14px;
  width: auto;
}

body.app-mode .alert-card-danger {
  position: relative;
  border-color: rgba(180, 35, 24, 0.55) !important;
  background: linear-gradient(135deg, rgba(180, 35, 24, 0.13), rgba(255, 255, 255, 0.05)) !important;
}

html[data-theme="light"] body.app-mode .alert-card-danger {
  background: #FFF5F5 !important;
  border-color: #FEB2B2 !important;
}

body.app-mode .budget-warning-badge {
  align-self: flex-start;
  margin-top: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #B42318;
  background: #FFE8E6;
  font-size: 0.74rem;
  font-weight: 900;
}

body.app-mode .ai-fab {
  overflow: visible;
}

body.app-mode .ai-fab-tooltip {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 10px);
  min-width: 142px;
  padding: 8px 10px;
  border-radius: 10px;
  color: #FFFFFF;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

body.app-mode .ai-fab:hover .ai-fab-tooltip,
body.app-mode .ai-fab:focus-visible .ai-fab-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* Final UX fixes: classification review modal, sticky footer, and readable cards. */
html,
body {
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.container {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.site-footer {
  margin-top: auto;
  margin-bottom: 98px;
}

body.app-mode .site-footer {
  margin-inline: 16px;
}

body.app-mode .widget {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 22px 24px;
  gap: 10px;
}

body.app-mode .widget::after {
  z-index: 0;
  opacity: 0.10;
  inset-inline-end: -42px;
  top: -34px;
  width: 136px;
  height: 136px;
}

body.app-mode .widget > span,
body.app-mode .widget > strong,
body.app-mode .budget-warning-badge {
  position: relative;
  z-index: 1;
}

body.app-mode .widget strong {
  max-width: calc(100% - 8px);
  overflow-wrap: anywhere;
  line-height: 1.15;
}

body.app-mode .budget-warning-badge {
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #7A160F;
  background: #FFF1F0;
  box-shadow: 0 8px 20px rgba(180, 35, 24, 0.18);
  letter-spacing: 0;
}

html[data-theme="dark"] body.app-mode .budget-warning-badge {
  color: #FFFFFF;
  background: #B42318;
  border-color: rgba(255, 255, 255, 0.28);
}

.ai-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1;
}

.ai-fab svg {
  display: block;
  flex: 0 0 auto;
}

.ai-fab #aiFabLabel {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.ai-chat-textarea {
  min-height: 118px;
  padding: 16px 18px;
  border-width: 2px;
  font-size: 1rem;
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 24px rgba(15, 23, 42, 0.06);
}

.ai-chat-textarea:focus {
  border-color: #0E7C66;
  box-shadow: 0 0 0 4px rgba(14, 124, 102, 0.16), 0 14px 28px rgba(15, 23, 42, 0.10);
}

.ai-result-card {
  background: rgba(240, 253, 250, 0.92);
  border-color: rgba(14, 124, 102, 0.26);
  overflow: hidden;
}

.ai-result-grid {
  gap: 10px;
  padding: 14px;
}

.ai-result-row {
  padding: 11px 12px;
  border: 1px solid rgba(14, 124, 102, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.ai-result-row-multi {
  border-bottom: 1px solid rgba(14, 124, 102, 0.14);
}

.ai-result-row-multi:last-child {
  border-bottom: 1px solid rgba(14, 124, 102, 0.14);
}

.ai-result-actions .btn-primary,
#aiConfirmBtn {
  background: linear-gradient(135deg, #0E7C66, #2563EB);
  border-color: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  box-shadow: 0 12px 26px rgba(14, 124, 102, 0.22);
}

html[data-theme="dark"] .ai-result-row {
  background: rgba(15, 23, 42, 0.42);
  border-color: rgba(255, 255, 255, 0.10);
}

@media (max-width: 900px) {
  .site-footer {
    margin-bottom: 112px;
  }
}

/* Dashboard compact tools, polished icons, and fixed footer. */
:root {
  --footer-height: 58px;
}

body {
  padding-bottom: var(--footer-height);
}

main.container {
  padding-bottom: calc(var(--footer-height) + 24px);
}

body.app-mode .finctrl-dashboard-shell {
  padding-bottom: calc(var(--footer-height) + 112px);
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: 100%;
  min-height: var(--footer-height);
  margin: 0 !important;
  border-radius: 0;
  border-inline: 0;
  border-bottom: 0;
  padding: 10px 22px;
  background: rgba(244, 247, 246, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .site-footer {
  background: rgba(15, 23, 32, 0.92);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.24);
}

.ai-fab {
  bottom: calc(var(--footer-height) + 24px);
}

[dir="rtl"] .ai-fab {
  bottom: calc(var(--footer-height) + 24px);
}

body.app-mode .finctrl-dashboard-shell > .grid-2[data-dashboard-panel="tools"]:not(.panel-hidden) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

body.app-mode .manage-card,
body.app-mode .budget-card,
body.app-mode .reconcile-card {
  padding: 0.85rem !important;
  border-radius: 14px;
  min-height: auto;
}

body.app-mode .manage-card h3,
body.app-mode .budget-card h3,
body.app-mode .reconcile-card h3,
body.app-mode .manage-card h4,
body.app-mode .budget-card h4,
body.app-mode .reconcile-card h4 {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
  line-height: 1.25;
}

body.app-mode .manage-card .inline-form,
body.app-mode .budget-card .inline-form {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

body.app-mode .manage-card input,
body.app-mode .manage-card select,
body.app-mode .budget-card input,
body.app-mode .budget-card select,
body.app-mode .reconcile-card input {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 0.86rem;
  border-radius: 9px;
}

body.app-mode .manage-card .btn,
body.app-mode .budget-card .btn,
body.app-mode .reconcile-card .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.84rem;
  border-radius: 10px;
}

body.app-mode .reconcile-card .table-wrap {
  max-height: 260px;
}

body.app-mode .reconcile-card table {
  font-size: 0.82rem;
}

body.app-mode .reconcile-card th,
body.app-mode .reconcile-card td {
  padding: 7px 8px;
}

body.app-mode .budget-card .hint {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

body.app-mode .side-nav-btn {
  align-items: center;
  gap: 10px;
}

body.app-mode .side-nav-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.app-mode .side-nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.app-mode .side-nav-btn:hover .side-nav-icon,
body.app-mode .side-nav-btn:focus-visible .side-nav-icon {
  color: #9FF8EE;
  box-shadow: 0 0 18px rgba(22, 184, 166, 0.28);
}

html[data-theme="light"] body.app-mode .side-nav-btn:hover .side-nav-icon,
html[data-theme="light"] body.app-mode .side-nav-btn:focus-visible .side-nav-icon {
  color: #0E7C66;
  box-shadow: 0 0 18px rgba(14, 124, 102, 0.18);
}

@media (max-width: 900px) {
  :root {
    --footer-height: 64px;
  }

  main.container {
    padding-bottom: calc(var(--footer-height) + 72px);
  }

  body.app-mode .finctrl-dashboard-shell {
    padding-bottom: calc(var(--footer-height) + 118px);
  }

  .site-footer {
    padding: 9px 14px;
  }

  body.app-mode .manage-card,
  body.app-mode .budget-card,
  body.app-mode .reconcile-card {
    padding: 0.75rem !important;
  }
}

/* Premium AI assistant contrast and transaction review states. */
.ai-chat-panel {
  overflow: hidden;
  color: var(--text);
  background: rgba(248, 250, 252, 0.96);
  border: 1px solid rgba(14, 124, 102, 0.18);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
}

html[data-theme="dark"] .ai-chat-panel {
  color: #EAF6F6;
  background: rgba(10, 20, 28, 0.96);
  border-color: rgba(159, 248, 238, 0.18);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.48);
}

.ai-chat-body {
  background: linear-gradient(180deg, rgba(14, 124, 102, 0.06), rgba(37, 99, 235, 0.035));
}

html[data-theme="dark"] .ai-chat-body {
  background: linear-gradient(180deg, rgba(14, 124, 102, 0.14), rgba(10, 20, 28, 0.98));
}

.ai-chat-hint {
  color: #36505B;
  background: rgba(14, 124, 102, 0.08);
  border: 1px solid rgba(14, 124, 102, 0.10);
}

html[data-theme="dark"] .ai-chat-hint {
  color: #C7DBDE;
  background: rgba(159, 248, 238, 0.08);
  border-color: rgba(159, 248, 238, 0.12);
}

.ai-chat-textarea {
  min-height: 96px;
  color: #1A202C;
  background: #FFFFFF;
  border: 1px solid rgba(14, 124, 102, 0.18);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] .ai-chat-textarea {
  color: #F8FAFC;
  background: rgba(6, 15, 22, 0.92);
  border-color: rgba(159, 248, 238, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 32px rgba(0, 0, 0, 0.24);
}

.ai-chat-textarea::placeholder {
  color: rgba(54, 80, 91, 0.68);
}

html[data-theme="dark"] .ai-chat-textarea::placeholder {
  color: rgba(234, 246, 246, 0.55);
}

.ai-chat-textarea:focus {
  border-color: #11B8A5;
  box-shadow: 0 0 0 4px rgba(17, 184, 165, 0.14), 0 14px 34px rgba(15, 23, 42, 0.10);
}

.ai-result-card {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(14, 124, 102, 0.16);
}

html[data-theme="dark"] .ai-result-card {
  background: rgba(8, 22, 29, 0.94);
  border-color: rgba(159, 248, 238, 0.16);
}

.ai-result-grid {
  max-height: min(330px, 46vh);
  overflow: auto;
}

.ai-result-row {
  position: relative;
  align-items: center;
  color: #1A202C;
  background: #FFFFFF;
  border: 1px solid rgba(14, 124, 102, 0.12);
}

html[data-theme="dark"] .ai-result-row {
  color: #EAF6F6;
  background: rgba(19, 34, 49, 0.92);
  border-color: rgba(159, 248, 238, 0.12);
}

.ai-result-label {
  color: #526B76;
  font-weight: 800;
}

html[data-theme="dark"] .ai-result-label {
  color: #9FF8EE;
}

.ai-result-value {
  color: inherit;
  line-height: 1.65;
}

.ai-result-value strong {
  color: #102A38;
  font-size: 1.04rem;
}

html[data-theme="dark"] .ai-result-value strong {
  color: #FFFFFF;
}

.ai-result-row-multi {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  border-inline-start: 4px solid #94A3B8;
}

.ai-result-row-multi small {
  color: #64748B;
}

html[data-theme="dark"] .ai-result-row-multi small {
  color: #B9CDD1;
}

.ai-result-row.ai-type-in {
  border-inline-start-color: #149A64;
  background: linear-gradient(90deg, rgba(20, 154, 100, 0.10), rgba(255, 255, 255, 0.92));
}

.ai-result-row.ai-type-out {
  border-inline-start-color: #D64545;
  background: linear-gradient(90deg, rgba(214, 69, 69, 0.09), rgba(255, 255, 255, 0.92));
}

html[data-theme="dark"] .ai-result-row.ai-type-in {
  background: linear-gradient(90deg, rgba(30, 213, 132, 0.16), rgba(19, 34, 49, 0.92));
}

html[data-theme="dark"] .ai-result-row.ai-type-out {
  background: linear-gradient(90deg, rgba(255, 92, 122, 0.16), rgba(19, 34, 49, 0.92));
}

.ai-result-actions {
  gap: 12px;
  background: rgba(14, 124, 102, 0.055);
  border-top: 1px solid rgba(14, 124, 102, 0.12);
}

html[data-theme="dark"] .ai-result-actions {
  background: rgba(159, 248, 238, 0.055);
  border-top-color: rgba(159, 248, 238, 0.12);
}

#aiConfirmBtn,
#aiRetryBtn {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 900;
}

#aiRetryBtn {
  color: #174052;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(14, 124, 102, 0.16);
}

html[data-theme="dark"] #aiRetryBtn {
  color: #EAF6F6;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(159, 248, 238, 0.14);
}

.ai-chat-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(54vh, 430px);
  min-height: 180px;
  overflow: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
}

.ai-message {
  display: flex;
  width: 100%;
}

.ai-message-user {
  justify-content: flex-end;
}

.ai-message-ai {
  justify-content: flex-start;
}

.ai-message-bubble {
  max-width: min(86%, 520px);
  padding: 11px 13px;
  border-radius: 16px;
  color: #16313D;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(14, 124, 102, 0.12);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.ai-message-bubble p {
  margin: 4px 0 0;
  line-height: 1.55;
}

.ai-message-user .ai-message-bubble {
  color: #FFFFFF;
  background: linear-gradient(135deg, #0E7C66, #2563EB);
  border-color: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .ai-message-bubble {
  color: #EAF6F6;
  background: rgba(19, 34, 49, 0.88);
  border-color: rgba(159, 248, 238, 0.12);
}

.ai-file-btn {
  color: #0E7C66;
}

html[data-theme="dark"] .ai-file-btn {
  color: #9FF8EE;
}

.ai-chat-input-row {
  align-items: flex-end;
}

.ai-chat-panel {
  max-height: min(92vh, 760px);
  display: flex;
  flex-direction: column;
}

.ai-chat-body {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ai-chat-hint {
  flex: 0 0 auto;
}

.ai-chat-input-row {
  flex: 0 0 auto;
  padding-top: 6px;
}

.ai-chat-textarea {
  min-height: 72px !important;
}

.ai-mic-btn,
.ai-send-btn,
.ai-file-btn {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  border-radius: 14px !important;
}

.ai-mic-btn,
.ai-file-btn {
  color: #0E7C66 !important;
  background: #FFFFFF !important;
  border: 1px solid rgba(14, 124, 102, 0.18) !important;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.ai-send-btn {
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #0E7C66, #2563EB) !important;
  border: 0 !important;
  box-shadow: 0 10px 22px rgba(14, 124, 102, 0.18) !important;
}

html[data-theme="dark"] .ai-mic-btn,
html[data-theme="dark"] .ai-file-btn {
  color: #9FF8EE !important;
  background: rgba(19, 34, 49, 0.92) !important;
  border-color: rgba(159, 248, 238, 0.16) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .ai-send-btn {
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #0BAF98, #2478E8) !important;
}

.ai-inline-preview {
  width: min(100%, 520px);
}

.ai-inline-preview-head {
  margin-bottom: 10px;
  font-weight: 900;
  color: inherit;
}

.ai-inline-preview-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-inline-end: 3px;
  scrollbar-width: thin;
}

.ai-preview-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 13px;
  border: 1px solid rgba(14, 124, 102, 0.13);
  background: rgba(255, 255, 255, 0.78);
  color: #17313D;
}

html[data-theme="dark"] .ai-preview-row {
  color: #EAF6F6;
  background: rgba(7, 18, 26, 0.72);
  border-color: rgba(159, 248, 238, 0.13);
}

.ai-preview-row.ai-type-in {
  border-inline-start: 4px solid #149A64;
}

.ai-preview-row.ai-type-out {
  border-inline-start: 4px solid #D64545;
}

.ai-preview-index {
  color: #0E7C66;
  font-weight: 900;
}

html[data-theme="dark"] .ai-preview-index {
  color: #9FF8EE;
}

.ai-preview-main {
  min-width: 0;
  line-height: 1.45;
}

.ai-preview-main strong {
  color: inherit;
  font-size: 1rem;
}

.ai-preview-main small {
  display: block;
  margin-top: 4px;
  color: #64748B;
  white-space: normal;
  word-break: break-word;
}

html[data-theme="dark"] .ai-preview-main small {
  color: #AFC4C9;
}

.ai-inline-preview-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.ai-inline-preview-actions .btn {
  min-height: 36px !important;
  padding: 8px 12px !important;
  border-radius: 11px !important;
  font-size: 0.86rem !important;
}

.ai-inline-confirm {
  background: linear-gradient(135deg, #0E7C66, #2563EB) !important;
  color: #FFFFFF !important;
  border: 0 !important;
}

.ai-inline-retry {
  color: #17313D !important;
  background: rgba(255, 255, 255, 0.78) !important;
  border: 1px solid rgba(14, 124, 102, 0.14) !important;
}

html[data-theme="dark"] .ai-inline-retry {
  color: #EAF6F6 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(159, 248, 238, 0.14) !important;
}

.ai-error-text {
  color: #B42318;
  font-weight: 700;
}

html[data-theme="dark"] .ai-error-text {
  color: #FF9A9A;
}

/* Enterprise layout and premium subscription overrides. */
:root {
  --footer-height: 50px;
}

body {
  padding-bottom: 70px !important;
}

main.container,
body.app-mode .finctrl-dashboard-shell {
  padding-bottom: 70px !important;
}

.site-footer {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  height: var(--footer-height) !important;
  min-height: var(--footer-height) !important;
  margin: 0 !important;
  z-index: 70 !important;
}

body.app-mode .dashboard-side-nav {
  height: calc(100vh - var(--footer-height)) !important;
  min-height: calc(100vh - var(--footer-height)) !important;
  max-height: calc(100vh - var(--footer-height)) !important;
  bottom: var(--footer-height) !important;
  inset-block-end: var(--footer-height) !important;
}

.ai-fab,
body.app-mode .ai-fab,
[dir="rtl"] .ai-fab {
  right: 24px !important;
  left: auto !important;
  inset-inline-end: 24px !important;
  inset-inline-start: auto !important;
  bottom: 80px !important;
}

#quickAddBtn,
.quick-add {
  position: fixed !important;
  right: 24px !important;
  left: auto !important;
  inset-inline-end: 24px !important;
  inset-inline-start: auto !important;
  bottom: 146px !important;
  z-index: 72 !important;
}

body.app-mode .manage-card,
body.app-mode .budget-card,
body.app-mode .reconcile-card {
  padding: 0.68rem !important;
  font-size: 0.86rem !important;
}

body.app-mode .manage-card h3,
body.app-mode .budget-card h3,
body.app-mode .reconcile-card h3,
body.app-mode .manage-card h4,
body.app-mode .budget-card h4,
body.app-mode .reconcile-card h4 {
  font-size: 0.88rem !important;
  margin-bottom: 0.5rem !important;
}

.customer-service-card {
  min-height: 260px;
}

.customer-service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.customer-service-grid article {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.customer-service-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.support-chat-shell {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(94, 234, 212, 0.16);
  background: rgba(255, 255, 255, 0.07);
}

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

.support-chat-head span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
}

.support-chat-messages {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border-radius: 14px;
  background: rgba(2, 10, 16, 0.18);
}

.support-message {
  max-width: min(88%, 680px);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.support-message.is-mine {
  justify-self: end;
  background: linear-gradient(135deg, rgba(14, 124, 102, 0.28), rgba(37, 99, 235, 0.24));
}

[dir="rtl"] .support-message.is-mine {
  justify-self: start;
}

.support-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.support-message p {
  margin: 0;
  line-height: 1.65;
}

.support-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.support-chat-target {
  grid-column: 1 / -1;
}

.support-chat-form textarea {
  min-height: 78px;
  resize: vertical;
}

.support-chat-gate {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 12px;
  color: #92400e;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

html[data-theme="light"] .support-chat-shell {
  background: #fff;
  border-color: rgba(15, 118, 110, 0.12);
}

html[data-theme="light"] .support-chat-messages {
  background: #f8fafc;
}

html[data-theme="light"] .support-message {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
}

.plans-dialog {
  background:
    radial-gradient(circle at 85% 12%, rgba(55, 124, 255, 0.18), transparent 28%),
    radial-gradient(circle at 12% 0%, rgba(245, 190, 77, 0.18), transparent 30%),
    rgba(10, 20, 31, 0.86) !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42) !important;
}

.plans-dialog .plan-item {
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
}

.plans-dialog .plan-item:has(#planEntTitle),
.plans-dialog .plan-item:nth-child(4) {
  background:
    linear-gradient(145deg, rgba(33, 84, 180, 0.32), rgba(203, 145, 45, 0.22)),
    rgba(255, 255, 255, 0.08);
  border-color: rgba(245, 190, 77, 0.46);
  box-shadow: 0 18px 48px rgba(245, 190, 77, 0.12);
}

.plans-dialog .plan-item:nth-child(4) .plan-btn {
  background: linear-gradient(135deg, #E8B84A, #2563EB);
  color: #08131F;
  border: 0;
}

@media (max-width: 900px) {
  body.app-mode .dashboard-side-nav {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    bottom: auto !important;
    inset-block-end: auto !important;
  }

  .ai-fab,
  body.app-mode .ai-fab,
  [dir="rtl"] .ai-fab,
  #quickAddBtn,
  .quick-add {
    right: 16px !important;
    inset-inline-end: 16px !important;
  }
}

/* Guest landing isolation and Glass Portal auth experience. */
body:not(.app-mode) {
  padding-bottom: 0 !important;
}

body:not(.app-mode) #dashboardSection,
body:not(.app-mode) .dashboard-side-nav,
body:not(.app-mode) #quickAddBtn,
body:not(.app-mode) .quick-add,
body:not(.app-mode) .ai-fab {
  display: none !important;
}

body:not(.app-mode) main.container {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 40px);
  padding-bottom: 32px !important;
}

body:not(.app-mode) .site-footer {
  position: static !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 24px auto 0 !important;
  width: min(1240px, calc(100% - 32px)) !important;
}

body.auth-portal-open {
  overflow: hidden;
}

.glass-portal.auth-card:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  margin: 0;
  padding: clamp(16px, 3vw, 36px);
  border: 0;
  border-radius: 0;
  overflow: auto;
  background:
    radial-gradient(circle at calc(20% + var(--portal-x, 0px)) calc(16% + var(--portal-y, 0px)), rgba(20, 184, 166, 0.28), transparent 28%),
    radial-gradient(circle at calc(86% - var(--portal-x, 0px)) calc(20% - var(--portal-y, 0px)), rgba(37, 99, 235, 0.24), transparent 32%),
    linear-gradient(135deg, #0f172a 0%, #111827 48%, #1e293b 100%);
  font-family: "Inter", "Poppins", "Tajawal", system-ui, sans-serif;
  color: #eef8ff;
}

.portal-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.portal-grid {
  position: absolute;
  inset: -2px;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black, transparent 72%);
}

.portal-orbit {
  position: absolute;
  width: 220px;
  aspect-ratio: 1;
  border: 1px solid rgba(148, 239, 255, 0.2);
  transform: translate(var(--portal-x, 0), var(--portal-y, 0)) rotate(14deg);
  animation: portalFloat 9s ease-in-out infinite;
}

.portal-orbit-a {
  top: 12%;
  left: 12%;
  border-radius: 38% 62% 48% 52%;
  background: rgba(20, 184, 166, 0.08);
}

.portal-orbit-b {
  right: 10%;
  bottom: 10%;
  width: 300px;
  border-radius: 52% 48% 62% 38%;
  background: rgba(37, 99, 235, 0.1);
  animation-delay: -3s;
}

.auth-portal-shell {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 22px;
  align-items: stretch;
}

.auth-security-panel,
.auth-glass-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}

.auth-security-panel {
  min-height: 560px;
  border-radius: 28px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.auth-brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-brand-mark strong {
  display: block;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.auth-brand-mark span,
.portal-kicker,
.auth-identity-preview span {
  color: rgba(226, 241, 246, 0.72);
  font-size: 0.86rem;
}

.biometric-scan {
  position: relative;
  width: min(280px, 80%);
  aspect-ratio: 1;
  margin: 38px auto;
  border-radius: 34px;
  background:
    radial-gradient(circle, rgba(20, 184, 166, 0.2), transparent 62%),
    rgba(4, 18, 27, 0.32);
  border: 1px solid rgba(148, 239, 255, 0.22);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.fingerprint {
  width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid rgba(187, 247, 238, 0.72);
  box-shadow:
    inset 0 0 0 16px rgba(187, 247, 238, 0.08),
    inset 0 0 0 34px rgba(187, 247, 238, 0.06),
    0 0 34px rgba(20, 184, 166, 0.28);
}

.scan-line {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #7dd3fc, #5eead4, transparent);
  box-shadow: 0 0 22px rgba(94, 234, 212, 0.76);
  animation: biometricScan 2.4s ease-in-out infinite;
}

.ai-greeting-bubble {
  position: relative;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(8, 32, 45, 0.56);
  border: 1px solid rgba(94, 234, 212, 0.22);
  color: #dffcf6;
  line-height: 1.7;
  font-weight: 600;
}

.ai-greeting-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  inset-inline-start: 26px;
  width: 18px;
  height: 18px;
  background: inherit;
  border-left: inherit;
  border-top: inherit;
  transform: rotate(45deg);
}

.auth-glass-card {
  border-radius: 30px;
  padding: clamp(22px, 4vw, 34px);
}

.portal-head {
  align-items: flex-start;
  margin-bottom: 18px;
}

.portal-head h2 {
  margin: 4px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.portal-close {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #eaf6ff;
  font-weight: 800;
  cursor: pointer;
}

.auth-identity-preview {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.auth-identity-preview img {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  object-fit: cover;
}

.auth-identity-preview strong {
  display: block;
  color: #f7fdff;
}

.glass-portal .auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 6px;
  margin: 0 0 18px;
  border-radius: 18px;
  background: rgba(4, 18, 27, 0.35);
}

.glass-portal .auth-tabs .btn {
  min-height: 44px;
  border-radius: 14px;
}

.portal-form,
.register-step {
  display: grid;
  gap: 14px;
}

.portal-field {
  position: relative;
  display: block;
}

.portal-field span {
  position: absolute;
  top: 15px;
  inset-inline-start: 16px;
  z-index: 2;
  color: rgba(226, 241, 246, 0.68);
  font-size: 0.92rem;
  font-weight: 700;
  pointer-events: none;
  transition: transform 0.2s ease, color 0.2s ease, font-size 0.2s ease;
}

.portal-field input,
.portal-field select {
  min-height: 58px;
  padding: 24px 16px 9px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 24, 34, 0.68);
  color: #f8fdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.portal-field input:focus,
.portal-field select:focus {
  border-color: rgba(94, 234, 212, 0.78);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.18), 0 0 26px rgba(20, 184, 166, 0.15);
}

.portal-field:focus-within span,
.portal-field.has-value span,
.portal-select span {
  transform: translateY(-9px);
  font-size: 0.72rem;
  color: #99f6e4;
}

.portal-field.has-action input {
  padding-inline-end: 68px;
}

.password-eye {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 3;
  width: 42px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #dffcf6;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}

.portal-submit {
  min-height: 50px;
  border: 0;
  border-radius: 16px !important;
  background: linear-gradient(135deg, #0f766e, #0ea5e9, #2563eb) !important;
  color: #ffffff !important;
  box-shadow: 0 18px 42px rgba(14, 165, 233, 0.24);
}

.shimmer-btn {
  position: relative;
  overflow: hidden;
}

.shimmer-btn::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -60%;
  width: 44%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shimmerSweep 2.8s ease-in-out infinite;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  color: #dffcf6;
  background: rgba(20, 184, 166, 0.14);
  border: 1px solid rgba(94, 234, 212, 0.22);
}

.step-pill span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #14b8a6;
  color: #06222c;
  font-weight: 900;
}

.password-strength {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.password-strength span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.25s ease, background 0.25s ease;
  background: #ef4444;
}

.password-strength span[data-score="2"],
.password-strength span[data-score="3"] {
  background: #f59e0b;
}

.password-strength span[data-score="4"] {
  background: #22c55e;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.48);
}

.password-ai-assistant {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 184, 166, 0.12);
  color: #dffcf6;
  border: 1px solid rgba(94, 234, 212, 0.18);
  font-size: 0.86rem;
  line-height: 1.6;
}

.glass-portal .password-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.glass-portal .rule-item {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.07);
}

.enterprise-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.enterprise-switch input {
  display: none;
}

.enterprise-switch > span {
  position: relative;
  width: 54px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.36);
  transition: background 0.2s ease;
}

.enterprise-switch > span::after {
  content: "";
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
}

.enterprise-switch input:checked + span {
  background: linear-gradient(135deg, #d4af37, #2563eb);
}

.enterprise-switch input:checked + span::after {
  transform: translateX(24px);
}

[dir="rtl"] .enterprise-switch input:checked + span::after {
  transform: translateX(-24px);
}

.portal-actions-row,
.portal-social-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portal-social-grid .btn {
  min-height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #eaf6ff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-github {
  background: rgba(15, 23, 42, 0.72) !important;
}

.portal-shake {
  animation: portalShake 0.38s ease;
}

@keyframes biometricScan {
  0%, 100% { top: 16%; opacity: 0.25; }
  50% { top: 82%; opacity: 1; }
}

@keyframes shimmerSweep {
  0%, 52% { left: -60%; opacity: 0; }
  70% { opacity: 1; }
  100% { left: 130%; opacity: 0; }
}

@keyframes portalFloat {
  0%, 100% { transform: translate(var(--portal-x, 0), var(--portal-y, 0)) rotate(14deg); }
  50% { transform: translate(calc(var(--portal-x, 0) * -0.6), calc(var(--portal-y, 0) * -0.6)) rotate(28deg); }
}

@keyframes portalShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 860px) {
  .auth-portal-shell {
    grid-template-columns: 1fr;
  }

  .auth-security-panel {
    min-height: auto;
    gap: 18px;
  }

  .biometric-scan {
    display: none;
  }

  .glass-portal .password-checklist,
  .portal-actions-row,
  .portal-social-grid {
    grid-template-columns: 1fr;
  }

  .glass-portal.auth-card:not(.hidden) {
    align-items: start;
  }
}

/* Enterprise AI/Admin release refinements. */
body.app-mode {
  position: relative;
  min-height: 100vh;
  padding-bottom: 80px !important;
}

body.app-mode main.container,
body.app-mode .finctrl-dashboard-shell {
  padding-bottom: 80px !important;
}

body.app-mode .site-footer {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 50px !important;
}

body.app-mode .ai-fab,
body.app-mode #quickAddBtn,
body.app-mode .quick-add {
  bottom: 70px !important;
}

body.app-mode #quickAddBtn,
body.app-mode .quick-add {
  bottom: 132px !important;
}

.privacy-toggle.is-active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(14, 165, 233, 0.18)) !important;
  border-color: rgba(245, 158, 11, 0.42) !important;
}

body.privacy-mode .summary-card strong,
body.privacy-mode .widget strong,
body.privacy-mode table td:nth-child(3),
body.privacy-mode .savings-item span,
body.privacy-mode .ai-preview-main strong {
  filter: blur(8px);
  user-select: none;
}

.admin-ai-wrap {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.ai-question-pending td {
  background: rgba(245, 158, 11, 0.08);
}

.ai-question-answered td {
  background: rgba(16, 185, 129, 0.06);
}

.admin-ai-wrap textarea {
  min-width: 260px;
  min-height: 76px;
}

#aiFabBtn.ai-fab {
  width: auto !important;
  min-width: 174px !important;
  height: 54px !important;
  padding: 0 18px !important;
  gap: 10px !important;
  border-radius: 18px !important;
  background: linear-gradient(135deg, #0f766e, #0ea5e9, #2563eb) !important;
  box-shadow: 0 22px 54px rgba(14, 165, 233, 0.28) !important;
}

#aiFabLabel::after {
  content: " Command Center";
}

[dir="rtl"] #aiFabLabel::after {
  content: " مركز الأوامر";
}

.ai-chat-overlay:not(.hidden) {
  display: block !important;
  background: rgba(3, 10, 18, 0.52) !important;
  backdrop-filter: blur(10px);
}

.ai-chat-panel {
  position: fixed !important;
  top: 18px !important;
  bottom: 68px !important;
  right: 18px !important;
  left: auto !important;
  width: min(520px, calc(100vw - 36px)) !important;
  height: auto !important;
  border-radius: 22px !important;
  overflow: hidden !important;
  transform: translateX(0);
  animation: commandCenterIn 0.24s ease-out;
}

[dir="rtl"] .ai-chat-panel {
  right: auto !important;
  left: 18px !important;
}

.ai-chat-loading {
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.18);
}

.ai-chat-loading::after {
  content: "";
  display: inline-block;
  width: 36px;
  height: 10px;
  margin-inline-start: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  animation: thinkingPulse 1.1s infinite ease-in-out;
  opacity: 0.5;
}

.ai-response-action .ai-message-bubble {
  border-color: rgba(16, 185, 129, 0.34) !important;
  background: rgba(16, 185, 129, 0.12) !important;
}

.ai-response-advice .ai-message-bubble {
  border-color: rgba(14, 165, 233, 0.34) !important;
  background: rgba(14, 165, 233, 0.12) !important;
}

.ai-response-fallback .ai-message-bubble {
  border-color: rgba(245, 158, 11, 0.42) !important;
  background: rgba(245, 158, 11, 0.14) !important;
}

.savings-progress span {
  transition: width 0.7s ease, background 0.25s ease;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
}

.chart-help,
[data-chart-tooltip] {
  position: relative;
}

[data-chart-tooltip]:hover::after {
  content: attr(data-chart-tooltip);
  position: absolute;
  z-index: 30;
  inset-inline-start: 0;
  bottom: calc(100% + 8px);
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--primary-text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.5;
}

@keyframes commandCenterIn {
  from { transform: translateX(34px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes thinkingPulse {
  0%, 100% { transform: translateX(-8px); opacity: 0.25; }
  50% { transform: translateX(8px); opacity: 0.8; }
}

/* Compact auth portal and secure recovery redesign. */
.glass-portal.auth-card:not(.hidden) {
  padding: clamp(10px, 2vh, 24px) !important;
  align-items: center !important;
}

.auth-portal-shell {
  max-height: calc(100vh - 28px);
  align-items: center;
}

.auth-security-panel {
  min-height: min(520px, calc(100vh - 44px)) !important;
  padding: clamp(16px, 2.4vw, 24px) !important;
}

.auth-glass-card {
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: clamp(16px, 2.5vw, 26px) !important;
  scrollbar-width: thin;
}

.portal-head h2 {
  font-size: clamp(1.65rem, 3vw, 2.45rem) !important;
}

.auth-identity-preview {
  padding: 9px !important;
  margin-bottom: 12px !important;
}

.auth-identity-preview img {
  width: 44px !important;
  height: 44px !important;
}

.glass-portal .auth-tabs {
  margin-bottom: 12px !important;
}

.portal-form,
.register-step {
  gap: 10px !important;
}

.portal-field input,
.portal-field select {
  min-height: 50px !important;
}

.auth-inline-link {
  justify-self: end;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 10px;
  color: #99f6e4 !important;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.16);
  text-decoration: none !important;
}

.auth-inline-link:hover {
  color: #ffffff !important;
  background: rgba(14, 165, 233, 0.18);
}

.biometric-scan {
  width: min(230px, 72%) !important;
  margin: 22px auto !important;
}

@media (max-height: 760px) and (min-width: 861px) {
  .auth-security-panel {
    min-height: 0 !important;
  }

  .biometric-scan {
    width: 190px !important;
    margin: 14px auto !important;
  }

  .ai-greeting-bubble {
    padding: 12px 14px !important;
    font-size: 0.86rem;
  }

  .password-checklist {
    display: none !important;
  }
}

.forgot-portal-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  border-radius: 28px;
  color: #eef8ff;
  background:
    radial-gradient(circle at 15% 10%, rgba(20, 184, 166, 0.24), transparent 34%),
    radial-gradient(circle at 90% 20%, rgba(37, 99, 235, 0.22), transparent 38%),
    rgba(15, 23, 42, 0.92);
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.54);
}

.forgot-portal-dialog::backdrop {
  background: rgba(3, 10, 18, 0.68);
  backdrop-filter: blur(10px);
}

.forgot-portal-card {
  position: relative;
  padding: clamp(20px, 4vw, 30px);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.forgot-close {
  position: absolute;
  top: 18px;
  inset-inline-end: 18px;
}

.forgot-portal-head {
  padding-inline-end: 50px;
  margin-bottom: 16px;
}

.forgot-portal-head h3 {
  margin: 4px 0;
  font-size: clamp(1.55rem, 4vw, 2.2rem);
}

.forgot-portal-head p {
  color: rgba(226, 241, 246, 0.72);
  margin: 0;
  line-height: 1.7;
}

.recovery-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: rgba(4, 18, 27, 0.42);
}

.recovery-tab {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(226, 241, 246, 0.76);
  font-weight: 800;
  cursor: pointer;
}

.recovery-tab.is-active {
  background: linear-gradient(135deg, #0f766e, #0ea5e9);
  color: #fff;
}

.recovery-tab.is-locked {
  cursor: not-allowed;
  opacity: 0.72;
}

.recovery-tab span {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  font-size: 0.7rem;
}

.forgot-phase {
  display: grid;
  gap: 13px;
  animation: forgotFade 0.24s ease;
}

.forgot-field input {
  background: rgba(7, 24, 34, 0.76) !important;
}

.email-mask-preview {
  padding: 10px 12px;
  border-radius: 14px;
  color: #cffafe;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.24);
  font-weight: 700;
}

.ai-guardian-box,
.forgot-success-state {
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(94, 234, 212, 0.2);
  background: rgba(20, 184, 166, 0.12);
}

.ai-guardian-box strong,
.forgot-success-state strong {
  display: block;
  color: #99f6e4;
  margin-bottom: 5px;
}

.ai-guardian-box p,
.forgot-success-state span {
  margin: 0;
  color: rgba(226, 241, 246, 0.78);
  line-height: 1.7;
}

.forgot-strength-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.forgot-strength {
  min-width: 160px;
}

.forgot-strength span[data-score="1"],
.forgot-strength span[data-score="2"] {
  background: #ef4444;
}

.forgot-strength span[data-score="3"],
.forgot-strength span[data-score="4"] {
  background: #f59e0b;
}

.forgot-strength span[data-score="5"] {
  background: #22c55e;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.5);
}

#forgotStrengthText {
  color: #dffcf6;
  white-space: nowrap;
}

.forgot-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.forgot-checklist li {
  padding: 9px 10px;
  border-radius: 12px;
  color: rgba(226, 241, 246, 0.7);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.forgot-checklist li::before {
  content: "";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-inline-end: 7px;
  border-radius: 50%;
  border: 1px solid rgba(226, 241, 246, 0.28);
  vertical-align: -4px;
}

.forgot-checklist li.is-ok {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.12);
  transform: translateY(-1px);
}

.forgot-checklist li.is-ok::before {
  content: "✓";
  background: #22c55e;
  border-color: #22c55e;
  color: #052e16;
  font-weight: 900;
}

.shake-lite {
  animation: portalShake 0.36s ease;
}

@keyframes forgotFade {
  from { opacity: 0; transform: translateY(8px) rotateX(-4deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

/* Final zero-conflict dashboard fixes */
:root {
  --card-padding: 0.85rem;
  --font-size-base: 0.94rem;
  --sidebar-width: 248px;
  --footer-height: 50px;
}

body.app-mode {
  font-size: var(--font-size-base);
  padding-bottom: calc(var(--footer-height) + 80px) !important;
}

body.app-mode main.container,
body.app-mode .finctrl-dashboard-shell {
  padding-bottom: calc(var(--footer-height) + 96px) !important;
}

body.app-mode .manage-card,
body.app-mode .budget-card,
body.app-mode .widgets-panel,
body.app-mode .admin-card {
  padding: var(--card-padding) !important;
}

body.app-mode .manage-card h3,
body.app-mode .budget-card h3,
body.app-mode .widgets-panel h3,
body.app-mode .admin-card h3 {
  font-size: 1rem !important;
  margin-bottom: 0.65rem !important;
}

body.app-mode .dashboard-side-nav {
  width: var(--sidebar-width) !important;
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  bottom: 0 !important;
  inset-block-end: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

body.app-mode .side-nav-icon,
body.app-mode .side-nav-icon svg {
  width: 20px !important;
  height: 20px !important;
  stroke-width: 2px !important;
}

body.app-mode .site-footer {
  position: fixed !important;
  bottom: 0 !important;
  left: var(--sidebar-width) !important;
  right: 0 !important;
  width: calc(100% - var(--sidebar-width)) !important;
  height: var(--footer-height) !important;
  min-height: var(--footer-height) !important;
  margin: 0 !important;
  padding: 0 18px !important;
  border-radius: 0 !important;
  z-index: 70 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(244, 247, 246, 0.78) !important;
  backdrop-filter: blur(14px) !important;
  border-top: 1px solid rgba(15, 23, 42, 0.08) !important;
  box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.08) !important;
}

html[data-theme="dark"] body.app-mode .site-footer {
  background: rgba(8, 15, 22, 0.78) !important;
  border-top-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.28) !important;
}

body.app-mode .site-footer-brand,
body.app-mode .site-footer-logo {
  display: none !important;
}

body.app-mode .site-footer p {
  text-align: center !important;
  margin: 0 auto !important;
  width: 100% !important;
  color: var(--muted) !important;
}

.ai-confidence-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 7px;
  padding: 3px 8px;
  border-radius: 999px;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  color: #064e3b;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.ai-confidence-badge.is-low,
.ai-review-warning {
  color: #7c2d12;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.34);
}

html[data-theme="dark"] .ai-confidence-badge {
  color: #bbf7d0;
}

html[data-theme="dark"] .ai-confidence-badge.is-low,
html[data-theme="dark"] .ai-review-warning {
  color: #fed7aa;
}

.ai-review-warning {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.84rem;
}

.ai-inline-preview.needs-review .ai-inline-confirm {
  background: linear-gradient(135deg, #f59e0b, #0ea5e9) !important;
}

/* Final auth/sidebar polish */
.glass-portal.auth-card:not(.hidden) {
  padding: 10px !important;
  overflow: hidden !important;
}

.auth-portal-shell {
  width: min(980px, calc(100vw - 28px)) !important;
  max-height: calc(100vh - 20px) !important;
  grid-template-columns: 0.92fr 1fr !important;
  gap: 20px !important;
}

.auth-security-panel {
  min-height: min(430px, calc(100vh - 40px)) !important;
  padding: 20px !important;
  border-radius: 24px !important;
}

.auth-glass-card {
  max-height: none !important;
  overflow: hidden !important;
  padding: 18px !important;
  border-radius: 24px !important;
}

.auth-identity-preview {
  display: none !important;
}

.portal-head {
  margin-bottom: 12px !important;
}

.portal-head h2 {
  font-size: clamp(1.65rem, 3vw, 2.4rem) !important;
  line-height: 1.02 !important;
}

.biometric-scan {
  width: min(190px, 46vw) !important;
  height: min(150px, 30vh) !important;
}

.ai-greeting-bubble {
  padding: 12px 14px !important;
  font-size: 0.9rem !important;
}

.portal-form,
.register-step {
  gap: 10px !important;
}

.portal-field input,
.portal-field select {
  min-height: 50px !important;
  padding: 21px 14px 7px !important;
  border-radius: 14px !important;
}

.portal-field span {
  top: 13px !important;
  font-size: 0.84rem !important;
}

.portal-field:focus-within span,
.portal-field.has-value span,
.portal-select span {
  transform: translateY(-8px) !important;
  font-size: 0.68rem !important;
}

.glass-portal .auth-tabs {
  margin-bottom: 10px !important;
}

.glass-portal .auth-tabs .btn,
.portal-submit,
.portal-social-grid .btn {
  min-height: 42px !important;
}

.social-divider {
  margin: 10px 0 !important;
}

.portal-social-grid {
  gap: 8px !important;
}

.portal-social-grid .btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 9px !important;
  padding: 0 10px !important;
  font-size: 0.86rem !important;
}

.portal-social-grid .btn::before {
  content: "";
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
}

#googleBtn::before {
  content: "G";
  background: #fff;
  color: #4285f4;
  box-shadow: inset 0 0 0 2px #ea4335;
}

#githubBtn::before {
  content: "GH";
  background: #0b1220;
  color: #fff;
  font-size: 0.55rem;
}

#microsoftBtn::before {
  content: "▦";
  border-radius: 6px;
  background: linear-gradient(135deg, #f25022 0 25%, #7fba00 25% 50%, #00a4ef 50% 75%, #ffb900 75% 100%);
  color: transparent;
}

#appleBtn::before {
  content: "";
  background: #fff;
  color: #111827;
  font-size: 0.95rem;
}

.social-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
}

.google-icon {
  background: #fff;
  color: #4285f4;
  box-shadow: inset 0 0 0 2px #ea4335;
}

.github-icon {
  background: #0b1220;
  color: #fff;
  font-size: 0.55rem;
}

.microsoft-icon {
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.microsoft-icon i {
  width: 7px;
  height: 7px;
  display: block;
}

.microsoft-icon i:nth-child(1) { background: #f25022; }
.microsoft-icon i:nth-child(2) { background: #7fba00; }
.microsoft-icon i:nth-child(3) { background: #00a4ef; }
.microsoft-icon i:nth-child(4) { background: #ffb900; }

.apple-icon {
  background: #fff;
  color: #111827;
  font-size: 0.95rem;
}

body.app-mode .dashboard-side-nav {
  overflow: hidden !important;
  padding-bottom: 12px !important;
}

body.app-mode .side-nav-brand {
  min-height: 58px !important;
  margin-bottom: 10px !important;
}

body.app-mode .side-nav-btn {
  min-height: 44px !important;
  margin-bottom: 5px !important;
  font-size: 0.9rem !important;
}

body.app-mode .side-nav-settings {
  gap: 6px !important;
  padding-top: 10px !important;
}

body.app-mode .side-nav-btn.is-active {
  background: linear-gradient(135deg, #0e7c66, #2563eb) !important;
  color: #fff !important;
}

body.app-mode .side-nav-btn:not(.is-active) {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--secondary-text) !important;
}

html[data-theme="light"] body.app-mode .side-nav-btn:not(.is-active) {
  background: rgba(248, 250, 252, 0.92) !important;
  color: #2D3748 !important;
}

.portal-close {
  width: auto !important;
  min-width: 42px !important;
  max-width: none !important;
  padding: 0 14px !important;
  white-space: nowrap !important;
  font-size: 0.78rem !important;
  line-height: 1 !important;
}

.forgot-close {
  width: 42px !important;
  min-width: 42px !important;
  padding: 0 !important;
  font-size: 1rem !important;
}

.auth-inline-link {
  color: #99f6e4 !important;
  border: 1px solid rgba(153, 246, 228, 0.18) !important;
  background: rgba(20, 184, 166, 0.08) !important;
}

html[data-theme="light"] .auth-inline-link {
  color: #0f766e !important;
  background: rgba(15, 118, 110, 0.08) !important;
  border-color: rgba(15, 118, 110, 0.18) !important;
}

.portal-submit.is-loading {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.portal-social-grid {
  grid-template-columns: repeat(4, minmax(46px, 1fr)) !important;
}

.portal-social-grid .btn {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 46px !important;
  padding: 0 !important;
  gap: 0 !important;
  font-size: 0 !important;
  overflow: hidden !important;
}

.portal-social-grid .btn::before {
  width: 24px !important;
  height: 24px !important;
  flex-basis: 24px !important;
  margin: 0 !important;
  font-size: 0.75rem !important;
}

#githubBtn::before {
  font-size: 0.58rem !important;
}

#microsoftBtn::before {
  content: "" !important;
}

#appleBtn::before {
  content: "A" !important;
  font-family: Inter, Arial, sans-serif !important;
  font-size: 0.8rem !important;
}

body.app-mode .side-nav-btn:not(.is-active):hover,
body.app-mode .side-nav-btn:not(.is-active):focus-visible {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--primary-text) !important;
}

@media (max-width: 640px) {
  .portal-social-grid {
    grid-template-columns: repeat(4, minmax(42px, 1fr)) !important;
  }

  .mobile-app-card,
  .support-chat-form {
    grid-template-columns: 1fr;
  }

  .mobile-store-actions {
    width: 100%;
  }

  .store-button {
    flex: 1 1 100%;
  }
}

/* Final compact admin controls and footer layering fix. */
body.app-mode .admin-team input[type="checkbox"],
body.app-mode .admin-team-form input[type="checkbox"],
body.app-mode .permissions-dialog input[type="checkbox"],
body.app-mode .check-inline input[type="checkbox"] {
  appearance: auto !important;
  -webkit-appearance: checkbox !important;
  width: 16px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  height: 16px !important;
  min-height: 16px !important;
  max-height: 16px !important;
  padding: 0 !important;
  margin: 0 8px !important;
  border-radius: 3px !important;
  transform: none !important;
  vertical-align: middle !important;
  accent-color: #0e7c66;
}

body.app-mode .admin-team td input[type="checkbox"] {
  display: inline-block !important;
}

body.app-mode .check-inline {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-height: 38px !important;
}

:root {
  --footer-height: 42px;
}

body.app-mode {
  padding-bottom: calc(var(--footer-height) + 56px) !important;
}

body.app-mode main.container,
body.app-mode .finctrl-dashboard-shell {
  padding-bottom: calc(var(--footer-height) + 86px) !important;
}

body.app-mode .dashboard-side-nav {
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  bottom: 0 !important;
  inset-block-end: 0 !important;
  z-index: 120 !important;
}

body.app-mode .site-footer,
html[dir="rtl"] body.app-mode .site-footer {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: var(--footer-height) !important;
  min-height: var(--footer-height) !important;
  margin: 0 !important;
  padding: 0 14px !important;
  border-radius: 0 !important;
  z-index: 45 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(8, 15, 22, 0.82) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
}

html[data-theme="light"] body.app-mode .site-footer {
  background: rgba(244, 247, 246, 0.92) !important;
  border-top-color: rgba(15, 23, 42, 0.08) !important;
}

body.app-mode .site-footer p {
  width: 100% !important;
  margin: 0 auto !important;
  text-align: center !important;
  font-size: 0.82rem !important;
  line-height: 1.2 !important;
}

@media (max-width: 900px) {
  body.app-mode .dashboard-side-nav,
  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    z-index: 120 !important;
  }
}

.ai-chat-body {
  position: relative;
}

.ai-drop-zone {
  position: absolute;
  inset: 10px;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 18px;
  background: rgba(5, 15, 22, 0.72);
  border: 1px dashed rgba(159, 248, 238, 0.72);
  backdrop-filter: blur(12px);
  color: #EAF6F6;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 20px 60px rgba(0, 0, 0, 0.28);
}

.ai-drop-zone.hidden {
  display: none !important;
}

.ai-drop-zone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.ai-drop-zone-card svg {
  color: #9FF8EE;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.35));
}

.ai-drop-zone-card strong {
  font-size: 1rem;
}

.ai-drop-zone-card span {
  color: rgba(234, 246, 246, 0.74);
  font-size: 0.86rem;
}

.ai-chat-body.is-dragging-file .ai-chat-history,
.ai-chat-body.is-dragging-file .ai-chat-input-row,
.ai-chat-body.is-dragging-file .ai-chat-hint {
  filter: blur(1.5px);
}

html[data-theme="light"] .ai-drop-zone {
  background: rgba(248, 250, 252, 0.84);
  border-color: rgba(14, 124, 102, 0.5);
  color: #12313A;
}

html[data-theme="light"] .ai-drop-zone-card svg {
  color: #0E7C66;
}

html[data-theme="light"] .ai-drop-zone-card span {
  color: rgba(18, 49, 58, 0.68);
}

/* Final transaction dialog select theme fix. */
html[data-theme="dark"] .tx-dialog select,
html[data-theme="dark"] .tx-dialog input,
html[data-theme="dark"] .tx-dialog textarea {
  color: #F3FAFC !important;
  background-color: #1A2734 !important;
  border-color: rgba(159, 248, 238, 0.18) !important;
}

html[data-theme="dark"] .tx-dialog select option {
  color: #F3FAFC !important;
  background-color: #162231 !important;
}

html[data-theme="dark"] .tx-dialog select option:checked,
html[data-theme="dark"] .tx-dialog select option:hover {
  color: #FFFFFF !important;
  background-color: #0E7C66 !important;
}

html[data-theme="light"] .tx-dialog select,
html[data-theme="light"] .tx-dialog input,
html[data-theme="light"] .tx-dialog textarea {
  color: #1A202C !important;
  background-color: #FFFFFF !important;
  border-color: #CBD5E0 !important;
}

html[data-theme="light"] .tx-dialog select option {
  color: #1A202C !important;
  background-color: #FFFFFF !important;
}

.auth-portal-shell {
  max-height: min(650px, calc(100vh - 24px)) !important;
  overflow: hidden !important;
}

.auth-glass-card {
  padding: 18px !important;
  gap: 8px !important;
  overflow: hidden !important;
}

.auth-security-panel {
  padding: 20px !important;
  min-height: 0 !important;
}

.auth-portal-copy h2 {
  font-size: clamp(1.65rem, 4vh, 2.45rem) !important;
  margin: 2px 0 !important;
}

.portal-field input,
.portal-field select {
  min-height: 42px !important;
}

.auth-tabs,
.portal-actions-row {
  gap: 8px !important;
}

.biometric-scan {
  transform: scale(0.88) !important;
}

@media (max-height: 700px) and (min-width: 861px) {
  .auth-portal-shell {
    width: min(920px, calc(100vw - 24px)) !important;
  }

  .auth-security-panel {
    min-height: 0 !important;
  }

  .biometric-scan {
    display: none !important;
  }

  .portal-kicker,
  .ai-greeting-bubble {
    display: none !important;
  }
}

html[dir="rtl"] body.app-mode .site-footer {
  left: 0 !important;
  right: var(--sidebar-width) !important;
}

body.app-mode .ai-smart-input {
  display: none !important;
}

body.app-mode .ai-fab,
body.app-mode #quickAddBtn,
body.app-mode .quick-add {
  position: fixed !important;
  right: 20px !important;
  left: auto !important;
  inset-inline-end: 20px !important;
  inset-inline-start: auto !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}

body.app-mode .ai-fab {
  bottom: calc(var(--footer-height) + 20px) !important;
}

body.app-mode #quickAddBtn,
body.app-mode .quick-add {
  bottom: calc(var(--footer-height) + 84px) !important;
}

body.app-mode .ai-fab:hover,
body.app-mode #quickAddBtn:hover,
body.app-mode .quick-add:hover {
  transform: scale(1.06) !important;
}

@media (max-width: 900px) {
  body.app-mode .dashboard-side-nav {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    bottom: auto !important;
    inset-block-end: auto !important;
  }

  body.app-mode .site-footer,
  html[dir="rtl"] body.app-mode .site-footer {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}

/* Final responsive dashboard correction for tablet and mobile viewports. */
@media (max-width: 900px) {
  body.app-mode,
  html[dir="rtl"] body.app-mode {
    overflow-x: hidden !important;
  }

  body.app-mode .finctrl-dashboard-shell,
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 12px calc(var(--footer-height, 50px) + 98px) !important;
    margin: 0 !important;
  }

  body.app-mode .dashboard-side-nav,
  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    position: sticky !important;
    top: 0 !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    inset: auto !important;
    z-index: 120 !important;
    width: calc(100% + 24px) !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 -12px 14px !important;
    padding: 10px 12px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-radius: 0 0 18px 18px !important;
    scrollbar-width: thin !important;
  }

  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    direction: rtl !important;
  }

  body.app-mode .dashboard-side-nav::-webkit-scrollbar {
    height: 5px !important;
  }

  body.app-mode .side-nav-brand {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 150px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 8px 10px !important;
  }

  body.app-mode .side-nav-btn,
  body.app-mode .side-user-btn,
  body.app-mode .side-setting-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 122px !important;
    max-width: 180px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 9px 12px !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  body.app-mode .side-nav-btn > span:last-child,
  body.app-mode .side-user-btn > span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-mode .side-nav-settings {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
  }

  body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav),
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell > :not(.dashboard-side-nav) {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }

  body.app-mode .app-command-bar,
  body.app-mode .dashboard-hero,
  body.app-mode .glass-panel,
  body.app-mode .card,
  body.app-mode .widgets-grid,
  body.app-mode .grid-2 {
    max-width: 100% !important;
  }

  body.app-mode .summary-grid,
  body.app-mode .widgets-grid,
  body.app-mode .grid-2 {
    grid-template-columns: 1fr !important;
  }

  body.app-mode .ai-fab,
  body.app-mode #quickAddBtn,
  body.app-mode .quick-add {
    right: 12px !important;
    left: auto !important;
    inset-inline-end: 12px !important;
    inset-inline-start: auto !important;
  }
}

@media (max-width: 640px) {
  body.app-mode .finctrl-dashboard-shell,
  html[dir="rtl"] body.app-mode .finctrl-dashboard-shell {
    padding-inline: 8px !important;
  }

  body.app-mode .dashboard-side-nav,
  html[dir="rtl"] body.app-mode .dashboard-side-nav {
    width: calc(100% + 16px) !important;
    margin-inline: -8px !important;
    padding: 8px !important;
  }

  body.app-mode .side-nav-brand {
    min-width: 118px !important;
  }

  body.app-mode .side-nav-btn,
  body.app-mode .side-user-btn,
  body.app-mode .side-setting-btn {
    min-width: 104px !important;
    max-width: 136px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 0.78rem !important;
  }

  .ai-chat-panel,
  [dir="rtl"] .ai-chat-panel {
    top: 8px !important;
    right: 8px !important;
    left: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 16px !important;
  }

  .ai-chat-body {
    padding: 12px !important;
  }

  .ai-chat-input-row {
    gap: 6px !important;
  }

  .ai-chat-textarea {
    min-height: 58px !important;
    font-size: 0.9rem !important;
  }

  .ai-action-btn,
  .ai-chat-send,
  .ai-chat-mic,
  .ai-chat-file {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
  }
}
