/* ==========================================================================
   Masarifi (مصاريفي) — World-Class Mobile-First Fintech Design System
   Uses CSS Logical Properties for effortless Arabic (RTL) & English (LTR)
   ========================================================================== */

:root {
  --bg: #F5F7F4;
  --surface: #FFFFFF;
  --surface-subtle: #F8FAF8;
  --surface-muted: #EFF3EF;
  --border: #E2E8E3;
  --border-strong: #CCD6CE;

  --primary: #0F5C4D;
  --primary-hover: #0B473C;
  --primary-soft: #E9F4F0;
  --primary-border: #BFE0D6;

  --gold: #C88318;
  --gold-soft: #FEF6E6;
  --gold-border: #F2D7A5;

  --danger: #C23B3B;
  --danger-soft: #FDF0F0;
  --danger-border: #ECC5C5;

  --ink: #111C18;
  --ink-secondary: #485A53;
  --ink-muted: #768880;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(17, 28, 24, 0.04);
  --shadow-md: 0 6px 20px rgba(17, 28, 24, 0.06);
  --shadow-lg: 0 18px 44px rgba(17, 28, 24, 0.16);

  --font-ar: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
  --font-en: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html[dir="ltr"] body {
  font-family: var(--font-en);
}

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

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.hidden {
  display: none !important;
}

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

.shrink-0 {
  flex-shrink: 0;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-md {
  width: 20px;
  height: 20px;
}

/* Shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Sticky Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 600px;
  margin-inline: auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

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

.brand-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.brand-tagline {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn-ghost {
  background: var(--primary-soft);
  color: var(--primary);
}

.pill-btn-ghost:hover {
  background: #DCEEE8;
}

.pill-btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.pill-btn-outline:hover {
  background: var(--surface-subtle);
}

.pill-btn-lang {
  background: var(--surface-muted);
  color: var(--ink-secondary);
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-btn-lang:hover {
  background: #E2E9E4;
}

/* Sticky Mini Summary Ribbon */
.sticky-ribbon {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease;
  background: var(--surface-subtle);
  border-top: 1px solid transparent;
}

.sticky-ribbon.visible {
  max-height: 44px;
  opacity: 1;
  border-top-color: var(--border);
}

.sticky-ribbon-inner {
  max-width: 600px;
  margin-inline: auto;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sticky-metric {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.sticky-label {
  font-size: 12px;
  color: var(--ink-muted);
}

.sticky-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
}

.sticky-val.is-deficit {
  color: var(--danger);
}

.sticky-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
}

/* Main Content */
.main-content {
  width: 100%;
  max-width: 600px;
  margin-inline: auto;
  padding: 14px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Trust Strip */
.trust-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
}

.trust-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* Resume Banner */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: #6B4408;
}

.resume-banner-copy strong {
  display: block;
  font-size: 13.5px;
}

.resume-banner-copy p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.info-chip {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: #EDF5FF;
  border: 1px solid #C8DDF8;
  color: #1B4E8A;
  font-size: 12.5px;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.month-picker-wrap {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.month-input {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

#month-select {
  width: 76px;
  padding-inline: 6px;
}

#month-year {
  width: 51px;
  padding-inline: 4px;
  text-align: center;
}

/* Form Controls */
.budget-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.select-control,
.text-control {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select-control:focus,
.text-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 92, 77, 0.13);
}

.text-control-lg {
  height: 48px;
  font-size: 19px;
  font-weight: 700;
}

.currency-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-input-wrap .text-control {
  padding-inline-end: 66px;
}

.currency-tag {
  position: absolute;
  inset-inline-end: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.field-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  font-size: 12px;
}

.meta-pill {
  max-width: 100%;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 -1px 0 rgba(15, 92, 77, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.budget-toolbar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.text-action {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.text-action:hover {
  text-decoration: underline;
}

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

.toolbar-sep {
  color: var(--border-strong);
}

/* Validation Alert Banner */
.validation-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1.5px solid var(--danger-border);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 700;
}

/* Collapsible Sections */
.section-list-title {
  margin: 4px 2px 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.section-card.has-error,
.section-card.has-omitted-edits {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(194, 59, 59, 0.12);
}

.section-header {
  background: var(--surface);
  padding: 11px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto clamp(58px, 18vw, 108px);
  align-items: center;
  gap: 8px;
}

.sections-selection-hint {
  margin: 0 0 10px;
  color: var(--ink-secondary);
  font-size: 12px;
}

.section-header-btn {
  min-width: 0;
  border: none;
  background: transparent;
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-align: start;
}

.section-inclusion-checkbox:focus-visible,
.section-header-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 7px;
}

.section-inclusion {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-block-size: 34px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.section-inclusion-checkbox {
  flex-shrink: 0;
  inline-size: 17px;
  block-size: 17px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.section-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-icon svg {
  width: 19px;
  height: 19px;
}

.section-meta {
  min-width: 0;
  flex: 1;
}

.section-name {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.section-submeta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 6px;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.section-submeta .meta-pill {
  padding: 1px 6px;
}

.section-incomplete-pill {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  font-size: 10.5px;
  font-weight: 700;
}

.section-total {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-align: end;
  overflow-wrap: anywhere;
}

.section-total.is-zero {
  color: var(--ink-muted);
  font-weight: 500;
}

.chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}

@media (max-width: 390px) {
  .section-header {
    padding-inline: 8px;
    gap: 6px;
  }
  .section-header-btn {
    gap: 5px;
  }
  .section-header .section-icon {
    width: 29px;
    height: 29px;
  }
  .section-header .chevron {
    width: 14px;
    height: 14px;
  }
}

.section-card.is-open .chevron {
  transform: rotate(180deg);
}

.section-body {
  display: none;
  padding: 0 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.section-card.is-open .section-body {
  display: block;
}

.items-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.empty-section-note {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-size: 12.5px;
  color: var(--ink-muted);
  text-align: center;
}

/* Item Row Card */
.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 11px 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.item-row.state-unused {
  border-style: dashed;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.72);
}

.item-row.state-complete {
  border-color: var(--primary-border);
}

.item-row.state-incomplete {
  border-color: var(--danger);
  background: #FFFBFB;
}

.item-row.has-omitted-edits {
  border-color: var(--danger);
}

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

.item-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.item-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.item-inclusion {
  margin-bottom: 5px;
}

.section-omission-pill {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.item-badge {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.item-badge-suggested {
  background: var(--surface-muted);
  color: var(--ink-muted);
}

.item-badge-missing {
  background: var(--danger-soft);
  color: var(--danger);
}

.item-top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.item-type-select {
  height: 28px;
  padding: 0 7px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.item-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.item-delete-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Item Input Fields Grid */
.item-fields {
  display: grid;
  gap: 7px;
  align-items: end;
}

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

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

.item-fields-bill {
  grid-template-columns: minmax(0, 1fr);
}

.mini-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mini-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-input,
.mini-select {
  width: 100%;
  height: 38px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
}

.mini-input:focus,
.mini-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2.5px rgba(15, 92, 77, 0.13);
}

.mini-input.is-missing,
.mini-select.is-missing {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 2.5px rgba(194, 59, 59, 0.16);
}

.item-footer-line {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.item-footer-label {
  color: var(--ink-muted);
  font-weight: 500;
}

.item-subtotal-val {
  font-weight: 700;
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  height: 38px;
  padding: 0 13px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-outline:hover {
  background: var(--surface-subtle);
}

.btn-danger-outline {
  background: var(--surface);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-soft);
}

.btn-full {
  width: 100%;
}

/* Summary Card */
.summary-card {
  border-width: 1.5px;
  border-color: var(--primary-border);
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FBF9 100%);
}

.summary-card.is-deficit {
  border-color: var(--danger-border);
  background: linear-gradient(180deg, #FFFFFF 0%, #FDF4F4 100%);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.deficit-badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

.summary-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
}

.summary-card.is-deficit .summary-hero {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.summary-kicker {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 4px;
}

.summary-big-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--primary);
  word-break: break-word;
}

.summary-card.is-deficit .summary-big-value {
  color: var(--danger);
}

.summary-secondary {
  text-align: end;
}

.summary-pct-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}

.summary-pct-value.is-zero-note {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.summary-card.is-deficit .summary-pct-value:not(.is-zero-note) {
  color: var(--danger);
}

.progress-track {
  margin-top: 12px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 0.25s ease, background 0.25s ease;
}

.progress-fill.is-warn {
  background: var(--gold);
}

.progress-fill.is-deficit {
  background: var(--danger);
}

.summary-breakdown {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.breakdown-cell {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.breakdown-label {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.breakdown-val {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

/* Pre-Export Choices & Share CTA */
.export-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.choice-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1.5px solid var(--border);
  transition: border-color 0.15s ease;
}

.choice-block.needs-choice {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.choice-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice-question {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
}

.choice-hint {
  font-size: 12px;
  color: var(--ink-muted);
}

.segmented-yesno {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.seg-btn {
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.is-selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.choice-divider {
  height: 1px;
  background: var(--border);
}

.fawateeri-opt-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1.5px solid var(--border);
  cursor: pointer;
}

.custom-checkbox {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.fawateeri-opt-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.btn-share-pdf {
  height: 52px;
  font-size: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(15, 92, 77, 0.24);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 6px 8px 16px;
  font-size: 12px;
  color: var(--ink-muted);
}

.app-footer p {
  margin: 0;
}

.footer-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Modals & Drawers */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 28, 24, 0.52);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

@media (min-width: 560px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sheet-tall {
  max-height: 90dvh;
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.icon-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font-size: 15px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body > * {
  flex-shrink: 0;
}

.omissions-dialog {
  width: calc(100% - 24px);
  padding: 0;
  border: 1px solid var(--border);
  color: var(--ink);
}

.omissions-dialog:not([open]) {
  display: none;
}

.omissions-dialog::backdrop {
  background: rgba(18, 36, 30, 0.52);
}

.omissions-dialog p {
  margin: 0;
}

.omissions-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.omissions-list ul {
  margin: 0;
  padding-inline-start: 18px;
}

.omissions-list button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  text-align: start;
  text-decoration: underline;
  cursor: pointer;
}

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

.omissions-actions .btn {
  flex: 1 1 auto;
}

.price-hero-box {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  text-align: center;
}

.price-hero-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
}

.benefits-list {
  margin: 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.subscription-benefits {
  display: grid;
  gap: 8px;
}

.subscription-benefits h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.subscription-estimates {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.flow-caption {
  margin: 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-secondary);
  text-align: center;
}

.dev-preview-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  border: 1px dashed var(--gold);
  font-size: 12.5px;
  color: #6B4408;
  word-break: break-all;
}

.modal-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.fawateeri-sub-pill {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
}

.fawateeri-sticky-summary {
  margin-inline: -16px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 4px 12px rgba(17, 28, 24, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fawateeri-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
  align-items: end;
}

.fawateeri-filter-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fawateeri-filter-field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.fawateeri-filter-select {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
}

.fawateeri-filter-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.fawateeri-currency-summaries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fawateeri-currency-card {
  padding: 10px 11px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fawateeri-currency-card.is-deficit {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.fawateeri-currency-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fawateeri-currency-pill {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
}

.fawateeri-currency-card.is-deficit .fawateeri-currency-pill {
  background: var(--danger);
}

.fawateeri-months-badge {
  font-size: 12px;
}

.fawateeri-currency-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fawateeri-metric-box {
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 0;
}

.fawateeri-metric-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.fawateeri-metric-val {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  word-break: break-word;
}

.fawateeri-metric-val.is-positive {
  color: var(--primary);
}

.fawateeri-metric-val.is-deficit {
  color: var(--danger);
}

.fawateeri-latest-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.fawateeri-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fawateeri-item {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.fawateeri-item.is-earlier-copy {
  border-style: dashed;
  background: var(--surface);
}

.fawateeri-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.fawateeri-item-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fawateeri-version-badge {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
}

.fawateeri-version-latest {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.fawateeri-version-earlier {
  background: var(--surface-muted);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
}

.fawateeri-item-date {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.fawateeri-item-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fawateeri-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 18px;
  inset-inline: 14px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 520px;
  width: 100%;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast-action-link {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.toast-action-link:hover {
  background: rgba(255, 255, 255, 0.28);
}

.toast-error {
  background: var(--danger);
}

.toast-success {
  background: var(--primary);
}

/* Responsive tweaks for compact phones (360px) */
@media (max-width: 400px) {
  .topbar-inner {
    padding: 8px 10px;
    gap: 6px;
  }
  .brand {
    gap: 7px;
  }
  .brand-mark {
    width: 30px;
    height: 30px;
  }
  .brand-name {
    font-size: 15.5px;
    white-space: nowrap;
  }
  .brand-tagline {
    display: none;
  }
  .topbar-actions {
    gap: 5px;
  }
  .pill-btn {
    padding: 0 8px;
    font-size: 11.5px;
    gap: 4px;
  }
  .pill-btn .icon-sm {
    width: 14px;
    height: 14px;
  }
  .pill-btn-lang {
    padding: 0;
  }
  .summary-hero {
    grid-template-columns: 1fr;
  }
  .summary-secondary {
    text-align: start;
  }
}

/* Narrowest phones (320px–350px) — zero header overlap or horizontal scroll */
@media (max-width: 350px) {
  .topbar-inner {
    padding: 7px 8px;
    gap: 4px;
  }
  .brand {
    gap: 5px;
  }
  .brand-mark {
    width: 26px;
    height: 26px;
  }
  .brand-name {
    font-size: 13.5px;
  }
  .topbar-actions {
    gap: 4px;
  }
  .pill-btn {
    height: 32px;
    padding: 0 6px;
    font-size: 11px;
    gap: 3px;
  }
  .pill-btn .icon-sm {
    display: none;
  }
  .pill-btn-lang {
    width: 46px;
    min-width: 46px;
    max-width: 46px;
    padding: 0;
  }
  .card-head {
    flex-wrap: wrap;
    gap: 8px;
  }
}
