/* Mobilskal (≤ 760 px, 2026-10-20). Hör ihop med web-mobil.js. Laddas sist och ersätter de äldre mobilreglerna i web.css där de krockar.
   Ett toppfält (52 px) + en bottenmeny (60 px), sidans innehåll i full bredd utan kort-i-kort, tryckytor minst 40–44 px,
   inmatningsfält 16 px (annars zoomar iPhone in), tabeller som kort, filterlistor som vågräta chips. */
#mtop, #mnav, #msheet, #msheet-bg { display: none; }

@media (max-width: 760px) {
  body.web-mob { --mt-h: calc(52px + env(safe-area-inset-top)); --mn-h: calc(60px + env(safe-area-inset-bottom)); }

  /* ── Skalet: sajtens sidhuvud, panelens toppfält, tillbaka-knappen och sidrubriken ersätts ── */
  body.web-mob #webbar, body.web-mob .m-back, body.web-mob .pagehead, body.web-mob .mg-online { display: none !important; }
  body.web-mob:not(.m-search) .topbar2 { display: none !important; }
  body.web-mob #root { inset: var(--mt-h) 0 var(--mn-h) 0 !important; padding-bottom: 0 !important; }
  body.web-mob.has-notisask #root { bottom: calc(var(--mn-h) + var(--nb-h, 0px)) !important; }

  body.web-mob #mtop { display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: var(--mt-h); box-sizing: border-box; align-items: center; gap: 6px;
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    background: color-mix(in oklab, var(--site-bg) 92%, transparent); backdrop-filter: blur(18px); border-bottom: 1px solid var(--site-border); }
  #mtop.hidden, #mnav.hidden, #msheet.hidden, #msheet-bg.hidden { display: none !important; }
  .mt-title { flex: 1; min-width: 0; margin: 0 4px; font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--site-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mt-logo { flex: none; width: 34px; height: 34px; margin-left: 4px; border-radius: 9px; display: grid; place-items: center; font-family: var(--font-display); font-size: 18px;
    color: var(--site-primary-fg); background: var(--site-primary); }
  .mt-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--site-fg); font-size: 18px; display: grid; place-items: center; cursor: pointer; }
  .mt-btn.on { background: color-mix(in oklab, var(--site-primary) 18%, transparent); color: #fff; }
  .mt-me { flex: none; position: relative; width: 44px; height: 44px; border: 0; background: transparent; padding: 0; display: grid; place-items: center; cursor: pointer; }
  .mt-me .avatar, .ms-head .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--site-fg);
    background: var(--mg-card3, #2a2d35); border: 1px solid var(--site-border); }
  .mt-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--mg-muted, #888); flex: none; }
  .mt-me .mt-dot { position: absolute; right: 4px; bottom: 5px; border: 2px solid var(--site-bg); }
  .mt-dot.tillganglig { background: #22c55e; } .mt-dot.upptagen { background: #f59e0b; } .mt-dot.ej { background: #6b7280; }
  .mt-warn { position: absolute; right: 3px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--site-danger); border: 2px solid var(--site-bg); }

  /* sökraden: panelens eget sökfält, ensamt under toppfältet */
  body.web-mob.m-search .topbar2 { position: fixed !important; top: var(--mt-h); left: 0; right: 0; z-index: 59; display: flex !important; height: auto !important; padding: 8px 12px !important;
    background: var(--site-bg) !important; border-bottom: 1px solid var(--site-border); }
  body.web-mob.m-search .topbar2 > :not(.gsearch2) { display: none !important; }
  body.web-mob.m-search .topbar2 .gsearch2 { flex: 1 1 100%; width: 100% !important; max-width: none !important; order: 0 !important; }
  body.web-mob.m-search .topbar2 .gsbox { height: 46px !important; }
  body.web-mob.m-search .topbar2 .gsearch2 kbd { display: none !important; }
  body.web-mob.m-search .topbar2 .gs-pop { position: fixed !important; left: 8px !important; right: 8px !important; top: calc(var(--mt-h) + 64px) !important; width: auto !important; max-height: 60dvh; overflow-y: auto; }
  body.web-mob.m-search #root { top: calc(var(--mt-h) + 63px) !important; }

  /* ── Bottenmeny ── */
  body.web-mob #mnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: var(--mn-h); box-sizing: border-box; padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    background: color-mix(in oklab, var(--site-bg) 94%, transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--site-border); }
  .mn-i { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent;
    color: var(--site-fg2); font-size: 11.5px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .mn-i i { font-size: 19px; }
  .mn-i span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mn-i.on { color: #fff; }
  .mn-i.on i { color: var(--site-primary); }
  .mn-n { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; font-style: normal; font-size: 11px; font-weight: 700;
    line-height: 18px; text-align: center; color: #fff; background: var(--site-danger); }

  /* Menyn (alla sidor) som en låda från vänster ovanför bottenmenyn */
  body.web-mob .shell.ui2 .navpop, body.web-mob .shell.mg .navpop { position: fixed !important; top: var(--mt-h) !important; left: 0 !important; bottom: var(--mn-h) !important; z-index: 58 !important;
    width: min(320px, 86vw) !important; max-height: none !important; border-radius: 0 14px 14px 0 !important; padding: 10px !important; overflow-y: auto; }
  body.web-mob .navpop .ns-i { min-height: 46px; font-size: 16px; }
  body.web-mob .navpop .ns-t { font-size: 12px; padding-top: 10px; }

  /* ── Bladet "Du" ── */
  body.web-mob #msheet-bg { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .55); }
  body.web-mob #msheet { display: flex; flex-direction: column; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-height: 88dvh; overflow-y: auto; box-sizing: border-box;
    padding: 6px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--mg-card, #16181d); border-top: 1px solid var(--site-border); border-radius: 18px 18px 0 0; box-shadow: 0 -16px 40px rgba(0, 0, 0, .5); font-size: 15px; }
  .ms-grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--site-border); margin: 4px 0 2px; }
  .ms-head { display: flex; align-items: center; gap: 12px; }
  .ms-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .ms-head b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ms-head small { font-size: 13px; color: var(--site-fg2); }
  .ms-head .avatar { width: 44px; height: 44px; font-size: 15px; }
  .ms-pills { display: flex; flex-wrap: wrap; gap: 6px; }
  .ms-pills .wb-pill { height: 30px; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .ms-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--site-fg2); }
  .ms-sec { margin-top: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--site-fg2); }
  .ms-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .ms-seg button { min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px 4px; border-radius: 12px;
    border: 1px solid var(--site-border); background: transparent; color: var(--site-fg2); font-size: 13px; font-weight: 600; line-height: 1.15; text-align: center; cursor: pointer; }
  .ms-seg button.on { color: #fff; border-color: var(--site-primary); background: color-mix(in oklab, var(--site-primary) 16%, transparent); }
  .ms-tools { display: grid; gap: 8px; }
  .ms-tools .wb-ljud { position: static; }
  .ms-tools .wb-btn, .ms-row { width: 100% !important; height: auto !important; min-height: 48px; justify-content: flex-start; gap: 12px !important; padding: 0 14px !important; border-radius: 12px;
    font-size: 15px !important; font-weight: 600; text-align: left; }
  .ms-tools .wb-btn i { width: 20px; text-align: center; }
  .ms-tools .wb-ljudpop { position: static; width: auto; margin-top: 8px; box-shadow: none; }
  .ms-row { display: flex; align-items: center; border: 1px solid var(--site-border); background: transparent; color: var(--site-fg); cursor: pointer; }
  .ms-row > span { flex: 1; }
  .ms-row > i:first-child { width: 20px; text-align: center; color: var(--site-fg2); }
  .ms-row > i:last-child { color: var(--site-fg2); font-size: 12px; }
  .ms-row.danger { color: #fca5a5; border-color: color-mix(in oklab, var(--site-danger) 45%, transparent); }
  .ms-row.danger > i { color: #fca5a5; }

  /* Notiser och svar: nere, ovanför bottenmenyn (uppe skymde de toppfältet) */
  body.web-mob #toasts { top: auto !important; left: 10px !important; right: 10px !important; bottom: calc(var(--mn-h) + 10px) !important; max-width: none !important; }
  body.web-mob #alerts { top: calc(var(--mt-h) + 8px) !important; left: 8px !important; right: 8px !important; max-width: none !important; }

  /* ── Innehållet: full bredd, inga kort-i-kort, luft i kanterna ── */
  body.web-mob .mg-work { padding: 0 !important; gap: 0 !important; display: block !important; height: 100%; overflow: hidden; }
  body.web-mob .mg-work > .main { height: 100%; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; overflow: hidden; }
  body.web-mob .mg-work > .main > .page { height: 100%; box-sizing: border-box; margin: 0 !important; padding: 12px 12px 24px !important; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  body.web-mob .mg-col.flat .main, body.web-mob .main.flat { padding: 0 !important; }
  body.web-mob .page > section.mg-card, body.web-mob .page > .mg-card { border-radius: 14px; }
  body.web-mob .mg-card-h { flex-wrap: wrap; row-gap: 8px; }
  body.web-mob .mg-card-h > .mg-grow { min-width: 0; flex: 1 1 160px; }
  body.web-mob .mg-subtabs, body.web-mob .mgp-tabs, body.web-mob .mg-tabs { flex-wrap: nowrap !important; overflow-x: auto !important; overflow-y: hidden; scrollbar-width: none; height: auto !important; }
  body.web-mob .mg-subtabs::-webkit-scrollbar, body.web-mob .mgp-tabs::-webkit-scrollbar, body.web-mob .mg-tabs::-webkit-scrollbar { display: none; }
  body.web-mob .mg-subtabs > button, body.web-mob .mgp-tabs > button, body.web-mob .mg-tabs > button { flex: none !important; min-height: 42px; white-space: nowrap; }

  /* Tryckytor och läsbar text */
  body.web-mob #root .mg-btn, body.web-mob #root .btn, body.web-mob #root .seg > button { min-height: 42px; }
  body.web-mob #root .rowbtn, body.web-mob #root .tbtn { min-width: 40px; min-height: 40px; }
  body.web-mob #root input:not([type=checkbox]):not([type=radio]):not([type=range]), body.web-mob #root select, body.web-mob #root textarea { font-size: 16px !important; min-height: 44px; }
  body.web-mob #root textarea { min-height: 44px; }

  /* Filterlistor (Audit-logg, Vapenlogg, Loggar): vågräta chips i stället för en rullruta i rutan */
  body.web-mob .mg-filter { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; gap: 6px; overflow-x: auto !important; overflow-y: hidden !important;
    max-height: none !important; height: auto !important; width: auto !important; padding: 2px 0 8px !important; background: transparent !important; border: 0 !important; scrollbar-width: none; }
  body.web-mob .mg-filter::-webkit-scrollbar { display: none; }
  body.web-mob .mg-filter .mg-section { display: none !important; }
  body.web-mob .mg-filter > button { flex: none !important; width: auto !important; height: 40px !important; min-height: 40px; padding: 0 14px !important; border-radius: 999px !important;
    border: 1px solid var(--site-border) !important; display: inline-flex !important; align-items: center; gap: 8px; white-space: nowrap; }
  body.web-mob .mg-filter > button.on { border-color: var(--site-primary) !important; background: color-mix(in oklab, var(--site-primary) 16%, transparent) !important; }
  body.web-mob .mg-filter > button em { margin-left: 2px; }
  body.web-mob [class$='-body'], body.web-mob .au-body { display: flex !important; flex-direction: column !important; gap: 10px; }
  body.web-mob .au-body > *, body.web-mob [class$='-body'] > * { min-width: 0; max-width: 100%; }

  /* ── Tabeller som kort (rubriken står vid varje värde, se web-mobil.js) ── */
  body.web-mob .tablewrap { overflow: visible !important; border: 0 !important; background: transparent !important; }
  body.web-mob table.m-cards { display: block; width: 100% !important; min-width: 0 !important; border: 0; }
  body.web-mob table.m-cards > thead { display: none; }
  body.web-mob table.m-cards > tbody { display: flex; flex-direction: column; gap: 8px; }
  body.web-mob table.m-cards > tbody > tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 12px 14px; border-radius: 12px; height: auto !important;
    background: var(--mg-card, #16181d); border: 1px solid var(--site-border); }
  body.web-mob table.m-cards > tbody > tr > td { display: inline-flex; align-items: baseline; gap: 6px; padding: 0 !important; border: 0 !important; height: auto !important; min-width: 0; max-width: 100%;
    font-size: 14px; white-space: normal; word-break: break-word; background: transparent !important; }
  body.web-mob table.m-cards > tbody > tr > td[data-th]:not([data-th=''])::before { content: attr(data-th); flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--site-fg2); }
  body.web-mob table.m-cards > tbody > tr > td:empty { display: none; }
  body.web-mob table.m-cards > tbody > tr > td.m-main { order: -2; flex: 1 1 100%; font-size: 16px; font-weight: 600; }
  body.web-mob table.m-cards > tbody > tr > td.m-main::before { display: none; }
  body.web-mob table.m-cards > tbody > tr > td.m-act { order: 99; flex: 1 1 100%; justify-content: flex-end; gap: 8px; }
  body.web-mob table.m-cards > tbody > tr > td[colspan] { flex: 1 1 100%; }
  body.web-mob table.m-cards > tbody > tr > td[colspan]::before { display: none; }

  /* ── Startsidan ── */
  body.web-mob .mg-welcome { flex-wrap: wrap; gap: 8px; }
  body.web-mob .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  body.web-mob .kpi { min-width: 0; flex-wrap: wrap; align-items: flex-start; padding: 12px !important; height: auto !important; }
  body.web-mob .kpi .tag { position: static !important; order: 9; margin: 6px 0 0 !important; }
  body.web-mob .kpi .kt { min-width: 0; }
  body.web-mob .kpi .kt span { white-space: normal; }

  /* ── Spelarprofil ── */
  body.web-mob .mgp-top .mg-btn { display: none; }   /* tillbaka finns i toppfältet */
  body.web-mob .mgp-hero { flex-direction: column !important; align-items: stretch !important; gap: 12px; }
  body.web-mob .mgp-actcol { width: 100% !important; }
  body.web-mob .mgp-acts { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; justify-content: stretch !important; }
  body.web-mob .mgp-acts > .mg-btn, body.web-mob .mgp-acts > button { width: 100%; justify-content: center; }
  body.web-mob .mgp-acts > .mgp-more { justify-self: stretch; }
  body.web-mob .mgp-acts > .mgp-more > button { width: 100%; }
  body.web-mob .mgp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  body.web-mob .mg-stat { position: relative; min-width: 0; }
  body.web-mob .mg-stat .k { display: block; padding-right: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.web-mob .mg-stat .ic { position: absolute; top: 12px; right: 12px; }

  /* ── Ärenden ── */
  body.web-mob .sc.sc2 { height: 100%; overflow-y: auto; }
  body.web-mob.m-open .sc.sc2 { overflow: hidden; display: flex !important; flex-direction: column; }
  body.web-mob.m-open .sc.sc2 > .col-main { flex: 1; min-height: 0 !important; display: flex; flex-direction: column; }
  body.web-mob.m-open .sc.sc2 > .col-side { display: none !important; }
  body.web-mob.m-open .sc.sc2 .thead { flex: none; max-height: 42dvh; overflow-y: auto; }
  body.web-mob.m-open .sc.sc2 .thead .acts { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
  body.web-mob.m-open .sc.sc2 .thead .acts > button, body.web-mob.m-open .sc.sc2 .thead .acts > * { width: 100%; justify-content: center; min-height: 42px; }
  body.web-mob.m-open .sc.sc2 [class*='hx-ctl'] { flex-wrap: wrap !important; white-space: normal !important; max-width: 100%; box-sizing: border-box; }
  body.web-mob.m-open .sc.sc2 .composer2 { flex: none; padding-bottom: 8px; }
  body.web-mob .sc.sc2 .tk2 { min-height: 64px; }

  /* ── Spectate ── */
  body.web-mob .ws { display: flex !important; flex-direction: column; gap: 10px; height: auto !important; overflow: visible !important; }
  body.web-mob .ws-side { max-height: none !important; overflow: visible !important; }
  body.web-mob .ws-row { padding: 10px 12px !important; }
  body.web-mob .ws-row .btn { min-height: 44px; }
  body.web-mob .ws-view { min-height: 260px; }
}

/* ── Rättelser efter mobilgranskningen (skärmbilder 390/360 px) ── */
@media (max-width: 760px) {
  body.web-mob .kpis .kpi { display: grid !important; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 6px; align-items: center; }
  body.web-mob .kpis .kpi .tag { position: static !important; inset: auto !important; transform: none !important; grid-column: 1 / -1; justify-self: start; margin: 0 !important; }
  body.web-mob .mg-card-h { height: auto !important; min-height: 0 !important; flex-shrink: 0 !important; }
  body.web-mob .mg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  body.web-mob .mg-subtabs { margin: 0 0 10px !important; max-width: 100%; box-sizing: border-box; }
  body.web-mob #root .seg, body.web-mob .ctabs { flex-wrap: nowrap !important; overflow-x: auto !important; overflow-y: hidden; scrollbar-width: none; max-width: 100%; height: auto !important; }
  body.web-mob #root .seg::-webkit-scrollbar, body.web-mob .ctabs::-webkit-scrollbar { display: none; }
  body.web-mob #root .seg > button, body.web-mob .ctabs > button { flex: none !important; white-space: nowrap; }
  body.web-mob .dcg-bar { flex-direction: column !important; align-items: stretch !important; height: auto !important; gap: 10px; }
  body.web-mob .dcg-bar > .mg-grow { width: auto !important; }
  body.web-mob .dcg-bar > .btn { width: 100%; justify-content: center; }
  body.web-mob .mgp-top { display: none !important; }
  body.web-mob .mgp-actcol { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 !important; align-items: stretch; }
  body.web-mob .mgp-actcol > .mgp-acts { display: contents !important; }
  body.web-mob .sc.sc2 .tk2 .tags, body.web-mob .sc.sc2 .tk2 > * { min-width: 0; }
}
@media (max-width: 760px) {
  body.web-mob .kpis .kpi .kx { grid-column: 1 / -1; position: static !important; inset: auto !important; justify-self: start; margin: 0 !important; }
  body.web-mob.m-open .sc.sc2 .hx-ctl .hx-id { display: none; }
}
@media (max-width: 760px) {
  /* verktygsrader (sök + val + knapp): sökfältet på egen rad, resten under */
  body.web-mob [class$='-tools'], body.web-mob .pltools { flex-wrap: wrap !important; height: auto !important; row-gap: 8px !important; }
  body.web-mob [class$='-tools'] > .mg-input, body.web-mob [class$='-tools'] > .search, body.web-mob [class$='-tools'] > label:first-child { flex: 1 1 100% !important; width: auto !important; max-width: none !important; }
  /* ärendets rubrik står redan i toppfältet */
  body.web-mob.m-open .sc.sc2 .thead .trow h2 { display: none; }
}
@media (max-width: 760px) {
  body.web-mob.m-open.m-side .sc.sc2 > .col-main { display: none !important; }
  body.web-mob.m-open.m-side .sc.sc2 > .col-side { display: block !important; flex: 1; width: 100% !important; max-width: none !important; margin: 0 !important; overflow-y: auto; }
}
@media (max-width: 760px) { body.web-mob .hx-add, body.web-mob .hx-more, body.web-mob .namebtn { min-width: 40px; min-height: 40px; } }
