/* V0.15 layer. Same AI Manager palette as V0.11 (deep blue / light blue / coral on white); no third-party visuals.
   Every sticky bar uses --am-sticky-top published by AM15.stickyTop() so bars never stack under the app header. */
:root { --am-sticky-top: 0px; --v15-in: #175E8C; --v15-out: #B4462A; --v15-move: #52667D; }

/* ---------------------------------------------------------------- P1-06 每日收支 */
.v15-daily { background: #FFFFFF; border: 1px solid var(--line, #DFE6EF); border-radius: var(--r-card, 18px); box-shadow: var(--shadow-card);
  margin: 0 0 16px; padding: 0 0 12px; overflow: clip; }
.v15-daily[hidden] { display: none; }
.v15-daily-bar { position: sticky; top: var(--am-sticky-top); z-index: 20; background: #FFFFFF; padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line, #DFE6EF); border-radius: var(--r-card, 18px) var(--r-card, 18px) 0 0; }
.v15-month-row { display: flex; align-items: center; gap: 6px; }
.v15-month { flex: 1; margin: 0; font-size: 17px; font-weight: 700; color: var(--brand, #1F3A5F); text-align: center; letter-spacing: .02em; }
.v15-icon-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--brand, #1F3A5F);
  font-size: 22px; line-height: 1; cursor: pointer; }
.v15-icon-btn:hover { background: var(--brand-soft, #EAF3FC); }
.v15-today-btn { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong, #C9D6E5);
  background: #FFFFFF; color: var(--brand, #1F3A5F); font-weight: 600; cursor: pointer; }
.v15-today-btn[aria-pressed="true"] { border-color: var(--brand, #1F3A5F); background: var(--brand-soft, #EAF3FC); }
.v15-week-wrap { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.v15-week-wrap .v15-icon-btn { width: 32px; font-size: 20px; }
.v15-week { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; touch-action: pan-y; }
.v15-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 58px; min-width: 0; padding: 4px 0 6px; border: 1px solid transparent; border-radius: 14px; background: var(--surface-2, #F5F7FA);
  color: var(--ink, #243447); cursor: pointer; transition: background .15s, color .15s; }
.v15-day:hover { background: var(--brand-soft, #EAF3FC); }
.v15-dow { font-size: 11px; color: var(--muted, #52667D); }
.v15-date { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.v15-day.is-weekend .v15-dow { color: var(--v15-out); }
.v15-day.is-other-month { background: #FFFFFF; border-color: var(--line, #DFE6EF); }
.v15-day.is-other-month .v15-date { color: var(--muted, #52667D); }
.v15-day.is-today { border-color: var(--action, #FF7A59); }
.v15-day.is-today .v15-dow { color: var(--action-ink, #B4462A); font-weight: 700; }
.v15-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.v15-dot.has { background: var(--action, #FF7A59); }
.v15-day.is-selected { background: var(--brand, #1F3A5F); border-color: var(--brand, #1F3A5F); color: #FFFFFF; }
.v15-day.is-selected .v15-dow, .v15-day.is-selected .v15-date { color: #FFFFFF; }
.v15-day.is-selected .v15-dot.has { background: #FFC3B2; }
.v15-day:focus-visible, .v15-icon-btn:focus-visible, .v15-tx:focus-visible { outline: 3px solid var(--sky, #4DA8DA); outline-offset: 2px; }

.v15-summary { margin: 12px 12px 0; padding: 12px 14px; border-radius: 14px; background: #FFFFFF; border: 1px solid var(--line, #DFE6EF); }
.v15-summary.is-loading { opacity: .6; }
.v15-summary-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin-bottom: 6px; }
.v15-summary-head h2 { margin: 0; font-size: 15px; color: var(--brand, #1F3A5F); }
.v15-sum-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; }
.v15-sum-row + .v15-sum-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line, #DFE6EF); }
.v15-sum-row:has(.v15-cur) { grid-template-columns: auto repeat(3, minmax(0, 1fr)); }
.v15-cur { align-self: center; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft, #EAF3FC); color: var(--brand, #1F3A5F); }
.v15-sum { min-width: 0; padding-left: 8px; border-left: 3px solid var(--line, #DFE6EF); }
.v15-sum:nth-of-type(1) { border-left-color: var(--action, #FF7A59); }
.v15-sum:nth-of-type(2) { border-left-color: var(--sky, #4DA8DA); }
.v15-sum small { display: block; font-size: 11px; color: var(--muted, #52667D); }
.v15-sum strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ink, #243447); }
.v15-out { color: var(--v15-out) !important; }
.v15-in { color: var(--v15-in) !important; }
.v15-neg { color: var(--v15-out) !important; }

.v15-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 12px 4px; }
.v15-filter button { min-height: 36px; }
.v15-add { min-height: 40px; white-space: nowrap; }
.v15-pending { display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); margin: 8px 12px 0; min-height: 44px; padding: 8px 12px;
  border: 1px dashed var(--action, #FF7A59); border-radius: 12px; background: var(--action-soft, #FFF0EA); color: var(--action-ink, #B4462A); text-align: left; cursor: pointer; }
.v15-pending span { font-weight: 700; } .v15-pending small { flex: 1; color: var(--muted, #52667D); } .v15-pending b { font-size: 18px; }
.v15-error { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 12px 0; padding: 8px 12px;
  border-radius: 10px; background: var(--danger-bg, #FFF0EA); color: var(--danger-ink, #A33A22); }

.v15-tx-list { list-style: none; margin: 6px 0 0; padding: 0 4px; }
.v15-tx-list li + li { border-top: 1px solid var(--line, #DFE6EF); }
.v15-tx { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 60px;
  padding: 8px 8px; border: 0; border-radius: 12px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.v15-tx:hover { background: var(--surface-2, #F5F7FA); }
.v15-cat { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 700; font-size: 15px; }
.v15-cat-out { background: var(--action-soft, #FFF0EA); color: var(--action-ink, #B4462A); }
.v15-cat-in { background: var(--brand-soft, #EAF3FC); color: var(--v15-in); }
.v15-cat-move { background: var(--surface-2, #F5F7FA); color: var(--v15-move); }
.v15-tx-main { min-width: 0; }
.v15-tx-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.v15-tx-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; font-size: 12px; color: var(--muted, #52667D); }
.v15-tx-meta > span:not(.v15-chip) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v15-chip { padding: 0 6px; border-radius: 6px; background: var(--surface-2, #F5F7FA); border: 1px solid var(--line, #DFE6EF); }
.v15-tx-amt { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v15-tx-amt small { font-size: 11px; font-weight: 500; color: var(--muted, #52667D); }
.v15-out.v15-tx-amt { color: var(--v15-out); } .v15-in.v15-tx-amt { color: var(--v15-in); } .v15-move.v15-tx-amt { color: var(--v15-move); }
.v15-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.v15-empty { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 12px 0; padding: 14px; border-radius: 12px;
  background: var(--surface-2, #F5F7FA); color: var(--muted, #52667D); }
.v15-empty p { margin: 0; }
.v15-loading { margin: 12px; color: var(--muted, #52667D); }
.v15-rule { margin: 10px 14px 0; }

@media (min-width: 761px) { .v15-daily { max-width: 920px; } }
@media (max-width: 760px) {
  .v15-daily { margin: -4px -4px 14px; border-radius: 16px; }
  .v15-daily-bar { padding: 6px 6px 6px; }
  .v15-month { font-size: 16px; }
  .v15-day { min-height: 52px; border-radius: 12px; }
  .v15-date { font-size: 16px; }
}
@media (max-width: 360px) {
  .v15-week { gap: 2px; }
  .v15-week-wrap .v15-icon-btn { width: 26px; }
  .v15-today-btn { padding: 0 10px; }
  .v15-sum strong { font-size: 14px; }
  .v15-tx { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; }
  .v15-cat { width: 34px; height: 34px; }
  .v15-toolbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .v15-day { transition: none; } }

/* ---------------------------------------------------------------- P0-02 待整理工時 */
.v15-ov { margin-bottom: 16px; border-color: var(--action, #FF7A59); }
.v15-ov[hidden] { display: none; }
.v15-ov-card { margin-top: 12px; padding: 12px; border: 1px solid var(--line, #DFE6EF); border-radius: 14px; background: #FFFFFF; }
.v15-ov-card header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.v15-ov-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.v15-ov-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2, #F5F7FA); }
.v15-ov-side strong { overflow-wrap: anywhere; }
.v15-ov-tag { align-self: flex-start; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--brand, #1F3A5F); color: #FFFFFF; }
.v15-ov-hint { margin: 8px 0 0; }
.v15-ov-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.v15-ov-actions button { min-height: 44px; }
.v15-ov-preview table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.v15-ov-preview th, .v15-ov-preview td { padding: 6px; border-bottom: 1px solid var(--line, #DFE6EF); text-align: left; vertical-align: top; }
.v15-ov-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.v15-ov-form p, .v15-ov-form .record-actions { grid-column: 1 / -1; margin: 0; }
.v15-ov-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
@media (max-width: 560px) { .v15-ov-pair, .v15-ov-form { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- P0-03 整理任務歸屬 */
.v15-hint { display: block; margin-top: 2px; color: var(--ok-ink, #175E8C); }
.v15-hint .text-button { min-height: 32px; margin-left: 4px; }
.v15-impact { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.v15-impact caption { text-align: left; font-weight: 700; padding-bottom: 4px; }
.v15-impact th, .v15-impact td { padding: 6px; border-bottom: 1px solid var(--line, #DFE6EF); text-align: left; }

/* ---------------------------------------------------------------- P1-01 五格完成度 */
.v15-progress { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; }
.v15-blocks { display: inline-grid; grid-template-columns: repeat(5, 1fr); gap: 3px; width: 110px; }
.v15-blocks i { display: block; height: 10px; border-radius: 3px; background: #E3E9F1; box-shadow: inset 0 0 0 1px #D3DCE7; }
.v15-blocks i.on { background: var(--brand, #1F3A5F); box-shadow: none; transition: background .25s; }
.v15-num { min-width: 2.2em; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--brand, #1F3A5F); text-align: right; }
.v15-done { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--ok-bg, #E6F2FB); color: var(--ok-ink, #175E8C); }
.v15-progress.is-compact { display: none; }
.v15-progress[data-value=""] .v15-num { color: var(--muted, #52667D); }
@media (max-width: 760px) {
  .v15-progress.is-compact { display: inline-flex; }
  .project-summary .v15-full-pct, .goal-v07 .v15-full-pct, .goal-v07 > .progress { display: none; }
  .project-summary, .goal-v07 { padding-top: 12px; padding-bottom: 12px; }
  .project-summary h2, .goal-v07 h2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .v15-blocks i.on { transition: none; } }

/* ---------------------------------------------------------------- P0-04 任務卡 */
.v15-task-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.v15-task-head p { margin: 0; }
.v15-task-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.v15-task-card { cursor: pointer; padding: 14px; margin: 0; }
.v15-task-card:focus-visible { outline: 3px solid var(--sky, #4DA8DA); outline-offset: 2px; }
.v15-task-card.is-done .v15-task-title { color: var(--muted, #52667D); }
.v15-task-top { display: flex; align-items: flex-start; gap: 8px; }
.v15-task-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.v15-more { flex: none; min-width: 44px !important; min-height: 44px !important; font-size: 18px; }
.v15-task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: var(--muted, #52667D); }
.v15-detail h3 { margin: 0 0 4px; }
.v15-dl { display: grid; gap: 6px; margin: 12px 0; }
.v15-dl div { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; }
.v15-dl dt { color: var(--muted, #52667D); } .v15-dl dd { margin: 0; overflow-wrap: anywhere; }
.v15-checks { margin: 0 0 12px; padding-left: 1.2em; }
@media (max-width: 760px) { .v15-task-list { grid-template-columns: 1fr; gap: 8px; } .v15-task-card { padding: 10px 12px; } }

/* ---------------------------------------------------------------- P1-02 / P1-03 吸頂（每個畫面只固定一列功能分頁） */
@media (min-width: 761px) {
  .sidebar { max-height: 100vh; overflow-y: auto; overscroll-behavior: contain; }
  #section-tabs:not([hidden]) { position: sticky; top: var(--am-sticky-top); z-index: 25; background: var(--bg, #F5F7FA);
    padding: 8px 0; margin-top: -8px; box-shadow: 0 6px 8px -8px #1F3A5F33; }
  body[data-am-view="schedules"] #view-schedules > .toolbar { position: sticky; top: var(--am-sticky-top); z-index: 24; }
  body[data-am-view="dashboard"] .v13-worknav-head { position: sticky; top: var(--am-sticky-top); z-index: 24; background: var(--bg, #F5F7FA); padding: 8px 0; }
  /* finance daily on desktop: the section tabs are the sticky row; the date strip scrolls with its card */
  body[data-am-view="finance"] .v15-daily-bar { position: static; }
}
@media (max-width: 760px) {
  body[data-am-view="dashboard"] .v13-worknav-head { position: sticky; top: var(--am-sticky-top); z-index: 24; background: var(--bg, #F5F7FA);
    padding: 6px 0 4px; margin: 0 -2px; }
  body[data-am-view="dashboard"] .v13-worknav-head .v13-range { margin: 2px 0 0; }
}
.v15-top { position: fixed; z-index: 40; left: calc(var(--am-main-left, 0px) + 16px); bottom: calc(24px + env(safe-area-inset-bottom));
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong, #C9D6E5); background: #FFFFFFEE;
  color: var(--brand, #1F3A5F); font-weight: 600; box-shadow: var(--shadow-lift); cursor: pointer; }
.v15-top[hidden] { display: none; }
@media (max-width: 760px) { .v15-top { left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------------------------------------------------------------- P1-04 表單進階設定 */
.v15-advanced { border: 1px solid var(--line, #DFE6EF); border-radius: 12px; padding: 0 12px; background: var(--surface-2, #F5F7FA); }
.v15-advanced > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--brand, #1F3A5F); }
.v15-advanced[open] { padding-bottom: 12px; background: #FFFFFF; }
.v15-advanced > .form-grid { margin-top: 4px; }
.v15-form-hint { margin: 0; }

/* ---------------------------------------------------------------- P1-05 計算機 */
.v15-amount-wrap { display: flex; align-items: stretch; gap: 6px; width: 100%; }
.v15-amount-wrap > input { flex: 1; min-width: 0; }
.v15-calc-btn { flex: none; width: 44px; min-height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line-strong, #C9D6E5);
  background: #FFFFFF; color: var(--brand, #1F3A5F); cursor: pointer; }
.v15-calc-btn:hover { background: var(--brand-soft, #EAF3FC); }
/* V0.16 P1: [幣別] [數值] [計算機] are three flex items — nothing is absolutely positioned over the digits. */
.v16-amount-row { align-items: stretch; min-width: 0; max-width: 100%; }
/* basis 0 + width 0: the input's intrinsic size (size=20 at 26px ≈ 440px) must not widen the grid cell past the screen. */
.v16-amount-row > input { flex: 1 1 0%; width: 0; min-width: 0; }
.v16-amount-row > .v15-calc-btn { min-width: 44px; }
.form-grid > .v16-amount-label { grid-column: 1 / -1; }
.v16-cur { flex: none; align-self: center; position: static; transform: none; min-width: 2.75em; padding: 4px 8px; text-align: center; white-space: nowrap;
  border-radius: 999px; background: var(--brand-soft, #EAF3FC); color: var(--brand, #1F3A5F); font-size: 13px; font-weight: 700; line-height: 1.4; }
.v12-amount-wrap .v16-amount-row .v12-currency { position: static; right: auto; top: auto; transform: none; }
.v12-amount-wrap .v16-amount-row > input { padding-right: 12px; }
.v15-calc-btn svg { pointer-events: none; }
.v15-calc-btn:focus-visible { outline: 3px solid var(--sky, #4DA8DA); outline-offset: 1px; }
@media (max-width: 360px) {
  .v16-amount-row { gap: 4px; }
  .v16-cur { padding: 4px 6px; min-width: 2.4em; font-size: 12px; }
  .v12-amount-wrap .v16-amount-row > input { font-size: 22px; }
}
.v15-calc { width: min(380px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 0; border: 0; border-radius: 20px; background: #FFFFFF; box-shadow: var(--shadow-lift); }
.v15-calc::backdrop { background: #1F3A5F55; }
.v15-calc-body { padding: 14px; }
.v15-calc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.v15-calc-head h2 { margin: 0; font-size: 16px; color: var(--brand, #1F3A5F); }
.v15-calc-screen { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2, #F5F7FA); text-align: right; min-height: 84px; }
.v15-calc-expr { font-size: 18px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.v15-calc-result { font-size: 26px; font-weight: 700; color: var(--brand, #1F3A5F); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-height: 1.3em; }
.v15-calc-error { color: var(--danger-ink, #A33A22); font-size: 13px; min-height: 1.2em; }
.v15-calc-angle { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 6px; }
.v15-calc-angle button { min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong, #C9D6E5); background: #FFFFFF; font-weight: 700; }
.v15-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.v15-keys.is-sci { grid-template-columns: repeat(6, 1fr); margin-bottom: 6px; }
.v15-key { min-height: 52px; border-radius: 12px; border: 1px solid var(--line, #DFE6EF); background: #FFFFFF; font-size: 18px; font-weight: 600; color: var(--ink, #243447); cursor: pointer; }
.v15-key.is-fn { min-height: 40px; font-size: 14px; background: var(--surface-2, #F5F7FA); }
.v15-key.is-op { background: var(--brand-soft, #EAF3FC); color: var(--brand, #1F3A5F); }
.v15-key.is-eq { background: var(--brand, #1F3A5F); color: #FFFFFF; border-color: var(--brand, #1F3A5F); }
.v15-key:focus-visible { outline: 3px solid var(--sky, #4DA8DA); outline-offset: 1px; }
@media (max-width: 760px) {
  .v15-calc { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .v15-key { min-height: 54px; }
}

/* V0.15: `overflow-x: hidden` on html/body (V0.10) turned <body> into a scroll container, so position:sticky bound to a box
   that never scrolls. `clip` keeps "no horizontal page scroll" without creating a scroll container. */
html, body { overflow-x: clip; }
@supports not (overflow: clip) { html { overflow-x: hidden; } body { overflow-x: visible; } }

/* V0.17: 連接 Claude 區塊（與 ChatGPT 連接同一個對話框）。 */
.claude-connect { margin-top: 16px; padding: 14px; display: grid; gap: 10px; }
.claude-connect .claude-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.claude-connect input { width: 100%; min-width: 0; }
.claude-connect .row { display: flex; flex-wrap: wrap; gap: 8px; }
.claude-connect .row > * { min-height: 44px; display: inline-flex; align-items: center; }
