/* KotbiBudget — adaptation iPhone, portrait et paysage. */
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
img,video { max-width:100%; height:auto; }
@media (max-width: 932px) and (pointer:coarse), (max-width:650px) {
  :root { --iphone-gutter:16px; }
  body, .app-shell, .auth-layout { min-height:100vh; min-height:100dvh; }
  .main-wrap, .page-content, .panel, .page-title-row>div { min-width:0; }
  .app-body .sidebar {
    position:fixed; left:0; top:0; bottom:0; width:min(320px,86vw); flex-basis:auto;
    height:100vh; height:100dvh; z-index:60; overflow-y:auto; overscroll-behavior:contain;
    padding:calc(22px + env(safe-area-inset-top,0px)) 18px calc(18px + env(safe-area-inset-bottom,0px)) calc(18px + env(safe-area-inset-left,0px));
    transform:translateX(-105%); transition:transform .2s ease;
  }
  .app-body .sidebar.is-open { transform:translateX(0); }
  .sidebar-brand { margin-bottom:24px; }
  .sidebar-family { margin-bottom:24px; }
  .sidebar-tip { margin-top:20px; }
  .sidebar-bottom { flex-shrink:0; }
  .app-body .mobile-overlay.is-open { display:block;position:fixed;inset:0;z-index:59;background:#10192ea8; }
  body.iphone-nav-open { position:fixed; width:100%; overflow:hidden; }
  .iphone-menu-close { display:grid; place-items:center; margin:0 0 16px auto; width:44px; min-height:44px; border:1px solid #ffffff30; border-radius:12px; background:#ffffff12; color:white; font:24px system-ui; }
  .app-body .menu-toggle { display:grid;place-items:center;width:44px;height:44px;flex:0 0 44px; margin-right:10px;border:0;border-radius:12px;background:#f1f2fb;color:#536181;font-size:21px; }
  .app-body .topbar { height:auto; min-height:68px; padding:calc(10px + env(safe-area-inset-top,0px)) calc(16px + env(safe-area-inset-right,0px)) 10px calc(16px + env(safe-area-inset-left,0px)); gap:0; }
  .breadcrumb { flex:1; min-width:0; font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
  .breadcrumb span { padding:0 5px; }
  .topbar-right { gap:8px; flex-shrink:0; margin-left:8px; }
  .topbar-date { display:none; }
  .topbar-notifications { width:44px; height:44px; }
  .top-avatar { width:32px; height:32px; }
  .page-content { padding:22px calc(var(--iphone-gutter) + env(safe-area-inset-right,0px)) calc(18px + env(safe-area-inset-bottom,0px)) calc(var(--iphone-gutter) + env(safe-area-inset-left,0px)); }
  .page-title-row { gap:12px; flex-wrap:wrap; margin-bottom:22px; }
  .page-title-row h1 { font-size:clamp(25px,6.5vw,30px); line-height:1.25; overflow-wrap:anywhere; }
  .subtitle { font-size:14px; line-height:1.65; }
  .btn, .btn-small, .nav-item, .month-nav a, .logout-link, .show-password, .stats-year-switch a { min-height:44px; }
  .btn { white-space:normal; line-height:1.4; overflow-wrap:anywhere; }
  .field input, .field select, .field textarea, .sub-edit-form input, input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea { font-size:16px; max-width:100%; }
  .field input, .field select { min-height:48px; }
  .field textarea, textarea { width:100%; min-height:100px; padding:12px; border:1px solid #dfe4ee; border-radius:10px; font-family:inherit; }
  input[type=date], input[type=month], input[type=datetime-local] { min-width:0; width:100%; -webkit-appearance:none; appearance:none; }
  .show-password { right:5px; min-width:44px; }
  .month-nav { width:100%; justify-content:space-between; }
  .month-nav a { min-width:44px; }
  .dashboard-welcome, .operations-toolbar { flex-direction:column; align-items:stretch; gap:14px; }
  .dashboard-welcome .month-nav, .operations-toolbar .month-nav { align-self:stretch; }
  .kpi-grid, .stats-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
  .kpi-card { min-height:146px; padding:16px 12px; }
  .kpi-value { font-size:clamp(19px,5vw,24px); overflow-wrap:anywhere; }
  .kpi-top, .kpi-bottom { font-size:11px; line-height:1.5; }
  .stats-kpi strong { font-size:clamp(18px,4.8vw,23px); }
  .panel { padding:18px 14px; border-radius:18px; }
  .panel-heading { flex-wrap:wrap; align-items:flex-start; }
  .panel-heading h2 { font-size:17px; }
  .quick-actions .action-buttons { display:grid; grid-template-columns:1fr; width:100%; }
  .quick-actions .btn { width:100%; font-size:14px; }
  .dashboard-panels, .family-panels, .stats-main-grid { grid-template-columns:minmax(0,1fr); }
  .form-grid-2, .form-grid-3 { grid-template-columns:minmax(0,1fr); }
  .filter-toolbar { align-items:stretch; }
  .filter-toolbar .field, .filter-toolbar .field-small { flex:1 1 100%; min-width:0; }
  .filter-toolbar>.btn { width:100%; }
  .table-scroll { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; border-radius:10px; }
  .table-scroll:focus-visible { outline:3px solid #8589ec; outline-offset:3px; }
  .table-scroll table { min-width:620px; }
  .table-scroll td, .table-scroll th { padding-top:14px; padding-bottom:14px; }
  .stats-category-line { flex-wrap:wrap; gap:4px 10px; }
  .stats-alert-item { flex-wrap:wrap; }
  .stats-alert-content { flex-basis:60%; }
  .stats-alert-delta { margin-left:auto; }
  .stats-year-chart { height:230px; }
  .stats-year-month-name { font-size:10px; }
  .app-body .loan-grid, .app-body .loan-form-grid { grid-template-columns:minmax(0,1fr)!important; }
  .app-body .loan-form-grid>* { grid-column:auto!important; min-width:0; }
  .app-body .loan-card { min-width:0; padding:18px 14px; }
  .app-body .loan-card-head { flex-wrap:wrap; gap:10px; }
  .app-body .loan-card-title { min-width:0; flex:1; }
  .app-body .loan-card-title h3 { overflow-wrap:anywhere; }
  .app-body .loan-card-numbers { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
  .app-body .loan-card-numbers .loan-num-remain { grid-column:1/-1; }
  .app-body .loan-card-numbers strong { overflow-wrap:anywhere; }
  .app-body .loan-actions, .app-body .loan-card-bottom { display:flex;flex-direction:column;align-items:stretch;gap:12px; }
  .app-body .loan-actions .btn { width:100%; }
  .app-body .loan-card-bottom>div { display:flex;flex-wrap:wrap;gap:12px;align-items:center; }
  .app-body .loan-remove-payment, .app-body .loan-delete-btn { min-height:44px;min-width:44px; }
  .auth-layout { display:block; }
  .auth-showcase { display:none; }
  .auth-form-side { min-height:100vh;min-height:100dvh; padding:calc(24px + env(safe-area-inset-top,0px)) calc(16px + env(safe-area-inset-right,0px)) calc(24px + env(safe-area-inset-bottom,0px)) calc(16px + env(safe-area-inset-left,0px)); background:#f5f7fc; align-items:center; }
  .auth-card { padding:26px 20px; border-radius:22px; max-width:500px; background:#fff; }
  .auth-mobile-brand { display:flex;gap:8px;align-items:center; }
  .auth-mobile-brand .brand-name { color:#253451; }
  .auth-mobile-brand .brand-accent { color:#6f6fdd; }
  .auth-assurance { margin-top:28px; }
  .choice-tabs label span, .type-toggle label span { min-height:48px; font-size:13px!important; padding:8px; }
  .notice { overflow-wrap:anywhere; line-height:1.6; }
  .invitation-code strong { overflow-wrap:anywhere; }
  .footer { padding-bottom:12px; line-height:1.7; }
}
.iphone-menu-close { -webkit-tap-highlight-color:transparent; }
@media (min-width:933px), (min-width:651px) and (pointer:fine) { .iphone-menu-close { display:none; } }
@media (max-width:380px) { .kpi-grid { grid-template-columns:1fr; } }
@media (prefers-reduced-motion:reduce) { .app-body .sidebar { transition:none; } }
