    :root {
      --bg: #f0f4f8;
      --card: #ffffff;
      --header: #0f172a;
      --text: #1e293b;
      --sub: #64748b;
      --border: #e2e8f0;
      --green: #22c55e;
      --orange: #f97316;
      --red: #ef4444;
      --blue: #3b82f6;
      --purple: #8b5cf6;
      --radius: 14px;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
    html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
    body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
    canvas { max-width: 100%; display: block; }

    /* ── Header (Apple iOS frosted glass) ── */
    .header {
      background: rgba(242,242,247,0.88);
      backdrop-filter: blur(20px) saturate(180%);
      -webkit-backdrop-filter: blur(20px) saturate(180%);
      border-bottom: 0.5px solid var(--border);
      color: var(--fg);
      padding: 12px 18px 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 200;
    }
    .header-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); }
    .header-refresh { background: rgba(0,0,0,0.06); border: none; border-radius: 50%; color: var(--accent); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s; }
    .header-refresh:active { background: rgba(0,0,0,0.12); }
    @keyframes spin { to { transform: rotate(360deg); } }
    .header-refresh.spinning svg { animation: spin 0.55s ease both; }

    /* ── Period bar ── */
    .period-bar {
      background: var(--bg);
      padding: 14px 16px 0;
      display: flex;
      justify-content: center;
    }
    .period-picker {
      display: inline-flex;
      align-items: center;
      gap: 0;
      background: var(--card);
      border: 1.5px solid var(--border);
      border-radius: 999px;
      padding: 6px 18px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    }
    .period-label {
      font-size: 13px;
      color: var(--sub);
      font-weight: 500;
      padding: 0 4px;
      white-space: nowrap;
    }
    select {
      background: transparent;
      color: var(--text);
      border: none;
      border-radius: 6px;
      padding: 2px 2px;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      outline: none;
      appearance: none;
      -webkit-appearance: none;
      text-align: center;
    }
    #sel-year  { width: 56px; }
    #sel-month { width: 38px; }
    select option { background: #fff; color: #1e293b; }

    /* ── Page layout ── */
    .page { display: none; }
    .page.active { display: block; }
    .main { padding: 16px; max-width: 860px; margin: 0 auto; }

    /* ── Section label ── */
    .section-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--sub);
      text-transform: uppercase;
      letter-spacing: 0.07em;
      margin: 26px 0 12px;
    }

    /* ── Summary cards ── */
    .cards-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card {
      background: var(--card);
      border-radius: var(--radius);
      padding: 16px 18px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .card-label { font-size: 12px; color: var(--sub); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
    .card-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
    .cv-blue   { color: var(--blue); }
    .cv-red    { color: var(--red); }
    .cv-green  { color: var(--green); }
    .cv-orange { color: var(--orange); }
    .cv-text   { color: var(--text); }

    /* ── Budget progress ── */
    .budget-progress {
      background: var(--card);
      border-radius: var(--radius);
      padding: 14px 16px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
      margin-top: 10px;
    }
    .bp-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 8px; }
    .bp-label { font-size: 13px; color: var(--sub); font-weight: 600; min-width: 0; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .bp-amounts { font-size: 14px; font-weight: 700; color: var(--text); flex-shrink: 0; }
    .bar-bg { height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
    .bar-fill { height: 100%; border-radius: 5px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }
    .bar-green  { background: var(--green); }
    .bar-orange { background: var(--orange); }
    .bar-red    { background: var(--red); }
    .bp-pct { font-size: 13px; text-align: right; margin-top: 5px; font-weight: 700; }

    /* ── Budget edit ── */
    .card-editable { position: relative; }
    .card-edit-btn { position: absolute; top: 10px; right: 10px; background: none; border: none; padding: 4px; cursor: pointer; color: var(--sub); opacity: 0.55; line-height: 1; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
    .card-edit-btn:active { opacity: 1; background: rgba(128,128,128,0.1); }
    .budget-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
    .budget-modal-overlay.open { opacity: 1; pointer-events: all; }
    .budget-modal { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg); border-radius: 20px 20px 0 0; padding: 0 20px calc(env(safe-area-inset-bottom,24px) + 24px); z-index: 301; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; box-sizing: border-box; }
    .budget-modal.open { transform: translateY(0); }
    .budget-modal-handle { width: 36px; height: 4px; background: rgba(128,128,128,0.22); border-radius: 2px; margin: 14px auto 0; }
    .budget-modal-title { font-size: 18px; font-weight: 800; padding: 16px 0 4px; }
    .budget-modal-sub { font-size: 13px; color: var(--sub); margin-bottom: 18px; }
    .budget-modal-input { width: 100%; background: var(--card); border: 1.5px solid rgba(128,128,128,0.12); border-radius: 10px; padding: 13px 14px; font-size: 22px; font-weight: 700; color: var(--text); box-sizing: border-box; -webkit-appearance: none; font-family: inherit; text-align: center; letter-spacing: -0.5px; }
    .budget-modal-input:focus { outline: none; border-color: var(--blue); }
    .budget-modal-save { width: 100%; margin-top: 14px; padding: 14px; background: var(--blue); color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; }
    .budget-modal-save:active { opacity: 0.85; }

    /* ── Accounts grid ── */
    .accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
    .acc-card {
      background: var(--card);
      border-radius: var(--radius);
      padding: 16px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .acc-name { font-size: 12px; color: var(--sub); font-weight: 600; margin-bottom: 6px; }
    .acc-balance { font-size: 20px; font-weight: 800; letter-spacing: -0.4px; }
    .acc-type { font-size: 11px; color: var(--sub); margin-top: 4px; }

    /* ── Credit cards ── */
    .cc-list { display: flex; flex-direction: column; gap: 10px; }
    .cc-card {
      background: var(--card);
      border-radius: var(--radius);
      padding: 14px 16px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
      display: flex;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
    }
    .cc-name { font-size: 13px; font-weight: 700; min-width: 110px; }
    .cc-bills { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
    .cc-bill { display: flex; flex-direction: column; }
    .cc-bill-label { font-size: 12px; color: var(--sub); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
    .cc-bill-value { font-size: 16px; font-weight: 700; margin-top: 3px; }
    .badge {
      font-size: 12px; font-weight: 700;
      padding: 5px 12px; border-radius: 999px;
      white-space: nowrap;
    }
    .badge-paid    { background: #dcfce7; color: #15803d; }
    .badge-urgent  { background: #fee2e2; color: #b91c1c; }
    .badge-soon    { background: #fef9c3; color: #a16207; }
    .badge-normal  { background: #dbeafe; color: #1d4ed8; }

    /* ── Categories ── */
    .cat-section { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .cat-list {
      background: var(--card); border-radius: var(--radius);
      padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
      overflow: hidden;
    }
    .cat-item {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 0; border-bottom: 1px solid var(--border);
    }
    .cat-item:last-child { border-bottom: none; }
    .cat-name { font-size: 14px; font-weight: 500; }
    .cat-amt  { font-size: 14px; font-weight: 700; }
    .chart-wrap {
      background: var(--card); border-radius: var(--radius);
      padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
      position: relative;
    }

    /* ── Detail button ── */
    .detail-btn {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      width: 100%; margin-top: 24px; padding: 18px;
      background: var(--header); color: #fff;
      border: none; border-radius: var(--radius);
      font-size: 16px; font-weight: 700; cursor: pointer;
      min-height: 56px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      transition: opacity 0.15s;
    }
    .detail-btn:active { opacity: 0.8; }

    /* ── Loading / Error ── */
    .loading { text-align: center; padding: 60px 20px; color: var(--sub); }
    .spinner {
      width: 32px; height: 32px;
      border: 3px solid var(--border);
      border-top-color: var(--blue);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      margin: 0 auto 12px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .empty-msg { text-align: center; color: var(--sub); padding: 20px; font-size: 13px; }

    /* ── Detail page ── */
    #page-detail .header { position: sticky; top: 0; }
    #detail-content { max-width: 860px; margin: 0 auto; padding: 0 16px 24px; }
    .detail-summary { padding: 16px 0; }
    .back-btn {
      background: none; border: none; color: #fff;
      font-size: 22px; cursor: pointer; padding: 8px 12px; line-height: 1;
      min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
    }
    .detail-summary {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 10px; padding: 16px;
    }
    .summary-chip {
      background: var(--card); border-radius: var(--radius); padding: 16px;
      text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .summary-chip-label { font-size: 12px; color: var(--sub); font-weight: 600; margin-bottom: 6px; }
    .summary-chip-value { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
    .trans-list { padding: 0 16px 28px; }
    .trans-item {
      background: var(--card); border-radius: var(--radius);
      padding: 14px 16px; margin-bottom: 10px;
      display: flex; align-items: center; gap: 14px;
      min-height: 62px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .trans-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
    .dot-支出  { background: var(--red); }
    .dot-收入  { background: var(--green); }
    .dot-領錢  { background: var(--sub); }
    .dot-儲值  { background: var(--purple); }
    .trans-info { flex: 1; min-width: 0; }
    .trans-note { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .trans-meta { font-size: 12px; color: var(--sub); margin-top: 3px; }
    .trans-right { text-align: right; flex-shrink: 0; }
    .trans-amount { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; }
    .amt-支出  { color: var(--red); }
    .amt-收入  { color: var(--green); }
    .amt-領錢  { color: var(--sub); }
    .amt-儲值  { color: var(--purple); }
    .trans-type-tag { font-size: 11px; color: var(--sub); margin-top: 3px; }

    /* ── Responsive：CSS media query（桌面）── */
    @media (max-width: 768px) {
      .cat-section { grid-template-columns: 1fr; display: flex; flex-direction: column-reverse; }
      .chart-wrap { max-height: 220px; }
      .accounts-grid { grid-template-columns: repeat(2, 1fr); }
      .acc-balance { font-size: 18px; }
      .cc-card { flex-direction: column; align-items: stretch; gap: 10px; }
      .cc-name { min-width: 0; font-size: 15px; font-weight: 800; }
      .cc-bills { gap: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
      .cc-bill { text-align: center; padding: 6px 0; }
      .cc-bill-value { font-size: 15px; }
      .badge { align-self: flex-start; }
      .card { padding: 14px 16px; }
      .card-value { font-size: 22px; }
      .main { padding: 14px; }
      .section-title { margin: 20px 0 10px; }
      .detail-summary { padding: 14px; gap: 8px; }
      .summary-chip { padding: 14px; }
      .trans-list { padding: 0 14px 24px; }
      .trans-note { font-size: 15px; }
      .trans-amount { font-size: 15px; }
    }

    /* ── Responsive：JS 動態偵測（針對 GAS WebView）── */
    body.is-mobile .cat-section { grid-template-columns: 1fr; display: flex; flex-direction: column-reverse; }
    body.is-mobile .chart-wrap { max-height: 220px; }
    body.is-mobile .accounts-grid { grid-template-columns: repeat(2, 1fr); }
    body.is-mobile .acc-balance { font-size: 18px; }
    body.is-mobile .cc-card { flex-direction: column; align-items: stretch; gap: 10px; }
    body.is-mobile .cc-name { min-width: 0; font-size: 15px; font-weight: 800; }
    body.is-mobile .cc-bills { gap: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
    body.is-mobile .cc-bill { text-align: center; padding: 6px 0; }
    body.is-mobile .cc-bill-value { font-size: 15px; }
    body.is-mobile .badge { align-self: flex-start; }
    body.is-mobile .card { padding: 14px 16px; }
    body.is-mobile .card-value { font-size: 22px; }
    body.is-mobile .main { padding: 14px; }
    body.is-mobile .section-title { margin: 20px 0 10px; }
    body.is-mobile .detail-summary { padding: 14px; gap: 8px; }
    body.is-mobile .summary-chip { padding: 14px; }
    body.is-mobile .trans-list { padding: 0 14px 24px; }
    body.is-mobile .trans-note { font-size: 15px; }
    body.is-mobile .trans-amount { font-size: 15px; }

    body.is-mobile .card-value { font-size: 20px; }
    body.is-mobile .summary-chip-value { font-size: 20px; }
    body.is-mobile .acc-balance { font-size: 16px; }

    @media (max-width: 360px) {
      .card-value, body.is-mobile .card-value { font-size: 18px; }
      .cards-2 { grid-template-columns: 1fr; }
      .period-picker { padding: 6px 14px; }
    }

    /* ── Group Accordion ── */
    .group-accordion {
      border-radius: var(--radius);
      margin-bottom: 10px;
    }
    .group-header {
      display: flex; align-items: center; gap: 14px;
      padding: 14px 16px; min-height: 62px; box-sizing: border-box;
      border-radius: var(--radius);
      background: var(--card);
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
      cursor: pointer; user-select: none; -webkit-user-select: none;
      transition: background 0.15s;
    }
    .group-header:active { background: rgba(128,128,128,0.07); }
    .group-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
    .group-info { flex: 1; min-width: 0; }
    .group-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .group-meta { font-size: 12px; color: var(--sub); margin-top: 3px; }
    .group-right { text-align: right; flex-shrink: 0; }
    .group-total { font-size: 16px; font-weight: 800; color: var(--red); letter-spacing: -0.3px; }
    .group-chevron {
      width: 14px; height: 14px; color: var(--sub); margin-top: 3px;
      transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
    }
    .group-accordion.open .group-chevron { transform: rotate(180deg); }
    .group-body {
      height: 0; overflow: hidden;
      transition: height 0.32s cubic-bezier(0.4,0,0.2,1);
    }
    .group-body-inner {
      padding: 6px 0 0 28px;
    }
    .group-body .trans-item {
      padding: 9px 12px; margin-bottom: 6px;
      border-radius: 9px; min-height: 0;
      box-shadow: 0 1px 2px rgba(0,0,0,0.04);
      background: var(--card);
      border: 1px solid rgba(128,128,128,0.08);
    }
    .group-body .trans-item:last-child { margin-bottom: 0; }
    .group-body .trans-note { font-size: 13px; }
    .group-body .trans-meta { font-size: 11px; }
    .group-body .trans-amount { font-size: 14px; }
    .group-body .trans-type-tag { font-size: 10px; }
    .group-body .trans-dot { width: 8px; height: 8px; }

    /* ── Detail header row ── */
    .detail-header-row { display: flex; align-items: center; margin: 26px 0 12px; }
    .detail-header-row .section-title { margin: 0; flex: 1; }
    .gm-add-btn { background: rgba(99,102,241,0.11); color: #6366F1; border: none; border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
    @keyframes catItemIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
    @keyframes barGrow { from{transform:scaleX(0)} to{transform:scaleX(1)} }
    .cat-bar { transform-origin:left; animation:barGrow 0.5s ease both; }
    .bar-fill { animation:barGrow 0.8s cubic-bezier(0.4,0,0.2,1) both; transform-origin:left; }
    .gm-existing-main { display:flex; align-items:center; gap:10px; flex:1; cursor:pointer; min-width:0; overflow:hidden; border-radius:8px; padding:2px 4px; transition:background 0.15s; }
    .gm-existing-main:active { background:rgba(128,128,128,0.1); }
    .gm-add-btn:active { background: rgba(99,102,241,0.22); }
    .group-select { width:100%; margin:8px 0 4px; padding:7px 36px 7px 12px; border-radius:8px; border:1.5px solid var(--border); background:var(--card); color:var(--text); font-size:13px; font-weight:600; appearance:none; -webkit-appearance:none; cursor:pointer; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; }
    .group-sum-meta { font-size:11px; color:var(--sub); margin-bottom:8px; display:flex; align-items:center; gap:6px; }

    /* ── Group Modal ── */
    .gm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; opacity: 0; transition: opacity 0.22s; pointer-events: none; touch-action: none; }
    .gm-overlay.open { opacity: 1; pointer-events: all; }
    .gm-modal { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg); border-radius: 20px 20px 0 0; padding: 0 0 env(safe-area-inset-bottom,20px); z-index: 201; transform: translateY(100%); transition: transform 0.32s cubic-bezier(0.4,0,0.2,1); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    .gm-modal.open { transform: translateY(0); }
    .gm-modal-inner { padding: 0 20px 24px; }
    .gm-handle { width: 36px; height: 4px; background: rgba(128,128,128,0.22); border-radius: 2px; margin: 14px auto 0; }
    .gm-modal-title { font-size: 18px; font-weight: 800; padding: 16px 0 4px; }
    .gm-section-label { font-size: 12px; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 8px; }
    .gm-existing { display: flex; flex-direction: column; gap: 6px; }
    .gm-existing-item { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 10px; padding: 10px 12px; }
    .gm-existing-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
    .gm-existing-name { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gm-existing-meta { font-size: 11px; color: var(--sub); white-space: nowrap; }
    .gm-del-btn { background: none; border: none; color: var(--sub); font-size: 16px; cursor: pointer; padding: 8px 10px; line-height: 1; flex-shrink: 0; min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
    .gm-del-btn:active { background: rgba(255,60,60,0.12); color: var(--red); }
    .gm-empty-msg { font-size: 13px; color: var(--sub); text-align: center; padding: 14px 0 6px; }
    /* 全畫面 loading */
    .gm-loading { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.28); display: flex; align-items: center; justify-content: center; }
    .gm-spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: gm-spin 0.7s linear infinite; }
    @keyframes gm-spin { to { transform: rotate(360deg); } }
    .gm-divider { height: 1px; background: rgba(128,128,128,0.1); margin: 18px 0 4px; }
    .gm-field { margin-bottom: 14px; }
    .gm-label { font-size: 13px; font-weight: 600; color: var(--sub); margin-bottom: 6px; }
    .gm-input { width: 100%; background: var(--card); border: 1.5px solid rgba(128,128,128,0.12); border-radius: 10px; padding: 11px 14px; font-size: 15px; color: var(--text); box-sizing: border-box; -webkit-appearance: none; font-family: inherit; }
    .gm-input:focus { outline: none; border-color: #6366F1; }
    .gm-row { display: flex; gap: 10px; }
    .gm-row .gm-field { flex: 1; min-width: 0; }
    /* ── Calendar ── */
    .gm-cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
    .gm-cal-title { font-size: 15px; font-weight: 700; }
    .gm-cal-arr { background: none; border: none; font-size: 22px; color: var(--sub); cursor: pointer; padding: 2px 10px; line-height: 1; }
    .gm-cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 1px; }
    .gm-cal-dow { font-size: 11px; font-weight: 600; color: var(--sub); text-align: center; padding: 5px 0 6px; }
    .gm-cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; border-radius: 4px; position: relative; transition: background 0.1s; -webkit-tap-highlight-color: transparent; }
    .gm-cal-day.other { visibility: hidden; cursor: default; }
    .gm-cal-day.today { font-weight: 800; }
    .gm-cal-day.sel-start, .gm-cal-day.sel-end, .gm-cal-day.in-range { background: rgba(99,102,241,0.18); border-radius: 4px; color: #6366F1; font-weight: 700; }
    .gm-cal-chips { display: flex; gap: 8px; margin-top: 12px; }
    .gm-cal-chip { flex: 1; background: var(--card); border: 1.5px solid rgba(128,128,128,0.12); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
    .gm-cal-chip.active { border-color: #6366F1; }
    .gm-cal-chip-label { font-size: 11px; color: var(--sub); font-weight: 600; margin-bottom: 2px; }
    .gm-cal-chip-val { font-size: 14px; font-weight: 600; }
    .gm-cal-chip-val.empty { color: var(--sub); font-weight: 400; }
    .gm-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
    .gm-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2.5px solid transparent; box-sizing: border-box; transition: border-color 0.15s, transform 0.15s; }
    .gm-swatch.active { border-color: var(--text); transform: scale(1.15); }
    .gm-btn-row { display: flex; gap: 10px; margin-top: 20px; }
    .gm-btn { flex: 1; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 700; border: none; cursor: pointer; }
    .gm-btn-cancel { background: var(--card); color: var(--text); }
    .gm-btn-save { background: #6366F1; color: #fff; transition: opacity 0.15s; }
    .gm-btn-save:disabled { opacity: 0.4; cursor: not-allowed; }

    /* ── Trans Edit Modal ── */
    .tm-del-btn { width:100%; margin-top:8px; padding:13px; border-radius:12px; border:none; background:rgba(239,68,68,0.1); color:var(--red); font-size:15px; font-weight:700; cursor:pointer; transition:background 0.15s; }
    .tm-del-btn:active { background:rgba(239,68,68,0.2); }
    .trans-item { cursor:pointer; transition:opacity 0.15s; }
    .trans-item:active { opacity:0.72; }

    /* ── Top segmented tab bar ── */
    .top-tab-bar {
      background: rgba(242,242,247,0.92);
      backdrop-filter: blur(20px) saturate(180%);
      -webkit-backdrop-filter: blur(20px) saturate(180%);
      border-bottom: 0.5px solid var(--border);
      padding: 7px 16px 9px;
      position: sticky;
      top: 58px;
      z-index: 190;
    }
    .top-tab-seg {
      display: flex;
      background: rgba(116,116,128,0.12);
      border-radius: 9px;
      padding: 2px;
      max-width: 200px;
      margin: 0 auto;
    }
    .top-tab-btn {
      flex: 1;
      padding: 6px 0;
      font-size: 14px;
      font-weight: 600;
      border: none;
      border-radius: 7px;
      background: transparent;
      color: var(--sub);
      cursor: pointer;
      transition: all 0.18s cubic-bezier(.4,0,.2,1);
      font-family: inherit;
      -webkit-tap-highlight-color: transparent;
    }
    .top-tab-btn.active { background: #fff; color: var(--fg); box-shadow: 0 1px 4px rgba(0,0,0,0.14); }
    .tab-section { display: none; }
    .tab-section.active { display: block; }

    /* 任何彈出視窗開啟時，隱藏右下角 FAB，避免視窗內容被蓋住 */
    body:has(.gm-overlay.open) #fab-add,
    body:has(.budget-modal-overlay.open) #fab-add {
      display: none;
    }
