/* NestPeople — phone layout (screens up to 768 px). Loaded on every page via
   core/partials/common_head.html. Desktop and tablets (> 768 px) are untouched. */
#np-ham, #np-bottom-nav, .np-backdrop { display: none; }

@media (max-width: 768px) {
  html body { height: 100dvh !important; overflow-x: hidden !important; -webkit-text-size-adjust: 100%; }

  /* Sidebar → slide-out drawer */
  html body aside.sidebar {
    position: fixed !important; top: 0; bottom: 0; left: 0; z-index: 1300;
    width: min(84vw, 300px) !important; height: 100dvh !important; max-height: 100dvh;
    transform: translateX(-105%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
    overflow-y: auto !important; padding-top: env(safe-area-inset-top);
  }
  html body aside.sidebar::after { display: none !important; }      /* desktop rainbow edge line */
  html body.np-nav-open aside.sidebar { transform: none; box-shadow: 16px 0 48px rgba(15,13,40,.45); }
  .np-backdrop { position: fixed; inset: 0; z-index: 1250; background: rgba(15,13,40,.45);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s; }
  body.np-nav-open .np-backdrop { display: block; opacity: 1; }

  /* Content takes the full width */
  html body .main, html body .content-wrap { width: 100% !important; min-width: 0 !important;
    max-width: 100vw !important; margin-left: 0 !important; }

  /* Hamburger (injected into each page's header) */
  #np-ham { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; margin-right: 8px; border: 1.5px solid #e6e3f5; border-radius: 12px;
    background: #fff; color: #1e1b4b; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  #np-ham:active { transform: scale(.95); }

  /* Bottom navigation */
  #np-bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
    height: calc(62px + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid #ece9f8; box-shadow: 0 -6px 24px rgba(30,20,90,.08); }
  #np-bottom-nav a, #np-bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; border: 0; background: none; color: #8a86a6; font: 600 10.5px/1.1 Inter, system-ui, sans-serif;
    text-decoration: none; border-radius: 12px; -webkit-tap-highlight-color: transparent; min-width: 0; }
  #np-bottom-nav .np-ic { width: 40px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 14px; transition: background .15s; }
  #np-bottom-nav .on { color: #4c3bc4; }
  #np-bottom-nav .on .np-ic { background: #ede9fe; }
  #np-bottom-nav span.lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* Comfortable touch + no iOS zoom on focus */
  input, select, textarea { font-size: 16px !important; }
  .nav-item { min-height: 44px; }

  /* Pop-ups fit the screen */
  .ov > div, .modal, .modal-box, .mod, [role="dialog"] > div:first-child {
    max-width: calc(100vw - 20px) !important; max-height: calc(100dvh - 24px); overflow-y: auto; }

  /* Wide tables scroll inside their card instead of squeezing */
  .np-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

  /* Page headers: keep ☰, title, bell, avatar; greeting / clock / search are hidden on phones */
  .np-hide-mobile { display: none !important; }
  header.topnav > div:first-child { height: auto !important; min-height: 58px; padding: 8px 12px !important;
    gap: 8px !important; flex-wrap: nowrap !important; }
  header.topnav #topnav-company { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Home: main column and NestFeed stack and scroll as one page */
  .page-body { overflow-y: auto !important; }
  .home-layout, .hero-cards-row { overflow: visible !important; height: auto !important; }
  .hero-cards-row { flex-direction: column !important; }
  .nestfeed-panel { width: 100% !important; max-width: 100% !important; border-left: 0 !important; }
  .left-content-panel, .left-content-area { flex: 0 0 auto !important; height: auto !important; overflow: visible !important; }
  .nestfeed-panel, .nf-feed { height: auto !important; max-height: none !important; overflow: visible !important; }

  /* Header rows never wrap: the title shrinks instead */
  .np-hdr-row { flex-wrap: nowrap !important; }
  .np-hdr-row > *:not(#np-ham) { min-width: 0; }
  .np-hdr-row > :not(#np-ham):not(.np-hdr-title) { flex-shrink: 0 !important; }
  .np-hdr-row .np-hdr-title { flex: 1 1 0 !important; overflow: hidden; }
  .np-hdr-row .np-hdr-title * { white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .np-hdr-row * { flex-wrap: nowrap !important; }

  /* Slim top bar for pages without their own header row (e.g. My Profile) */
  .np-topbar { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; flex-shrink: 0;
    background: #fff; border-bottom: 1px solid #ece9f8; position: sticky; top: 0; z-index: 40; }
  .np-topbar #np-ham { margin-right: 0; }
  .np-topbar-title { font: 800 16px/1.2 Inter, system-ui, sans-serif; color: #1e1b4b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* 📱 Mobile Layout: sections / tabs switched off for phones */
  .np-ml-off { display: none !important; }

  /* NestFeed tab: Home page shows only the feed */
  body.np-feed-only .left-content-panel { display: none !important; }
  body.np-feed-only .nestfeed-panel { display: flex !important; }

  .np-hdr-row { gap: 6px !important; }

  /* KPI cards (Helpdesk, Expenses, Timesheet): compact 2 × 2 tiles */
  .np-kpi { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px !important;
    margin-bottom: 14px !important; flex-wrap: wrap; }
  .np-kpi > * { min-width: 0 !important; min-height: 0 !important; width: auto !important; margin: 0 !important;
    padding: 12px 12px 11px !important; border-radius: 14px !important; position: relative; overflow: hidden;
    display: flex !important; flex-direction: column !important; align-items: flex-start !important;
    justify-content: flex-start !important; text-align: left !important; gap: 2px !important; }
  .np-kpi .sum-blob, .np-kpi .sum-glow, .np-kpi [class*="blob"], .np-kpi [class*="glow"]:not(.glow-blue):not(.glow-orange):not(.glow-purple):not(.glow-green) { display: none !important; }
  .np-kpi .sum-sm-ico, .np-kpi .sum-icon, .np-kpi [class*="-ico"], .np-kpi [class*="icon"] {
    width: 28px !important; height: 28px !important; min-width: 28px; border-radius: 9px !important; margin: 0 0 6px !important;
    position: static !important; }
  .np-kpi .sum-sm-ico svg, .np-kpi .sum-icon svg { width: 15px !important; height: 15px !important; }
  .np-kpi .sum-card-top { display: flex !important; flex-direction: row-reverse !important; justify-content: flex-end !important;
    align-items: center !important; gap: 8px !important; width: 100%; margin: 0 0 4px !important; }
  .np-kpi .sum-card-top .sum-icon { margin: 0 !important; }
  .np-kpi .sum-sm-val, .np-kpi .sum-val, .np-kpi [class*="val"] { font-size: 21px !important; line-height: 1.15 !important; margin: 0 !important; }
  .np-kpi .sum-sm-lbl, .np-kpi .sum-lbl, .np-kpi [class*="lbl"], .np-kpi [class*="label"] { font-size: 11.5px !important;
    font-weight: 700 !important; letter-spacing: .02em; margin: 0 !important; }
  .np-kpi .sum-sm-sub, .np-kpi .sum-desc, .np-kpi [class*="sub"], .np-kpi [class*="desc"] { font-size: 11px !important; opacity: .75; margin: 0 !important; }

  /* Header drop-downs (notifications, messages, profile menu): a sheet under the header
     that always fits the screen (they were 360 px wide and anchored to the icon → cut off) */
  #notif-dd, #mail-dd {
    position: fixed !important; top: calc(62px + env(safe-area-inset-top)) !important;
    left: 10px !important; right: 10px !important; width: auto !important; max-width: none !important;
    max-height: 70dvh; overflow-y: auto; transform: none !important; z-index: 1400 !important; }
  #profile-dd {
    position: fixed !important; top: calc(62px + env(safe-area-inset-top)) !important;
    left: auto !important; right: 10px !important; width: min(300px, calc(100vw - 20px)) !important;
    transform: none !important; z-index: 1400 !important; }

  /* My Profile banner: no duplicate bell/avatar (the ☰ header has them); stats in an even row */
  .prof-banner-stats > :not(.prof-bs) { display: none !important; }
  .prof-banner-stats { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important; width: 100% !important; align-items: start !important; margin-top: 10px !important; }
  .prof-bs { min-width: 0 !important; width: auto !important; text-align: center; padding: 6px 4px !important;
    border-radius: 12px; background: rgba(255,255,255,.08); border: 0 !important; margin: 0 !important; }
  .prof-bs * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .prof-bs > :first-child { font-size: 19px !important; line-height: 1.2 !important; letter-spacing: -.3px; }
  .prof-bs > :last-child { font-size: 9px !important; letter-spacing: .06em; }
  .prof-banner, .prof-banner-content { height: auto !important; min-height: 0 !important; }
  .prof-banner-content { padding-bottom: 16px !important; }

  /* My Profile → Career timeline: date on its own line, then role/company + badges */
  .ctl-card { flex-wrap: wrap !important; row-gap: 6px !important; }
  .ctl-card .ctl-date { min-width: 0 !important; width: 100%; }
  .ctl-card .ctl-sep { display: none !important; }
  .ctl-card .ctl-main { flex: 1 1 140px !important; }

  /* Month calendars stay 7 columns; day cells scale to the width */
  .mc-grid { grid-template-columns: repeat(7, minmax(0, 1fr)) !important; gap: 4px 2px !important; }
  .mc-grid .mc-day { width: 100% !important; max-width: 38px; height: auto !important; aspect-ratio: 1; margin: 0 auto; font-size: 12px !important; }

  /* List tables shown as cards (rows labelled by mobile.js) */
  table.np-cards, table.np-cards tbody { display: block !important; width: 100% !important; min-width: 0 !important; }
  table.np-cards thead { display: none !important; }
  table.np-cards tr { display: block !important; padding: 10px 14px; margin: 0 0 10px; background: #fff;
    border: 1px solid #ece9f8; border-radius: 14px; box-shadow: 0 2px 8px rgba(30,20,90,.04); }
  table.np-cards td { display: flex !important; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 6px;
    padding: 6px 0 !important; border: 0 !important; text-align: right !important; width: auto !important; min-width: 0 !important; }
  table.np-cards td + td { border-top: 1px dashed #f0edf9 !important; }
  table.np-cards td::before { content: attr(data-label); flex-shrink: 0; margin-right: auto; text-align: left; font-size: 10.5px; font-weight: 700;
    letter-spacing: .05em; text-transform: uppercase; color: #94a3b8; }
  table.np-cards td[data-label=""]::before { content: none; }
  table.np-cards td.np-full { display: block !important; text-align: center !important; }
  table.np-cards td.np-full::before { content: none; }
  table.np-cards tr:has(td.np-full:only-child) { background: transparent; border: 0; box-shadow: none; padding: 4px 0; }
  .empty-state img, td.np-full img { max-width: min(240px, 72%) !important; height: auto !important; margin: 0 auto; display: block; }

  /* Space so the bottom bar never covers the last item */
  .np-pad-bottom { padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; }

  /* Header buttons (bell, mail…) and avatar: one compact, consistent size.
     Icon buttons get a soft tint; the avatar keeps its own colour/photo. */
  .np-hdr-btn { width: 34px !important; height: 34px !important; min-width: 34px !important; min-height: 34px !important;
    padding: 0 !important; display: inline-flex !important; align-items: center; justify-content: center;
    flex-shrink: 0; box-shadow: none !important; }
  .np-hdr-btn:not(.np-avatar) { border: 0 !important; border-radius: 10px !important; background: #f4f2fd !important; }
  .np-hdr-btn svg { width: 17px !important; height: 17px !important; }
  .np-hdr-btn.np-avatar { border-radius: 50% !important; font-size: 12px !important; overflow: hidden; }
  #np-ham { width: 36px; height: 36px; border: 0; background: #f4f2fd; margin-right: 6px; }
  .np-brand-n { width: 26px; height: 26px; flex-shrink: 0; margin-right: 6px; object-fit: contain; }

  /* ── KPI cards v2: compact 2-column tiles (Helpdesk, Expenses, Timesheet) ── */
  .np-kpi { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; margin-bottom: 14px !important; }
  .np-kpi > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .np-kpi > * { position: relative; display: flex !important; flex-direction: column; justify-content: center; gap: 1px;
    min-height: 58px !important; height: auto !important; padding: 9px 12px 9px 14px !important; border-radius: 12px !important;
    text-align: left !important; box-shadow: none !important; transform: none !important; overflow: hidden; }
  .np-kpi > *::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #8b7fff; }
  .np-kpi > .glow-blue::before, .np-kpi > .blue::before { background: #3b82f6; }
  .np-kpi > .glow-orange::before, .np-kpi > .orange::before { background: #f59e0b; }
  .np-kpi > .glow-purple::before, .np-kpi > .purple::before { background: #8b5cf6; }
  .np-kpi > .glow-green::before, .np-kpi > .green::before { background: #10b981; }
  .np-kpi > .glow-red::before, .np-kpi > .red::before { background: #ef4444; }
  .np-kpi .sum-sm-ico, .np-kpi .sum-blob, .np-kpi .sum-sm-sub, .np-kpi .sum-glow, .np-kpi .sum-icon,
  .np-kpi .sum-desc, .np-kpi .sum-bar { display: none !important; }
  .np-kpi .sum-card-top { display: contents !important; }
  .np-kpi .sum-sm-lbl, .np-kpi .sum-lbl { order: -1; margin: 0 !important; font-size: 10.5px !important; font-weight: 700 !important;
    text-transform: uppercase; letter-spacing: .05em; color: #8a86a6 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .np-kpi .sum-sm-val, .np-kpi .sum-val { margin: 0 !important; font-size: 19px !important; line-height: 1.2 !important; }
}
