/* Shared web app: compact navigation on phones, full workspace from 1024px.
   Keep this after the prototype styles so desktop overrides stay in one place. */
.desktop-header,
.desktop-sidebar { display: none; }
.home-personal { display: contents; }
.crm-scope .file-button { min-width: 0; max-width: 100%; flex-wrap: wrap; min-height: 44px; }
.crm-scope .file-button input[type="file"] { width: 200px; max-width: 100%; min-width: 0; font-size: 12px; }

/* Tablets use the available screen, with readable form widths. */
@media (min-width: 600px) and (max-width: 1023px) {
  .screen > .in { max-width: 760px; margin-inline: auto; }
  .crm-tools { flex-wrap: wrap; }
}

@media (min-width: 1024px) {
  body { background: var(--bg); }
  .stage { padding: 0; }
  .phone {
    width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .phone[data-mode="admin"] { grid-template-columns: 224px minmax(0, 1fr); }
  .proto, #ahead, .tabbar { display: none; }
  .desktop-header {
    grid-column: 1 / -1; grid-row: 1;
    display: flex; align-items: center; gap: 24px;
    min-height: 80px; padding: 12px 32px;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .desktop-brand { flex: none; border-radius: 8px; }
  .desktop-brand .logo { width: 120px; color: var(--primary); }
  .desktop-client-nav { display: flex; justify-content: center; gap: 4px; flex: 1; }
  .desktop-client-nav button {
    display: flex; align-items: center; gap: 6px; position: relative;
    min-height: 44px; padding: 10px 14px; border-radius: 12px;
    font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap;
  }
  .desktop-client-nav svg { display: none; }
  .desktop-client-nav button[aria-current="page"] { background: var(--mist); color: var(--primary); }
  .desktop-client-nav .badge {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px;
    padding-inline: 5px; border-radius: 10px; font-size: 11px;
    background: var(--primary); color: #fff;
  }
  .desktop-header-actions { display: flex; align-items: center; gap: 20px; margin-left: auto; }
  .desktop-action, .desktop-account {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; text-decoration: none; font-size: 14px; font-weight: 500;
    color: var(--primary); white-space: nowrap;
  }
  .desktop-action { border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
  .desktop-account { color: var(--muted); }
  .desktop-workspace-title { padding-left: 24px; border-left: 1px solid var(--line); font-weight: 500; }
  .desktop-header svg.icon, .desktop-sidebar svg { width: 22px; height: 22px; flex: none; }
  .phone[data-mode="admin"] .desktop-sidebar {
    display: flex; flex-direction: column; gap: 24px;
    grid-column: 1; grid-row: 2 / 4; min-height: 0; overflow-y: auto;
    padding: 24px 12px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .desktop-sidebar-main, .desktop-sidebar-footer { display: grid; gap: 4px; }
  .desktop-sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
  .desktop-sidebar button, .desktop-sidebar a {
    display: flex; align-items: center; gap: 12px; min-height: 44px;
    padding: 10px 14px; color: var(--muted); font-size: 14px; font-weight: 500;
    text-decoration: none; text-align: left; border-radius: 12px;
  }
  .desktop-sidebar [aria-current="page"] { background: var(--mist); color: var(--primary); }
  .desktop-sidebar button:hover, .desktop-sidebar a:hover,
  .desktop-client-nav button:hover, .desktop-action:hover { background: var(--mist); color: var(--primary-dark); }
  .screen { grid-column: 1; grid-row: 2; min-width: 0; padding: 32px; }
  .phone[data-mode="admin"] .screen { grid-column: 2; }
  .screen > .in { width: 100%; max-width: 880px; margin-inline: auto; gap: 24px; }
  .phone[data-view="home"] .screen > .in { max-width: 1200px; gap: 32px; }
  .phone[data-mode="admin"] .screen > .in { max-width: 1600px; }
  .h1 { font-size: 28px; }
  .cta-bar { grid-column: 1; grid-row: 3; padding: 16px max(32px, calc((100% - 880px) / 2)); }
  .phone[data-mode="admin"] .cta-bar { grid-column: 2; padding-inline: 32px; }
  .cta-bar > .btn { max-width: 440px; margin-left: auto; }
  .cta-bar[hidden] { display: none; }
  .storage-error { grid-column: 1 / -1; }

  /* A wide service catalogue keeps the original blue hero and product imagery. */
  .hero {
    margin: 0; padding: 36px 40px; border-radius: 24px;
    grid-template-columns: minmax(220px, .8fr) minmax(0, 1.4fr);
    gap: 40px; align-items: center; justify-items: start; text-align: left;
  }
  .hero .brand { justify-items: start; gap: 12px; }
  .hero::before { display: none; }
  .hero .logo { width: 180px; }
  .hero .lead { justify-items: start; max-width: 100%; }
  .hero .h1 { font-size: clamp(30px, 2.8vw, 42px); line-height: 1.25; max-width: 22ch; }
  .home-account { margin: 0; padding: 0; border-radius: 0; gap: 32px; }
  .home-account::before, .home-account::after { display: none; }
  .home-catalog { gap: 20px; }
  .home-catalog > .h2 { max-width: none; font-size: 28px; margin: 0; }
  .home-services { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .home-service { padding: 20px; border-radius: 20px; }
  .service-tile-art { height: 180px; aspect-ratio: auto; margin: 16px 0; }
  .home-service .service-tile-heading b { font-size: 22px; }
  .home-service .small { min-height: 32px; font-size: 17px; }
  .home-personal {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start; gap: 24px; padding-top: 28px; border-top: 1px solid var(--line);
  }
  .home-greeting, .home-support { grid-column: 1 / -1; }
  .home-greeting { max-width: 560px; }
  .home-account .bonus-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); }
  .home-empty, .active-order { margin: 0; }
  .home-empty .btn { width: auto; justify-self: start; }
  .home-support { justify-self: start; }

  /* CRM has a permanent role-aware navigation and uses real desktop tables. */
  .crm-tools { display: none; }
  .crm-scope h1 { font-size: 28px; }
  .crm-scope .page-heading { margin-bottom: 24px; }
  .crm-scope .summary-line { font-size: 14px; gap: 20px; margin-bottom: 24px; }
  .crm-scope .desktop-only:not([hidden]) { display: inline-flex; }
  .crm-scope .mobile-only { display: none; }
  .crm-scope .toolbar { padding: 16px 20px; gap: 12px; }
  .crm-scope .search-box { flex: 1 1 240px; max-width: 460px; }
  .crm-scope .toolbar-spacer { display: block; flex: 1; }
  .crm-scope .results-count { font-size: 13px; }
  .crm-scope .pipeline-tabs { padding-inline: 12px; }
  .crm-scope .pipeline-tab { font-size: 14px; padding-inline: 16px; gap: 8px; }
  .crm-scope .advanced-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 20px; }
  .crm-scope .request-list { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 20px; gap: 16px; }
  .crm-scope .request-card { gap: 12px; padding: 20px; }
  .crm-scope .request-card .muted { font-size: 13px; }
  .crm-scope .production-grid, .crm-scope .task-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .crm-scope .two-col, .crm-scope .report-grid, .crm-scope .form-grid,
  .crm-scope .rules-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-scope .settings-layout { grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr); }
  .crm-scope .stats-grid, .crm-scope .finance-strip.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .crm-scope .finance-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-scope .report-order { grid-template-columns: minmax(0, 1fr) auto auto; }
  .crm-scope .report-order strong { grid-column: auto; text-align: right; }
  .crm-scope .report-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .crm-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-scope .table-wrap { overflow-x: auto; }
  .crm-scope .data-table { display: table; min-width: 700px; border-collapse: collapse; }
  .crm-scope .data-table thead {
    display: table-header-group; position: static; width: auto; height: auto;
    clip: auto; overflow: visible; white-space: normal;
  }
  .crm-scope .data-table tbody { display: table-row-group; padding: 0; }
  .crm-scope .data-table tr { display: table-row; border: 0; padding: 0; }
  .crm-scope .data-table td,
  .crm-scope .data-table td:first-child,
  .crm-scope .data-table td:last-child {
    display: table-cell; position: static; padding: 16px; border-bottom: 1px solid var(--line);
    font-size: 14px; overflow-wrap: normal;
  }
  .crm-scope .data-table th { padding: 12px 16px; font-size: 12px; color: var(--muted); background: var(--bg); }
  .crm-scope .data-table td::before { display: none; }
  .crm-scope .data-table .client-cell b { font-size: 14px; }
  .crm-scope dialog.detail-drawer {
    inset: 0 0 0 auto; margin: 0; width: min(840px, 85vw); height: 100dvh;
    border-radius: 24px 0 0 24px;
  }
  .crm-scope dialog.modal { width: min(760px, calc(100vw - 64px)); max-height: calc(100dvh - 64px); }
  .crm-scope .drawer-heading, .crm-scope .drawer-content, .crm-scope .drawer-footer,
  .crm-scope .modal-heading, .crm-scope .modal-content, .crm-scope .modal-footer { padding: 24px; }
  .crm-scope .drawer-heading h2 { font-size: 24px; }
  .crm-scope .detail-tabs { padding-inline: 24px; }
  .crm-scope .detail-tabs button { font-size: 14px; padding-inline: 16px; }
  .crm-scope .detail-grid { gap: 16px; }
  .crm-scope .detail-block { padding: 16px; }
  .overlay { align-items: center; justify-content: center; padding: 32px; }
  .sheet { max-width: 600px; border-radius: 24px; padding: 32px; max-height: 100%; }
  .toast { max-width: 560px; margin-inline: auto; bottom: 24px; }
  .phone.has-cta .toast { bottom: 100px; }

  /* Mouse/keyboard users need visible scroll affordances. */
  .screen, .desktop-sidebar, .crm-scope .table-wrap,
  .crm-scope .drawer-content, .crm-scope .modal-content, .sheet {
    scrollbar-width: thin; scrollbar-color: #a7b3cd transparent;
  }
  .screen::-webkit-scrollbar, .desktop-sidebar::-webkit-scrollbar,
  .crm-scope .table-wrap::-webkit-scrollbar, .crm-scope .drawer-content::-webkit-scrollbar,
  .crm-scope .modal-content::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: block; width: 8px; height: 8px; }
  .screen::-webkit-scrollbar-thumb, .desktop-sidebar::-webkit-scrollbar-thumb,
  .crm-scope .table-wrap::-webkit-scrollbar-thumb, .crm-scope .drawer-content::-webkit-scrollbar-thumb,
  .crm-scope .modal-content::-webkit-scrollbar-thumb, .sheet::-webkit-scrollbar-thumb { background: #a7b3cd; border-radius: 8px; }
}

@media (min-width: 1024px) and (max-width: 1199px) {
  .desktop-header { padding-inline: 24px; gap: 16px; }
  .desktop-client-nav button { padding-inline: 10px; }
  .screen { padding: 24px; }
  .hero { padding: 32px; gap: 24px; }
  .home-service { padding: 16px; }
  .service-tile-art { height: 150px; }
}

@media print {
  .desktop-header, .desktop-sidebar { display: none !important; }
}
