/**
 * Trendmetrik UI v2 — Shell Layout
 * Grid-based layout: sidebar | [header + page content]
 * Reference: trendmetrik-v2 target design
 *
 * --tmv2-* tasarım tokenları: theme-variables.css (tek kaynak).
 */

/* ============ APP SHELL — CSS GRID ============ */
.tmv2-app {
  display: grid;
  grid-template-columns: var(--tmv2-sb-w) 1fr;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  font-family: var(--tmv2-ff-sans);
  color: var(--tmv2-ink);
  background: var(--tmv2-page);
  overflow-x: hidden;
}

.tmv2-app:not(:has(#tmv2SidebarRoot)) {
  grid-template-columns: 1fr;
}

/* ============ SIDEBAR (ortak görünüm; konum masaüstü / mobil medya sorgularında) ============ */
#tmv2SidebarRoot.tmv2-sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--tmv2-surface);
  border-right: 1px solid var(--tmv2-line-2);
  padding: var(--tmv2-sp-5) var(--tmv2-sp-4) var(--tmv2-sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--tmv2-sp-3);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#tmv2SidebarRoot.tmv2-sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/*
 * Masaüstü: sol sütun viewport’a sabitlenir; sayfa (ana sütun) scroll olurken sidebar yerinde kalır.
 * Sticky + tek grid satırında uzun içerik ile güvenilir değil; fixed + ana sütun offset.
 */
@media (min-width: 1025px) {
  .tmv2-app:has(#tmv2SidebarRoot) {
    display: block;
  }

  #tmv2SidebarRoot.tmv2-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--tmv2-sb-w);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    z-index: var(--tmv2-z-sidebar);
  }

  .tmv2-main:not(.tmv2-main--no-sidebar) {
    margin-left: var(--tmv2-sb-w);
    width: calc(100% - var(--tmv2-sb-w));
    min-width: 0;
    box-sizing: border-box;
  }

  .tmv2-main.tmv2-main--no-sidebar {
    margin-left: 0;
    width: 100%;
  }
}

/* ============ MAIN COLUMN ============ */
.tmv2-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.tmv2-main--no-sidebar {
  grid-column: 1 / -1;
}

/* ============ HEADER (sticky in main column) ============ */
header.tmv2-header {
  position: sticky;
  top: 0;
  z-index: var(--tmv2-z-header);
  background: var(--tmv2-surface);
  border-bottom: 1px solid var(--tmv2-line-2);
  padding: 0 var(--tmv2-layout-gutter);
  min-height: 58px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Inner header bar: flexbox row */
header.tmv2-header .tmv2-header-inner {
  display: flex;
  align-items: center;
  gap: var(--tm-layout-gap);
  width: 100%;
  max-width: var(--tmv2-page-inner-max, 1600px);
  margin: 0 auto;
  min-height: 58px;
  /* visible: overflow:hidden kesiyordu — bildirim / hesap dropdown'ları header altına taşınamıyordu */
  overflow: visible;
}

/* Title/search section shrinks to fit */
header.tmv2-header .tmv2-header--inline-in-bar {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

/* Action buttons don't shrink */
header.tmv2-header .header-actions,
header.tmv2-header .tmv2-header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mobile menu button: visible only on tablet/mobile */
header.tmv2-header #mobileMenuToggle {
  display: none;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  header.tmv2-header #mobileMenuToggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--tmv2-ink-2);
    border-radius: 8px;
  }
  header.tmv2-header #mobileMenuToggle:hover {
    background: var(--tmv2-surface-2);
  }
}

html.dark-mode header.tmv2-header {
  background: var(--tmv2-surface);
  border-bottom-color: var(--tmv2-line);
}

/* ============ PAGE HOST + MAIN (tek sayfa tuvali: padding/bg burada) ============ */
#tmv2App #tmv2Page.tmv2-page-host {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* main.tmv2-page: global page contract kökü (base.html) — pad-x/pad-y theme token */
#tmv2App main#mainContent.tmv2-page {
  --tmv2-page-inner-max: var(--tmv2-page-inner-standard-max, 1600px);
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--tmv2-page-pad-y) var(--tmv2-page-pad-x) var(--tmv2-page-pad-bottom);
  background: var(--tmv2-page-bg, var(--tmv2-page));
  position: relative;
  z-index: 1;
}

