/* Phone redesign (V2C-001 phone pass). Everything that changes the layout lives under max-width:899px, so desktop (>=900px) is untouched.
   Pattern: read-only values + one Edit action (.ph-ro shown, .ph-ed hidden until [data-ph].ph-edit), secondary actions in a menu, calculations collapsed (details.ph-fold). */
.ph-fold>summary.ph-sum,.x-menu .ph-lbl{display:none}
.st-s{display:none}
@media (min-width:900px){
  details.ph-fold>.section{margin-top:0 !important}
  .ph-only,.ph-ro{display:none !important}
  .x-menu{display:contents}
  .sv-body{display:flex;flex-direction:column}
  .sv-new{order:-1}
  .sv-pots{order:0}
}
@media (max-width:899px){
  details.ph-fold>.section{margin-top:0}
  .dsk-only{display:none !important}
  span.ph-only{display:inline} div.ph-only,.card.ph-only{display:block} .btn.ph-only{display:inline-flex}
  [data-ph]:not(.ph-edit) .ph-ed{display:none}
  [data-ph].ph-edit .ph-ro{display:none}
  .ph-fold>summary.ph-sum{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;padding:0 16px;font-weight:600;font-size:15px;color:var(--ink);cursor:pointer;list-style:none;background:var(--surface);border:1px solid var(--line);border-radius:14px}
  .ph-fold>summary.ph-sum::-webkit-details-marker{display:none}
  .ph-fold>summary.ph-sum::after{content:"";width:8px;height:8px;border-right:2px solid var(--ink-soft);border-bottom:2px solid var(--ink-soft);transform:rotate(45deg);margin-top:-3px;flex:none}
  .ph-fold[open]>summary.ph-sum{margin-bottom:12px}
  .ph-fold[open]>summary.ph-sum::after{transform:rotate(-135deg);margin-top:3px}

  /* P5: one component system for every phone screen */
  main .card,.card{padding:16px;border-radius:14px}
  main .grid{gap:12px}
  main .section{margin-top:24px}
  .ec-sum-ph .big-num,.inc-pay .big-num,.pl-fc .big-num{font-size:30px !important;line-height:1.15;font-weight:700}
  main .btn,main button.x,.subtab,.tabs .tab{min-height:44px}
  main input:not([type=checkbox]):not([type=radio]),main select{min-height:44px}
  main label.lbl,.np-l,.ph-l{font-size:14px}
  .page-sub{-webkit-line-clamp:2 !important;line-height:1.4}
  div[style*="position:relative"]+.legend-inline{display:none} /* legend shown once */

  /* sub tabs: all of them visible, none clipped */
  .subtab{position:relative}
  .subtabs.n4{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));overflow:visible;white-space:normal}
  .subtabs.n4 .subtab{padding:0 2px;font-size:14px;line-height:1.2;text-align:center;min-width:0}
  .subtab .st-l,.pl-tabs .st-l{display:none}
  .subtab .st-s,.pl-tabs .st-s{display:inline}

  /* P1 debts */
  .debts-kp>.kpi:first-child{grid-column:1/-1}
  .debts-kp>.kpi:first-child .v{font-size:30px}
  .debt-card .top{display:flex;flex-direction:column;align-items:flex-start;gap:2px;margin-bottom:12px}
  .debt-card .ph-name{margin:0;font-size:17px;font-weight:700}
  .debt-card .top>.amt{font-size:30px;font-weight:700;line-height:1.1}
  .debt-card .ph-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px 12px;margin-top:16px;padding-top:16px;border-top:1px solid var(--line)}
  .ph-cell{display:flex;flex-direction:column;gap:2px;min-width:0}
  .ph-cell .ph-l{color:var(--ink-soft)} .ph-cell .ph-v{font-size:16px;font-weight:600}
  .debt-card .foot{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:16px}
  .debt-card .foot>span:not(.x-menu){display:none}
  .debt-card .foot>.btn:first-child{flex:1 1 100%}
  .debt-card .foot>.btn.ph-only:not(.ph-more){flex:1 1 0}
  .debt-card .foot .ph-more{width:44px;padding:0;justify-content:center}
  .x-menu{display:none}
  .menu-open>.foot>.x-menu{display:flex;flex-direction:column;flex:1 1 100%;gap:4px;border-top:1px solid var(--line);padding-top:8px}
  .x-menu .x{display:flex;align-items:center;justify-content:flex-start;gap:10px;width:100%;padding:0 8px}
  .x-menu .ph-lbl{display:inline;font-size:14px}
  .debt-card.ph-edit .form-row.ph-ed{display:grid;grid-template-columns:1fr 1fr;gap:12px}
  .debt-card.ph-edit .form-row.ph-ed .lbl input{width:100% !important}

  /* P4 savings */
  .sv-body{display:flex;flex-direction:column;gap:12px}
  .sv-pots{margin-top:0 !important}
  .sv-new{display:none}
  .sv-body.new-open .sv-new{display:block}
  .sv-body.new-open .sv-newbtn{display:none}
  .sv-newbtn{width:100%;justify-content:center}
  .sv-pot .foot{flex-wrap:wrap}
  .sv-pot:not(.pk-adding) .ph-add{display:none}
  .sv-pot.pk-adding .btn.ph-addbtn{display:none}
  .sv-pot .foot .btn.ph-addbtn{flex:1}
  .sv-pot.pk-adding .foot .pk-amt{flex:1 1 100%}
  .ph-late{margin-top:12px}

  /* P3 income */
  .inc-list{display:block}
  .inc-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--line);min-height:56px}
  .inc-list>.inc-row:first-child{border-top:0}
  .inc-nm{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
  .inc-nm b{font-size:15px;overflow-wrap:anywhere}
  .inc-kind{font-size:14px;color:var(--ink-soft)}
  .inc-amt{font-size:15px;font-weight:600;white-space:nowrap}
  .inc-tot{padding-bottom:0}
  .inc-src .inc-add{display:none}
  .inc-src.add-open .inc-add{display:flex}
  .inc-src.add-open .inc-newbtn{display:none}
  .inc-newbtn{width:100%;justify-content:center;margin-top:12px}
  .inc-src:not(.ph-edit) .inc-done{display:none}
  .inc-done{margin-top:12px}
  .inc-pay{text-align:center}
  .inc-pay .l{text-align:center}
  .inc-top .kpi .v{font-size:22px}
  .inc-calc[open]>#smooth-used{margin-top:0}

  /* P2 monthly plan */
  .pl-manage{display:flex;flex-direction:column;align-items:flex-end;margin:8px 0 0}
  .pl-manage .pl-manage-items{display:none !important;margin:8px 0 0 !important}
  .pl-manage.menu-open .pl-manage-items{display:flex !important}
  .pl-tabs{margin-top:6px !important;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));overflow:visible;gap:6px}
  .pl-tabs .tab{padding:0 4px;font-size:14px;white-space:nowrap;flex:none}
  .note.pl-due{flex-wrap:wrap;align-items:center}
  .note.pl-due>div{flex:1 1 100%}
  .note.pl-due .btn{margin-top:8px}
  .pl-fc{margin-top:12px}
  .pl-fc .l{font-size:14px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--ink-soft);margin-bottom:4px}
  .pl-fc .sub{margin-top:6px}
  #pl-panel-overview .grid.g3>.kpi:nth-child(3){order:-1;grid-column:1/-1}
  #pl-panel-overview .grid.g3>.kpi:nth-child(3) .v{font-size:30px}
}
@media (min-width:360px) and (max-width:899px){ main button.x{min-width:44px} }

/* E2E 25 Nov: the fixed bar on top, the raised Add button of the bottom nav, the toast and the cookie bar must never sit on top of a control that was scrolled into view
   (scrollIntoView / focus / anchor jumps keep a control clear of them). Content below the last control is padded the same way. */
@media (max-width: 900px) {
  html { scroll-padding-top: 76px; scroll-padding-bottom: 250px; }
  #page { padding-bottom: 250px; }
}
