/* Butter Works CRM: polish layer for desktop + mobile (loaded after the base styles). */

/* ---------- everywhere ---------- */
html{-webkit-text-size-adjust:100%}
body{overscroll-behavior-y:none}
main{animation:none}
main.fade>*{animation:bwFade .22s ease-out both}
@keyframes bwFade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
/* hidden drawer no longer casts a shadow on the right edge */
.drawer{visibility:hidden;transition:transform .28s cubic-bezier(.2,.8,.2,1),visibility 0s linear .28s}
.drawer.open{visibility:visible;transition:transform .28s cubic-bezier(.2,.8,.2,1),visibility 0s}
.overlay{backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}
.btn{min-height:38px}
.btn:active{transform:scale(.98)}
:focus-visible{outline:2px solid var(--gold,#a8790f);outline-offset:2px}
/* tidy scrollbars on desktop */
*{scrollbar-width:thin;scrollbar-color:#d6cdb9 transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:#d6cdb9;border-radius:10px;border:2px solid transparent;background-clip:padding-box}
::-webkit-scrollbar-track{background:transparent}
/* sidebar scrolls if the screen is short */
.side{overflow-y:auto}
/* wide tables scroll inside their own box on desktop instead of breaking the page */
main table{max-width:100%}
.tbl-wrap{overflow-x:auto;border-radius:18px}
/* the mobile bottom bar + more sheet are hidden on desktop */
.bw-tabs,.bw-more,.bw-more-bg{display:none}

/* ---------- tablet ---------- */
@media (max-width:1100px){
  main{padding:28px 26px 60px}
  .kpis{grid-template-columns:repeat(2,1fr)}
}

/* ---------- phone ---------- */
@media (max-width:860px){
  /* top strip replaced by a bottom tab bar */
  .side{display:none!important}
  main{margin:0!important;padding:18px 14px calc(96px + env(safe-area-inset-bottom))!important;max-width:100%}
  .head{align-items:flex-start;margin-bottom:18px}
  .head h1,main h1{font-size:28px!important;line-height:1.1}
  .head>div:last-child{width:100%}
  .head .btn{flex:1}

  /* no iOS zoom when tapping a field; comfortable tap targets */
  input,select,textarea{font-size:16px!important}
  .btn{min-height:44px}
  .btn-sm{min-height:38px}

  .kpis{grid-template-columns:1fr 1fr!important;gap:10px!important}
  .kpi .v{font-size:24px!important}
  .grid2,.two,.g2,.g3,.ed-wrap,.split{grid-template-columns:1fr!important}
  .card{border-radius:16px}

  /* tables become stacked cards (labels come from the column headers) */
  main table,main table tbody,main table tr,main table td{display:block;width:100%}
  main table{border:0!important;background:transparent!important;overflow:visible!important}
  main table thead{display:none}
  main table tr{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:12px 14px;margin-bottom:10px;position:relative;display:grid!important;grid-template-columns:1fr 1fr;gap:2px 14px}
  main table td:first-child,main table td:has(input[type=checkbox]) + td{grid-column:1/-1}
  main table tr td:has(.btn):last-child{grid-column:1/-1}
  main table tr:has(td[colspan]){display:block!important}
  main table tr.click:active{transform:scale(.99)}
  main table td{border:0!important;padding:5px 0!important;text-align:left!important;white-space:normal!important}
  main table td[data-label]:not([data-label=""])::before{content:attr(data-label);display:block;font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);margin-bottom:1px}
  main table td:first-child::before{display:none!important}
  main table td:empty{display:none}
  main table td .btn{width:auto}
  main table td input[type=checkbox]{width:22px;height:22px}
  main table tr td:first-child:has(input[type=checkbox]){position:absolute;right:12px;top:12px;width:auto;padding:0!important}

  /* pipeline: swipe one column at a time */
  .board{grid-template-columns:repeat(6,82vw)!important;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;margin:0 -14px;padding:0 14px 10px}
  .board .col{scroll-snap-align:start}

  /* side panels open full screen */
  .drawer{width:100%!important;padding:20px 16px calc(28px + env(safe-area-inset-bottom))!important;border-radius:0}
  .drawer .actions{position:sticky;bottom:calc(-28px - env(safe-area-inset-bottom));background:var(--card);padding:12px 0;margin-top:16px;z-index:2;border-top:1px solid var(--line)}
  .drawer .actions .btn{flex:1}
  .toast{bottom:calc(92px + env(safe-area-inset-bottom))!important}

  /* bottom tab bar */
  .bw-tabs{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;z-index:45;background:rgba(11,12,15,.96);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);padding:6px 6px calc(6px + env(safe-area-inset-bottom));border-top:1px solid rgba(255,255,255,.06)}
  .bw-tabs button{all:unset;display:flex;flex-direction:column;align-items:center;gap:3px;padding:7px 2px;border-radius:12px;color:#8d93a0;font-size:10.5px;font-weight:600;cursor:pointer;-webkit-tap-highlight-color:transparent;position:relative}
  .bw-tabs button svg{width:22px;height:22px}
  .bw-tabs button.on{color:#fff}
  .bw-tabs button.on svg{color:var(--butter,#f3c34f)}
  .bw-tabs button.on::after{content:"";position:absolute;top:0;width:22px;height:3px;border-radius:0 0 3px 3px;background:var(--butter,#f3c34f)}
  .bw-tabs .dot{position:absolute;top:4px;right:calc(50% - 18px);min-width:16px;height:16px;border-radius:99px;background:#ef4444;color:#fff;font-size:10px;display:grid;place-items:center;padding:0 4px}

  /* "More" sheet */
  .bw-more-bg{display:block;position:fixed;inset:0;background:rgba(11,12,15,.4);z-index:46;opacity:0;pointer-events:none;transition:opacity .2s}
  .bw-more{display:block;position:fixed;left:0;right:0;bottom:0;z-index:47;background:var(--card);border-radius:22px 22px 0 0;padding:10px 14px calc(18px + env(safe-area-inset-bottom));transform:translateY(105%);transition:transform .28s cubic-bezier(.2,.8,.2,1);box-shadow:0 -20px 50px -20px rgba(0,0,0,.35)}
  .bw-more.open{transform:none}.bw-more-bg.open{opacity:1;pointer-events:auto}
  .bw-more .grab{width:40px;height:5px;border-radius:99px;background:var(--line);margin:4px auto 12px}
  .bw-more .grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
  .bw-more button{all:unset;display:flex;flex-direction:column;align-items:center;gap:6px;padding:14px 6px;border-radius:14px;background:var(--bg,#f7f3ea);font-size:12.5px;font-weight:600;text-align:center;cursor:pointer;color:var(--text)}
  .bw-more button svg{width:22px;height:22px}
  .bw-more button.on{background:var(--ink,#0b0c0f);color:#fff}
}
@media (prefers-reduced-motion:reduce){main.fade>*{animation:none}.bw-more,.drawer{transition:none}}

.bw-tabs .dot[hidden]{display:none!important}

/* close button inside side panels */
.bw-x{position:sticky;top:0;float:right;z-index:5;margin:-6px -6px 0 10px;width:38px;height:38px;border-radius:50%;border:1px solid var(--line);background:var(--card);color:var(--text);display:grid;place-items:center;cursor:pointer;box-shadow:0 6px 16px -8px rgba(0,0,0,.25)}
.bw-x:hover{background:#fff}