/* =================================================================
   HEADER ↔ İÇERİK HİZALAMA — VARIANT-AWARE
   ----------------------------------------------------------------
   Kök sorun: header-inner sabit 1600px max-width kullanıyordu;
   .tmv2-page-inner--wide (1920px) variant'lı sayfalarda içerik
   320px daha geniş yayılıyor, header dar kalıyordu → sol/sağ
   boşluklar "tutarsız" görünüyordu. :has() ile main column içindeki
   variant'ı tespit edip --tmv2-page-inner-max'i tek noktadan
   güncelliyoruz; header otomatik aynı genişliğe geçiyor.
   ================================================================= */

/* Page variant'ı .tmv2-main seviyesine yükselt — header de aynı sınırı görür */
.tmv2-main:has(.tmv2-page-inner--wide),
.tmv2-main:has(.tmv2-page-inner--ops) {
  --tmv2-page-inner-max: var(--tmv2-page-inner-wide-max, 1920px);
}
.tmv2-main:has(.tmv2-page-inner--standard) {
  --tmv2-page-inner-max: var(--tm-content-max, 1280px);
}
.tmv2-main:has(.tmv2-page-inner--narrow) {
  --tmv2-page-inner-max: 760px;
}
.tmv2-main:has(.tmv2-page-inner--fluid) {
  --tmv2-page-inner-max: none;
}

/* Header inner artık main'in scope'undan variant değerini alır.
   Eski kural (line 111) hâlâ geçerli ama artık doğru max'i okur.
   Sadece --fluid için özel davranış: max-width 'none' olamaz max-width
   property için; o yüzden --fluid'de header-inner full width açıyoruz. */
.tmv2-main:has(.tmv2-page-inner--fluid) header.tmv2-header .tmv2-header-inner {
  max-width: none;
}

/* Genişlik tek kaynak: .tmv2-page-inner; main tam sütun */
main.tmv2-content,
#tmv2App main#mainContent.tmv2-content,
#tmv2App main#mainContent {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  min-width: 0;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  position: relative;
  z-index: 1;
}

#tmv2App .tmv2-page-body {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--tmv2-section-gap);
}

/* Dashboard page: white surface for KPI/panel cards */
html:not(.dark-mode) #tmv2App main#mainContent.tmv2-page:has(.tmv2-dashboard) {
  background: var(--tmv2-surface);
}

html.dark-mode #tmv2App main#mainContent.tmv2-page:has(.tmv2-dashboard) {
  background: var(--tmv2-page);
}

/* Buybox ve benzeri araç sayfaları: dashboard ile aynı tuval (solid zemin) */
html:not(.dark-mode) #tmv2App main#mainContent.tmv2-page:has(.buybox-control-module) {
  background: var(--tmv2-surface);
}

html.dark-mode #tmv2App main#mainContent.tmv2-page:has(.buybox-control-module) {
  background: var(--tmv2-page);
}

/* Hakediş / finans: içerik kartları beyaz; ana tuval surface-2 ile tek ton (beyaz şerit yok) */
html:not(.dark-mode) #tmv2App main#mainContent.tmv2-page:has(.payout-dash.tm-payout) {
  background: var(--tmv2-surface-2, var(--tmv2-surface));
}

html.dark-mode #tmv2App main#mainContent.tmv2-page:has(.payout-dash.tm-payout) {
  background: var(--tmv2-page);
}

/* XML Yönetimi — tuval buybox ile aynı; grid dekoru yumuşat */
html:not(.dark-mode) #tmv2App main#mainContent.tmv2-page:has(.xml-sources-page) {
  background: var(--tmv2-surface);
}

html.dark-mode #tmv2App main#mainContent.tmv2-page:has(.xml-sources-page) {
  background: var(--tmv2-page);
}

#tmv2Page.tmv2-page-host:has(.xml-sources-page) {
  --tm-app-grid-line: rgba(15, 23, 42, 0.028);
}

#tmv2Page.tmv2-page-host:has(.xml-sources-page) .bg-shapes::after {
  opacity: 0.42;
}

#tmv2Page.tmv2-page-host:has(.xml-sources-page) .shape {
  opacity: 0.12 !important;
}

/* ----- v2 sayfa hiyerarşisi: .tmv2-page-inner → .tmv2-page-shell → header / grid ----- */
#tmv2App .tmv2-page-inner {
  width: 100%;
  max-width: var(--tmv2-page-inner-max, 1600px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  /* Yatay padding main’de (--tmv2-page-pad-x); burada çift gutter yok */
  padding-left: 0;
  padding-right: 0;
}

#tmv2App .tmv2-page-shell {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--tmv2-section-gap);
  margin-top: 0;
  padding-top: 0;
}

