/* =========================================================
   STOVIT Logistics Hub – base.css (FINAL)
   - spójne breakpointy: 576 (phone), 992 (tablet/desktop)
   - fullbleed bez 100vw (brak “prawego marginesu” od scrollbara)
   - mobile UX: home + zamowienia_list (filtry/KPI/tabela)
   ========================================================= */

/* =========================
   TOKENS / THEME
   ========================= */
:root{
  --bg:#f3f4f6;
  --card-bg:#ffffff;
  --text:#0f172a;
  --muted:rgba(0,0,0,.65);
  --border:rgba(0,0,0,.08);

  --shadow-sm:0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 4px 16px rgba(0,0,0,.06);

  --nav-grad-1:#0f766e;
  --nav-grad-2:#14b8a6;

  --thead-bg:#0f172a;
  --thead-fg:#e5e7eb;

  --primary:#2563eb;
  --primary-bg:#eff6ff;

  --danger:#dc2626;
  --success:#16a34a;

  /* padding content-shell (używane do full-bleed bez vw) */
  --shell-pad:24px;
}
@media (max-width:991.98px){
  :root{ --shell-pad:16px; }
}
@media (max-width:575.98px){
  :root{ --shell-pad:12px; }
}

/* =========================
   BASE LAYOUT
   ========================= */
html,body{height:100%;}
body{
  background:var(--bg);
  font-family:"Inter",system-ui,-apple-system,sans-serif;
  margin:0;
  padding:0;
  color:var(--text);
  overflow-x:hidden;
}

/* pełna szerokość contentu (użyj w base.html: <main class="app-shell">) */
.app-shell{
  width:100%;
  max-width:100%;
  margin:0;
  padding:18px var(--shell-pad) 24px;
  box-sizing:border-box;
}

/* =========================
   NAVBAR
   ========================= */
.stv-navbar{
  background:linear-gradient(90deg,var(--nav-grad-1),var(--nav-grad-2));
}
.stv-navbar .navbar-brand{
  font-weight:700;
  letter-spacing:.03em;
}
.navbar-logo{height:32px;width:auto;display:block;}
.navbar-nav .nav-item form{display:flex;align-items:center;}
.navbar-nav .nav-item form button.nav-link{display:flex;align-items:center;height:100%;}

/* =========================
   FILTER PANEL (base)
   ========================= */
.filter-panel{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:14px;
  background:var(--card-bg);
  padding:14px 20px;
  border-radius:10px;
  margin-bottom:20px;
  box-shadow:0 2px 8px rgba(0,0,0,.05);
  box-sizing:border-box;
}
.filter-panel input[type="date"],
.filter-panel input[type="text"]{
  padding:6px 10px;
  border:1px solid #d1d5db;
  border-radius:6px;
  font-size:14px;
}
.filter-panel label{font-size:14px;color:#374151;}

/* mobile: tylko dla “zwykłego” filter-panel */
@media (max-width:575.98px){
  .filter-panel:not(.filter-panel--fullbleed){padding:10px;}
  .filter-panel:not(.filter-panel--fullbleed) label{
    width:100%;
    display:flex;
    justify-content:space-between;
    gap:10px;
  }
  .filter-panel:not(.filter-panel--fullbleed) input[type="text"],
  .filter-panel:not(.filter-panel--fullbleed) input[type="date"]{
    width:100%;
    min-width:0;
  }
}

/* =========================
   FILTER PANEL FULLBLEED (zamowienia_list)
   - bez 100vw => brak prawego “marginesu” od scrollbara
   ========================= */
.filter-panel.filter-panel--fullbleed{
  width:calc(100% + (2 * var(--shell-pad)));
  margin-left:calc(-1 * var(--shell-pad));
  margin-right:calc(-1 * var(--shell-pad));

  padding:14px 24px;
  border-radius:0;
  border-top:1px solid rgba(0,0,0,.06);
  border-bottom:1px solid rgba(0,0,0,.06);
  background:#fff;
  display:flex;
  flex-direction:column;
  gap:10px;
  box-shadow:none;
  box-sizing:border-box;
}

.filter-panel--fullbleed .filter-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  align-items:center;
}
.filter-panel--fullbleed .filter-row.top{justify-content:space-between;}
.filter-panel--fullbleed .filter-left,
.filter-panel--fullbleed .filter-oracle,
.filter-panel--fullbleed .filter-raben,
.filter-panel--fullbleed .filter-actions{
  display:inline-flex;
  flex-wrap:wrap;
  gap:10px 12px;
  align-items:center;
}
.filter-panel--fullbleed .filter-actions{margin-left:auto;}
.filter-panel--fullbleed .filter-row.bottom{justify-content:flex-start;}
.filter-panel--fullbleed label{
  display:inline-flex;
  gap:8px;
  align-items:center;
  margin:0;
  white-space:nowrap;
}
.filter-panel--fullbleed input[type="text"]{min-width:240px;}
.filter-panel--fullbleed input[type="date"]{min-width:150px;}
.filter-panel--fullbleed .filter-sep{
  width:1px;height:22px;background:rgba(0,0,0,.12);
  margin:0 4px;align-self:center;
}
.filter-panel--fullbleed .filter-title{font-weight:600;margin-right:4px;}
.filter-panel--fullbleed .btn-row{
  display:inline-flex;flex-wrap:wrap;gap:10px;align-items:center;
}

