/* Kite Bill on a computer: HD (1366x768, 1280x720) and HD+ (1600x900) screens and small laptops.
 * Loaded LAST on billing/admin (website, Windows / Mac / Linux apps). Phones (820px and less) are not touched.
 * Goal: the work fits the screen without scrolling the page: less empty space, one-line table headings, the bill's
 * lines visible as soon as the invoice opens, the POS header on one row, the Save bar always on screen.
 * Test: scripts/tests/browser/billing-hd-layout.js (every menu page and the main forms at 1366x768 and 1280x720). */

/* ---------------------------------------------------------------- every computer screen */
@media (min-width: 821px) {
  /* a table heading never runs into the next one: it wraps to two lines inside its own column */
  .data-table th { white-space: normal !important; line-height: 1.25 !important; vertical-align: bottom !important; overflow-wrap: anywhere; }
  /* toasts: at most three, never over the Save bar */
  #toastWrap { max-height: 50vh; overflow: hidden; }
}

/* ---------------------------------------------------------------- HD / HD+ (up to 900px tall, or up to 1440px wide) */
@media (min-width: 821px) and (max-height: 900px), (min-width: 821px) and (max-width: 1440px) {
  /* page: less empty space above and around the work */
  html body .mbb-main { padding: 12px 20px 16px !important; }
  html body .mbb-main .tab-pane > .page-header, html body .mbb-main .tab-pane > div:first-child { margin-top: 0 !important; }

  /* left menu: smaller rows so more of it fits on a short screen */
  html body #mbbSidebar .mbb-nav-item { min-height: 32px !important; padding-top: 2px !important; padding-bottom: 2px !important; }
  html body #mbbSidebar .mbb-nav-section, html body #mbbSidebar .mbb-nav-label { margin-top: 8px !important; margin-bottom: 2px !important; }

  /* dashboard cards: tighter */
  /* the four main cards always on one row; the page title closer to them */
  html body #pane-dashboard .metrics-row { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: .7rem !important; margin-bottom: .8rem !important; }
  html body #pane-dashboard .metric-card { padding: .85rem 1rem !important; min-width: 0 !important; }
  html body #pane-dashboard .page-top { margin-bottom: .7rem !important; }
  /* the six money tiles on one row (Net profit was left alone on a second row) */
  html body #kbProfit { grid-template-columns: repeat(auto-fit, minmax(9.2rem, 1fr)) !important; gap: .6rem !important; margin-bottom: .9rem !important; }
  html body #kbProfit > div { padding: .7rem .85rem !important; }
  html body #pane-dashboard .card, html body #pane-dashboard .metric-card { padding: 14px 16px !important; }

  /* ---- forms that open as a panel (sales invoice, purchase, item) and large forms */
  html body .kbpn-ov .modal-box-header, html body .kux-full .modal-box-header { padding: 8px 18px !important; min-height: 0 !important; }
  html body .kbpn-ov .modal-box-header h3, html body .kux-full .modal-box-header h3 { font-size: 1.05rem !important; }
  html body .kbpn-ov .modal-box-header button.kbpn-btn { height: 32px !important; }
  html body .kbpn-ov .modal-box-header .kbpn-tools > button:not(.kbpn-btn) { width: 32px !important; height: 32px !important; }
  html body .kbpn-ov .modal-box-body, html body .kux-full .modal-box-body { padding: 12px 18px !important; }
  html body .kbpn-ov .modal-box-footer, html body .kux-full .modal-box-footer { padding: 8px 18px !important; }
  html body .kbpn-ov .modal-box-footer .btn, html body .kux-full .modal-box-footer .btn { min-height: 36px !important; padding-top: 6px !important; padding-bottom: 6px !important; }

  /* ---- new sales invoice: customer + bill details in about 200px, so the bill's lines show at once */
  html body #modalInvoice .inv-meta-grid { padding: 10px 14px !important; gap: 14px !important; margin-bottom: 10px !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) !important; }
  html body #modalInvoice .inv-meta-grid > div:last-child { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px 10px !important; align-content: start; }
  html body #modalInvoice .form-label, html body #modalPurchase .form-label { margin-bottom: 3px !important; font-size: .74rem !important; }
  html body #modalInvoice .form-input, html body #modalInvoice .form-select, html body #modalPurchase .form-input, html body #modalPurchase .form-select { min-height: 34px !important; padding-top: 5px !important; padding-bottom: 5px !important; font-size: .86rem !important; }
  html body #modalInvoice textarea.form-textarea { min-height: 0 !important; }
  html body #modalInvoice #invPartySearchInput { height: 40px !important; min-height: 40px !important; }
  html body #modalInvoice #invShippingAddressSection { margin-top: 6px !important; padding-top: 6px !important; }
  html body #modalInvoice .inv-quick-product-box { padding: 8px 10px !important; margin-bottom: 8px !important; }
  html body #modalInvoice .inv-quick-product-box .btn { min-height: 36px !important; padding-top: 6px !important; padding-bottom: 6px !important; }
  html body #modalInvoice .kb-opts, html body #modalPurchase .kb-opts { margin: 4px 0 8px !important; gap: 8px !important; }
  html body #modalInvoice .kb-opts button, html body #modalPurchase .kb-opts button { padding-top: 6px !important; padding-bottom: 6px !important; }
  html body #modalInvoice .inv-items-table-wrap td, html body #modalPurchase td { padding-top: 4px !important; padding-bottom: 4px !important; }

  /* ---- purchase: the "read the supplier's bill" strip on one short row */
  html body #modalPurchase .kbs-bar { padding: 8px 12px !important; margin-bottom: 10px !important; }
  html body #modalPurchase .kbs-bar p, html body #modalPurchase .kbs-bar small { display: none !important; }

  /* ---- add customer / supplier: the details get the room, the preview card is narrower */
  html body #kap .bd { grid-template-columns: minmax(0, 1fr) 15rem !important; gap: .9rem !important; padding: .8rem 1rem !important; }
  html body #kap .r3 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) !important; }
  html body #kap input, html body #kap select { font-size: .9rem !important; min-height: 38px !important; }
  html body #kap .seg button { padding-top: 8px !important; padding-bottom: 8px !important; font-size: .95rem !important; }

  /* ---- POS (Kite Sales Panel): the header on one row, more room for the cart */
  html body #pane-pos .ksp-bar { flex-wrap: wrap !important; gap: 8px !important; padding: 6px 10px !important; row-gap: 6px !important; }
  html body #pane-pos .ksp-bar-left { flex: 0 0 auto !important; gap: 8px !important; }
  html body #pane-pos .ksp-bar-title { white-space: nowrap !important; font-size: 1rem !important; }
  html body #pane-pos .ksp-bar-sub { display: none !important; }
  html body #pane-pos .ksp-bar-mid { flex: 1 1 auto !important; flex-wrap: wrap; gap: 8px !important; min-width: 0; }
  html body #pane-pos .ksp-bar-right { flex: 0 0 auto !important; margin-left: auto; gap: 6px !important; }
  html body #pane-pos .ksp-btn-sm, html body #pane-pos .ksp-seg-btn { white-space: nowrap !important; }
  /* the cart column and the item list were zoomed 110-130% for big screens (kite-bill-look.css): normal size on HD, so the
     cart shows its lines and the totals and pay buttons fit */
  html body .ksp-workspace .ksp-cart-col { zoom: 1 !important; }
  html body #pane-items .mbb-split-container { zoom: 1 !important; height: calc(100vh - 10rem) !important; max-height: calc(100vh - 10rem) !important; }
  html body #pane-pos .ksp-cart-footer { padding: 6px 12px !important; }
  html body #pane-pos .ksp-totals-row { font-size: .8rem !important; margin-bottom: 0 !important; }
  html body #pane-pos .ksp-totals-grand { font-size: 1.2rem !important; margin: 4px 0 6px !important; }
  html body #pane-pos .ksp-action-btn { padding: 9px 6px !important; }
}

