  body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #F4F6FA; color: #16213E; }
  header { background: #ffffff; border-bottom: 1px solid #EEF0F4; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
  .header-left { display: flex; align-items: center; gap: 10px; }
  .logo { width: 32px; height: 32px; border-radius: 9px; background: #3363E8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  header h1 { font-size: 17px; margin: 0; color: #2A46C4; font-weight: 700; }
  .header-right { display: flex; align-items: center; gap: 10px; }
  #userBadge { cursor: pointer; }
  .all-note { margin: 8px 2px 0; }
  #userBadge { width: 30px; height: 30px; border-radius: 50%; background: #DCEAFE; color: #2F5FE0; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

  #tabNav { display: flex; background: white; border-bottom: 1px solid #EEF0F4; position: sticky; top: 0; z-index: 5; }
  .tab-btn { flex: 1; padding: 12px 4px; border: none; background: none; font-size: 13px; cursor: pointer; color: #97A2B8; font-weight: 500; }
  .tab-btn.active { border-bottom: 3px solid #3363E8; font-weight: 700; color: #3363E8; }
  main { padding: 12px; max-width: 640px; margin: 0 auto; }
  .tab-content { display: none; }
  .tab-content.active { display: block; }

  .tx-row { background: white; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(16,24,64,0.05); cursor: pointer; border: 1px solid #EDEFF3; }
  .tx-row .tx-top { display: flex; justify-content: space-between; font-weight: 700; gap: 8px; }
  .tx-row .tx-note { color: #55617A; font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tx-row .tx-meta { color: #7C8AA5; font-size: 13px; margin-top: 4px; }
  .tx-row .tx-amount { text-align: right; white-space: nowrap; }
  .tx-row .vnd-approx { display: block; font-size: 12px; font-weight: 500; color: #7C8AA5; }
  .badge-uncategorized { color: #E0503C; font-size: 12px; }

  /* Needs Attention and All: sort control, fold button, month groups */
  .list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  .seg { display: inline-flex; background: #EAEEF5; border-radius: 10px; padding: 2px; }
  .seg-btn { padding: 6px 12px; background: none; color: #55617A; font-size: 12px; border-radius: 8px; }
  .seg-btn.on { background: #ffffff; color: #3363E8; box-shadow: 0 1px 2px rgba(16,24,64,0.12); }
  .link-btn { padding: 6px 4px; background: none; color: #3363E8; font-size: 12px; }
  .month-group { margin-bottom: 6px; }
  .month-head { display: flex; align-items: center; gap: 8px; padding: 8px 4px; margin-bottom: 6px; border-bottom: 1px solid #E3E7EF; cursor: pointer; border-radius: 6px; }
  .month-head:focus-visible { outline: 2px solid #93A8F3; outline-offset: 2px; }
  .month-head .chevron { display: inline-block; width: 12px; color: #97A2B8; transition: transform 0.15s; }
  .month-group:not(.collapsed) .month-head .chevron { transform: rotate(90deg); }
  .month-label { flex: 1; font-weight: 700; color: #16213E; }
  .month-meta { font-size: 12px; color: #7C8AA5; white-space: nowrap; }
  .month-group.collapsed .month-body { display: none; }

  [hidden] { display: none !important; }
  body.modal-open { overflow: hidden; }
  button { padding: 8px 14px; border-radius: 8px; border: none; background: #3363E8; color: white; cursor: pointer; font-weight: 600; }
  button.danger { background: #E0503C; }
  button.secondary { background: #EEF1F7; color: #3363E8; }
  button:disabled { opacity: 0.45; cursor: default; }

  .search-row { margin-bottom: 10px; }
  .search-input { width: 100%; box-sizing: border-box; }

  #filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
  #filters select, #filters input { flex: 1; min-width: 100px; padding: 6px; border: 1px solid #DAD5C9; border-radius: 8px; }
  .filter-summary { font-size: 12px; font-weight: 600; color: #3363E8; background: #EEF3FF; border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }

  /* ===== Form components: fields, buttons, category picker, edit sheet, toast ===== */
  .field { margin-top: 16px; min-width: 0; }
  .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .field > label, .field-label { display: block; font-size: 12px; font-weight: 700; color: #55617A; margin-bottom: 6px; }
  .optional { font-weight: 500; color: #97A2B8; }
  .field-hint { margin-top: 6px; font-size: 12px; color: #B25E00; }
  .input { width: 100%; box-sizing: border-box; height: 44px; padding: 0 12px; border: 1px solid #D9DEE7; border-radius: 12px; font-size: 15px; font-family: inherit; color: #16213E; background: #ffffff; }
  textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.4; }
  .input::placeholder { color: #A5AEC0; }
  .input:focus, .picker-trigger:focus-visible, .picker-search:focus-visible { outline: none; border-color: #3363E8; box-shadow: 0 0 0 3px rgba(51,99,232,0.18); }
  .form-card { padding: 22px; }
  .form-title { margin: 0 0 2px; font-size: 18px; font-weight: 700; color: #16213E; }
  .form-status { margin-top: 12px; font-size: 13px; color: #B3261E; min-height: 0; }
  .form-status:empty { display: none; }
  .form-error { margin-top: 14px; padding: 10px 12px; background: #FDECEA; color: #B3261E; border-radius: 10px; font-size: 13px; line-height: 1.4; }

  .btn-primary, .btn-ghost, .btn-danger, .btn-danger-text { height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14px; font-weight: 600; }
  .btn-primary { background: #3363E8; color: #ffffff; }
  .btn-primary:hover:not(:disabled) { background: #2A55D0; }
  .btn-ghost { background: #F1F3F8; color: #3363E8; }
  .btn-ghost:hover:not(:disabled) { background: #E6EAF3; }
  .btn-danger { background: #D93025; color: #ffffff; }
  .btn-danger-text { background: none; color: #D93025; padding: 0 8px; }
  .btn-danger-text:hover { background: #FDECEA; }
  .btn-block { width: 100%; margin-top: 18px; }
  .icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; background: #F1F3F8; color: #55617A; font-size: 20px; line-height: 1; flex-shrink: 0; }
  .icon-btn:hover { background: #E6EAF3; }
  .back-to-top { position: fixed; right: 16px; bottom: 22px; z-index: 15; background: #ffffff; box-shadow: 0 3px 10px rgba(16,24,64,0.22); }
  .back-to-top:hover { background: #F1F3F8; }
  button:focus-visible { outline: 2px solid #93A8F3; outline-offset: 2px; }

  /* category picker: a dropdown with a search box and the typical items under each name */
  .picker-trigger { width: 100%; height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; background: #ffffff; color: #16213E; border: 1px solid #D9DEE7; border-radius: 12px; font-size: 15px; font-weight: 500; text-align: left; }
  .picker-trigger:hover { border-color: #B8C2D6; }
  .picker.open .picker-trigger { border-color: #3363E8; }
  .picker-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .picker-value .placeholder { color: #97A2B8; font-weight: 400; }
  .picker-chevron { width: 8px; height: 8px; margin-right: 2px; border-right: 2px solid #7C8AA5; border-bottom: 2px solid #7C8AA5; transform: rotate(45deg) translateY(-2px); flex-shrink: 0; transition: transform 0.15s; }
  .picker.open .picker-chevron { transform: rotate(-135deg) translateY(-2px); }
  .picker-panel { margin-top: 6px; border: 1px solid #D9DEE7; border-radius: 12px; background: #ffffff; overflow: hidden; }
  .picker-search { display: block; width: 100%; box-sizing: border-box; height: 42px; padding: 0 12px; border: none; border-bottom: 1px solid #EDEFF3; font-size: 14px; font-family: inherit; color: #16213E; }
  .picker-search:focus-visible { box-shadow: none; }
  .picker-list { max-height: 248px; overflow-y: auto; }
  .picker-option { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #F4F6FA; }
  .picker-option:last-child { border-bottom: none; }
  .picker-option.active { background: #F1F5FF; }
  .opt-name { font-size: 14px; font-weight: 600; color: #16213E; }
  .picker-option[aria-selected="true"] .opt-name::after { content: "\2713"; margin-left: 8px; color: #3363E8; }
  .opt-examples { margin-top: 2px; font-size: 12px; line-height: 1.35; color: #7C8AA5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .picker-empty { padding: 14px 12px; font-size: 13px; color: #7C8AA5; }
  .tag-old { margin-left: 8px; padding: 2px 6px; border-radius: 6px; background: #FFF1DC; color: #B25E00; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

  /* the edit sheet: a centred card on a laptop, a bottom sheet on a phone */
  .modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(16,24,64,0.45); z-index: 30; animation: fade-in 0.15s ease-out; }
  .modal.hidden { display: none; }
  .sheet { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; background: #ffffff; border-radius: 20px; box-shadow: 0 24px 60px rgba(16,24,64,0.28); animation: sheet-in 0.18s ease-out; }
  .sheet-grip { display: none; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: #D9DEE7; }
  .sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
  .sheet-head-text { min-width: 0; }
  .sheet-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #7C8AA5; }
  .sheet-title { margin: 3px 0 0; font-size: 18px; font-weight: 700; line-height: 1.3; color: #16213E; word-break: break-word; }
  .sheet-summary { padding: 14px 24px 0; }
  .amount-main { font-size: 30px; font-weight: 800; letter-spacing: -0.01em; color: #16213E; }
  .amount-sub { margin-top: 2px; font-size: 13px; color: #7C8AA5; }
  .facts { display: flex; gap: 28px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid #EDEFF3; }
  .facts dt { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #97A2B8; }
  .facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: #16213E; }
  .bank-note { margin-top: 12px; }
  .bank-note-label { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #97A2B8; }
  .bank-note-text { margin-top: 2px; font-size: 14px; color: #16213E; word-break: break-word; }
  .sheet-form { padding: 4px 24px 22px; transition: opacity 0.15s; }
  .sheet-form.loading { opacity: 0.45; pointer-events: none; }
  .sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 22px; }
  .sheet-actions .spacer { flex: 1; }
  .confirm-bar { margin-top: 22px; padding: 14px; border-radius: 14px; background: #FDF3F2; }
  .confirm-text { font-size: 14px; line-height: 1.4; color: #5A1A15; }
  .confirm-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  @media (max-width: 560px) {
    .modal { align-items: flex-end; padding: 0; }
    .sheet { max-width: none; max-height: 92vh; border-radius: 20px 20px 0 0; animation-name: sheet-up; }
    .sheet-grip { display: block; }
    .sheet-head { padding-top: 14px; }
  }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
  @keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
  @media (prefers-reduced-motion: reduce) { .modal, .sheet { animation: none; } .sheet-form, .picker-chevron { transition: none; } }

  .signin { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; background: #F4F6FA; }
  .signin[hidden] { display: none; }
  .signin-card { width: 100%; max-width: 360px; background: #ffffff; border: 1px solid #EEF0F4; border-radius: 16px; padding: 28px 24px; text-align: center; box-shadow: 0 8px 24px rgba(16,24,64,0.08); }
  .signin-card h2 { margin: 0 0 6px; font-size: 20px; }
  #signInButton { display: flex; justify-content: center; margin: 20px 0 8px; min-height: 44px; }
  .signin-message { min-height: 20px; margin: 8px 0; font-size: 14px; color: #16213E; }
  .signin-message.error { color: #B3261E; }
  #signOutBtn { display: inline-flex; align-items: center; gap: 6px; width: auto; min-width: 36px; padding: 0 8px; }
  #signOutBtn.armed { background: #B3261E; color: #ffffff; border-color: #B3261E; }
  #signOutLabel { font-size: 13px; font-weight: 600; white-space: nowrap; }
  #toast { position: fixed; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); transform: translate(-50%, 16px); padding: 11px 18px; border-radius: 12px; background: #16213E; color: #ffffff; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(16,24,64,0.25); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 40; }
  #toast.show { opacity: 1; transform: translate(-50%, 0); }
  #toast.error { background: #B3261E; }

  .reports-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .reports-title { font-size: 20px; font-weight: 700; color: #16213E; }
  .year-pill { display: flex; align-items: center; gap: 6px; background: #F1F3F8; border-radius: 20px; padding: 6px 12px; }
  .year-pill select { border: none; background: none; font-size: 12px; font-weight: 600; color: #55617A; padding: 0; margin: 0; width: auto; }
  .period-row { display: flex; gap: 8px; margin-bottom: 8px; }
  .period-btn { font-size: 12px; font-weight: 600; color: #55617A; background: #F1F3F8; border: none; border-radius: 20px; padding: 8px 16px; }
  .period-btn.active { background: #3363E8; color: #ffffff; font-weight: 700; }
  .report-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 14px; }
  .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .chip { padding: 6px 16px; border-radius: 20px; border: 1px solid #D9DEE7; background: #ffffff; color: #7C8AA5; font-size: 13px; font-weight: 600; }
  .chip.on { background: #3363E8; border-color: #3363E8; color: #ffffff; }
  .switch-group { display: flex; align-items: center; justify-content: flex-end; gap: 10px 18px; flex-wrap: wrap; }
  .switch-row { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #55617A; cursor: pointer; user-select: none; }
  .switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
  .switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: #C7CCD8; transition: background 0.15s; flex-shrink: 0; }
  .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #ffffff; transition: transform 0.15s; }
  .switch-row input:checked + .switch { background: #3363E8; }
  .switch-row input:checked + .switch::after { transform: translateX(16px); }
  .switch-row input:focus-visible + .switch { outline: 2px solid #93A8F3; outline-offset: 2px; }
  .report-warning { background: #FFF6E5; border: 1px solid #F2D9A6; color: #7A5200; border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.4; margin-bottom: 14px; }

  .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
  .stat-card { background: #ffffff; border: 1px solid #EDEFF3; border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(16,24,64,0.05); min-width: 0; }
  .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #7C8AA5; margin-bottom: 6px; }
  .stat-value { font-size: 18px; font-weight: 700; color: #16213E; word-break: break-word; }
  .stat-value-text { font-size: 16px; }
  .stat-delta { font-size: 11px; color: #2F9E63; font-weight: 600; margin-top: 4px; }
  .stat-delta.negative { color: #E0503C; }
  .stat-delta.neutral { color: #9AA6BE; font-weight: 500; }
  .caption { font-size: 12px; color: #7C8AA5; margin-top: 4px; }

  .card { background: #ffffff; border: 1px solid #EDEFF3; border-radius: 16px; padding: 18px; box-shadow: 0 1px 3px rgba(16,24,64,0.05); margin-bottom: 16px; }
  .card-heading { font-size: 15px; font-weight: 700; color: #16213E; }
  .card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .card-head-row .year-pill select { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .trend-category-stats { display: flex; gap: 10px 18px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: #F7F9FC; border-radius: 10px; }
  .trend-stat { font-size: 12px; color: #55617A; }
  .trend-stat b { color: #16213E; font-weight: 700; }
  .legend-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
  .caption-center { text-align: center; margin-top: 12px; }
  .legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 8px; flex-shrink: 0; }
  .legend-dot:first-child { margin-left: 0; }

  .two-col { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: stretch; }
  @media (min-width: 720px) {
    .two-col { grid-template-columns: 1.4fr 1fr; }
    .two-col-report { grid-template-columns: 1fr 1.6fr; align-items: start; }
    .stat-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
    main { max-width: 1100px; }
  }

  /* ===== Charts: fixed-slot flexible columns, no horizontal scrollbar ===== */
  .chart-area { margin-top: 14px; }
  .chart-row { display: flex; gap: 7px; width: 100%; align-items: flex-end; }
  .chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .chart-value { font-size: 11px; font-weight: 700; color: #16213E; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .chart-value.ghost { color: #C7CCD8; }
  .chart-track { height: 100px; width: 100%; max-width: 26px; display: flex; align-items: flex-end; }
  .chart-fill { width: 100%; border-radius: 6px 6px 0 0; min-height: 2px; background: #3363E8; }
  .chart-fill.reserved { background: #F3F5F9 !important; border: 1px dashed #D9DEE7; box-sizing: border-box; }
  .chart-label { font-size: 10px; color: #9AA6BE; font-weight: 500; }

  .yoy-values-col { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%; }
  .yoy-values-col .chart-value { font-size: 10.5px; }
  .yoy-prev-value { color: #9AA6BE; font-weight: 500; font-size: 9px !important; }
  .yoy-bars-row { display: flex; gap: 2px; align-items: flex-end; height: 100px; width: 100%; justify-content: center; }
  .yoy-bar-single { flex: 1; max-width: 12px; border-radius: 4px 4px 0 0; min-height: 2px; }


  .donut-card { display: flex; flex-direction: column; }
  .donut-wrap { display: flex; flex-direction: column; align-items: center; }
  .donut { width: 176px; height: 176px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 14px 0; }
  .donut-hole { width: 122px; height: 122px; border-radius: 50%; background: #ffffff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; box-sizing: border-box; }
  .donut-hole .caption { margin: 0; }
  .donut-hole .stat-value { font-size: 16px; text-align: center; }
  .donut-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
  .donut-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
  .donut-legend-item .name { font-weight: 600; color: #16213E; }

  .category-list { display: flex; flex-direction: column; gap: 12px; }
  .category-row { display: flex; flex-direction: column; gap: 5px; }
  .category-head { display: flex; flex-direction: column; gap: 5px; cursor: pointer; border-radius: 8px; padding: 2px 0; }
  .category-head:focus-visible { outline: 2px solid #93A8F3; outline-offset: 2px; }
  .category-head .chevron { display: inline-block; width: 12px; color: #97A2B8; transition: transform 0.15s; }
  .category-row.open .chevron { transform: rotate(90deg); }
  .category-detail { margin: 2px 0 6px; padding: 6px 10px; background: #F7F9FC; border-radius: 10px; max-height: 420px; overflow-y: auto; }
  .cat-tx { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid #EDEFF3; font-size: 13px; }
  .cat-tx:last-child { border-bottom: none; }
  .cat-date { color: #7C8AA5; }
  .cat-amount { font-weight: 700; text-align: right; }
  .cat-original { display: block; font-size: 11px; font-weight: 500; color: #7C8AA5; }
  .cat-user { color: #55617A; font-weight: 600; text-align: right; }
  .cat-merchant { grid-column: 1 / -1; color: #16213E; word-break: break-word; }
  .cat-note { grid-column: 1 / -1; color: #7C8AA5; font-size: 12px; word-break: break-word; }
  @media (min-width: 520px) {
    .cat-tx { grid-template-columns: 84px 120px 44px 1fr; align-items: baseline; gap: 10px; }
    .cat-merchant { grid-column: auto; }
    .cat-user { text-align: left; }
  }
  .category-top { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
  .category-amount { font-weight: 500; white-space: nowrap; }
  .category-track { width: 100%; height: 6px; background: #F1F3F8; border-radius: 3px; overflow: hidden; }
  .category-fill { height: 100%; border-radius: 3px; min-width: 2px; }
