@font-face {
  font-family: "Manrope Variable";
  src: url("/fonts/manrope-latin.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Manrope Variable";
  src: url("/fonts/manrope-latin-ext.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Manrope Variable";
  src: url("/fonts/manrope-cyrillic.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face { font-family: "Tajawal"; src: url("/fonts/tajawal-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/fonts/tajawal-arabic-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/fonts/tajawal-arabic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/fonts/tajawal-arabic-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --ink: #101827;
  --ink-soft: #53627a;
  --muted: #718096;
  --line: #dde3ec;
  --line-strong: #cbd4e1;
  --canvas: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --blue: #1467f3;
  --blue-dark: #0b54cf;
  --blue-soft: #eaf3ff;
  --green: #1f9d49;
  --green-soft: #eaf7ef;
  --coral: #f04d3a;
  --coral-soft: #fff0ed;
  --tip: #f0faf8;
  --tip-line: #a9ddd2;
  --danger: #c9362b;
  --shadow-menu: 0 18px 52px rgb(19 34 56 / 14%), 0 4px 14px rgb(19 34 56 / 7%);
  --shadow-modal: 0 30px 90px rgb(12 24 42 / 22%);
  --radius-sm: 8px;
  --radius: 11px;
  --radius-lg: 18px;
  --focus: 0 0 0 3px rgb(8 102 229 / 22%);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Manrope Variable", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[lang="ar"] { font-family: "Tajawal", sans-serif; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] strong { letter-spacing: 0; }

body {
  position: relative;
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  contain: inline-size;
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="radio"],
label[for] {
  cursor: pointer;
}

button {
  border: 0;
}

a {
  color: var(--blue);
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3,
strong {
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.06;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 11px 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  display: block;
  resize: vertical;
  line-height: 1.35;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aeb9c8;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

input::placeholder {
  color: #8e99a9;
}

label > span:first-child,
legend {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.hidden {
  display: none !important;
}

.required-mark { color: var(--danger); font-weight: 800; }
.signup-plan-fieldset { min-width: 0; margin: 0; border: 0; padding: 0; }
.signup-plan-fieldset legend { margin-bottom: 8px; }
.signup-plan-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.signup-plan-option { position: relative; min-width: 0; }
.signup-plan-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.signup-plan-option > span { display: grid; min-height: 66px; align-content: center; gap: 3px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); padding: 10px 11px; cursor: pointer; }
.signup-plan-option strong { font-size: 14px; }
.signup-plan-option small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.signup-plan-option:hover > span { border-color: #a8bfea; background: var(--surface-soft); }
.signup-plan-option input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue), 0 0 0 2px rgb(20 103 243 / 10%); }
.signup-plan-option input:focus-visible + span { box-shadow: var(--focus); }
.signup-pin-row { row-gap: 8px; }
.signup-pin-row .pin-help { grid-column: 1 / -1; margin-top: -1px; white-space: nowrap; overflow-wrap: normal; }
.consent-check { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 10px; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.consent-check input { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--blue); }
.consent-check > span { min-width: 0; margin: 0 !important; }
.inline-legal-link { display: inline; margin: 0; border: 0; background: transparent; color: var(--blue); padding: 0; font: inherit; font-weight: 750; text-decoration: underline; }
.inline-legal-link:hover { color: var(--blue-dark); }
.plan-summary-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 18px; }
.plan-summary-heading strong { color: var(--blue); font-size: 22px; }
.plan-summary-heading small { color: var(--muted); font-size: 12px; }
.plan-choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.plan-choice { display: grid; gap: 5px; min-height: 88px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px; text-align: left; cursor: pointer; }
.plan-choice:hover, .plan-choice:focus-visible { border-color: #8fb9ff; background: #f6faff; outline: none; }
.plan-choice.is-selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 2px rgb(20 103 243 / 12%); }
.plan-choice strong { font-size: 16px; }
.plan-choice span { color: var(--muted); font-size: 11px; }
.plan-step-heading { margin: 18px 0 10px; color: var(--ink-soft); font-weight: 650; }
.plan-review-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 20px; }
.plan-review-summary > div { display: grid; gap: 4px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 13px 14px; }
.plan-review-summary span { color: var(--muted); font-size: 11px; }
.plan-review-summary strong { overflow-wrap: anywhere; font-size: 16px; }
.plan-review-summary small { color: var(--muted); font-size: 10px; font-weight: 600; }
.checkout-line { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; color: var(--ink-soft); }
.checkout-line strong { color: var(--ink); font-size: 20px; }
.checkout-note { margin-top: 8px; border-left: 3px solid var(--green); color: var(--muted); font-size: 12px; line-height: 1.5; padding: 10px 12px; background: var(--green-soft); }
.checkout-note strong { color: var(--ink); }
.plan-confirmation { text-align: center; }
.plan-confirmation > i { display: block; margin: 16px auto 10px; color: var(--green); font-size: 48px; }
.plan-confirmation h3 { font-size: 22px; }
.legal-modal-content { display: grid; gap: 13px; max-height: 52vh; overflow: auto; color: var(--ink-soft); font-size: 13px; line-height: 1.65; padding-right: 4px; }
.legal-modal-content h3 { margin-top: 5px; color: var(--ink); font-size: 16px; }
.legal-modal-content ul { display: grid; gap: 7px; margin: 0; padding-left: 20px; }
.account-plan-badge { display: inline-flex; width: fit-content; margin-top: 4px; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: 3px 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.billing-view { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 70px; }
.billing-page-header { max-width: 720px; }
.billing-page-header h1 { margin: 10px 0 10px; font-size: clamp(34px, 5vw, 58px); letter-spacing: -.055em; line-height: 1.03; }
.billing-page-header p:last-child { color: var(--ink-soft); font-size: 17px; line-height: 1.6; }
.billing-view > .billing-cycle-toggle { display: flex; width: max-content; margin: 30px auto 0; }
.billing-cycle-toggle { display: inline-flex; gap: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 4px; }
.billing-cycle-toggle button { border: 0; border-radius: 999px; background: transparent; color: var(--ink-soft); cursor: pointer; padding: 9px 16px; font-size: 12px; font-weight: 800; }
.billing-cycle-toggle button.is-active { background: white; color: var(--blue); box-shadow: 0 4px 14px rgb(16 24 39 / 10%); }
.billing-cycle-toggle button[data-app-billing-cycle="year"] { display: inline-flex; align-items: center; gap: 8px; }
.billing-cycle-toggle button span:not(.billing-promo) { margin-left: 4px; color: var(--green); font-size: 10px; }
.billing-promo { display: inline-flex; min-height: 25px; align-items: center; gap: 5px; margin-left: 2px; border: 1px solid #a6ddb7; border-radius: 999px; background: linear-gradient(135deg, #eaf7ef, #d8f6e3); box-shadow: 0 5px 12px rgb(31 157 73 / 16%); color: #16783b !important; padding: 4px 8px 4px 6px; font-size: 10px !important; line-height: 1; }
.billing-promo i { color: var(--coral); font-size: 13px; }
.billing-promo strong { font-size: 10px; letter-spacing: .01em; }
.billing-promo small { color: #16783b; font-size: 8px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.billing-plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
.billing-plan-card { display: flex; min-height: 475px; flex-direction: column; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); padding: 25px; box-shadow: 0 18px 44px rgb(19 34 56 / 6%); }
.billing-plan-card.is-current { background: #f4f7fb; box-shadow: none; opacity: .76; }
.billing-plan-card h2 { margin: 9px 0 0; font-size: 28px; }
.billing-plan-card .billing-price { display: flex; align-items: baseline; gap: 7px; margin-top: 10px; }
.billing-price strong { font-size: 40px; letter-spacing: -.06em; }
.billing-price span { color: var(--muted); font-size: 11px; }
.billing-plan-card ul { display: grid; flex: 1; gap: 11px; margin: 25px 0; padding: 0; list-style: none; }
.billing-plan-card li { display: flex; gap: 8px; color: var(--ink-soft); font-size: 13px; line-height: 1.45; }
.billing-plan-card li i { flex: 0 0 auto; color: var(--green); }
.billing-plan-card .button { width: 100%; }
.billing-current-label { display: inline-flex; align-self: flex-start; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: 5px 9px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.billing-footer-actions { display: flex; align-items: center; gap: 18px; margin-top: 24px; }
.billing-footer-actions .form-message { margin: 0; }
.billing-summary-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.billing-summary-details > div { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 12px 14px; }
.billing-summary-details span { color: var(--muted); font-size: 11px; }
.billing-summary-details strong { font-size: 14px; }
.checkout-note-prominent { margin: 4px 0 20px; color: var(--ink-soft); font-size: 13px; }
.plan-summary-actions { flex-wrap: wrap; }
.compact-menu button:disabled { cursor: not-allowed; opacity: .45; }
@media (max-width: 780px) { .billing-view { width: min(100% - 28px, 600px); padding-top: 22px; } .billing-plan-grid { grid-template-columns: 1fr; } .billing-plan-card { min-height: auto; } .billing-footer-actions { align-items: flex-start; flex-direction: column; } }
@media (max-width: 620px) { .plan-choice-grid, .signup-plan-options, .plan-review-summary, .billing-summary-details { grid-template-columns: 1fr; } .plan-summary-heading { align-items: flex-start; flex-direction: column; } }

.invisible {
  visibility: hidden;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}

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

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.button-primary {
  background: var(--blue);
  color: white;
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-primary.button-cash-out { background: var(--coral); }
.button-primary.button-cash-out:hover { background: #d83f2e; }

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: #a8b4c5;
  background: var(--surface-soft);
}

.button-danger {
  border-color: #f3b7b0;
  background: white;
  color: var(--danger);
}

.button-large {
  min-height: 52px;
  padding-inline: 20px;
}

.text-button {
  min-height: 38px;
  background: transparent;
  color: var(--blue);
  padding: 6px 8px;
  font-weight: 650;
}

.danger-text {
  color: var(--danger) !important;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-message {
  min-height: 20px;
  color: var(--ink-soft);
  font-size: 13px;
}

.form-message.is-error,
.error-message {
  color: var(--danger);
}

.form-message.is-success {
  color: var(--green);
}

.supporting-copy {
  margin-top: 8px;
  color: var(--ink-soft);
}

/* Authentication */
.auth-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
  background: var(--surface);
}

.auth-brand {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  background: #eef5ff;
  padding: clamp(32px, 5vw, 72px);
}

.brand-link,
.auth-mobile-logo,
.app-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--blue); font-size: 27px; font-weight: 800; letter-spacing: -.045em; text-decoration: none; }
.brand-link img, .auth-mobile-logo img, .app-logo img { width: 34px; height: 34px; border-radius: 9px; }

.auth-message {
  max-width: 560px;
}

.auth-message h1 {
  max-width: 13ch;
  margin-top: 14px;
  font-size: clamp(42px, 5vw, 66px);
  letter-spacing: -0.055em;
}

.auth-message > p:last-child {
  max-width: 48ch;
  margin-top: 24px;
  color: var(--ink-soft);
  font-size: 18px;
}

.back-to-site {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-weight: 650;
  text-decoration: none;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-panel-inner {
  width: min(100%, 460px);
}

.auth-mobile-logo {
  display: none;
  margin-bottom: 36px;
}

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

.auth-form h2 {
  margin-top: 8px;
  font-size: 31px;
}

.auth-form .button {
  width: 100%;
}

.password-field,
.amount-input {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.input-icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 19px;
}

.auth-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 44px;
  color: var(--muted);
  font-size: 12px;
}

.auth-switch-button {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 3px 6px;
  font-size: 13px;
  font-weight: 680;
}

.auth-switch-button:hover {
  text-decoration: underline;
}

.language-compact,
.language-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.language-compact select,
.language-control select {
  width: auto;
  min-height: 36px;
  border: 0;
  background: transparent;
  padding: 4px 18px 4px 2px;
}

/* App shell */
.app-view {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
}

.app-header,
.header-left,
.header-actions,
.ledger-workspace,
.project-overview,
.project-heading,
.balance-summary,
.ledger-split,
.composer-column,
.history-column {
  min-width: 0;
  max-width: 100%;
}

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  padding: 0 26px;
  backdrop-filter: blur(12px);
}

.header-left,
.header-actions {
  display: flex;
  align-items: center;
}

.header-left {
  gap: 22px;
}

.header-actions {
  gap: 14px;
}

.app-logo {
  display: inline-flex;
}

.app-logo { font-size: 24px; }
.app-logo img { width: 31px; height: 31px; }

.project-switcher {
  position: relative;
  min-width: 260px;
}

.switcher-button {
  display: grid;
  width: 100%;
  min-height: 42px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 9px 12px;
  font-weight: 700;
  text-align: left;
}
.switcher-button:hover, .switcher-button[aria-expanded="true"] { border-color: #aab9cc; background: var(--surface-soft); }
.switcher-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-button > i:first-child { color: var(--blue); font-size: 18px; }
.switcher-button > i:last-child { color: var(--muted); font-size: 13px; }

.switcher-menu {
  position: absolute;
  z-index: 70;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: 340px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  padding: 6px;
}
.switcher-menu button { display: flex; width: 100%; min-height: 42px; align-items: center; justify-content: space-between; gap: 18px; border-radius: 8px; background: transparent; padding: 9px 11px; text-align: left; white-space: nowrap; }
.switcher-menu button:hover, .switcher-menu button[aria-checked="true"] { background: var(--blue-soft); color: var(--blue); }
.switcher-menu button i { color: var(--blue); }

.language-control {
  position: relative;
  border-right: 1px solid var(--line);
  padding-right: 16px;
}
.language-control > button { display: inline-flex; min-height: 40px; align-items: center; gap: 7px; border-radius: 8px; background: transparent; padding: 7px 8px; }
.language-control > button:hover, .language-control > button[aria-expanded="true"] { background: var(--surface-soft); }
.language-menu { right: 16px; left: auto; min-width: 180px; }
.language-menu button span { color: var(--muted); font-size: 11px; }

.account-wrap,
.export-menu-wrap {
  position: relative;
}

.account-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  background: transparent;
  padding: 4px 8px;
  font-weight: 680;
}

.account-button:hover {
  background: var(--surface-soft);
}

.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--blue);
  font-size: 20px;
}

.account-menu,
.compact-menu {
  position: absolute;
  z-index: 50;
  right: 0;
  min-width: 230px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
}

.account-menu {
  top: calc(100% + 10px);
}

body > .account-menu {
  position: fixed;
  z-index: 1000;
}

.account-menu-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.account-menu-heading span:last-child {
  display: grid;
}

.account-menu-heading small {
  color: var(--muted);
  text-transform: capitalize;
}

.account-menu > button,
.compact-menu > button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  background: transparent;
  padding: 10px 16px;
  text-align: left;
}

.account-menu > button:hover,
.compact-menu > button:hover {
  background: var(--surface-soft);
}

.menu-divider {
  height: 1px;
  background: var(--line);
}

.app-content {
  width: min(100%, 1600px);
  max-width: 100%;
  overflow-x: clip;
  margin: 0 auto;
  padding: 10px 32px 42px;
}

.tip-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--tip-line);
  border-radius: var(--radius);
  background: var(--tip);
  padding: 11px 16px;
  color: #244b45;
}

