/* app-02-layout.css
 * 版面：各種螢幕寬度的調整、模式列、記帳頁的左右分割
 *
 * 這是 app.css 拆開後的第 2 層（共 6 層）。
 * CSS 是後面蓋前面，所以 index.html 必須照 app-01 → app-06 → v4.css 的順序載入。
 * 要改外觀，先找最後面的層（v4.css），那裡改不動才往前找。
 */
/* ── RESPONSIVE ── */
@media(max-width:768px){
  body{display:block;height:auto;overflow-y:auto;overflow-x:hidden}
  .mobile-topbar{display:flex}
  .sidebar{position:fixed;top:0;left:0;height:100vh;z-index:200;transform:translateX(-100%);transition:transform .25s ease,width .25s ease;width:215px!important}
  .sidebar.mobile-open{transform:translateX(0)}
  .sb-toggle{display:none}
  .main{padding:14px;padding-top:66px;min-height:calc(100vh - 52px);overflow-y:visible}
  .g4{grid-template-columns:repeat(2,1fr)}
  .g3{grid-template-columns:repeat(2,1fr)}
  .g2{grid-template-columns:1fr}
  .charts-grid{grid-template-columns:1fr}
  .health-grid{grid-template-columns:repeat(2,1fr)}
  .items-grid{grid-template-columns:repeat(3,1fr)}
  .calc-layout{grid-template-columns:1fr}
  .form-row{grid-template-columns:1fr}
  .table-card{overflow-x:auto}
  .modal{width:95vw;max-width:95vw;padding:18px}
  .page-title{font-size:17px}
  .card-value{font-size:20px}
  .donut-layout{flex-direction:column;align-items:flex-start}
  .donut-canvas{flex:0 0 120px;height:120px}
}
@media(max-width:480px){
  .g4{grid-template-columns:1fr}
  .g3{grid-template-columns:1fr}
  .health-grid{grid-template-columns:repeat(2,1fr)}
  .items-grid{grid-template-columns:repeat(2,1fr)}
  .main{padding:10px;padding-top:62px}
}

