/* V0.11 layer. Loaded last: overrides only what V0.11 changes.
   Palette stays with AI Manager: deep blue, light blue, coral, warm white. Green is not a primary colour. */
:root {
  --brand: #1F3A5F; --brand-2: #2C507C; --brand-soft: #EAF3FC; --sky: #4DA8DA; --sky-soft: #D6E8F7;
  --action: #FF7A59; --action-ink: #B4462A; --action-soft: #FFF0EA; --warm: #FFFBF7;
  --surface: #FFFFFF; --surface-2: #F5F7FA; --line: #DFE6EF; --line-strong: #C9D6E5;
  --ink: #243447; --ink-2: #3A4C61; --muted: #52667D; --muted-2: #6B7D92;
  --ok-ink: #175E8C; --ok-bg: #E6F2FB; --warn-ink: #8A5A00; --warn-bg: #FFF5DB; --danger-ink: #A33A22; --danger-bg: #FFF0EA;
  --r-card: 18px; --r-ctl: 10px; --gap: 18px; --tap: 44px;
  --shadow-card: 0 1px 2px #1F3A5F0A, 0 6px 20px #1F3A5F08;
  --shadow-lift: 0 2px 4px #1F3A5F0D, 0 14px 32px #1F3A5F14;
  --ease: cubic-bezier(.2,.8,.2,1);
}
body { background: var(--surface-2); color: var(--ink); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body:has(dialog[open]) { overflow: hidden; }
.num, td.num { font-variant-numeric: tabular-nums; }
:where(button, a, summary, [tabindex]):focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.card { border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.eyebrow { letter-spacing: .12em; font-weight: 650; color: var(--muted-2); }

/* ---------- Top of every page ---------- */
.workspace-line { padding-bottom: 18px; }
.workspace-line .workspace-account { border-radius: 999px; min-height: 36px; padding: 0 14px; }
.topbar { margin-bottom: 22px; }
.topbar h1 { letter-spacing: -.02em; }
#page-title:focus { outline: none; }
#alerts-banner .alert-banner { border-radius: 14px; }

/* ---------- Desktop rail: five main entries + three single group entries (no disclosures) ---------- */
.sidebar .nav-divider { height: 1px; margin: 10px 6px; background: #FFFFFF1F; flex-shrink: 0; }
@media (min-width: 901px) {
  #app .sidebar nav { gap: 4px; }
  #app .sidebar nav button { color: #C9D7E8; border-radius: 12px; }
  #app .sidebar nav button:hover { background: #FFFFFF12; color: #FFFFFF; }
  #app .sidebar nav button.active { background: #FFFFFF1F; color: #FFFFFF; }
  #app .sidebar nav button.active::before { content: ""; position: absolute; left: -10px; top: 50%; width: 3px; height: 20px; margin-top: -10px; border-radius: 0 3px 3px 0; background: var(--action); }
  #app .sidebar nav button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: -2px; }
  #app .sidebar nav button .nav-icon { flex-shrink: 0; }
  #app .sidebar .pin-nav { color: #C9D7E8; }
}

/* ---------- Back bar (detail pages) ---------- */
.v11-backbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: -6px 0 18px; }
.v11-backbar[hidden] { display: none; }
.v11-back { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--brand); font-weight: 650; font-size: 14px; box-shadow: var(--shadow-card);
  transition: border-color .15s, background .15s; }
.v11-back:hover { border-color: var(--line-strong); background: var(--brand-soft); }
.v11-back span { font-size: 16px; line-height: 1; }
.v11-crumb { color: var(--muted-2); font-size: 13px; }
.v11-crumb i { font-style: normal; padding: 0 8px; color: var(--line-strong); }
body.v11-detail #view-reports > .section-heading:first-child .subtle-link { display: none; }

/* ---------- Hub pages ---------- */
.v11-hub-head { margin: 0 0 20px; max-width: 760px; }
.v11-hub-head .eyebrow { margin: 0 0 6px; font-size: 11px; }
.v11-hub-lead { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.v11-card-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.v11-card-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 960px; }
@media (max-width: 1180px) { .v11-card-grid, .v11-card-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .v11-card-grid, .v11-card-grid[data-count="2"] { grid-template-columns: 1fr; } }

.v11-card { position: relative; display: grid; grid-template-columns: 68px minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 14px;
  width: 100%; min-height: 176px; padding: 20px 20px 18px; text-align: left; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card); cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.v11-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.v11-card:active { transform: translateY(0); }
.v11-card:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.v11-card-art { grid-row: 1 / span 2; align-self: start; display: grid; place-items: center; width: 68px; height: 68px; }
.v11-ill { display: block; width: 64px; height: 64px; }
.v11-ill.sm { width: 44px; height: 44px; flex-shrink: 0; }
.v11-card-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.v11-card-title { font-size: 16px; font-weight: 700; color: var(--brand); line-height: 1.35; }
.v11-card-summary { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v11-card-scope { font-size: 13px; line-height: 1.55; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.v11-card-foot { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.v11-go { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--brand); font-size: 15px;
  transition: background .2s, transform .2s var(--ease); flex-shrink: 0; }
.v11-card:hover .v11-go { background: var(--brand); color: #fff; transform: translateX(2px); }
.v11-admin-row { margin-top: 28px; max-width: 560px; }
.v11-admin-row .eyebrow { margin-bottom: 10px; }

/* Short status label: text always present, colour is secondary. */
.v11-status { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v11-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }
.v11-status[data-tone="ok"] { background: var(--ok-bg); color: var(--ok-ink); }
.v11-status[data-tone="ok"]::before { background: var(--sky); }
.v11-status[data-tone="warning"] { background: var(--warn-bg); color: var(--warn-ink); }
.v11-status[data-tone="warning"]::before { background: #E3A21A; }
.v11-status[data-tone="loading"] { color: var(--muted-2); }
.v11-status[data-tone="loading"]::before { background: var(--line-strong); }
@media (prefers-reduced-motion: no-preference) { .v11-status[data-tone="loading"]::before { animation: v11-pulse 1s ease-in-out infinite; } }
@keyframes v11-pulse { 50% { opacity: .3; } }

/* ---------- Detail pages ---------- */
.v11-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.v11-detail-grid > .full, .v11-detail-grid > .v11-inline-error { grid-column: 1 / -1; }
@media (max-width: 1000px) { .v11-detail-grid { grid-template-columns: 1fr; } }
.v11-section-card { padding: 22px; min-width: 0; }
.v11-section-card h2 { font-size: 18px; margin: 2px 0 0; }
.v11-section-card h3 { font-size: 14px; margin: 18px 0 8px; color: var(--ink-2); }
.v11-section-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.v11-section-head > div { flex: 1; min-width: 0; }
.v11-section-head .eyebrow { margin: 0; font-size: 10px; }
.v11-subhead { margin: 30px 0 14px; font-size: 18px; color: var(--ink); }
.v11-facts { display: grid; gap: 0; margin: 12px 0 16px; border-top: 1px solid var(--line); }
.v11-facts > div { display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.v11-facts dt { color: var(--muted); font-size: 13px; }
.v11-facts dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.v11-facts code { font-size: 12px; }
.v11-section-card .row { flex-wrap: wrap; gap: 10px; }
.v11-tools-row { margin-top: 14px; }
.v11-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.v11-form-foot .error { margin: 0 auto 0 0; }
.v11-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; }
.v11-two-col h3 { margin-top: 4px; }
.v11-two-col label:not(.check) { display: block; margin-top: 10px; }
@media (max-width: 760px) { .v11-two-col { grid-template-columns: 1fr; } }
.v11-checks { flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
.v11-log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.v11-log li { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.v11-log li > span:first-child { color: var(--muted); }
.v11-danger-text { color: var(--danger-ink) !important; }

/* Integration status strip */
.v11-status-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: var(--gap); }
.v11-chip { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); }
.v11-chip strong { font-size: 14px; color: var(--brand); }
.v11-chip span { font-size: 13px; color: var(--muted); }
.v11-chip[data-tone="ok"] { border-left-color: var(--sky); }
.v11-chip[data-tone="warning"] { border-left-color: #E3A21A; }
@media (max-width: 700px) { .v11-status-strip { grid-template-columns: 1fr; } }
#view-connections .v11-section-card .integration-row { border-bottom: 0; padding: 0; }
#view-connections #connections-content > .notice { border-radius: 14px; }

/* Account (security only) */
.v11-account-grid { gap: var(--gap); }
.v11-account-grid .account-card { padding: 22px; }
#v11-account-extra { margin-top: var(--gap); }
.security-row h3 { font-size: 14px; }
.security-row small { font-size: 12px; }

/* Settings (preferences only) */
.v11-pref-form { gap: var(--gap); }
.v11-save-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.v11-save-bar h2 { margin: 0 0 4px; }
.v11-save-bar .muted { margin: 0; }
.v11-save-bar .error:empty { display: none; }
.v11-export-row { flex-wrap: wrap; gap: 10px; margin: 6px 0 16px; }

/* Empty / error states */
.v11-empty { display: flex; align-items: center; gap: 18px; padding: 18px 4px; }
.v11-empty strong { display: block; font-size: 15px; color: var(--brand); margin-bottom: 4px; }
.v11-empty p { margin: 0 0 12px; }
.v11-inline-error { border-color: #F0C8BC; background: var(--danger-bg); }
.v11-inline-error .v11-empty strong { color: var(--danger-ink); }
.v11-refreshing { opacity: .6; transition: opacity .2s; pointer-events: none; }

/* ---------- Finance ---------- */
.finance-stats .stat-box { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.finance-stats .stat-box:first-child { background: var(--surface); color: var(--ink); border-color: var(--line); }
.finance-stats .stat-box:first-child small, .finance-stats .stat-box:first-child span { color: var(--muted); }
.finance-stats .stat-box.v11-stat-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.finance-stats .stat-box.v11-stat-active small, .finance-stats .stat-box.v11-stat-active span { color: #C9D7E8; }
.v11-filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 20px; margin: 18px 0; }
.v11-filter-bar .eyebrow { margin: 0 0 2px; font-size: 10px; }
.v11-filter-bar strong { font-size: 14px; color: var(--ink-2); }
.v11-direction { display: inline-grid; grid-template-columns: repeat(3, minmax(76px, 1fr)); padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.v11-direction button { min-height: 40px; border-radius: 9px; font-weight: 650; color: var(--muted); background: transparent; }
.v11-direction button.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px #1F3A5F1F; }
.v11-chart-purpose { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55; max-width: 720px; }
.v11-chart-purpose strong { color: var(--ink-2); margin-right: 6px; }
.v11-advanced-toggle { border: 1px dashed var(--line-strong) !important; background: transparent !important; }
.v11-advanced-toggle[aria-expanded="true"] { color: var(--brand) !important; }
.v11-advanced-tabs { align-items: center; margin-top: -12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.v11-advanced-tabs[hidden] { display: none; }
.v11-advanced-tabs .micro { margin-right: 6px; }
.v11-sample-note { margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.v11-axis-note { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.category-summary table tfoot th { border-top: 2px solid var(--line); padding-top: 12px; font-size: 13px; color: var(--ink-2); }
.category-summary .v11-cat-name { display: inline-block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.v11-balance-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.v11-balance-tiles > div { padding: 16px; border-radius: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.v11-balance-tiles small { color: var(--muted); font-size: 12px; }
.v11-balance-tiles strong { font-size: 22px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.v11-balance-tiles span { font-size: 12px; color: var(--muted); }
.v11-balance-diff[data-state="surplus"] { background: var(--ok-bg) !important; }
.v11-balance-diff[data-state="surplus"] span { color: var(--ok-ink) !important; font-weight: 650; }
.v11-balance-diff[data-state="deficit"] { background: var(--danger-bg) !important; }
.v11-balance-diff[data-state="deficit"] span { color: var(--danger-ink) !important; font-weight: 650; }
@media (max-width: 700px) { .v11-balance-tiles { grid-template-columns: 1fr; } }
.v11-bars { display: grid; gap: 12px; margin: 6px 0 14px; }
.v11-bar-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.v11-bar-row strong { font-variant-numeric: tabular-nums; }
.v11-bar-track { height: 18px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.v11-bar-track i { display: block; height: 100%; border-radius: 9px; }
.v11-bar-track i.income { background: var(--sky); }
.v11-bar-track i.expense { background: var(--action); }
@media (prefers-reduced-motion: no-preference) { .v11-bar-track i, .v11-progress-track i { animation: v11-grow-x .5s var(--ease) both; transform-origin: left; } }
@keyframes v11-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.v11-compare { max-width: 640px; margin: 18px auto; }
.v11-compare-state { text-align: center; font-weight: 650; margin-top: 8px; }
.v11-compare-state[data-state="surplus"] { color: var(--ok-ink); }
.v11-compare-state[data-state="deficit"] { color: var(--danger-ink); }
.v11-progress { display: grid; gap: 16px; padding: 4px 0; }
.v11-progress-row { display: grid; gap: 8px; }
.v11-progress-label { justify-self: start; font-size: 14px; color: var(--ink); padding: 0; min-height: 0; }
.v11-progress-track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.v11-progress-track i { display: block; height: 100%; border-radius: 6px; background: var(--sky); }
.v11-progress-row[data-state="warning"] .v11-progress-track i { background: #E3A21A; }
.v11-progress-row[data-state="over"] .v11-progress-track i { background: var(--action); }
.v11-progress-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.v11-project-budgets { margin-bottom: 22px; }
.v11-project-row { padding: 16px 0; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.v11-project-row:first-of-type { border-top: 0; }
.v11-project-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.v11-project-head h3 { margin: 0; font-size: 15px; color: var(--brand); }
.v11-project-line-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.v11-project-row .text-button { justify-self: start; padding: 0; min-height: 32px; }
.v11-project-unallocated { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pill.danger { background: var(--danger-bg); color: var(--danger-ink); }

/* ---------- Mobile "更多功能" sheet: same bottom sheet, categories and two-column cards ---------- */
.more-sheet .dialog-heading { margin-bottom: 6px; }
.more-category { padding: 12px 0; }
.more-category summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 15px; color: var(--ink); list-style: none; }
.more-category summary::-webkit-details-marker { display: none; }
.more-category summary::after { content: ""; width: 8px; height: 8px; margin-right: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.more-category[open] summary::after { transform: rotate(-135deg); }
.more-grid { gap: 10px; padding-top: 4px; }
.more-grid button { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.35; text-align: left; }
.more-grid button:active { background: var(--brand-soft); }
.more-grid button.active { border-color: var(--brand); background: var(--brand-soft); }
.more-ill { width: 44px; height: 44px; flex-shrink: 0; }
@media (max-width: 360px) { .more-ill { width: 40px; height: 40px; } .more-grid button { font-size: 12px; padding: 8px 10px; } }

/* ---------- Footer ---------- */
.page-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted-2); }
.page-footer .footer-links { display: inline-flex; gap: 8px; align-items: center; }
.page-footer a { color: var(--muted); }
.page-footer span { max-width: none; text-align: left; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .v11-backbar { margin: -4px 0 14px; }
  .v11-back { min-height: var(--tap); }
  .v11-card { grid-template-columns: 52px minmax(0, 1fr); min-height: 0; padding: 16px; column-gap: 12px; }
  .v11-card-art { width: 52px; height: 52px; }
  .v11-ill { width: 50px; height: 50px; }
  .v11-section-card { padding: 18px 16px; }
  .v11-filter-bar { padding: 14px 16px; }
  .v11-direction { width: 100%; }
}
@media (max-width: 650px) {
  .v11-crumb { display: none; }
  .v11-facts > div { grid-template-columns: 1fr; gap: 2px; }
  .v11-form-foot { flex-direction: column; align-items: stretch; }
  .v11-form-foot .primary, .v11-form-foot .secondary { width: 100%; }
  .v11-save-bar .row, .v11-save-bar .primary { width: 100%; }
  .v11-empty { align-items: flex-start; }
  .v11-empty .v11-ill { width: 48px; height: 48px; flex-shrink: 0; }
  .page-footer { justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .v11-card, .v11-go, .v11-back { transition: none; }
  .v11-card:hover { transform: none; }
}

/* 整合與通知: consistent rhythm between the status strip, LINE card, sync cards and the notification form. */
#v11-integrations-top > .card, #v11-integrations-extra { margin-top: var(--gap); }
#v11-integrations-extra { display: grid; gap: var(--gap); }
#v11-integrations-extra .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 650px) { #v11-integrations-extra .form-grid { grid-template-columns: 1fr; } }
#view-connections .v04-grid { gap: var(--gap); }