.tip-banner > i {
  color: #128c72;
  font-size: 25px;
}

.tip-banner button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #315f57;
  padding: 8px;
  font-weight: 650;
}

.ledger-workspace {
  margin-top: 8px;
}

.project-overview {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(620px, 1.45fr);
  align-items: center;
  gap: 24px;
  padding: 0 0 10px;
}

.project-heading-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.project-heading h1 {
  letter-spacing: -0.045em;
}

#projectHeading { position: relative; display: inline-flex; min-width: 0; max-width: 100%; flex: 1 1 auto; align-items: center; }
#projectHeading > button {
  display: inline-flex;
  min-width: 0;
  max-width: 430px;
  align-items: center;
  gap: 10px;
  border-radius: 9px;
  background: transparent;
  padding: 2px 5px 2px 0;
  color: var(--ink);
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 770;
  letter-spacing: -.045em;
  text-align: left;
}
#projectButtonLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-currency { display: inline-flex; flex: 0 0 auto; align-items: center; padding-top: 7px; }
#projectHeading > button:hover, #projectHeading > button[aria-expanded="true"] { background: var(--blue-soft); color: var(--blue); }
#projectHeading > button i { color: var(--muted); font-size: 15px; }
.project-menu { top: calc(100% + 5px); min-width: 260px; font-size: 14px; font-weight: 650; letter-spacing: 0; }

