/* FootballDesk 9.0.46 Cloud — Line Up gesture repair + full-site Midnight theme v4.0.0.
   This stylesheet loads last, after the original mobile 0.6/0.7/0.8 layers.
   No width-expansion mode, no touch event hijacking and no modification to player statuses. */

/* 1. Horizontal movement in mobile Line Up, matching the Personal Matches browser gestures.
   Mobile 0.6 / 0.7 force "pan-y pinch-zoom !important" on these exact elements.
   Those declarations prevent one-finger horizontal panning of the zoomed viewport. */
@media (max-width:760px) and (pointer:coarse) {
  body.lineup-mode #lineupWindow,
  body.lineup-mode #lineupWindow #lineupList,
  body.lineup-mode #lineupWindow .lineup-games,
  body.lineup-mode #lineupWindow .lineup-game-wrap,
  body.lineup-mode #lineupWindow .lineup-game,
  body.lineup-mode #lineupWindow .lineup-preview,
  body.lineup-mode #lineupWindow .lineup-preview-block,
  body.lineup-mode #lineupWindow .lineup-fd-grid,
  body.lineup-mode #lineupWindow .lineup-fd-image-link,
  body.lineup-mode #lineupWindow .lineup-fd-snapshot-link,
  body.lineup-mode #lineupWindow .lineup-fd-image,
  body.lineup-mode #lineupWindow .lineup-fd-snapshot-image,
  body.lineup-mode #lineupWindow .lineup-league-drag,
  body.lineup-mode #lineupWindow .lineup-inline-odds {
    touch-action:pan-x pan-y pinch-zoom !important;
  }
  /* Do not make the entire fixture list into a horizontal overflow container:
     this previously trapped the vertical page scroll on mobile Chrome. */
  body.lineup-mode #lineupWindow #lineupList {
    overflow:visible !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
  body.lineup-mode #lineupWindow .lineup-league {
    width:100% !important;
    min-width:0 !important;
    max-width:100% !important;
  }
  /* Native swipeable odds strip, just like a Personal Matches table wrapper;
     it does not change the width of the page or team rows. */
  body.lineup-mode #lineupWindow .lineup-game .lineup-inline-odds {
    display:flex !important;
    flex-flow:row nowrap !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
    max-width:100% !important;
    min-width:0 !important;
    width:100% !important;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain;
    scrollbar-width:thin;
    padding-bottom:5px !important;
  }
  body.lineup-mode #lineupWindow .lineup-game .lineup-inline-card,
  body.lineup-mode #lineupWindow .lineup-game .lineup-fav-group {
    flex:0 0 auto !important;
    max-width:none !important;
    white-space:nowrap !important;
  }
  /* Touch scrolling for genuinely wide preview tables without widening fixture cards. */
  body.lineup-mode #lineupWindow .lineup-preview :is(.lineup-fd-roster,.lineup-preview-block) {
    max-width:100%;
    min-width:0;
    touch-action:pan-x pan-y pinch-zoom !important;
  }
  /* Compact nav keeps both FD/Line Up labels and the theme toggle reachable. */
  .workspace-tabs {gap:4px !important;}
  .workspace-tabs .workspace-tab {flex:1 1 0!important;min-width:0!important;justify-content:center!important;padding:6px 4px!important;}
  .workspace-tabs .workspace-tab small {font-size:9px!important;}
}

/* 2. Theme switch in the top section tabs on PC and mobile, never a floating overlay. */
#fd-theme-v4-switch {
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  flex:0 0 auto;align-self:stretch;min-width:88px;
  font:650 12px/1.1 Inter,"Segoe UI",Arial,sans-serif;
  letter-spacing:.01em;padding:7px 12px;
  border-radius:9px;border:1px solid #bacbd4;
  background:#fafdfe;color:#334b5c;
  box-shadow:0 1px 3px #122c4210;
  cursor:pointer;
}
#fd-theme-v4-switch:hover{background:#eaf5f4;border-color:#89bcb4}
#fd-theme-v4-switch:focus-visible{outline:2px solid #24a999;outline-offset:2px}
#fd-theme-v4-switch .fd-theme-v4-icon{font-size:17px;line-height:1}
#fd-theme-v4-switch .fd-theme-v4-label{white-space:nowrap}
body > #fd-theme-v4-switch {position:fixed;right:16px;top:15px;z-index:1000;min-height:38px;align-self:auto}
@media(max-width:760px) {
  .workspace-tabs #fd-theme-v4-switch{min-width:36px!important;width:38px!important;padding:4px!important;border-radius:8px!important}
  .workspace-tabs #fd-theme-v4-switch .fd-theme-v4-label{display:none!important}
  body > #fd-theme-v4-switch {right:12px;top:9px}
}