#tmv2App .tmv2-page-header {
  width: 100%;
  min-width: 0;
}

#tmv2App .tmv2-section-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--tmv2-section-gap);
  align-items: start;
  width: 100%;
}

@media (max-width: 991.98px) {
  #tmv2App .tmv2-section-grid {
    grid-template-columns: 1fr;
  }
}

/* Liste / tablo gövdesi — tek yüzey, token border + radius */
#tmv2App .tmv2-table-shell {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: var(--tmv2-r-lg, 14px);
  border: 1px solid var(--tmv2-line-2, var(--tmv2-line));
  background: var(--tmv2-surface);
  box-shadow: var(--tmv2-sh-1, 0 1px 2px rgba(15, 23, 42, 0.04));
  overflow: hidden;
}

html.dark-mode #tmv2App .tmv2-table-shell {
  border-color: var(--tmv2-line);
}

/* Neutralize legacy wrappers if they somehow still exist inside v2 shell */
#tmv2App .app-layout,
#tmv2App .page-shell,
#tmv2App .page-shell__inner {
  display: block !important;
  width: 100% !important;
  min-height: 0 !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Tabbed dashboard */
.tmv2-dashboard {
  width: 100%;
  min-width: 0;
}

/* Dashboard nav: no extra margins, flush to page top */
.tmv2-dashboard .dashboard-shell--nav {
  margin-top: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Dashboard main content: compact spacing */
.tmv2-dashboard .dashboard-main {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* ============ SIDEBAR COMPONENTS ============ */
.tmv2-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 10px;
}
.tmv2-brand-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--tmv2-ink);
}
.tmv2-brand-link:hover { color: var(--tmv2-ink); text-decoration: none; }
.tmv2-brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--tm-logo-blue-deep), var(--color-secondary));
  display: grid; place-items: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  color: var(--tm-fg-on-brand, #fff);
  overflow: hidden;
}
.tmv2-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.tmv2-brand-name {
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.tmv2-brand-name b { color: var(--tmv2-primary); }

/* Workspace switcher */
.tmv2-workspace {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: var(--tmv2-surface-2);
  border: 1px solid var(--tmv2-line);
  border-radius: 12px; cursor: pointer;
}
.tmv2-workspace--readonly { cursor: default; }
.tmv2-workspace:hover { background: var(--tmv2-surface-2); }
.tmv2-workspace--readonly:hover { background: var(--tmv2-surface-2); }
.tmv2-wk-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--tmv2-ink), var(--tmv2-ink-2));
  color: var(--tm-fg-on-brand, #fff); display: grid; place-items: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.tmv2-wk-info { flex: 1; min-width: 0; }
.tmv2-wk-name {
  font-size: 13px; font-weight: 600; color: var(--tmv2-ink);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tmv2-wk-meta { font-size: 11px; color: var(--tmv2-ink-2); margin-top: 2px; }
.tmv2-wk-chev { color: var(--tmv2-mute); }

.tmv2-wk-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--tmv2-surface); border: 1px solid var(--tmv2-line);
  border-radius: var(--tmv2-r-lg); box-shadow: var(--tmv2-sh-2); padding: var(--tmv2-sp-2);
  z-index: var(--tmv2-z-dropdown); display: none;
}
.tmv2-workspace.open .tmv2-wk-menu { display: block; }
.tmv2-wk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer;
  color: var(--tmv2-ink); text-decoration: none;
}
.tmv2-wk-item:hover { background: var(--tmv2-surface-2); color: var(--tmv2-ink); }
.tmv2-wk-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tmv2-mute); }
.tmv2-wk-item.active .dot { background: var(--tmv2-primary); }
.tmv2-wk-item .nm { font-size: 12.5px; font-weight: 600; }
.tmv2-wk-item .sub { font-size: 11px; color: var(--tmv2-ink-2); }
.tmv2-wk-sep { height: 1px; background: var(--tmv2-line-2); margin: 4px 2px; }
.tmv2-wk-add {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 8px; cursor: pointer;
  color: var(--tmv2-primary); font-size: 12.5px; font-weight: 600;
  text-decoration: none;
}
.tmv2-wk-add:hover { background: var(--tmv2-primary-soft); }