.currency-badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.05em;
}

.project-updated {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

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

.balance-summary > div {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 1px 20px;
}

.balance-summary dt {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.balance-summary dt i {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
}

.balance-summary dd {
  overflow: hidden;
  margin-top: 4px;
  font-size: clamp(23px, 2vw, 30px);
  font-weight: 760;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-summary small {
  color: var(--muted);
}

.balance-in dd,
.balance-in dt {
  color: var(--green);
}

.balance-in dt i {
  background: var(--green-soft);
}

.balance-out dd,
.balance-out dt {
  color: var(--coral);
}

.balance-out dt i {
  background: var(--coral-soft);
}

.ledger-split {
  display: grid;
  min-height: 560px;
  grid-template-columns: minmax(310px, 0.78fr) minmax(0, 2.22fr);
  border-top: 1px solid var(--line);
}

.composer-column {
  border-right: 1px solid var(--line);
  padding: 22px 28px 28px 0;
}

.transaction-composer {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 13px;
  border: 1px solid #82c998;
  border-radius: 14px;
  background: #e0f5e7;
  padding: 17px;
  transition: background 180ms ease, border-color 180ms ease;
}

.transaction-composer label,
.transaction-composer fieldset,
.transaction-composer input,
.transaction-composer select,
.transaction-composer textarea,
.transaction-composer button {
  min-width: 0;
  max-width: 100%;
}

.transaction-composer label > span:first-child,
.transaction-composer legend,
.transaction-composer .button,
.transaction-composer .text-button {
  overflow-wrap: anywhere;
}

.transaction-composer[data-transaction-type="out"] { border-color: #e69488; background: #ffe9e5; }

.access-toolbar { display: grid; grid-template-columns: minmax(170px, .7fr) auto auto; align-items: end; gap: 10px; margin-bottom: 14px; }
.access-toolbar select { min-height: 44px; }
.access-scope-field { display: grid; gap: 5px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.invitation-code { display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid #b9d3fb; border-radius: 11px; background: var(--blue-soft); padding: 14px 16px; }
.invitation-code span { display: grid; gap: 2px; }
.invitation-code small { color: var(--ink-soft); }
.invitation-code strong { color: var(--blue); font-size: 20px; letter-spacing: .12em; }
.management-subheading { margin: 22px 0 8px; }

.section-title-row,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.transaction-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  margin: 2px 0 0;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0;
  gap: 10px;
}

.transaction-type input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.transaction-type span {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px 10px;
  text-align: center;
  overflow-wrap: anywhere;
  font-weight: 700;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.transaction-type input:focus-visible + span {
  box-shadow: var(--focus);
}

.transaction-type input:checked + span {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.transaction-type label:last-child input:checked + span { border-color: var(--coral); background: var(--coral); }

.amount-currency-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(88px, 104px); gap: 10px; }
.amount-currency-row > label { min-width: 0; }
.transaction-currency-field { min-width: 0; }
.currency-readonly { display: flex; min-height: 48px; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 11px 13px; color: var(--ink); font-weight: 760; }

.amount-input > span {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--ink-soft);
  font-weight: 650;
}

.amount-input input {
  padding-left: 38px;
  font-size: 19px;
  font-weight: 650;
}

.proof-field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.proof-field > span small {
  font-weight: 500;
}

.proof-dropzone {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  border: 1px dashed #b9c4d2;
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  transition: border-color 150ms ease, background 150ms ease;
}

.proof-dropzone:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.proof-dropzone > i {
  color: var(--blue);
  font-size: 23px;
}

.proof-dropzone > span {
  display: grid;
  gap: 3px;
}

.proof-dropzone small {
  color: var(--muted);
  font-size: 11px;
}

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

.proof-actions button {
  background: transparent;
  color: var(--blue);
  padding: 4px 0;
  font-size: 12px;
  font-weight: 650;
}

.proof-actions button:last-child {
  color: var(--danger);
}

.proof-voice-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; min-width: 0; }
.voice-field { display: flex; min-width: 44px; align-items: flex-end; padding-bottom: 1px; }
.voice-controls { display: flex; min-height: 48px; align-items: center; justify-content: center; gap: 7px; min-width: 44px; }
.voice-icon-button { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--blue); padding: 0; transition: background 150ms ease, border-color 150ms ease, color 150ms ease; }
.voice-icon-button:hover { border-color: var(--blue); background: var(--blue-soft); }
.voice-stop-button { color: var(--coral); }
.voice-status { display: block; min-height: 0; color: var(--coral); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.voice-preview { width: 100%; max-width: 100%; min-height: 38px; }
.field-help { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.transaction-private-note { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.transaction-row-clickable { cursor: pointer; }
.transaction-row-clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.transaction-row-clickable:hover td { background: var(--surface-soft); }
.private-voice-indicator { display: inline-grid; width: 22px; height: 22px; margin-inline-start: 7px; place-items: center; border: 1px solid #b9d3fb; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 13px; vertical-align: middle; }
.transaction-details-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.transaction-detail-item { display: grid; min-width: 0; gap: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); padding: 12px; }
.transaction-detail-item > span,
.transaction-detail-block > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.transaction-detail-item strong { overflow-wrap: anywhere; }
.transaction-detail-item.detail-in strong { color: var(--green); }
.transaction-detail-item.detail-out strong { color: var(--coral); }
.transaction-detail-block { display: grid; gap: 8px; margin-top: 18px; }
.transaction-detail-copy { margin: 0; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.transaction-detail-proof-button { max-width: min(100%, 320px); }
.transaction-details-audio { display: block; width: 100%; max-width: 520px; min-height: 42px; }
textarea { min-height: 76px; resize: vertical; }

.composer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.composer-actions .button-primary {
  min-width: 190px;
}

.history-column {
  min-width: 0;
  padding: 22px 0 30px 30px;
}

.history-header > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.history-header p {
  color: var(--muted);
  font-size: 13px;
}

.history-toolbar {
  display: flex;
  gap: 10px;
}

.compact-menu {
  top: calc(100% + 8px);
  min-width: 180px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 150px auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  border-block: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 14px;
}

.filter-panel input {
  min-height: 42px;
}

.transaction-table-wrap {
  min-width: 0;
  overflow-x: auto;
  margin-top: 18px;
}

.transaction-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  table-layout: auto;
}

.transaction-table th {
  border-bottom: 1px solid var(--line-strong);
  padding: 12px 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.transaction-table td {
  border-bottom: 1px solid var(--line);
  padding: 15px 10px;
  vertical-align: middle;
}

.transaction-table td:first-child,
.transaction-table th:first-child {
  padding-left: 0;
}

.transaction-table td:last-child,
.transaction-table th:last-child {
  padding-right: 0;
}

.transaction-table small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.transaction-note {
  min-width: 160px;
}

.transaction-type-cell {
  white-space: nowrap;
}

.transaction-type-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.transaction-in,
.transaction-in .transaction-type-label {
  color: var(--green);
}

.transaction-out,
.transaction-out .transaction-type-label {
  color: var(--coral);
}

.money-cell,
.balance-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.money-cell {
  font-weight: 680;
}

.proof-link {
  display: inline-flex;
  max-width: 150px;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  background: transparent;
  color: var(--blue);
  padding: 4px 0;
  text-decoration: underline;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proof-file-button {
  display: inline-flex;
  max-width: 150px;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  background: transparent;
  color: var(--blue);
  padding: 4px 0;
  font-size: 12px;
  text-decoration: underline;
  white-space: nowrap;
}

.proof-file-button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-cell,
.description-cell {
  min-width: 130px;
}

.description-cell {
  min-width: 170px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.type-badge.type-in {
  background: var(--green-soft);
  color: var(--green);
}

.type-badge.type-out {
  background: var(--coral-soft);
  color: var(--coral);
}

.amount-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount-cell.amount-in {
  color: var(--green);
}

.amount-cell.amount-out {
  color: var(--coral);
}

.row-actions {
  min-width: 72px;
  white-space: nowrap;
}

.row-icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 17px;
}

.row-icon-button:hover {
  background: var(--surface-soft);
  color: var(--blue);
}

.row-icon-button.danger-text:hover {
  background: var(--coral-soft);
  color: var(--danger);
}

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

.row-actions-wrap {
  position: relative;
}

.row-actions-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  font-size: 20px;
}

.row-actions-button:hover {
  background: var(--surface-soft);
}

.row-menu {
  position: absolute;
  z-index: 20;
  top: 35px;
  right: 0;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  padding: 5px;
}

.row-menu button {
  display: block;
  width: 100%;
  border-radius: 6px;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
}

.row-menu button:hover {
  background: var(--surface-soft);
}

.empty-transactions,
.empty-workspace {
  text-align: center;
}

.empty-transactions {
  padding: 72px 24px;
  color: var(--ink-soft);
}

.empty-transactions > i {
  color: var(--blue);
  font-size: 38px;
}

.empty-transactions h3 {
  margin-top: 14px;
  color: var(--ink);
}

.empty-transactions p {
  margin-top: 5px;
}

.empty-workspace {
  width: min(100%, 620px);
  margin: 10vh auto 0;
  padding: 50px 24px;
}

.empty-icon,
.onboarding-icon {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 22px;
  place-items: center;
  border-radius: 20px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 33px;
}

.empty-workspace h1 {
  margin-top: 10px;
}

.empty-workspace > p:not(.eyebrow) {
  max-width: 48ch;
  margin: 14px auto 24px;
  color: var(--ink-soft);
}

/* Modal and management */
.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgb(12 21 35 / 48%);
  backdrop-filter: blur(3px);
}

.modal {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  width: min(calc(100% - 32px), 570px);
  max-height: min(86vh, 820px);
  overflow-y: auto;
  transform: translate(-50%, -50%);
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  padding: 26px;
}

.modal-wide {
  width: min(calc(100% - 32px), 840px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.modal-header h2 {
  margin-top: 6px;
  font-size: 25px;
}

.modal-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 21px;
}

.modal-close:hover {
  background: var(--surface-soft);
}

.modal-form {
  display: grid;
  gap: 17px;
}

.currency-fieldset { margin: 0; border: 0; padding: 0; }
.currency-fieldset > p { margin: -2px 0 10px; color: var(--muted); font-size: 12px; }
.currency-options { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.currency-options label { position: relative; }
.currency-options input { position: absolute; opacity: 0; pointer-events: none; }
.currency-options span { display: grid; min-height: 42px; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: white; font-size: 12px; font-weight: 760; }
.currency-options input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modal-actions.spread {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.account-danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.account-danger-zone > div { display: grid; gap: 3px; }
.account-danger-zone small { color: var(--muted); }

.management-list {
  display: grid;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.management-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(105px, auto) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 17px 4px;
}
.management-row > .row-actions { display: flex; min-width: 0; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.management-row > .row-actions .button { min-height: 36px; padding: 7px 10px; font-size: 12px; }

.inline-member-form { display: grid; gap: 13px; margin-top: 14px; border: 1px solid #bfd6fa; border-radius: 12px; background: #f5f9ff; padding: 16px; }
.inline-form-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.inline-form-heading > div { display: grid; }
.inline-form-heading small { color: var(--muted); }
.inline-member-form > .button { justify-self: start; }

.management-icon,
.management-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 19px;
  font-weight: 760;
}

.management-avatar {
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
}

.management-row > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.management-row > span:nth-child(2) strong,
.management-row > span:nth-child(2) small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
}

.status-active {
  background: var(--green-soft);
  color: var(--green);
}

.status-inactive {
  background: var(--surface-soft);
  color: var(--muted);
}

.empty-list-copy {
  margin: 22px 0 4px;
  color: var(--muted);
}

.management-row-main {
  display: grid;
  gap: 3px;
}

.management-row small {
  color: var(--muted);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  text-transform: capitalize;
}

.status-dot::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.status-dot.inactive::before {
  background: var(--muted);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-block: 1px solid var(--line);
  padding: 14px 0;
}

.switch-row > span {
  margin: 0;
}

.switch-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 450;
}

.switch-row input {
  width: 44px;
  min-height: 24px;
  accent-color: var(--blue);
}

.member-fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
}

.member-fieldset p {
  color: var(--muted);
  font-size: 12px;
}

.member-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.member-options > label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-options > label input {
  width: 18px;
  min-height: 18px;
}

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

.member-option input {
  width: 18px;
  min-height: 18px;
}

.onboarding-modal {
  width: min(calc(100% - 32px), 520px);
  padding: 34px;
  text-align: center;
}

.onboarding-modal .modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.onboarding-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 28px;
}

.onboarding-progress span {
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}

.onboarding-progress span.active {
  background: var(--blue);
}

.onboarding-step h2 {
  margin-top: 10px;
  font-size: 29px;
}

.onboarding-step > p:last-child {
  max-width: 43ch;
  margin: 14px auto 0;
  color: var(--ink-soft);
}

.proof-preview {
  display: grid;
  min-height: 300px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.proof-preview img,
.proof-preview iframe {
  width: 100%;
  height: min(62vh, 620px);
  border: 0;
  object-fit: contain;
}

.toast-region {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 22px;
  display: grid;
  max-width: min(380px, calc(100% - 44px));
  gap: 10px;
}

.toast {
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  padding: 13px 16px;
  animation: toast-in 200ms ease both;
}

.toast.error {
  border-left-color: var(--coral);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1120px) {
  .project-overview {
    grid-template-columns: minmax(260px, .75fr) minmax(560px, 1.4fr);
    gap: 18px;
  }

  .balance-summary > div:first-child {
    border-left: 0;
    padding-left: 0;
  }

  .ledger-split {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.6fr);
  }

  .composer-column {
    padding-right: 26px;
  }

  .history-column {
    padding-left: 26px;
  }

  .filter-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 850px) {
  .app-header {
    min-height: 64px;
    padding: 0 18px;
  }

  .header-left {
    gap: 14px;
  }

  .app-logo { font-size: 21px; }
  .app-logo img { width: 29px; height: 29px; }

  .project-switcher {
    min-width: 210px;
  }

  .language-control,
  .account-button > span:not(.account-avatar) {
    display: none;
  }

  .account-button {
    padding: 0;
  }

  .app-content {
    padding: 18px 18px 40px;
  }

  .project-overview { grid-template-columns: 1fr; gap: 18px; }

  .tip-banner {
    align-items: start;
  }

  .tip-banner button span {
    display: none;
  }

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

  .composer-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 26px 0 30px;
  }

  .transaction-composer {
    position: static;
  }

  .history-column {
    padding: 30px 0 0;
  }

  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    padding: 24px;
  }

  .auth-mobile-logo {
    display: inline-flex;
  }
}

@media (max-width: 620px) {
  #appView,
  #appView .app-header,
  #appView .app-content {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  #appView .app-content > *,
  #appView .ledger-workspace > *,
  #appView .ledger-split > *,
  #appView .transaction-composer > *,
  #appView .history-column > * {
    min-width: 0;
    max-width: 100%;
  }

  h1 {
    font-size: 30px;
  }

  .app-header {
    width: 100%;
    min-width: 0;
    gap: 8px;
    padding-inline: 14px;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  .app-logo span { display: none; }
  .app-logo img { width: 31px; height: 31px; }

  .project-switcher {
    width: auto;
    min-width: 0;
    flex: 1 1 128px;
  }

  .switcher-button {
    min-height: 44px;
    overflow: hidden;
    padding-inline: 10px;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .switcher-menu {
    width: auto;
    max-width: 100%;
  }

  .app-header .project-switcher > .switcher-menu {
    position: fixed;
    top: 60px;
    right: 14px;
    left: 14px;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .project-menu {
    right: auto;
    left: 0;
    width: min(340px, calc(100% - 28px));
    min-width: 0;
  }

  .switcher-menu button span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 4px;
  }

  .account-avatar {
    width: 38px;
    height: 38px;
  }

  .account-menu {
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    right: 14px;
    left: 14px;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100dvh - 76px - env(safe-area-inset-top));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .tip-banner {
    grid-template-columns: auto 1fr auto;
    padding: 12px;
    font-size: 13px;
  }

  .project-overview {
    width: 100%;
    min-width: 0;
    padding-bottom: 14px;
  }

  .project-heading,
  .project-heading-row,
  #projectHeading,
  #projectHeading > button,
  .balance-summary,
  .ledger-split,
  .composer-column,
  .transaction-composer,
  .history-column,
  .history-header,
  .filter-panel {
    min-width: 0;
    max-width: 100%;
  }

  .project-heading-row {
    align-items: flex-start;
  }

  .summary-currency { padding-top: 6px; }

  .balance-summary {
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-block: 1px solid var(--line);
  }

  .balance-summary > div {
    border-left: 0;
    padding: 17px 8px;
  }

  .balance-summary > div:first-child {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
    padding-left: 8px;
  }

  .balance-summary > div:last-child {
    border-left: 1px solid var(--line);
    padding-left: 18px;
  }

  .balance-summary dd {
    font-size: 21px;
    letter-spacing: -0.035em;
  }

  .access-toolbar { grid-template-columns: 1fr; }

  .transaction-type {
    gap: 8px;
  }

  .amount-currency-row { grid-template-columns: minmax(0, 1fr) 92px; }
  .billing-promo small { display: none; }
  .currency-options { grid-template-columns: repeat(3, 1fr); }

  .history-header {
    align-items: flex-end;
  }

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

  .history-header > *,
  .section-title-row > *,
  .transaction-type > label,
  .proof-dropzone > span {
    min-width: 0;
  }

  .history-header > div:first-child {
    display: block;
  }

  .history-header p {
    margin-top: 3px;
  }

  .history-toolbar .button {
    min-width: 44px;
    padding-inline: 11px;
    font-size: 0;
  }

  .history-toolbar .button i {
    font-size: 17px;
  }

  .filter-panel {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

  .filter-panel label:first-child,
  .filter-panel .text-button {
    grid-column: 1 / -1;
  }

  .transaction-table {
    max-width: 100%;
    min-width: 0;
  }

  .transaction-table-wrap {
    max-width: 100%;
    overflow-x: hidden;
  }

  .transaction-table thead {
    display: none;
  }

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

  .transaction-table td {
    display: block;
    width: auto;
    min-width: 0;
  }

  .transaction-table tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 16px;
    border-bottom: 1px solid var(--line);
    padding: 16px 0;
  }

  .transaction-table td {
    border: 0;
    padding: 0 !important;
  }

  .transaction-table td:nth-child(1) { grid-column: 1; grid-row: 2; }
  .transaction-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .transaction-table td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .transaction-table td:nth-child(4) { grid-column: 2; grid-row: 1; text-align: right; }
  .transaction-table td:nth-child(5) { grid-column: 2; grid-row: 2; text-align: right; }
  .transaction-table td:nth-child(6) { grid-column: 1 / -1; grid-row: 4; }
  .transaction-table td:nth-child(7) { position: static; grid-column: 2; grid-row: 4; width: auto; justify-self: end; }

  .date-cell,
  .description-cell,
  .row-actions {
    min-width: 0;
  }

  .description-cell strong,
  .description-cell small {
    overflow-wrap: anywhere;
  }

  .transaction-type-cell::before {
    color: var(--muted);
    content: "Type: ";
  }

  .balance-cell::before {
    color: var(--muted);
    content: "Balance ";
    font-size: 11px;
  }

  .proof-link {
    max-width: 100%;
  }

  .proof-file-button { max-width: 100%; }

  .composer-actions { gap: 10px; }
  .composer-actions .button-primary { min-width: 0; flex: 1 1 auto; }

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

  .modal {
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: 92dvh;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .modal-wide {
    width: 100%;
  }

  .management-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 7px 14px;
  }

  .management-row > :nth-child(3) {
    grid-column: 2;
  }

  .management-row > :last-child {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-self: start;
  }

  .management-row > .row-actions { justify-content: flex-start; }

  .invitation-code {
    align-items: stretch;
    flex-direction: column;
  }

  .invitation-code strong { overflow-wrap: anywhere; }

  .modal-actions.spread {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions.spread span {
    display: none;
  }

  .modal-actions.spread .button-danger {
    grid-column: 1 / -1;
  }

  .account-danger-zone { align-items: stretch; flex-direction: column; }
  .account-danger-zone .button { width: 100%; }

  .auth-panel {
    align-items: start;
    padding-top: max(30px, env(safe-area-inset-top));
  }

  .auth-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .header-left,
html[dir="rtl"] .header-actions,
html[dir="rtl"] .history-toolbar,
html[dir="rtl"] .composer-actions,
html[dir="rtl"] .account-menu-heading,
html[dir="rtl"] .tip-banner,
html[dir="rtl"] .proof-dropzone {
  direction: rtl;
}

html[dir="rtl"] .account-menu,
html[dir="rtl"] .compact-menu {
  right: auto;
  left: 0;
}

html[dir="rtl"] .composer-column {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding-right: 0;
  padding-left: 36px;
}

html[dir="rtl"] .history-column {
  padding-right: 36px;
  padding-left: 0;
}

html[dir="rtl"] .transaction-table th,
html[dir="rtl"] .transaction-table td {
  text-align: right;
}

@media (max-width: 850px) {
  html[dir="rtl"] .composer-column {
    border-left: 0;
    padding-left: 0;
  }

  html[dir="rtl"] .history-column {
    padding-right: 0;
  }
}
