@media (max-width: 980px) {
  .calendar-layout, .plan-layout, .plan-evidence-layout { grid-template-columns: 1fr; }
  .today-layout { grid-template-columns: minmax(0, 1.55fr) minmax(238px, .75fr); gap: 18px; }
  .app-content { padding-left: 24px; padding-right: 24px; }
  .outlook-hero { gap: 20px; padding-left: 24px; padding-right: 24px; }
  .payment-row { grid-template-columns: minmax(0, 1fr) minmax(130px, auto); }
  .payment-row .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 90; height: auto; padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); display: block; border-top: 1px solid #29312b; }
  .brand, .sidebar-settings { display: none; }
  .mobile-settings { display: flex; }
  .main-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .nav-item { min-height: 52px; justify-content: center; gap: 4px; padding: 5px; flex-direction: column; border-radius: 10px; font-size: 11px; }
  .nav-item .ph { font-size: 21px; }
  .nav-item.active::before { inset: auto 22% -2px; width: auto; height: 3px; }

  .app-content { padding: 20px 16px calc(98px + env(safe-area-inset-bottom)); }
  .native-shell .app-content { padding-top: max(76px, calc(20px + env(safe-area-inset-top))); }
  .page-header { min-height: auto; margin-bottom: 22px; align-items: flex-start; }
  .page-header h1 { font-size: 29px; }
  .page-subtitle { font-size: 13px; }
  .page-header .eyebrow { display: none; }
  .header-actions { align-self: flex-start; }
  .quick-add { display: none; }
  .primary-button, .secondary-button { min-height: 46px; }
  #addButton { width: 46px; padding: 0; font-size: 0; }
  #addButton .ph-bold { font-size: 20px; }

  .today-layout { gap: 18px; }
  .today-layout { grid-template-columns: 1fr; }
  .side-panel { order: 2; }
  .lifecycle-guide { grid-template-columns: 1fr; gap: 13px; padding: 16px 52px 16px 16px; }
  .lifecycle-guide-steps { margin-right: -36px; }
  .attention-item { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .outlook-hero { min-height: 0; display: block; padding: 22px; }
  .hero-divider { display: none; }
  .hero-insight { margin-top: 22px; padding-top: 20px; border-top: 1px solid #39423b; grid-template-columns: 44px 1fr; }
  .hero-insight-icon { width: 44px; height: 44px; font-size: 23px; }
  .hero-insight strong { font-size: 16px; }
  .outlook-total { font-size: 34px; }
  .agenda { margin-top: 17px; }
  .payment-row { min-height: 86px; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 2px; }
  .payment-main { gap: 12px; }
  .payment-icon { width: 44px; height: 44px; font-size: 22px; }
  .payment-title strong { font-size: 15px; }
  .payment-title small { font-size: 12px; }
  .amount-cell { grid-column: 2; grid-row: 1; align-self: center; }
  .amount-cell strong { font-size: 14px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .row-action { min-height: 44px; }
  .overflow { position: relative; }
  .overflow-menu { right: 0; }
  .calm-note { align-items: flex-start; flex-wrap: wrap; }
  .calm-note button { width: 100%; justify-content: flex-start; margin-left: 52px; min-height: 44px; }

  .side-panel { border-radius: 16px; }
  .mini-calendar { padding: 19px 16px; }
  .week-day b { width: 34px; height: 34px; }
  .side-upcoming { display: none; }

  .calendar-panel { overflow-x: hidden; }
  .calendar-toolbar, .calendar-grid { min-width: 0; }
  .calendar-toolbar { padding: 16px 12px; }
  .calendar-toolbar h2 { font-size: 17px; }
  .calendar-weekday { padding: 10px 2px; font-size: 10px; }
  .calendar-day { min-height: 74px; padding: 5px 3px; }
  .calendar-day .day-number { width: 27px; height: 27px; font-size: 11px; }
  .calendar-day .day-events { gap: 2px; margin-top: 3px; }
  .calendar-day .day-event { padding: 2px 3px; font-size: 8px; }
  .selected-day { padding: 20px; }
  .cashflow-hero { grid-template-columns: 1fr; }
  .cashflow-hero > div { min-height: 122px; padding: 22px; }
  .plan-evidence-layout { gap: 16px; }
  .bill-card-grid { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 8px; }
  .bill-intelligence-card { padding: 17px; }
  .month-row { grid-template-columns: 82px minmax(0, 1fr); gap: 10px; }
  .month-currency-row { grid-template-columns: 1fr; gap: 5px; }
  .month-currency-row strong { text-align: left; font-size: 12px; }
  .plan-outlook { margin-top: 16px; }
  .plan-outlook > summary { min-height: 82px; padding: 16px 18px; }
  .plan-outlook > summary strong { font-size: 16px; }
  .plan-outlook-body { padding: 2px 18px 18px; }

  .auth-screen { min-height: calc(100vh - 67px); display: flex; flex-direction: column; justify-content: center; gap: 34px; padding: 32px 20px 98px; }
  .auth-copy { text-align: center; }
  .auth-copy h1 { font-size: 42px; }
  .auth-copy > p { margin: 17px 0; font-size: 15px; }
  .trust-list { display: none; }
  .auth-card { width: 100%; padding: 22px; }

  dialog.sheet-dialog { width: 100%; max-width: none; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .payment-form, .settings-sheet, .import-form { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .dialog-head { margin-bottom: 18px; }
  .type-selector, .form-row, .advanced-grid { grid-template-columns: 1fr; }
  .type-selector { grid-template-columns: 1fr 1fr; }
  .type-selector label > span { min-height: 74px; grid-template-columns: 24px 1fr; }
  .amount-mode { flex-wrap: wrap; overflow: visible; padding-bottom: 3px; }
  .lifecycle-steps { gap: 4px; }
  .lifecycle-steps > span { min-height: 54px; padding: 5px 3px; font-size: 10px; }
  .amount-mode label > span { min-height: 44px; white-space: normal; }
  .field input, .field select, .field textarea, .password-field input { font-size: 16px; }
  .scenario-button, .candidate-actions button, .overflow-menu button { min-height: 44px; }
  .field-wide { grid-column: auto; }
  .dialog-actions { position: sticky; bottom: 0; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); }
  .toast { right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .demo-banner { min-height: 58px; align-items: center; flex-direction: row; gap: 10px; margin-bottom: 16px; padding: 8px 9px 8px 12px; }
  .demo-banner small { display: none; }
  .demo-banner .quiet-button { width: auto; min-height: 44px; flex: 0 0 auto; padding: 0 10px; font-size: 11px; }
  .lifecycle-guide { gap: 8px; padding: 12px 50px 12px 14px; }
  .lifecycle-guide-copy > p:last-child { display: none; }
  .lifecycle-guide-steps { margin-right: -34px; }
  .lifecycle-guide-steps li { min-height: 58px; flex-direction: column; justify-content: center; gap: 2px; text-align: center; }
  .lifecycle-guide-steps strong, .lifecycle-guide-steps small { white-space: normal; }
  .attention-item { gap: 9px; padding-left: 11px; padding-right: 11px; }
  .attention-item .row-action { min-width: 0; padding: 0 8px; font-size: 11px; }
  .provenance-counts > div { padding: 10px 8px; }
  .payment-row { grid-template-columns: minmax(0, 1fr); }
  .amount-cell { grid-column: 1; grid-row: auto; text-align: left; padding-left: 56px; }
  .row-actions { justify-content: stretch; padding-left: 56px; }
  .row-action { flex: 1; }
  .empty-actions { flex-direction: column; align-items: stretch; }
  .empty-actions > * { width: 100%; }
  .manage-payment { align-items: flex-start; }
  .file-picker, .danger-zone { align-items: stretch; flex-direction: column; }
  .file-picker input { max-width: 100%; }
  .danger-button { width: 100%; }
  .type-selector { grid-template-columns: 1fr; }
  .week-day { font-size: 10px; }
  .week-day b { width: 32px; height: 32px; }
}

/* iPhone-first visual system */
@media (max-width: 760px) {
  html { background: #f5f6fb; }
  body {
    background:
      radial-gradient(circle at 92% -4%, rgba(255, 107, 87, .18), transparent 38%),
      #f5f6fb;
    color: #151827;
  }

  .sidebar {
    height: auto;
    padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid rgba(23, 27, 45, .12);
    background: rgba(255, 255, 255, .9);
    color: #73778a;
    box-shadow: 0 -8px 28px rgba(23, 27, 45, .08);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
  }
  .main-nav { gap: 2px; }
  .nav-item { min-height: 54px; color: #888c9e; font-size: 10px; font-weight: 650; }
  .nav-item .ph { color: #888c9e; font-size: 22px; }
  .nav-item:hover { background: #f0f1f7; }
  .nav-item.active { background: #fff0ed; color: #b9343f; font-weight: 780; }
  .nav-item.active::before { inset: 4px 28% auto; width: auto; height: 3px; background: #ff6b57; }
  .nav-item.active .ph { color: #ff6b57; }

  .app-content { padding: 24px 17px calc(108px + env(safe-area-inset-bottom)); }
  .native-shell .app-content { padding-top: max(78px, calc(24px + env(safe-area-inset-top))); }
  .page-header { margin-bottom: 25px; }
  .page-header-leading { gap: 8px; }
  .back-button { min-height: 38px; padding-left: 1px; font-size: 12px; }
  .back-button .ph { font-size: 19px; }
  .page-header h1 { color: #171b2d; font-size: 34px; font-weight: 820; letter-spacing: -.06em; }
  .page-subtitle { margin-top: 7px; color: #73778a; font-size: 14px; }
  .header-actions { gap: 8px; }
  #addButton { width: 48px; height: 48px; min-height: 48px; border-radius: 16px; box-shadow: 0 10px 20px rgba(255, 107, 87, .26); }
  #addButton .ph-bold { font-size: 21px; }

  .demo-banner { min-height: 56px; margin: 0 -1px 18px; border: 0; border-radius: 18px; background: #eeefff; box-shadow: 0 8px 18px rgba(91, 97, 255, .08); }
  .demo-banner > div > .ph { color: #5b61ff; }
  .demo-banner strong { color: #30356f; }
  .demo-banner small { color: #666b96; }
  .demo-banner .quiet-button { color: #4b51c1; font-weight: 780; }

  .today-layout { gap: 20px; }
  .lifecycle-guide { margin-bottom: 16px; border: 0; border-radius: 20px; background: #fff; box-shadow: 0 8px 24px rgba(23, 27, 45, .06); }
  .lifecycle-guide-copy h2 { color: #171b2d; font-size: 16px; }
  .lifecycle-guide-steps li { border: 0; background: #f5f6fb; }
  .lifecycle-guide-steps .pending .ph { color: #ff9b4a; }
  .lifecycle-guide-steps .estimated .ph { color: #5b61ff; }
  .lifecycle-guide-steps .exact .ph { color: #277a72; }
  .attention-panel { border: 0; border-radius: 20px; background: #fff; box-shadow: 0 8px 24px rgba(23, 27, 45, .06); }
  .attention-panel > header { min-height: 62px; padding: 14px 16px; border-bottom-color: #f0f1f7; }
  .attention-panel > header h2 { font-size: 16px; }
  .attention-panel > header > span { background: #fff0ed; color: #b9343f; }
  .attention-item { padding: 11px 15px; border-top-color: #f0f1f7; }
  .attention-item > .ph { background: #f5f6fb; }
  .attention-item.overdue > .ph { background: #fff0ed; color: #db4f4c; }
  .attention-item.pending > .ph { background: #fff3e4; color: #c97820; }
  .attention-item.anomaly > .ph { background: #eef0ff; color: #5b61ff; }

  .outlook-hero { min-height: 0; margin: 0 -1px; padding: 24px 21px 21px; border-radius: 24px; background: linear-gradient(150deg, #171b2d 0%, #2b3150 68%, #44365d 100%); box-shadow: 0 18px 30px rgba(23, 27, 45, .2); }
  .outlook-label { margin-bottom: 13px; color: #b8bdd1; font-size: 11px; }
  .outlook-total { font-size: 38px; font-weight: 800; }
  .outlook-note { color: #b8bdd1; font-size: 13px; }
  .hero-insight { margin-top: 24px; padding-top: 21px; border-top-color: rgba(255, 255, 255, .14); }
  .hero-insight-icon { background: rgba(255, 155, 141, .16); color: #ff9b8d; }
  .hero-insight strong { font-size: 16px; }
  .hero-insight p { color: #c6cada; font-size: 13px; }

  .agenda { margin-top: 20px; }
  .agenda-group-title { padding: 7px 3px 9px; color: #73778a; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
  .payment-row { min-height: 0; margin-bottom: 9px; padding: 15px 13px; border: 1px solid #e7e8f0; border-radius: 18px; background: #fff; box-shadow: 0 6px 16px rgba(23, 27, 45, .045); }
  .payment-main { gap: 11px; }
  .payment-icon { width: 43px; height: 43px; border: 0; background: #f0f1f7; color: #5b61ff; font-size: 21px; }
  .payment-icon.bill { background: #eef0ff; color: #5b61ff; }
  .payment-title strong { color: #171b2d; font-size: 14px; }
  .payment-title small { color: #73778a; font-size: 11px; }
  .amount-cell strong { color: #171b2d; font-size: 14px; }
  .amount-cell.pending strong { color: #c97820; }
  .amount-cell.estimated strong { color: #5b61ff; }
  .amount-cell small { color: #9ca0b2; font-size: 10px; }
  .row-actions { padding-top: 5px; }
  .row-action { min-height: 40px; border-color: #e4e6ef; border-radius: 11px; background: #f8f8fb; color: #34384b; }
  .row-action.primary-inline { border-color: #ff6b57; background: #ff6b57; color: #fff; }
  .icon-control { border-radius: 12px; }
  .side-panel { border: 0; border-radius: 22px; background: #fff; box-shadow: 0 8px 24px rgba(23, 27, 45, .06); }
  .mini-calendar { padding: 20px 17px; }
  .side-head h2 { font-size: 16px; }
  .week-strip { margin-top: 20px; }
  .week-day b { color: #34384b; }
  .week-day.today b { background: #ff6b57; color: #fff; box-shadow: 0 7px 14px rgba(255, 107, 87, .24); }
  .calm-note { margin: 14px 0 0; border: 0; border-radius: 18px; background: #eeefff; }
  .calm-note .ph { background: #dfe1ff; color: #5b61ff; }

  .calendar-panel, .plan-panel { border: 0; border-radius: 22px; box-shadow: 0 8px 24px rgba(23, 27, 45, .06); }
  .calendar-toolbar { padding: 18px 17px; border-bottom-color: #f0f1f7; }
  .calendar-toolbar h2 { color: #171b2d; font-size: 18px; }
  .calendar-weekday { border-bottom-color: #f0f1f7; color: #9ca0b2; }
  .calendar-day { min-height: 74px; border-right-color: #f0f1f7; border-bottom-color: #f0f1f7; background: #fff; }
  .calendar-day.outside { background: #fafafd; color: #b3b6c4; }
  .calendar-day.selected { box-shadow: inset 0 0 0 2px #5b61ff; background: #f5f5ff; }
  .calendar-day.today .day-number { background: #ff6b57; box-shadow: 0 4px 10px rgba(255, 107, 87, .22); }
  .day-event { background: #ffe9e5; color: #9d3d38; }
  .day-event.bill { background: #eef0ff; color: #4e55c8; }
  .selected-day { padding: 19px 17px; }
  .selected-day h2 { font-size: 18px; }
  .cashflow-hero { border-radius: 22px; background: #282d48; }
  .plan-panel { padding: 21px 17px; }
  .plan-panel h2 { font-size: 18px; }
  .plan-outlook { border-radius: 20px; background: #fff; box-shadow: 0 8px 24px rgba(23, 27, 45, .06); }

  .auth-screen { min-height: calc(100vh - 20px); padding: 36px 20px 60px; background: linear-gradient(145deg, #171b2d 0%, #272d4a 60%, #4a375d 100%); color: #fff; }
  .auth-copy { max-width: 360px; }
  .auth-kicker { color: #ff9b8d; letter-spacing: .13em; }
  .auth-copy h1 { color: #fff; font-size: 46px; letter-spacing: -.07em; }
  .auth-copy > p { color: #c6cada; font-size: 15px; line-height: 1.55; }
  .auth-card { padding: 22px; border: 0; border-radius: 24px; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
  .auth-brand { color: #171b2d; }
  .auth-card .primary-button { box-shadow: none; }

  dialog.sheet-dialog { border: 0; border-radius: 26px 26px 0 0; box-shadow: 0 -20px 60px rgba(23, 27, 45, .22); }
  .payment-form, .settings-sheet, .import-form { padding: 23px 18px calc(24px + env(safe-area-inset-bottom)); }
  .dialog-head h2 { color: #171b2d; font-size: 23px; }
  .dialog-actions { border-top-color: #f0f1f7; }
  .settings-list { border-top-color: #f0f1f7; }
  .settings-row { min-height: 72px; border-bottom-color: #f0f1f7; }
  .settings-row > .ph:first-child { color: #5b61ff; }
  .settings-row:hover { background: #fafafd; }
}

@media (max-width: 430px) {
  .app-content { padding-left: 14px; padding-right: 14px; }
  .page-header h1 { font-size: 32px; }
  .outlook-hero { padding-left: 19px; padding-right: 19px; }
  .payment-row { padding-left: 11px; padding-right: 11px; }
  .payment-row .amount-cell { padding-left: 54px; }
  .payment-row .row-actions { padding-left: 54px; }
  .auth-copy h1 { font-size: 41px; }
}