@media (max-width:991.98px){
  .filter-panel.filter-panel--fullbleed{padding:12px 16px;}
  .filter-panel--fullbleed input[type="text"]{min-width:200px;}
}

/* phone: filtry układ “kolumny”, przyciski 100% */
@media (max-width:575.98px){
  .filter-panel.filter-panel--fullbleed{padding:12px 12px;}
  .filter-panel--fullbleed .filter-sep{display:none;}

  .filter-panel--fullbleed .filter-left,
  .filter-panel--fullbleed .filter-oracle,
  .filter-panel--fullbleed .filter-raben,
  .filter-panel--fullbleed .filter-actions,
  .filter-panel--fullbleed .btn-row{
    width:100%;
  }

  .filter-panel--fullbleed label{
    width:100%;
    display:flex;
    justify-content:space-between;
    gap:10px;
    white-space:normal;
  }
  .filter-panel--fullbleed input[type="text"],
  .filter-panel--fullbleed input[type="date"]{
    width:100%;
    min-width:0;
  }

  .filter-panel--fullbleed .filter-actions{margin-left:0;}
  .filter-panel--fullbleed .filter-actions .btn,
  .filter-panel--fullbleed .btn-row .btn{
    width:100%;
    padding:10px 12px;
    border-radius:12px;
    font-weight:700;
  }
}

/* =========================
   TABLES
   ========================= */
.table-wrapper{
  background:var(--card-bg);
  border-radius:12px;
  box-shadow:var(--shadow-md);
  max-width:100%;

  /* klucz: scroll X bez psucia layoutu */
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  box-sizing:border-box;
}

