/* ============================================================
   CEDAR FINANCE — DESKTOP LAYOUT
   Activates at ≥1024px only. Zero effect on mobile/PWA.
   ============================================================ */

@media (min-width: 1024px) {

  /* ── Unlock the phone constraints on html/body ── */
  html, body {
    position: static !important;
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  /* ── App shell: row layout, full width ── */
  .app {
    max-width: none !important;
    width: 100% !important;
    flex-direction: row !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    margin: 0 !important;
  }

  /* ── Hide phone bottom nav & FAB ── */
  .bnav, #bottomNav, nav.bnav { display: none !important; }
  .fab { display: none !important; }

  /* ── Sidebar ── */
  .desk-sidebar {
    width: 220px;
    min-width: 220px;
    height: 100%;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex !important;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    z-index: 20;
  }
  .desk-sidebar::-webkit-scrollbar { display: none; }

  .dsb-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    flex-shrink: 0;
  }
  .dsb-logo img {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
  }
  .dsb-logo span {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
  }

  .dsb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: 8px;
    margin: 1px 8px;
    cursor: pointer;
    color: var(--ink3);
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    font-family: var(--font);
    text-align: left;
    transition: background 0.12s, color 0.12s;
    width: calc(100% - 16px);
    flex-shrink: 0;
    text-decoration: none;
  }
  .dsb-item:hover {
    background: var(--bg3);
    color: var(--ink);
  }
  .dsb-item.active {
    background: var(--accent-bg);
    color: var(--accent);
  }
  .dsb-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    flex-shrink: 0;
  }
  .dsb-item.active svg { stroke-width: 2.2; }

  .dsb-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 6px 0;
    flex-shrink: 0;
  }

  /* ── Main area: topbar + scroll ── */
  .desk-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  /* ── Topbar ── */
  .tb {
    padding: 10px 20px !important;
    flex-shrink: 0;
  }
  .tb-name {
    max-width: none !important;
    font-size: 13px !important;
  }

  /* ── Desktop "+ New" button in topbar ── */
  .desk-add-btn {
    display: none; /* default; router overrides with inline style */
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
    order: -1; /* sits before the role badge */
  }
  .desk-add-btn:hover { opacity: 0.88; }

  /* ── Scroll area fills remaining height ── */
  .scroll {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: 32px !important;
    max-width: none !important;
    width: 100% !important;
  }

  /* ── More sheet not needed on desktop ── */
  .sheet, .overlay { display: none !important; }

  /* ── Page container padding ── */
  #pageContainer {
    padding: 0 24px;
    max-width: 1200px;
  }

  /* ── Toast repositioned ── */
  .toast {
    left: calc(220px + 50%) !important;
  }

  /* ── Modal: handled imperatively in ui.js openModal() for desktop ── */
  .m-body { padding: 16px 20px !important; }
  .m-hd { padding: 14px 20px !important; }

}

/* ── Invoice / document preview: scale up for desktop modal ── */
@media (min-width: 1024px) {
  /* The invoice paper is rendered at width:595px scale:0.62 for phone.
     On desktop the modal is 640px wide with 40px padding = 600px inner.
     We scale to fill that space: 600/595 ≈ 1.0, so reset to near full size. */
  .m-body [style*="transform:scale(0.62)"],
  .m-body [style*="transform: scale(0.62)"] {
    transform: scale(0.95) !important;
    transform-origin: top left !important;
  }
  /* Expand the clipping container to match the new scale */
  .m-body [style*="height:530px"],
  .m-body [style*="height: 530px"] {
    height: 820px !important;
  }
}