/* Sidebar body: scroll zone for nav */
.tmv2-sidebar-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tmv2-sidebar-body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Pro card */
.tmv2-pro-card {
  margin-top: auto;
  background: linear-gradient(
    160deg,
    var(--tm-logo-blue-deep) 0%,
    var(--color-primary) 60%,
    var(--color-primary-hover) 100%
  );
  color: var(--tm-fg-on-brand); padding: var(--tm-layout-gap); border-radius: var(--tmv2-r-lg);
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.tmv2-pro-card::before {
  content:""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,.18), transparent 60%);
  pointer-events: none;
}
.tmv2-pro-label { font-size: 11px; opacity: .85; font-weight: 600; }
.tmv2-pro-days {
  font-family: var(--tmv2-ff-serif); font-size: 20px; line-height: 1.15;
  letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap;
}
.tmv2-pro-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 6px 11px;
  background: rgba(255,255,255,.18); border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--tm-fg-on-brand) !important;
  text-decoration: none; cursor: pointer;
}
.tmv2-pro-cta:hover { background: rgba(255,255,255,.28); }

/* Sidebar — bölüm başlıkları + rozet (referans: kalın siyah başlık) */
.tmv2-nav-section {
  margin: 0 0 2px;
  padding: 0 4px;
}
.tmv2-nav-section:first-child {
  margin-top: 0;
}
.tmv2-nav-section--spaced {
  margin-top: 12px;
}
.tmv2-nav-section-label {
  margin: 0;
  padding: 4px 4px 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--tmv2-ink);
  line-height: 1.25;
}
html.dark-mode .tmv2-nav-section-label {
  color: var(--tmv2-ink);
}
.tmv2-nav-badge {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 1.5rem;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--tmv2-nav-muted);
  background: var(--tmv2-surface-3);
  border: 1px solid var(--tmv2-line-2);
}
html.dark-mode .tmv2-nav-badge {
  background: var(--tmv2-surface-2);
  color: var(--tmv2-ink-2);
  border-color: var(--tmv2-line);
}

/* ============ RESPONSIVE — collapse sidebar below 1024px ============ */
/* ============ RESPONSIVE: TABLET ≤1024px ============ */
@media (max-width: 1024px) {
  .tmv2-app {
    grid-template-columns: 1fr;
  }

  /* Sidebar: off-screen drawer */
  /* z-index: tm-z-layers.css — modal (1055) / backdrop (1050) her zaman bu katmanın üstünde olmalı; eski 100k değerler tüm modalları tıklanmaz bırakıyordu */
  #tmv2SidebarRoot.tmv2-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 320px);
    height: 100%;
    z-index: var(--tm-z-sidebar, 1035);
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
    box-shadow: none;
  }

  #tmv2SidebarRoot.tmv2-sidebar:has(#sidebar.mobile-open) {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  /* Perde, içerik ile drawer arası — modaldan (1050/1055) düşük kalmalı */
  .tmv2-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--tm-z-fixed, 1030);
    opacity: 0;
    transition: opacity 0.28s ease;
  }

  .tmv2-sidebar-backdrop.is-visible {
    display: block;
    opacity: 1;
  }

  .tmv2-main {
    grid-column: 1 / -1;
  }

  #tmv2App {
    --tmv2-layout-gutter: var(--tmv2-sp-4);
    --tmv2-page-pad-x: var(--tmv2-layout-gutter);
    --tmv2-page-pad-y: var(--tmv2-layout-gutter);
    --tmv2-page-pad-bottom: var(--tmv2-sp-6);
  }

  /* Header: compact; yatay padding = layout gutter */
  header.tmv2-header {
    padding: 0 var(--tmv2-layout-gutter);
    min-height: 52px;
  }

  /* Header search: hide on tablet */
  header.tmv2-header .tmv2-search,
  header.tmv2-header .tmv2-header-search {
    display: none !important;
  }

  /* Page padding now from tokens above */
}