/* ── MODE BAR ── */
.mode-bar{display:flex;align-items:center;gap:8px;margin-bottom:20px;padding-bottom:16px;border-bottom:2px solid var(--border)}
.mode-bar-title{font-size:12px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-right:4px}
.mode-btn{padding:7px 18px;border-radius:10px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid var(--border);background:var(--card);color:var(--muted);transition:.2s}
.mode-btn:hover{border-color:var(--primary);color:var(--primary)}
.mode-btn.active{background:var(--primary);color:#fff;border-color:var(--primary)}

/* ── SPLIT VIEW ── */
.split-view{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
.acct-right-stack{display:flex;flex-direction:column;gap:14px}
.acct-panel{background:var(--card);border-radius:14px;border:1px solid var(--border);overflow:hidden;box-shadow:0 1px 4px rgba(44,26,14,.06)}
.acct-tabs{display:flex;border-bottom:1px solid var(--border)}
.acct-tab{flex:1;padding:11px 6px;text-align:center;font-size:13px;font-weight:600;cursor:pointer;color:var(--muted);border:none;border-bottom:2px solid transparent;background:transparent;transition:.2s;margin-bottom:-1px}
.acct-tab:hover{color:var(--primary)}
.acct-tab.active{color:var(--primary);border-bottom-color:var(--primary)}
.acct-panel-body{padding:14px}
.acct-add-bar{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.acct-summary{font-size:12px;color:var(--muted)}
.acct-record-list{display:flex;flex-direction:column}
.acct-record{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 12px;align-items:center;padding:13px 0;border-bottom:1px solid var(--border)}
.acct-record:last-child{border-bottom:none}
.acct-record-main{min-width:0}
.acct-record-title{font-size:13px;font-weight:700;line-height:1.45;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.acct-record-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:5px;font-size:11px;color:var(--muted)}
.acct-record-value{font-size:15px;font-weight:800;white-space:nowrap;text-align:right}
.acct-record-value small{display:block;margin-top:2px;font-size:9px;font-weight:600;color:var(--muted)}
.acct-record-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:6px}
.acct-record-actions .btn{padding:5px 10px;font-size:11px}
.acct-donut-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px}
.acct-chart-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px}
.acct-chart-head .chart-title{white-space:nowrap;margin-bottom:0;line-height:1.25}
.acct-chart-controls{display:flex;gap:4px;flex-wrap:wrap;justify-content:flex-end;min-width:0}
.acct-period-tag{
  font-size:11px;
  color:var(--muted);
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:999px;
  padding:3px 8px;
  white-space:nowrap;
}
.acct-month-select{
  width:auto;
  min-width:112px;
  padding:4px 9px;
  font-size:11px;
  border-radius:7px;
}
.budget-panel{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:8px;
  padding:14px;
  box-shadow:0 1px 2px rgba(20,30,40,.04),0 8px 24px rgba(20,30,40,.04);
  margin-bottom:14px;
}
.budget-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}
.budget-title{font-size:15px;font-weight:700}
.budget-sub{font-size:11px;color:var(--muted);margin-top:2px}
.budget-grid{
  display:grid;
  grid-template-columns:minmax(160px,1fr) auto;
  gap:8px;
  align-items:end;
}
.budget-grid .form-group{margin-bottom:0}
.budget-progress{
  height:7px;
  background:var(--bg2);
  border-radius:999px;
  overflow:hidden;
  margin-top:8px;
}
.budget-progress-bar{
  height:100%;
  border-radius:999px;
  transition:width .25s ease;
}
.budget-progress-panel{padding:16px}
.budget-progress-main{display:flex;flex-direction:column;gap:8px}
.budget-progress-value{
  font-size:28px;
  font-weight:800;
  line-height:1.05;
}
.budget-progress-meta{
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:12px;
}
.budget-progress-foot{
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--text);
  font-size:12px;
  font-weight:600;
}
.acct-mini-note{
  font-size:11px;
  color:var(--muted);
  margin-top:6px;
}
.receivable-box{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:8px;
  padding:14px;
  box-shadow:0 1px 2px rgba(20,30,40,.04),0 8px 24px rgba(20,30,40,.04);
  margin-bottom:14px;
}
.receivable-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;gap:10px}
.receivable-title{font-size:15px;font-weight:700}
.receivable-total{font-size:13px;font-weight:800;color:var(--warn)}
.receivable-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.receivable-summary-line{font-size:12px;color:var(--muted);font-weight:700;margin-bottom:10px}
.receivable-summary-line b{font-size:13px;color:var(--warn)}
.receivable-list{display:flex;flex-direction:column;gap:8px}
.receivable-item{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:center;
  padding:9px 10px;
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:7px;
}
.receivable-name{font-size:13px;font-weight:700}
.receivable-meta{font-size:11px;color:var(--muted);margin-top:2px}
.receivable-empty{font-size:12px;color:var(--muted);padding:8px 0}
.cc-payable-row{
  display:grid;
  grid-template-columns:auto 1.3fr .8fr 1fr auto auto;
  gap:10px;
  align-items:center;
  padding:10px;
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:7px;
}
.cc-payable-check{width:16px;height:16px}
.cc-payable-amount{font-size:14px;font-weight:800;color:var(--warn);white-space:nowrap;text-align:right}
.cc-card-actions{display:flex;gap:6px;flex-wrap:wrap;margin:-4px 0 10px}
/* 對帳明細（點「對帳」展開，逐筆勾選本期要繳的） */
.cc-pay-items{margin:6px 0 2px 26px;padding:8px 10px;background:var(--bg2);border:1px solid var(--border);border-radius:7px;max-height:260px;overflow-y:auto}
.cc-pay-items-hint{font-size:11px;color:var(--muted);line-height:1.5;padding-bottom:6px;border-bottom:1px solid var(--border);margin-bottom:4px}
.cc-pay-item{display:flex;align-items:center;gap:8px;padding:5px 2px;cursor:pointer}
.cc-pay-item input{width:14px;height:14px;flex-shrink:0}
.cc-pay-item-date{font-size:12px;color:var(--muted);white-space:nowrap}
.cc-pay-item-name{flex:1;font-size:12px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cc-pay-item-amt{font-size:12px;font-weight:600;white-space:nowrap}
.cc-pay-item input:not(:checked)~.cc-pay-item-date,
.cc-pay-item input:not(:checked)~.cc-pay-item-name,
.cc-pay-item input:not(:checked)~.cc-pay-item-amt{opacity:.45;text-decoration:line-through}
@media(max-width:760px){
  .cc-payable-row{grid-template-columns:auto 1fr auto;align-items:flex-start}
  .cc-payable-amount{text-align:left}
  .cc-pay-items{margin-left:0}
}
/* var expense */
.ve-month-bar{display:flex;align-items:center;gap:8px;margin-bottom:12px;flex-wrap:wrap}
.ve-month-sel{padding:5px 10px;border:1px solid var(--border);border-radius:7px;font-size:12px;background:var(--card);color:var(--text);cursor:pointer;outline:none}
.ve-search-bar{display:flex;gap:8px;align-items:center;margin-bottom:10px;flex-wrap:wrap}
.ve-search-input{flex:1;min-width:120px;height:34px;border:1px solid var(--border);border-radius:8px;padding:0 12px;font-size:13px;color:var(--text);background:var(--card);outline:none}
.ve-search-input:focus{border-color:var(--primary)}
.ve-search-cat{height:34px;min-width:110px}
.ve-day-toolbar{display:grid;grid-template-columns:auto 1fr auto;gap:8px;align-items:center;margin-bottom:10px}
.ve-date-input{height:34px;border:1px solid var(--border);border-radius:8px;padding:0 10px;font-size:13px;color:var(--text);background:var(--card);outline:none}
.ve-day-summary{display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:8px;margin-bottom:12px;font-size:12px;color:var(--muted)}
.ve-day-total{font-size:13px;font-weight:800;color:var(--danger)}
.trend-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;flex-wrap:nowrap}
.trend-control-group{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;min-width:0}
.trend-seg{display:inline-flex;border:1px solid var(--border);border-radius:999px;background:var(--card);padding:3px;gap:2px;flex-shrink:0}
.trend-seg button{border:0;background:transparent;color:var(--muted);border-radius:999px;padding:5px 11px;font-size:12px;font-weight:800;cursor:pointer;height:28px;line-height:18px}
.trend-seg button.active{background:var(--primary);color:#fff}
.trend-control{height:34px;border:1px solid var(--border);border-radius:999px;padding:0 14px;font-size:12px;background:var(--card);color:var(--text);outline:none;min-width:150px}
.ve-cat-chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}
.ve-chip{padding:3px 10px;border-radius:999px;font-size:11px;font-weight:600;background:var(--bg);border:1px solid var(--border);color:var(--text)}
.ve-chip.total{background:var(--primary);color:#fff;border-color:var(--primary)}
.ve-list{display:flex;flex-direction:column;gap:0}
.ve-item{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px solid var(--border)}
.ve-item:last-child{border-bottom:none}
.ve-item-main{flex:1;min-width:0}
.ve-item-name{font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ve-item-meta{font-size:11px;color:var(--muted);margin-top:2px}
.ve-item-amt{font-size:15px;font-weight:700;color:var(--danger);white-space:nowrap}
.ve-item-acts{display:flex;gap:4px;flex-shrink:0}
.ve-cat-badge{display:inline-flex;padding:2px 7px;border-radius:999px;font-size:10px;font-weight:600}
/* left panel cashflow update row */
.cf-row-var{background:var(--card)}
@media(max-width:900px){.split-view{grid-template-columns:1fr}}
@media(max-width:1200px){.acct-donut-grid{grid-template-columns:1fr}}
@media(max-width:760px){
  .trend-toolbar{align-items:flex-start;flex-direction:column}
  .trend-control-group{width:100%}
  .trend-control{flex:1;min-width:0}
  .ve-day-summary{grid-template-columns:1fr auto}
  .ve-day-summary .btn{grid-column:1/-1}
}
/* 手機版記帳模式：隱藏擠成一團的消費趨勢、把記帳輸入區（分頁）移到最上面 */
@media(max-width:768px){
  .acct-trend-block{display:none}
  .split-view{display:flex;flex-direction:column}
  .acct-right-stack{order:-1}
}