.table-modern{
  width:100%;
  border-collapse:collapse;
}
.table-modern thead tr{background:var(--thead-bg);color:var(--thead-fg);}
.table-modern thead th{
  padding:10px 8px;
  font-weight:600;
  font-size:13px;
  text-align:left;
  position:sticky;
  top:0;
  z-index:10;
  white-space:nowrap;
}
.table-modern tbody tr{border-bottom:1px solid #e5e7eb;}
.table-modern tbody tr:hover{background:#f9fafb;}
.table-modern tbody td{
  padding:10px 8px;
  font-size:14px;
  vertical-align:middle;
}
@media (max-width:991.98px){
  .table-modern th,.table-modern td{font-size:12px;padding:8px 6px;}
}
@media (max-width:575.98px){
  .table-modern th,.table-modern td{padding:8px 6px;}
}

/* helpery do ukrywania kolumn */
@media (max-width:575.98px){ .col-hide-sm{display:none !important;} }
@media (max-width:991.98px){ .col-hide-md{display:none !important;} }

/* fullbleed tabela – bez 100vw */
.table-wrapper.table-wrapper--fullbleed{
  width:calc(100% + (2 * var(--shell-pad)));
  margin-left:calc(-1 * var(--shell-pad));
  margin-right:calc(-1 * var(--shell-pad));

  border-radius:0;
  border-top:1px solid rgba(0,0,0,.06);
  border-bottom:1px solid rgba(0,0,0,.06);
  background:#fff;
}

/* fullbleed: stabilne kolumny + ellipsis */
.table-wrapper--fullbleed .table-modern{
  table-layout:fixed;
  border-collapse:separate;
  border-spacing:0;
}
.table-wrapper--fullbleed .table-modern th,
.table-wrapper--fullbleed .table-modern td{
  overflow:hidden;
  text-overflow:ellipsis;
}

/* oddech po bokach */
.table-wrapper--fullbleed .table-modern th:first-child,
.table-wrapper--fullbleed .table-modern td:first-child{padding-left:24px;}
.table-wrapper--fullbleed .table-modern th:last-child,
.table-wrapper--fullbleed .table-modern td:last-child{padding-right:24px;}

/* przyciski w ostatniej kolumnie */
.table-wrapper--fullbleed .table-modern th:last-child,
.table-wrapper--fullbleed .table-modern td:last-child{
  overflow:visible;
  text-overflow:clip;
  white-space:nowrap;
}

@media (max-width:575.98px){
  .table-wrapper--fullbleed .table-modern th:first-child,
  .table-wrapper--fullbleed .table-modern td:first-child{padding-left:12px;}
  .table-wrapper--fullbleed .table-modern th:last-child,
  .table-wrapper--fullbleed .table-modern td:last-child{padding-right:12px;}
}

/* =========================
   ROW HIGHLIGHTS
   ========================= */
.row-high{background:#fef2f2 !important;}
.row-zalegle,.row-warning{background:#fff7ed !important;}

/* =========================
   BADGES
   ========================= */
.badge{
  padding:4px 8px;
  font-size:12px;
  border-radius:6px;
  display:inline-block;
  font-weight:600;
}
.badge-wysoki,.badge-prio-high{background:var(--danger);color:#fff;}
.badge-normalny,.badge-prio-normal{background:var(--success);color:#fff;}
.badge-zgloszone{background:var(--primary);color:#fff;}
.badge-kwota{background:#f0f9ff;color:#0369a1;border:1px solid #bae6fd;}
.badge-red{background:#fee2e2;color:#b91c1c;border:1px solid #fecaca;}
.badge-green{background:#dcfce7;color:#15803d;border:1px solid #bbf7d0;}
.badge-blue{background:#dbeafe;color:#1e3a8a;border:1px solid #bfdbfe;}
.badge-gray{background:#f3f4f6;color:#374151;border:1px solid #e5e7eb;}
.badge-orange{background:#f39c12;color:#fff;}

/* =========================
   BUTTON HELPERS
   ========================= */
.btn-reexport{border-color:var(--primary);color:#1d4ed8;background:var(--primary-bg);}
.btn-reexport:hover{background:#dbeafe;}

.btn-ghost{
  background:transparent;
  border:1px solid #d1d5db;
  padding:4px 10px;
  border-radius:6px;
  cursor:pointer;
  font-size:13px;
  transition:all .2s;
}
.btn-ghost:hover{background:#f3f4f6;}

/* SKU toggle */
.btn-sku-toggle{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;}
@media (max-width:575.98px){
  .btn-sku-toggle{
    width:100%;
    justify-content:center;
    padding:10px 12px;
    border-radius:12px;
    font-weight:700;
  }
}

/* =========================
   HOME / DASHBOARD
   ========================= */
.home-hero{margin-top:18px;margin-bottom:18px;}
.home-hero h2{font-weight:800;letter-spacing:.2px;margin-bottom:6px;}
.home-hero .home-subtitle{color:rgba(0,0,0,.60);font-size:14px;margin:0;}

.home-grid{
  display:grid;
  grid-template-columns:repeat(12,1fr);
  gap:16px;
  margin-top:16px;
  margin-bottom:18px;
}
.home-card{
  background:var(--card-bg);
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:var(--shadow-sm);
  transition:transform .12s ease, box-shadow .12s ease;
  overflow:hidden;
}
.home-card:hover{transform:translateY(-1px);box-shadow:0 10px 26px rgba(0,0,0,.10);}
.home-card a{display:block;color:inherit;text-decoration:none;}
.home-card .card-body{padding:18px 18px 16px;}
.home-card .card-title{
  font-size:12px;
  font-weight:800;
  letter-spacing:.6px;
  text-transform:uppercase;
  color:rgba(0,0,0,.55);
  margin-bottom:10px;
}
.home-card .card-main{display:flex;gap:14px;align-items:flex-start;}
.home-card .card-icon{
  width:44px;height:44px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  font-size:20px;
  background:rgba(13,110,253,.10);
  border:1px solid rgba(13,110,253,.12);
  flex:0 0 auto;
}
.home-card .card-text h3{font-size:18px;font-weight:800;margin:0 0 6px;}
.home-card .card-text p{font-size:13px;color:var(--muted);margin:0;line-height:1.35;}
.home-card .card-footer-lite{
  padding:12px 18px 14px;
  border-top:1px solid rgba(0,0,0,.06);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  background:rgba(0,0,0,.02);
}
.home-card .chip{font-size:12px;color:rgba(0,0,0,.62);}
.home-card .btn-go{font-size:12px;font-weight:700;padding:6px 10px;border-radius:10px;}

.home-col-6{grid-column:span 6;}
.home-col-12{grid-column:span 12;}

@media (max-width:991.98px){
  .home-col-6{grid-column:span 12;}
}
@media (max-width:575.98px){
  .home-grid{grid-template-columns:1fr;gap:12px;}
  .home-card .card-body{padding:16px;}
  .home-card .card-text p{font-size:14px;line-height:1.4;}
  .home-card .card-footer-lite{flex-direction:column;align-items:stretch;}
  .home-card .btn-go{width:100%;justify-content:center;}
}

/* =========================
   REALIZACJA (progress)
   ========================= */
.realizacja-wrap{width:160px;}
.realizacja-bar-bg{
  width:160px;height:12px;background:#eee;border-radius:6px;overflow:hidden;
}
.realizacja-bar{height:12px;border-radius:6px;}
.realizacja-label{font-size:11px;color:#555;margin-top:2px;white-space:nowrap;}

@media (max-width:575.98px){
  .realizacja-wrap{width:130px;}
  .realizacja-bar-bg{width:130px;}
}

/* =========================
   KPI BAR
   ========================= */
.kpi-bar{
  padding:12px 24px;
  border-bottom:1px solid rgba(0,0,0,.06);
  background:#fff;
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  align-items:stretch;
  max-width:100%;
  box-sizing:border-box;
}

/* fullbleed KPI – bez 100vw */
.kpi-bar.kpi-bar--fullbleed{
  width:calc(100% + (2 * var(--shell-pad)));
  margin-left:calc(-1 * var(--shell-pad));
  margin-right:calc(-1 * var(--shell-pad));
}

.kpi-card{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:2px;
  padding:10px 12px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:10px;
  background:#f8fafc;
  flex:1 1 190px;
  min-height:64px;
  box-sizing:border-box;
}
.kpi-label{font-size:12px;color:#475569;white-space:nowrap;}
.kpi-value{font-size:20px;font-weight:700;color:#0f172a;line-height:1.1;}
.kpi-hint{font-size:11px;color:#64748b;white-space:nowrap;}

@media (max-width:991.98px){
  .kpi-bar{padding:10px 16px;}
  .kpi-value{font-size:18px;}
}
@media (max-width:575.98px){
  .kpi-bar{padding:10px 12px;gap:10px;}
  .kpi-card{flex:1 1 100%;padding:12px 14px;min-height:74px;}
  .kpi-value{font-size:22px;}
  .kpi-hint{white-space:normal;}
}

/* =========================
   SKU detail table (expand)
   ========================= */
.sku-detail-table{
  width:100%;
  table-layout:fixed;
  border-collapse:separate;
  border-spacing:0;
}
.sku-detail-table thead th{
  position:sticky;
  top:0;
  z-index:6;
  background:var(--thead-bg);
  color:var(--thead-fg);
  white-space:nowrap;
}
.sku-detail-table th,
.sku-detail-table td{padding:10px 12px;vertical-align:top;}
.sku-detail-table tbody tr:nth-child(even){background:#fff;}
.sku-detail-table tbody tr:nth-child(odd){background:#f8fafc;}
.sku-detail-table tbody tr + tr td{border-top:1px solid rgba(0,0,0,.06);}

.sku-col-sku{width:110px;}
.sku-col-name{width:420px;}
.sku-col-jm{width:70px;}
.sku-col-plan{width:120px;}
.sku-col-real{width:240px;}
.sku-col-order{width:220px;}
.sku-col-val{width:170px;}

.nazwa-wrap{
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  display:block;
  line-height:1.25;
  word-break:break-word;
}

/* =========================
   FOOTER
   ========================= */
.stv-footer,
.stw-footer{
  font-size:.8rem;
  color:#6b7280;
}

/* =========================
   Orders list – kontrahent (2 linie na telefonie)
   - -webkit-line-clamp jest OK (VSCode czasem podkreśla, ale działa w Safari/Chrome)
   ========================= */
@media (max-width:575.98px){
  .orders-table .col-kontr{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
    white-space:normal;
    line-height:1.15;
  }
}

/* =========================
   FULLBLEED – fix: równo do krawędzi (lewa i prawa)
   ========================= */
.filter-panel.filter-panel--fullbleed,
.kpi-bar.kpi-bar--fullbleed,
.table-wrapper.table-wrapper--fullbleed{
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  max-width: 100vw;
  box-sizing: border-box;
  overflow-x: clip;
}
/* =========================
   SKU toggle – mobile: bez słowa "Pokaż"
   ========================= */
@media (max-width:575.98px){
  .btn-sku-toggle{
    width:auto;                 /* nie rozciągaj na 100% */
    max-width:120px;            /* pilnujemy szerokości */
    padding:8px 10px;
    border-radius:14px;
    font-weight:700;
    font-size:14px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    white-space:nowrap;
  }

  .btn-sku-toggle .btn-sku-text{ display:none; }  /* ukryj "Pokaż" */
  .btn-sku-toggle .btn-sku-count{ font-variant-numeric: tabular-nums; }
}