/* ============ RESPONSIVE: MOBILE ≤768px ============ */
@media (max-width: 768px) {
  #tmv2App {
    --tmv2-layout-gutter: var(--tmv2-sp-3);
    --tmv2-page-pad-x: var(--tmv2-layout-gutter);
    --tmv2-page-pad-y: var(--tmv2-layout-gutter);
    --tmv2-page-pad-bottom: var(--tmv2-sp-5);
  }

  header.tmv2-header {
    padding: 0 var(--tmv2-layout-gutter);
    min-height: 48px;
    /* x:hidden + y:visible bazı motorlarda dropdown'ı keser; panel açılıyor ama görünmüyordu */
    overflow: visible;
  }

  header.tmv2-header .tmv2-header-inner {
    gap: 6px;
    min-height: 48px;
  }

  /* Hide non-essential header items on mobile */
  header.tmv2-header .tmv2-header-status,
  header.tmv2-header .btn-nasil-yapilir {
    display: none !important;
  }

  /* Shrink action buttons on mobile: 44px → 36px */
  header.tmv2-header .header-actions,
  header.tmv2-header .tmv2-header-actions {
    gap: 4px !important;
  }

  header.tmv2-header .header-dropdown-btn,
  header.tmv2-header .header-actions .btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
  }

  header.tmv2-header .header-actions .btn i,
  header.tmv2-header .header-dropdown-btn i {
    width: 18px !important;
    height: 18px !important;
  }

  /* Account avatar smaller */
  header.tmv2-header #accountMenuToggle .rounded-circle {
    width: 32px !important;
    height: 32px !important;
  }

  /* Title: truncate if too long */
  header.tmv2-header .tmv2-header-title {
    font-size: 16px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  /* The inline-in-bar grid: collapse to min-content on mobile */
  header.tmv2-header .tmv2-header--inline-in-bar {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  /* Hide "What's New" button on mobile to save space */
  header.tmv2-header #whatsNewToggle {
    display: none !important;
  }

  /* Background grid: reduce on mobile */
  .bg-shapes::before {
    opacity: 0.4;
  }
}

/* ============ RESPONSIVE: SMALL MOBILE ≤480px ============ */
@media (max-width: 480px) {
  #tmv2App {
    --tmv2-layout-gutter: var(--tmv2-sp-2);
    --tmv2-page-pad-x: var(--tmv2-layout-gutter);
    --tmv2-page-pad-y: var(--tmv2-layout-gutter);
    --tmv2-page-pad-bottom: var(--tmv2-sp-4);
  }

  header.tmv2-header {
    padding: 0 var(--tmv2-layout-gutter);
    min-height: 44px;
  }

  header.tmv2-header .tmv2-header-inner {
    gap: 4px;
  }

  /* Further shrink buttons */
  header.tmv2-header .header-dropdown-btn,
  header.tmv2-header .header-actions .btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }

  /* Dark mode toggle mobilde de görünsün — kullanıcı talebi.
     Önceki "alan korumak için gizle" stratejisi UX maliyeti yarattı:
     gece kullanan kullanıcı temayı değiştirmek için sayfa derinine
     girmek zorunda kalıyordu. Buton 32x32 olduğu için zaten dar yer
     kaplıyor. */
  header.tmv2-header #darkModeToggle {
    display: inline-flex !important;
  }

  /* Title even more compact */
  header.tmv2-header .tmv2-header-title {
    font-size: 14px !important;
    max-width: 100px;
  }

  /* Floating buttons: hide on small screens */
  #tmFbkOpen {
    display: none !important;
  }
}

/* ============ MOBILE UTILITY CLASSES ============ */

/* Table scroll wrapper — prevents body horizontal scroll */
.tmv2-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Auto table scroll on mobile — any table inside page content */
@media (max-width: 1024px) {
  #tmv2App main#mainContent.tmv2-page .table-responsive,
  #tmv2App main#mainContent.tmv2-page .table-scroll,
  #tmv2App main#mainContent.tmv2-page table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent cards and containers from exceeding viewport */
  #tmv2App main#mainContent.tmv2-page .card,
  #tmv2App main#mainContent.tmv2-page .panel,
  #tmv2App main#mainContent.tmv2-page [class*="container"] {
    max-width: 100%;
    overflow-x: hidden;
  }
}

/* Filter bar: responsive wrap */
@media (max-width: 768px) {
  .tmv2-filter-bar,
  .tmv2-filterbar,
  .filter-bar,
  .dashboard-top-controls {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .tmv2-filter-bar > *,
  .tmv2-filterbar > *,
  .filter-bar > * {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
  }

  .tmv2-filter-bar .btn,
  .tmv2-filterbar .btn,
  .filter-bar .btn {
    flex: 0 0 auto;
  }
}

/* Empty state: compact on mobile */
@media (max-width: 768px) {
  .tmv2-empty-state,
  .empty-state-container {
    padding: 24px 16px !important;
    min-height: auto !important;
  }

  .tmv2-empty-state img,
  .empty-state-container img {
    max-width: 120px;
  }
}

/* Modal: mobile friendly */
@media (max-width: 768px) {
  .modal-dialog {
    max-width: calc(100vw - 16px) !important;
    margin: 8px auto !important;
  }

  .modal-body {
    max-height: 70vh;
    overflow-y: auto;
  }
}
