@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child { grid-column: span 2; }
  .wline { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-right: 56px; }
  .wline > .field:nth-child(1) { grid-column: span 3; }
  .wline > .field:nth-child(6) { grid-column: span 2; }
  .wline > .w-del { position: absolute; right: 10px; top: 34px; }
  .hide-md { display: none; }
}
@media (max-width: 1280px) {
  .user-meta, .user-btn > svg:last-child { display: none; }
}
@media (max-width: 1080px) {
  .grid-2, .grid-2-1, .grid-1-2 { grid-template-columns: minmax(0, 1fr); }
  .weigh-layout, .settle-layout, .ch-grid, .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .weigh-summary { position: static; }
  .calc-card { position: static; }
  .settings-nav { grid-auto-flow: column; overflow-x: auto; }
  .pick-list { max-height: 320px; }
  .book-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: min(300px, 86vw) !important; box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(12, 28, 24, .45); }
  .sidebar .sb-close { display: inline-grid; }
  .sb-collapse { display: none !important; }
  .main, body.sb-collapsed .main { margin-left: 0; }
  body.sb-collapsed .brand-text, body.sb-collapsed .nav-item span, body.sb-collapsed .nav-group-head span, body.sb-collapsed .demo-note div { display: initial; }
  body.sb-collapsed .nav-item { justify-content: flex-start; padding: 9px 11px; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; gap: 8px; }
  .user-meta, .user-btn > svg:last-child { display: none; }
  .gsearch kbd { display: none; }
  .view { padding: 18px 16px 32px; }
}
@media (max-width: 760px) {
  .demo-pill span, .fy-select > svg { display: none; }
  .demo-pill { padding: 4px 7px; }
  .kpi-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; flex-direction: column; }
  .kpi-ico { width: 34px; height: 34px; border-radius: 10px; }
  .kpi-value { font-size: 19px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 > :last-child { grid-column: auto; }
  .weigh-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .weigh-top > .field:first-child { grid-column: span 2; }
  .wline { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-right: 12px; }
  .wline > .field:nth-child(1) { grid-column: span 2; padding-right: 46px; }
  .wline > .field:nth-child(6) { grid-column: span 2; }
  .wline > .w-del { right: 10px; top: 34px; }
  .dash-hero { padding: 18px; }
  .dash-hero h1 { font-size: 22px; }
  .hero-side { align-items: flex-start; }
  .hero-stats { gap: 14px; flex-wrap: wrap; }
  h1 { font-size: 22px; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 94vh; border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: none !important; }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .spacer { display: none; }
  .tv-head { flex-wrap: wrap; }
  .tv-clock { margin-left: 0; text-align: left; width: 100%; }
  .pl { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: 120px 1fr; }
  .chart-card .chart-box { height: 230px; }
  .dt-search { max-width: none; flex-basis: 100%; }
  .dt-dates { flex-basis: 100%; }
  .dt-dates .input { flex: 1; width: auto; }
  .task-grid { grid-template-columns: minmax(0, 1fr); }
  .book-sum { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 0 16px 8px; }
  #toast-root { left: 16px; right: 16px; top: 70px; max-width: none; }
}
/* Tables become cards on phones */
@media (max-width: 640px) {
  .lang-switch button { padding: 5px 7px; }
  .tb-right > .fy-select { display: none; }
  .fy-mobile { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 10px; background: rgba(255,255,255,.07); color: #CFE2DA; }
  .fy-mobile select { flex: 1; background: transparent; border: 0; color: #fff; font-weight: 650; font-family: var(--font-data); }
  .fy-mobile select option { color: #111; }
  .topbar .gsearch-toggle { display: inline-grid; }
  .gsearch { display: none; min-width: 0; }
  .gsearch.open { display: flex; position: absolute; left: 8px; right: 8px; top: 12px; max-width: none; z-index: 5; }
  .gsearch.open .input { box-shadow: var(--shadow-lg); }
  .dt-dates { width: 100%; min-width: 0; }
  .dt-dates .input { min-width: 0; width: 0; flex: 1; }
  .demo-pill { display: none; }
  .dt .table thead { display: none; }
  .dt .table, .dt .table tbody, .dt .table tr, .dt .table td { display: block; width: 100%; }
  .dt .table tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .dt .table td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; text-align: right !important; }
  .dt .table td::before { content: attr(data-label); font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: left; flex: none; max-width: 45%; }
  .dt .table td[data-label=""]::before { display: none; }
  .dt .table td > * { min-width: 0; }
  .dt .table .cell-sub { max-width: 180px; margin-left: auto; }
  .dt .table td:has(.row-actions) { justify-content: flex-end; }
  .dt .table tfoot { display: block; }
  .dt .table tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px; }
  .dt .table tfoot td { display: inline; width: auto; padding: 0; }
  .dt .table tfoot td:empty { display: none; }
  .dt .table td[colspan] { justify-content: center; }
  .empty-row td::before { display: none; }
  .gsearch .input { font-size: 13px; }
  .user-btn { padding: 2px; }
  .tb-right { gap: 6px; }
  .card-list { padding: 12px; grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .demo-pill { display: none; }
  .bell { width: 34px; }
  .topbar { padding: 0 10px; }
}