/* ---------------------------------------------------------------- the smallest laptops (up to 1300px wide) */
@media (min-width: 821px) and (max-width: 1300px) {
  html body #pane-pos .ksp-bar-mid .ksp-seg-btn { padding-left: 8px !important; padding-right: 8px !important; font-size: .78rem !important; }
  html body #pane-pos .ksp-pill { display: none !important; }
}

/* ---------------------------------------------------------------- BACK OFFICE top bar on HD (it is also loaded there)
 * The right-hand buttons were wider than their space and spilled over the shop name ("ree GaMeshiTCadenec"). Up to
 * 1440px the less used buttons show their symbol only (the name stays as a tooltip); a long shop name ends with "…". */
@media (min-width: 821px) and (max-width: 1440px) {
  html body .top-header.kb-top { grid-template-columns: auto minmax(0, 1fr) auto !important; column-gap: 10px !important; }
  html body .top-header .kb-mid { min-width: 0 !important; overflow: hidden !important; }
  html body .top-header .kb-mid .kb-cmd { max-width: 100% !important; min-width: 0 !important; overflow: hidden !important; }
  html body .top-header #headerActiveStoreBadge { min-width: 0 !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
  html body .top-header .kb-right { min-width: 0 !important; gap: 6px !important; flex-wrap: nowrap !important; }
  html body .top-header .kb-where { display: none !important; }
  html body .top-header #kiteBillConnectPill > span:nth-child(2) { display: none !important; }
  html body .top-header .kb-btn:not(.primary) .kb-lbl { display: none !important; }
  html body .top-header #kiteHelpBtn span { display: none !important; }
  html body .top-header #boLook .bo-look-l { display: none !important; }
  html body .top-header #boLook button { padding-left: 9px !important; padding-right: 9px !important; }
}

/* Back office, Light look: typing boxes are light (kite-polish.css painted text / password boxes dark navy over it) */
html.bo-light body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.bo-light body select, html.bo-light body textarea { background: var(--card, #fff) !important; color: var(--text, #0f172a) !important; border: 1px solid var(--inner-border, #cbd5e1) !important; }

/* Back office menu: room under the last item, so the floating "Plan" button never covers it */
html body .nav-sidebar { padding-bottom: 64px !important; }

/* top bar: shown only while this computer and the server differ (kbShowMatch) — amber, small, a click opens "Check with the server" */
html body .kb-top .kb-diff{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border-radius:999px;border:1px solid rgba(245,158,11,.55);background:rgba(245,158,11,.12);color:#b45309;font:700 12px/1 Inter,system-ui,sans-serif;cursor:pointer;white-space:nowrap}
html body .kb-top .kb-diff[hidden]{display:none}
html body .kb-top .kb-diff .kb-diff-dot{width:8px;height:8px;border-radius:50%;background:#f59e0b}
html[data-theme="dark"] body .kb-top .kb-diff,body.dark-theme .kb-top .kb-diff{color:#fbbf24}
@media (max-width:1400px){html body .kb-top .kb-diff span:last-child{display:none}html body .kb-top .kb-diff{padding:0 9px}}
