/* Breventa Suite — phones & small tablets. Loaded after app.css / invoice.css. */
.topbar,.tabbar,.scrim,.side-close,.f-toggle,.m-jump{display:none}

@media (max-width:1100px){
  .split{grid-template-columns:minmax(0,1fr)!important}
  .split>aside,.split>.grid{position:static!important}
  .doc-split>aside{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;align-items:start}
  .aside-first>aside{order:-1}
  .editor.split .preview-pane{max-height:none!important;position:static}
}

@media (max-width:860px){
  /* ---- shell: header, drawer, bottom tabs ---- */
  body{-webkit-text-size-adjust:100%}
  .shell{grid-template-columns:1fr}
  .topbar{display:flex;align-items:center;gap:10px;padding:8px 12px;padding-top:max(8px,env(safe-area-inset-top));background:var(--side);color:#fff;position:sticky;top:0;z-index:30;box-shadow:0 1px 0 rgba(255,255,255,.06)}
  .topbar .tb-menu{flex:none;width:40px;height:40px;display:grid;place-items:center;border:0;border-radius:10px;background:rgba(255,255,255,.08);color:#fff;padding:0;cursor:pointer}
  .topbar svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}
  .topbar .tb-brand{flex:1;min-width:0;display:flex;align-items:center;gap:10px;color:#fff;text-decoration:none}
  .topbar .mark{flex:none;width:32px;height:32px;border-radius:8px;background:#fff;display:grid;place-items:center;overflow:hidden}
  .topbar .mark img{width:28px}
  .topbar .mark b{color:var(--brand);font:700 15px var(--f-head)}
  .topbar .tb-text{min-width:0;display:grid;line-height:1.2}
  .topbar .tb-text b{font:600 15px var(--f-head);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar .tb-text small{font-size:11.5px;color:#9fb5ca;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar .tb-me{flex:none;width:34px;height:34px;border-radius:50%;background:var(--brand);color:#fff;display:grid;place-items:center;font:600 14px var(--f-head);text-decoration:none}

  .side{position:fixed;inset:0 auto 0 0;width:min(300px,84vw);height:100%;z-index:60;transform:translateX(-100%);transition:transform .22s ease;box-shadow:none;padding-bottom:env(safe-area-inset-bottom)}
  .side.open{transform:none;box-shadow:8px 0 30px rgba(0,0,0,.25)}
  .side .brand{padding-right:56px}
  .side nav a{padding:11px 12px;font-size:14.5px}
  .side-close{display:grid;place-items:center;position:absolute;top:14px;right:12px;width:38px;height:38px;border:0;border-radius:10px;background:rgba(255,255,255,.08);color:#fff;cursor:pointer;z-index:2}
  .side-close svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round}
  .scrim{display:block;position:fixed;inset:0;background:rgba(8,20,35,.5);z-index:55}
  .scrim[hidden]{display:none}
  body.nav-open{overflow:hidden}

  .tabbar{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;position:fixed;left:0;right:0;bottom:0;z-index:35;background:#fff;border-top:1px solid var(--line);padding:4px 4px max(4px,env(safe-area-inset-bottom));box-shadow:0 -4px 16px rgba(12,42,69,.06)}
  .tabbar a,.tabbar button{display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 2px;border:0;background:none;color:var(--muted);text-decoration:none;font:600 11px var(--f-body);border-radius:10px;cursor:pointer;min-height:48px;justify-content:center}
  .tabbar svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linejoin:round;stroke-linecap:round}
  .tabbar .on{color:var(--brand)}
  .tabbar .on svg{stroke-width:2.2}
  body:has(.tabbar) .page{padding-bottom:96px}

  .auth .formside{padding:32px 20px max(32px,env(safe-area-inset-bottom));justify-content:flex-start;padding-top:12vh}

  /* ---- page ---- */
  .page{padding:16px 14px 40px}
  h1{font-size:20px}
  .page-head{flex-direction:column;align-items:stretch;gap:12px;margin-bottom:14px}
  .page-head h1{display:flex;flex-wrap:wrap;align-items:center;gap:8px;word-break:break-word}
  .page-head p{font-size:13px}
  .page-head .actions{gap:8px}
  .page-head .actions>.btn,.page-head .actions>form,.page-head .actions>a{flex:1 1 auto}
  .page-head .actions>form>.btn{width:100%}
  .btn{justify-content:center;min-height:40px;padding:9px 14px}
  .btn.sm{min-height:34px}
  .btn.link{min-height:0}
  .card-pad{padding:16px}
  .card-head{padding:12px 16px;gap:10px;flex-wrap:wrap}
  .grid{gap:12px}
  .alert{font-size:13px}

  /* inputs: 16px stops iPhone zooming in on focus */
  input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],input[type=month],input[type=search],input[type=tel],input[type=url],input[type=time],select,textarea{font-size:16px;padding:10px 12px;min-height:44px}
  input[type=file]{max-width:100%;font-size:13px}
  img{max-width:100%}
  .check{font-size:14px}
  .check input{width:20px;height:20px}

  /* ---- filters ---- */
  .filters{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:12px}
  .filters .field{min-width:0}
  .filters input[type=search]{min-width:0}
  .filters .field:has(input[type=search]),.filters .f-main{grid-column:1/-1}
  .filters>.btn{grid-column:auto}
  .filters>button.btn:only-of-type{grid-column:1/-1}
  .filters>.btn.link{grid-column:1/-1;justify-self:center}
  .filters:not(:has(.field)){grid-template-columns:minmax(0,1fr) auto}
  .filters:not(:has(.field))>.btn{grid-column:auto}
  .filters .f-toggle{display:inline-flex;order:10}
  .filters>button[type=submit],.filters>.btn.link{order:11}
  .filters:has(.f-toggle):not(.f-open)>.field:not(.f-main):not(:has(input[type=search])){display:none}
  .filters .f-toggle[aria-expanded=true]{border-color:var(--brand);color:var(--brand);background:var(--brand-50)}
  .chips{flex-wrap:nowrap;overflow-x:auto;margin:0 -14px 12px;padding:0 14px 4px;scrollbar-width:none}
  .chips::-webkit-scrollbar{display:none}
  .chip{flex:none}

  /* ---- stats ---- */
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
  .stat{padding:12px 14px}
  .stat .k{font-size:10.5px;letter-spacing:.04em}
  .stat .v{font-size:19px;word-break:break-word}
  .stat .s{font-size:11.5px}
  .bars{gap:8px}

  /* ---- editors & documents ---- */
  .m-jump{display:inline-flex;align-items:center;position:fixed;right:14px;bottom:calc(76px + env(safe-area-inset-bottom));z-index:34;background:var(--ink);color:#fff;text-decoration:none;font-weight:600;font-size:13.5px;padding:10px 16px;border-radius:24px;box-shadow:0 6px 18px rgba(0,0,0,.2);transition:opacity .2s}
  .m-jump.gone{opacity:0;pointer-events:none}
  body:not(:has(.tabbar)) .m-jump{bottom:calc(18px + env(safe-area-inset-bottom))}
  .preview-pane{scroll-margin-top:70px}
  .doc-bg{padding:10px 6px!important}
  .editor{gap:14px}
  .editor .preview-pane{padding:10px;min-height:0}
  .viewer{padding:10px;border-radius:10px}
  .line{padding:12px 10px}
  .line .row{grid-template-columns:1fr 64px 1fr;gap:6px}
  .sumbox{padding:12px}
  .smtp-row{grid-template-columns:1fr 1fr!important}
  .smtp-row>:first-child{grid-column:1/-1}
  .kv{grid-template-columns:110px minmax(0,1fr)}
  .copybox{flex-wrap:wrap}
  .copybox input{flex:1 1 200px;min-width:0}
  .perm-group .items{grid-template-columns:1fr}
  dialog.modal-d{width:100%;max-width:100%;margin:auto 0 0;border-radius:16px 16px 0 0;max-height:92vh}
  dialog.modal-d form{padding:18px 16px max(18px,env(safe-area-inset-bottom))}
  dialog.modal-d .g2{grid-template-columns:1fr}
  dialog.modal-d .actions .btn{flex:1}
}

/* ---- list tables become cards ---- */
@media (max-width:700px){
  .table-wrap{overflow:visible}
  table.list,table.list tbody{display:block;width:100%}
  table.list thead{display:none}
  table.list tbody tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 14px;padding:14px 16px;border-bottom:1px solid var(--line-2)}
  table.list tbody tr:last-child{border-bottom:0}
  table.list tbody tr:hover{background:none}
  table.list tbody tr:active{background:#f6f9fc}
  table.list td{display:block;padding:0;border:0!important;min-width:0;max-width:none!important;text-align:left!important;white-space:normal;word-break:break-word}
  table.list td::before{content:attr(data-label);display:block;font:600 10.5px var(--f-head);letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin-bottom:1px}
  table.list td:not([data-label])::before,table.list td[data-label=""]::before{display:none}
  table.list td:first-child{grid-column:1/-1;font-size:15px}
  table.list td:first-child::before{display:none}
  table.list td:empty,table.list .m-hide{display:none}
  table.list td:has(>form),table.list td:has(>.btn),table.list td:has(>.actions){grid-column:1/-1}
  table.list .num{text-align:left!important}
  /* tables without a header row (short lists inside cards) */
  table.list.no-head tbody tr{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:4px 12px}
  table.list.no-head td:first-child{flex:1 1 100%}
  table.list.no-head td::before{display:none}
  .pager{flex-direction:column;gap:8px;align-items:stretch;text-align:center}
  .pager nav{justify-content:center;flex-wrap:wrap}
}

@media print{
  .topbar,.tabbar,.scrim{display:none!important}
}