/* 3. Midnight — a consistent dark surface system across FD, Line Up, Forms,
   news, dialogs, calendar, odds, accounts and login. Never filter flags/images. */
html[data-fd-theme="dark"] {
  color-scheme:dark;
  --line:#31435b;
  --muted:#9fb0c5;
  --card:#182638;
  --accent:#54d2bb;
  --soft:#203343;
  --fd4-base:#0c1420;
  --fd4-main:#111c2a;
  --fd4-card:#182638;
  --fd4-elev:#203148;
  --fd4-subtle:#22364a;
  --fd4-line:#31455d;
  --fd4-text:#edf3fa;
  --fd4-muted:#a4b6c9;
  --fd4-dim:#8fa3b8;
  --fd4-teal:#5bd9c4;
  --fd4-gold:#f5cf82;
  --fd4-danger:#ff868d;
  background:var(--fd4-base)!important;
  color:var(--fd4-text)!important;
}
html[data-fd-theme="dark"] :is(body,.app,main,#appShell) {
  background:var(--fd4-base)!important;color:var(--fd4-text)!important;
}
html[data-fd-theme="dark"] aside {
  background:#121f2e!important;
  color:var(--fd4-text)!important;
  border-right:1px solid var(--fd4-line)!important;
}
html[data-fd-theme="dark"] .brand {color:#f1f5fb!important;}
html[data-fd-theme="dark"] .brand b{color:var(--fd4-teal)!important}
html[data-fd-theme="dark"] :is(.brand span,.side-note,.meta,.timing,.muted,.empty,.sync,
  .mobile-hint,.lineup-head p,.lineup-kicker,.lineup-time,.lineup-state,
  .lineup-auto-watch-state,.lineup-league-title small,.lineup-odd small,
  .lineup-team-side small,.lineup-fd-roster small,.news-head p,.news-card small,
  .news-card h4,.form-event-detail small,.odds-toolbar p,.odds-card-head small,
  .panel-title small,.dialog-title p,.calendar-state,.team-source-note,.fd4-subtitle,
  label,.foot,.sub,p.help,.state,.name small,.mobile-m1-note) {
  color:var(--fd4-muted)!important;
}
html[data-fd-theme="dark"] :is(h1,h2,h3,h4,h5,b,strong,.lineup-teams b,
  .lineup-team-side>b,.lineup-game .lineup-odd b,.form-team-head b,
  .team h2,.match-head h1,.lineup-head h1,.lineup-preview-block-head,
  .team-title,.lineup-team-title,.odds-market>b) {
  color:var(--fd4-text)!important;
}
html[data-fd-theme="dark"] :is(.workspace-tabs,.fd-match-tabs,.view-tabs) {
  background:#162638!important;
  color:var(--fd4-text)!important;
  border-color:var(--fd4-line)!important;
  box-shadow:0 5px 18px #0004!important;
}
html[data-fd-theme="dark"] :is(.workspace-tab,.fd-match-tab,.view-tabs .tab) {
  background:transparent!important;color:var(--fd4-muted)!important;border-color:transparent!important;
}
html[data-fd-theme="dark"] :is(.workspace-tab.active,.fd-match-tab.active,.view-tabs .tab.active) {
  background:#2b4b55!important;color:#f1fffb!important;border-color:#4d9c97!important;
  box-shadow:inset 0 -2px var(--fd4-teal)!important;
}
html[data-fd-theme="dark"] :is(.match-head,.team,.desk-section,.section-body,
  .lineup-window .lineup-head,.lineup-window .lineup-league,
  .lineup-window .lineup-game,.lineup-preview,.lineup-preview-block,
  .lineup-fd-panel,.lineup-fd-text,.lineup-job-manager,.lineup-filterbar,
  .news-head,.news-card,.odds-card,.odds-section-body,.odds-compare-wrap,
  .matcher-panel,.matcher-team,.team-text-match,.custom-article,
  .form-team,.form-match,.form-match-wrap,.form-event-detail,
  .brief-stats,.fd-team-sources,.fd-work-dialog,.fd9-signals,
  .fd9-match-intel,.fd9-match-intel details,.fd9-signals-bar,
  .match-item,.card,.user,.mobile-player-sheet,.player-sheet-stats,
  .mobile-player-sheet .player-sheet-history,.lineup-tools-card,
  .lineup-fd-roster,.lineup-league-odds-controls,.lineup-inline-card,
  .lineup-inline-odd,.lineup-inline-odds,.lineup-job-toolbar,
  .lineup-start-schedule-dialog,.lineup-start-schedule-form,
  dialog,.dialog-shell,.calendar-dialog,.calendar-match,
  #statusDialog,#compositionDialog,#historyDialog,#teamBindingDialog,#officialStartDialog,
  #lineupToolsDialog,#lineupStartScheduleDialog) {
  background:var(--fd4-card)!important;
  color:var(--fd4-text)!important;
  border-color:var(--fd4-line)!important;
}
/* Panels deliberately differentiate header and content, not a flat monochrome block. */
html[data-fd-theme="dark"] :is(.team-head,.section-toggle,.news-source,
  .lineup-window .lineup-game:nth-child(even),.lineup-game-wrap:nth-child(even) .lineup-game,
  .lineup-preview-toolbar,.lineup-preview-block-head,.dialog-title,
  .calendar-group,.odds-compare-head,.odds-card-head,.team-text-title,
  .mobile-m1-note,.form-team-head,.form-fixture-head,.form-comp-code,
  .status-grid,.recent span,.xi-list span,.player-sheet-stats>div,
  .lineup-job-toolbar,.fd-unmatched-row,.lineup-fd-roster>span,
  .lineup-inline-values,.lineup-fav-percent,.badge,.fd9-timing-row,
  .fd-match-tabs,.fd9-signals-bar,.fd-table-bar,.lineup-league-order) {
  background:var(--fd4-elev)!important;
  border-color:var(--fd4-line)!important;
  color:var(--fd4-text)!important;
}
/* Tournament banner retains a warm gold distinction in dark mode. */
html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-league-head,
html[data-fd-theme="dark"] .lineup-league-head {
  background:#3b3022!important;border-color:#6b5636!important;color:var(--fd4-gold)!important;
}
html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-league-head .lineup-league-title b,
html[data-fd-theme="dark"] .lineup-league-head :is(b,small){color:#f6d99e!important}
/* Inputs and actions are legible, including inline PIN/MY editors and popup dialogs. */
html[data-fd-theme="dark"] :is(input,select,textarea,button:not(.primary),
  .lineup-inline-edit input,.odds-row input,.team-text-match textarea) {
  background:#23364b!important;color:var(--fd4-text)!important;
  border-color:#405973!important;
}
html[data-fd-theme="dark"] :is(input,textarea)::placeholder {color:#a8b7c7!important;opacity:1}
html[data-fd-theme="dark"] :is(input,select,textarea):focus-visible {
  outline:2px solid var(--fd4-teal)!important;outline-offset:1px;
}
html[data-fd-theme="dark"] button:not(.primary):hover:not(:disabled){background:#30516a!important;border-color:#64a9a8!important}
html[data-fd-theme="dark"] :is(button.primary,.primary,button[type="submit"]:not(.secondary):not(.danger),#login) {
  background:#247e75!important;color:#fff!important;border-color:#35a999!important;
}
html[data-fd-theme="dark"] :is(button.primary,.primary,#login):hover{background:#2b968a!important}
html[data-fd-theme="dark"] :is(button.danger,.danger){color:#ffc1c1!important;border-color:#8a4e57!important}
html[data-fd-theme="dark"] :is(button:disabled,input:disabled,select:disabled){opacity:.58}
html[data-fd-theme="dark"] #fd-theme-v4-switch {
  background:#294458!important;color:#e4fff9!important;border:1px solid #527d80!important;
  box-shadow:0 2px 10px #0005!important;
}
html[data-fd-theme="dark"] #fd-theme-v4-switch:hover{background:#35616a!important}
/* Sidebar and saved matches selection. */
html[data-fd-theme="dark"] .match-item{background:#1a2a3a!important;box-shadow:none!important}
html[data-fd-theme="dark"] .match-item.active{background:#17433f!important;border-color:#50bcaa!important;box-shadow:inset 3px 0 var(--fd4-teal)!important}
html[data-fd-theme="dark"] .match-item:hover{background:#264253!important}
html[data-fd-theme="dark"] .match-item small{color:var(--fd4-muted)!important}
html[data-fd-theme="dark"] .match-delete-btn{background:transparent!important;color:#d2a2a6!important}
/* Data tables: contrasting column headers, subtle stripes and readable numbers. */
html[data-fd-theme="dark"] :is(table,.visual-table,.odds-compare,.lineup-fd-roster){color:var(--fd4-text)!important;background:var(--fd4-card)!important}
html[data-fd-theme="dark"] :is(th,.visual-table th,.odds-compare th){background:#26394e!important;color:#c7d7e7!important;border-color:var(--fd4-line)!important}
html[data-fd-theme="dark"] :is(td,.visual-table td,.odds-compare td){border-color:var(--fd4-line)!important;color:var(--fd4-text)!important}
html[data-fd-theme="dark"] :is(.visual-table tbody tr,.odds-compare tbody tr){background:var(--fd4-card)!important;color:var(--fd4-text)!important}
html[data-fd-theme="dark"] :is(.visual-table tbody tr:nth-child(even),.odds-compare tbody tr:nth-child(even)){
  background:#203146!important;
}
html[data-fd-theme="dark"] .visual-table tbody tr:active{background:#275466!important}
html[data-fd-theme="dark"] .visual-table tr.dropped-from-start{background:#523c29!important}
html[data-fd-theme="dark"] .visual-table td.name{background:transparent!important}
html[data-fd-theme="dark"] :is(.stat-rating,.form-record b){color:#84e3ad!important}
html[data-fd-theme="dark"] .stat-yellow{color:#f7d27c!important}
html[data-fd-theme="dark"] .stat-red{color:#fc8b8e!important}
html[data-fd-theme="dark"] .status-btn{background:transparent!important;color:#cfdae5!important;border-color:transparent!important}
html[data-fd-theme="dark"] .status-btn.injury{color:#ff8383!important}
html[data-fd-theme="dark"] .status-btn.suspended{color:#fbb785!important}
html[data-fd-theme="dark"] .status-btn.doubt{color:#f1cd6c!important}
html[data-fd-theme="dark"] .status-btn.absent{color:#ef99b2!important}
html[data-fd-theme="dark"] .circle.start{background:#1f5a46!important;color:#d9ffef!important;border-color:#39846a!important}
html[data-fd-theme="dark"] .circle.sub{background:#564525!important;color:#ffebb7!important;border-color:#987a37!important}
html[data-fd-theme="dark"] .circle.bench{background:#334356!important;color:#e1edfa!important;border-color:#53657c!important}
html[data-fd-theme="dark"] .mk.on.squad{background:#c9d7e5!important;border-color:#c9d7e5!important}
/* Odds indicators and injury warnings keep their semantic colour. */
html[data-fd-theme="dark"] :is(.lineup-league-odds-toggle,.lineup-league-pin-refresh,
  .lineup-league-pin-find,.lineup-pin-match-refresh,.lineup-pin-auto-btn) {
  background:#4c3b25!important;color:#ffdf99!important;border-color:#947447!important;
}
html[data-fd-theme="dark"] .lineup-game.low-start-ratio{background:#49362b!important}
html[data-fd-theme="dark"] .lineup-game.already-personal{box-shadow:inset 3px 0 #50bd9f!important}
html[data-fd-theme="dark"] .lineup-fd-roster>span.has-status{background:#4f3038!important}
html[data-fd-theme="dark"] :is(.lineup-start-error,.lineup-problems,.warnings,.bad,.err){color:#ff9ca5!important}
html[data-fd-theme="dark"] .lineup-start-error{background:#4f2935!important;border-color:#975060!important}
html[data-fd-theme="dark"] :is(.lineup-fav-percent.pin-move.increase,.lineup-fav-percent.my-ratio.above){background:#1c513f!important;color:#b6f8d5!important;border-color:#398867!important}
html[data-fd-theme="dark"] :is(.lineup-fav-percent.pin-move.decrease,.lineup-fav-percent.my-ratio.below){background:#532c35!important;color:#ffb1b8!important;border-color:#ad5765!important}
html[data-fd-theme="dark"] :is(.lineup-fav-percent.missing,.lineup-empty,.lineup-preview-empty){color:#b4c4d4!important;background:var(--fd4-elev)!important}
html[data-fd-theme="dark"] :is(.lineup-inline-note,.lineup-league-pin-status){color:#c8d6e2!important}
html[data-fd-theme="dark"] :is(.loss-list li,.form-fixture,.form-closing-odds,.brief-stats>div,
  .recent span,.news-card h4 em,.odds-market,.lineup-fd-snapshot-link span){background:#24374a!important;color:#deebf6!important;border-color:var(--fd4-line)!important}
html[data-fd-theme="dark"] :is(.news-source a,.back,a){color:#7bdfca}
/* Dialogs and secondary screens (login/accounts) inherit exactly the same palette. */
html[data-fd-theme="dark"] :is(dialog,.card,.user,.wrap,.calendar-dialog,.dialog-shell){color:var(--fd4-text)!important}
html[data-fd-theme="dark"] dialog::backdrop{background:#030913c9!important}
html[data-fd-theme="dark"] :is(.calendar-group,.lineup-preview-toolbar,.odds-compare-head){background:#263b4f!important}
html[data-fd-theme="dark"] :is(.badge,.ok){color:#9ff0d5!important}
html[data-fd-theme="dark"] .badge{background:#1f4a43!important}
html[data-fd-theme="dark"] button.secondary{background:#344a5e!important;color:#e8f2fc!important}
html[data-fd-theme="dark"] .form-match-wrap.outcome-w{box-shadow:inset 3px 0 #60d69a!important}
html[data-fd-theme="dark"] .form-match-wrap.outcome-l{box-shadow:inset 3px 0 #fc8d93!important}
html[data-fd-theme="dark"] .form-match-wrap.outcome-d{box-shadow:inset 3px 0 #efbf69!important}
/* HTML login/account pages have strong body backgrounds in their own inline style. */
html[data-fd-theme="dark"] body:has(> .card),html[data-fd-theme="dark"] body:has(> .wrap){background:#0c1420!important}
html[data-fd-theme="dark"] body > main.card {background:#182638!important;box-shadow:0 22px 70px #0007!important}
html[data-fd-theme="dark"] .wrap .card{background:#182638!important}
/* Never invert/filter UI images, flags, player pictures or screenshots. */
html[data-fd-theme="dark"] :is(img,svg,canvas,.nationality-flag){filter:none!important}
html[data-fd-theme="dark"] ::selection{background:#266d65;color:white}
html[data-fd-theme="dark"]{scrollbar-color:#48647e #152536}
@media (prefers-reduced-motion:reduce){#fd-theme-v4-switch{transition:none!important}}

/* 4. Mobile 0.7 uses ID-specific !important light backgrounds. These explicit
   dark overrides are intentionally more specific than those legacy rules. */
@media (max-width:760px) and (pointer:coarse) {
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-head h1 {
    color:var(--fd4-text)!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-game {
    background:var(--fd4-card)!important;
    color:var(--fd4-text)!important;
    border-color:var(--fd4-line)!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-game-wrap:nth-child(even) .lineup-game {
    background:#203146!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-preview,
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-preview-block {
    background:#192a3b!important;
    color:var(--fd4-text)!important;
    border-color:var(--fd4-line)!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-league {
    border-color:var(--fd4-line)!important;
    box-shadow:0 3px 12px #0004!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-row-actions > .fd-mobile-more {
    background:#284459!important;
    border-color:#4d6c80!important;
    color:#dfedf7!important;
  }
  html[data-fd-theme="dark"] body.lineup-mode #lineupWindow .lineup-row-actions > .fd-mobile-more[aria-expanded="true"] {
    background:#225349!important;
    border-color:#3d9b86!important;
    color:#baffeb!important;
  }
}
/* Mobile player tables previously carried an independent pale heading row. */
html[data-fd-theme="dark"] #desk .visual-table thead tr {
  background:#263a50!important;
  color:#d1e1ee!important;
  border-color:var(--fd4-line)!important;
}
/* Functional highlights in dark theme (preserve quick-glance trading signals). */
html[data-fd-theme="dark"] :is(.lineup-favorite.active,.lineup-match-favorite.active,.player-star-toggle.active){color:#ffd876!important}
html[data-fd-theme="dark"] :is(.lineup-auto-watch-btn.active,.lineup-pin-auto-btn.active,.lineup-preview-toggle.confirmed){border-color:#45b99f!important;color:#9ef2d4!important}
html[data-fd-theme="dark"] :is(.lineup-auto-watch-btn.active,.lineup-pin-auto-btn.active){background:#1b4d47!important}
