/* =============================================================
   OTMS — System zarządzania transportem
   Design System v1.0
   Kolorystyka: granat #0f2137, niebieski #1e5fa8
   ============================================================= */

/* --- ZMIENNE ------------------------------------------------- */
:root {
  /* Kolory główne */
  --primary:        #1e5fa8;
  --primary-dark:   #174d8c;
  --primary-light:  #e8f0fb;
  --primary-hover:  #1753a0;

  /* Sidebar */
  --sidebar-bg:     #0d1f35;
  --sidebar-hover:  #162d4a;
  --sidebar-active: #1a3a5c;
  --sidebar-text:   #94a8be;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-width:  240px;

  /* Layout */
  --topbar-h:       56px;
  --content-bg:     #f0f4f8;
  --card-bg:        #ffffff;
  --border:         #e2e8f0;
  --border-focus:   #1e5fa8;

  /* Tekst */
  --text:           #1a2332;
  --text-secondary: #5a6a7e;
  --text-muted:     #94a3b4;
  --text-link:      #1e5fa8;

  /* Statusy */
  --red:     #dc2626; --red-bg:     #fef2f2; --red-border:     #fecaca;
  --orange:  #ea580c; --orange-bg:  #fff7ed; --orange-border:  #fed7aa;
  --yellow:  #b45309; --yellow-bg:  #fefce8; --yellow-border:  #fde68a;
  --green:   #16a34a; --green-bg:   #f0fdf4; --green-border:   #bbf7d0;
  --blue:    #2563eb; --blue-bg:    #eff6ff; --blue-border:    #bfdbfe;
  --purple:  #7c3aed; --purple-bg:  #f5f3ff; --purple-border:  #ddd6fe;
  --gray:    #6b7280; --gray-bg:    #f9fafb; --gray-border:    #e5e7eb;
  --teal:    #0d9488; --teal-bg:    #f0fdfa; --teal-border:    #99f6e4;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);

  /* Radius */
  --r-sm:   4px;
  --r:      8px;
  --r-md:   10px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-full: 9999px;

  /* Transitions */
  --transition: 150ms ease;
}

/* --- TWEMOJI COUNTRY FLAGS — fix dla Chrome/Windows ---------- */
/* Windows nie ma fontu z flagami emoji (Segoe UI Emoji nie zawiera flag).
   Twemoji Country Flags webfont (~100kb) renderuje flagi 🇵🇱 🇬🇧 🇩🇪 itp.
   Dzięki unicode-range font ładuje się TYLKO dla zakresów flag — reszta tekstu
   używa systemowych fontów. Source: github.com/talkjs/country-flag-emoji-polyfill */
@font-face {
    font-family: "Twemoji Country Flags";
    unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067,
                   U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
    src: url("https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1.8/dist/TwemojiCountryFlags.woff2") format("woff2");
    font-display: swap;
}

/* --- RESET --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  /* Twemoji Country Flags PRZED system emoji fonts — Chrome/Windows pokaże flagi */
  font-family: "Twemoji Country Flags", -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', system-ui, sans-serif;
  color: var(--text);
  background: var(--content-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* --- LAYOUT APP ---------------------------------------------- */
.layout-app {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR ------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo */
.sidebar-logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.sidebar-logo-img {
  height: 32px;
  width: auto;
}
.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.logo-main {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
}
.logo-sub {
  font-size: 10px;
  color: var(--sidebar-text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Firma */
.sidebar-company {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--sidebar-text);
  border-bottom: 1px solid var(--sidebar-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nawigacja */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.nav-group {
  padding: 2px 8px;
}
.nav-group-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
  text-transform: uppercase;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r);
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.nav-item.nav-active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}
.nav-item.nav-active .nav-icon svg {
  color: #60a5fa;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}
.nav-label { flex: 1; }
.nav-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

/* Sidebar bottom */
.sidebar-bottom {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* --- MAIN AREA ----------------------------------------------- */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- TOPBAR -------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  color: var(--text-secondary);
}
.hamburger, .hamburger::before, .hamburger::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  transition: var(--transition);
}
.hamburger { position: relative; }
.hamburger::before { content:''; position:absolute; top:-6px; }
.hamburger::after  { content:''; position:absolute; bottom:-6px; }

.topbar-btn {
  position: relative;
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--r);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}
.topbar-btn:hover { background: var(--content-bg); }
.topbar-btn svg { width: 20px; height: 20px; }

/* Global search */
.global-search {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
#globalSearchInput {
  width: 240px;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--content-bg);
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--transition), width var(--transition);
  outline: none;
}
#globalSearchInput:focus {
  border-color: var(--border-focus);
  background: #fff;
  width: 320px;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 300px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
}

/* Notification bell */
.notif-bell { position: relative; }
.notif-btn svg { width: 20px; height: 20px; }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--r-full);
  min-width: 16px;
  text-align: center;
  line-height: 14px;
  border: 2px solid #fff;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.notif-mark-all {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
}

/* Notification items in dropdown */
.notif-drop-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-drop-item:hover { background: var(--content-bg); }
.notif-drop-item.unread { background: #f0f6ff; }
.notif-drop-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
}
.notif-drop-dot.read { background: transparent; border: 1px solid var(--gray-border); }
.notif-drop-title { font-size: 12px; font-weight: 600; color: var(--text); }
.notif-drop-msg   { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.notif-drop-time  { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* Priorities */
.priority-critical .notif-drop-dot,
.priority-critical .notif-feed-dot { background: var(--red); }
.priority-high     .notif-drop-dot,
.priority-high     .notif-feed-dot { background: var(--orange); }
.priority-medium   .notif-drop-dot,
.priority-medium   .notif-feed-dot { background: var(--blue); }

/* User menu */
.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { width: 10px; height: 10px; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.user-dropdown-name { font-weight: 600; font-size: 13px; }
.user-dropdown-role { margin-top: 4px; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  transition: background var(--transition);
  text-decoration: none;
}
.user-dropdown-item:hover { background: var(--content-bg); text-decoration: none; }
.user-dropdown-item svg { width: 16px; height: 16px; color: var(--text-secondary); }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-dropdown-logout { color: var(--red); }
.user-dropdown-logout:hover { background: var(--red-bg); }
.user-dropdown-logout svg { color: var(--red); }

/* --- CONTENT AREA -------------------------------------------- */
.app-content {
  flex: 1;
  padding: 24px;
  width: 100%;
  min-width: 0;       /* fix flex overflow */
}

/* --- FLASH MESSAGES ------------------------------------------ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13.5px;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } }
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-close { margin-left: auto; background: none; border: none; font-size: 18px; color: inherit; opacity: 0.7; cursor: pointer; padding: 0 4px; }
.flash-success { background: var(--green-bg);  color: #166534; border-bottom: 2px solid var(--green-border); }
.flash-error   { background: var(--red-bg);    color: #991b1b; border-bottom: 2px solid var(--red-border); }
.flash-info    { background: var(--blue-bg);   color: #1e40af; border-bottom: 2px solid var(--blue-border); }
.flash-warning { background: var(--yellow-bg); color: #92400e; border-bottom: 2px solid var(--yellow-border); }

/* --- PAGE HEADER --------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.page-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.page-header-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- PANELS / CARDS ------------------------------------------ */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.panel-action {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}
.panel-body { padding: 16px 18px; }
.panel-body-flush { padding: 0; }

/* --- KPI CARDS ----------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }
.kpi-card-alert { border-color: var(--blue-border); }
.kpi-card-muted { opacity: 0.7; }
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon-blue   { background: var(--blue-bg);   color: var(--blue);   }
.kpi-icon-green  { background: var(--green-bg);  color: var(--green);  }
.kpi-icon-orange { background: var(--orange-bg); color: var(--orange); }
.kpi-icon-red    { background: var(--red-bg);    color: var(--red);    }
.kpi-icon-gray   { background: var(--gray-bg);   color: var(--gray);   }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.kpi-value-alert { color: var(--blue); }
.kpi-value-muted { color: var(--text-muted); }
.kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.dashboard-col {}

/* Quick access */
.quick-access-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.quick-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity var(--transition), transform var(--transition);
  position: relative;
}
.quick-card:hover { transform: translateY(-1px); text-decoration: none; opacity: 0.9; }
.quick-card-soon  { opacity: 0.6; }
.quick-icon svg   { width: 16px; height: 16px; }
.quick-card-blue   { background: var(--blue-bg);   color: var(--blue);   }
.quick-card-green  { background: var(--green-bg);  color: var(--green);  }
.quick-card-orange { background: var(--orange-bg); color: var(--orange); }
.quick-card-teal   { background: var(--teal-bg);   color: var(--teal);   }
.quick-card-purple { background: var(--purple-bg); color: var(--purple); }
.quick-card-red    { background: var(--red-bg);    color: var(--red);    }
.coming-badge {
  font-size: 9px;
  font-weight: 600;
  background: rgba(0,0,0,0.1);
  padding: 1px 5px;
  border-radius: var(--r-full);
  margin-left: 4px;
}

/* --- STATUS PILLS -------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 18px;
}
.status-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.status-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.status-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.status-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.status-blue   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid var(--blue-border); }
.status-gray   { background: var(--gray-bg);   color: var(--gray);   border: 1px solid var(--gray-border); }
.status-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }

/* Priority pills */
.priority-pill-critical { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.priority-pill-high     { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.priority-pill-medium   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid var(--blue-border); }
.priority-pill-low      { background: var(--gray-bg);   color: var(--gray);   border: 1px solid var(--gray-border); }

/* Role badge */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}

/* Deadline colors */
.deadline-overdue  { color: var(--red);    font-weight: 600; }
.deadline-today    { color: var(--red);    font-weight: 600; }
.deadline-tomorrow { color: var(--orange); font-weight: 600; }
.deadline-soon     { color: var(--yellow); font-weight: 500; }

/* --- TABLES -------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}
.data-table th {
  padding: 9px 14px;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: left;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }
.data-table-sm th { padding: 7px 12px; }
.data-table-sm td { padding: 8px 12px; }
.row-inactive td { opacity: 0.55; }
.table-empty { text-align: center; padding: 40px 20px !important; color: var(--text-muted); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-datetime { white-space: nowrap; color: var(--text-secondary); font-size: 12.5px; }
.text-mono { font-family: monospace; font-size: 12px; color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* --- FORMS --------------------------------------------------- */
.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.form-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }
.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.form-actions {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group-inline { flex-direction: row; align-items: center; gap: 12px; }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-label-required::after { content: ' *'; color: var(--red); }
.form-label-link { font-size: 12px; font-weight: normal; color: var(--primary); }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(30,95,168,0.12);
}
.form-input.is-invalid, .form-select.is-invalid { border-color: var(--red); }
.form-input:disabled, .form-select:disabled { background: #f3f4f6; color: var(--text-secondary); cursor: not-allowed; }
.form-input-sm, .form-select-sm { padding: 6px 10px; font-size: 13px; }
.form-error { font-size: 12px; color: var(--red); }
.form-hint  { font-size: 11.5px; color: var(--text-muted); }
.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 38px; }
.input-icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.input-icon-btn:hover { color: var(--text-secondary); }

/* Toggle switch */
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--gray-border);
  border-radius: var(--r-full);
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: #fff;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.toggle-input:checked + .toggle-slider { background: var(--primary); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(18px); }

/* --- BUTTONS ------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(30,95,168,0.3); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--content-bg); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: none; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--content-bg); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-login { padding: 10px 20px; font-size: 14px; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--content-bg); color: var(--text); }
.btn-icon-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-icon svg { width: 14px; height: 14px; }
.actions-group { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

/* --- ALERTS -------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  border: 1px solid;
}
.alert-error   { background: var(--red-bg);  color: #991b1b; border-color: var(--red-border);  }
.alert-success { background: var(--green-bg); color: #166534; border-color: var(--green-border); }
.alert-info    { background: var(--blue-bg);  color: #1e40af; border-color: var(--blue-border);  }
.alert svg { width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; }
.error-list { margin: 6px 0 0 6px; }
.error-list li { margin-top: 3px; font-size: 13px; }

/* --- FILTERS BAR --------------------------------------------- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filters-bar-wrap { flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-search { min-width: 220px; }
.filter-count { font-size: 12px; color: var(--text-secondary); margin-left: 8px; }
.filter-sep { color: var(--text-muted); }

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border);
}
.tab-item {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: color var(--transition);
}
.tab-item:hover { color: var(--text); text-decoration: none; }
.tab-active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- PAGINATION ---------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  justify-content: center;
}
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff;
  text-decoration: none;
  transition: background var(--transition);
  min-width: 34px;
  text-align: center;
}
.page-btn:hover { background: var(--content-bg); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-dots { padding: 0 4px; color: var(--text-muted); }

/* --- USER CELLS --------------------------------------------- */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-fullname { font-weight: 500; font-size: 13.5px; }
.user-username { font-size: 11.5px; color: var(--text-muted); }

/* --- ACTIVITY / NOTIFICATIONS FEED -------------------------- */
.notif-feed { }
.notif-feed-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-feed-item:hover { background: var(--content-bg); }
.notif-feed-item:last-child { border-bottom: none; }
.notif-feed-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--blue);
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-unread .notif-feed-dot { background: var(--primary); }
.notif-read   .notif-feed-dot { background: var(--gray-border); }
.notif-feed-title { font-size: 13px; font-weight: 600; }
.notif-feed-msg   { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.notif-feed-time  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-feed-arrow { margin-left: auto; color: var(--text-muted); font-size: 14px; }

.notif-full-list {}
.notif-full-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.notif-full-item:last-child { border-bottom: none; }
.notif-full-unread { background: #f0f6ff; }
.notif-full-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-full-icon svg { width: 18px; height: 18px; }
.notif-priority-critical { background: var(--red-bg);    color: var(--red);    }
.notif-priority-high     { background: var(--orange-bg); color: var(--orange); }
.notif-priority-medium   { background: var(--blue-bg);   color: var(--blue);   }
.notif-priority-low      { background: var(--gray-bg);   color: var(--gray);   }
.notif-full-content { flex: 1; }
.notif-full-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.notif-full-title   { font-size: 13.5px; font-weight: 600; }
.notif-full-time    { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.notif-full-msg     { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.notif-full-meta    { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.notif-full-module  { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.notif-full-actions { display: flex; gap: 4px; align-items: flex-start; flex-shrink: 0; }

.activity-feed {}
.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.activity-item:last-child { border-bottom: none; }
.activity-badge { font-size: 10px !important; padding: 1px 6px !important; flex-shrink: 0; }
.activity-content { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-who    { font-weight: 600; }
.activity-module { color: var(--text-secondary); font-size: 11.5px; margin-left: 5px; }
.activity-label  { color: var(--text-muted); font-size: 11.5px; }
.activity-time   { color: var(--text-muted); font-size: 11px; flex-shrink: 0; white-space: nowrap; }

/* Logs detail */
.col-log-detail { font-size: 12px; }
.log-field  { color: var(--text-secondary); font-style: italic; margin-right: 4px; }
.log-old    { color: var(--red);   text-decoration: line-through; }
.log-arrow  { color: var(--text-muted); margin: 0 4px; }
.log-new    { color: var(--green); font-weight: 500; }

/* --- LOGIN PAGE ---------------------------------------------- */
.layout-blank {
  background: linear-gradient(135deg, #0d1f35 0%, #1a3a5c 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.login-card {
  width: 100%;
  background: #fff;
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.login-logo-img { height: 52px; }
.login-logo-text {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.login-logo-main { font-size: 22px; font-weight: 800; color: var(--primary); letter-spacing: 0.05em; }
.login-logo-sub  { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.2em; text-transform: uppercase; }
.login-subtitle { text-align: center; font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-alert { margin-bottom: 8px; }
.login-footer {
  margin-top: 16px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* --- EMPTY STATES -------------------------------------------- */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg { color: var(--border); margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; }
.empty-state-small {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-state-small svg { display: block; margin: 0 auto 10px; color: var(--border); }

/* --- COMING SOON -------------------------------------------- */
.coming-soon-card {
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 48px 36px;
  box-shadow: var(--shadow);
}
.coming-soon-icon { margin-bottom: 20px; color: var(--border); }
.coming-soon-icon svg { width: 72px; height: 72px; }
.coming-soon-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.coming-soon-card p { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.coming-soon-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 24px !important; }

/* --- MODAL -------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  animation: slideUp 0.15s ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-secondary); cursor: pointer; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* --- OVERLAY ------------------------------------------------ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* --- ERROR PAGES -------------------------------------------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 40px;
}
.error-code { font-size: 96px; font-weight: 800; color: var(--border); line-height: 1; }
.error-title { font-size: 24px; font-weight: 700; margin-top: 8px; }
.error-desc  { font-size: 14px; color: var(--text-secondary); margin-top: 8px; }

/* --- RESPONSIVE --------------------------------------------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible { display: block; }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .user-name { display: none; }
  #globalSearchInput { width: 180px; }
  #globalSearchInput:focus { width: 220px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .app-content { padding: 14px; }
  .login-card { padding: 24px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 12px; }
  .global-search { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filters-bar { gap: 6px; }
  .page-title { font-size: 18px; }
}

/* Fix: HTML [hidden] musi wygrać z display:flex/block z klas CSS */
[hidden] { display: none !important; }

/* Utility */
.d-none { display: none !important; }
.d-flex { display: flex !important; }
.mt-0 { margin-top: 0 !important; }
.mt-4 { margin-top: 16px !important; }

/* =============================================================
   DARK MODE
   ============================================================= */
body.dark-mode {
  --content-bg:   #0f172a;
  --card-bg:      #1e293b;
  --border:       #334155;
  --text:         #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:   #64748b;
  --text-link:    #60a5fa;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --primary-light:#1e3a5f;
  --primary-hover:#2563eb;
  --sidebar-bg:   #070f1a;
  --sidebar-hover:#1e293b;
  --sidebar-active:#1e3a5f;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-md:    0 10px 15px -3px rgba(0,0,0,.5);
}
body.dark-mode .topbar      { background: #1e293b; border-color: #334155; }
body.dark-mode .panel       { background: #1e293b; border-color: #334155; }
body.dark-mode .form-card   { background: #1e293b; border-color: #334155; }
body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .form-textarea { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark-mode .form-input:focus,
body.dark-mode .form-select:focus { background: #1e293b; border-color: #3b82f6; }
body.dark-mode .data-table thead tr { background: #0f172a; }
body.dark-mode .data-table td,
body.dark-mode .data-table th { border-color: #334155; }
body.dark-mode .data-table tbody tr:hover td { background: #263548; }
body.dark-mode .btn-secondary { background: #334155; color: #e2e8f0; border-color: #475569; }
body.dark-mode .btn-secondary:hover { background: #475569; }
body.dark-mode .btn-ghost:hover { background: #334155; }
body.dark-mode #globalSearchInput { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark-mode #globalSearchInput:focus { background: #1e293b; border-color: #3b82f6; }
body.dark-mode .user-dropdown,
body.dark-mode .notif-dropdown { background: #1e293b; border-color: #334155; }
body.dark-mode .user-dropdown-item:hover { background: #0f172a; }
body.dark-mode .notif-drop-item:hover { background: #0f172a; }
body.dark-mode .notif-drop-item.unread { background: #1a2e4a; }
body.dark-mode .flash-success { background: #14532d; color: #bbf7d0; }
body.dark-mode .flash-error   { background: #7f1d1d; color: #fecaca; }
body.dark-mode .flash-info    { background: #1e3a5f; color: #bfdbfe; }
body.dark-mode .kpi-card      { background: #1e293b; border-color: #334155; }
body.dark-mode .page-btn      { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .page-btn:hover { background: #334155; }
body.dark-mode .tabs-bar      { border-color: #334155; }
body.dark-mode .tab-item:hover { color: #e2e8f0; }
body.dark-mode .form-section  { border-color: #334155; }
body.dark-mode .form-actions  { background: #0f172a; border-color: #334155; }
body.dark-mode .panel-header  { border-color: #334155; }
body.dark-mode .filter-sep    { color: #475569; }
body.dark-mode select option  { background: #1e293b; }
body.dark-mode .notif-full-item { border-color: #334155; }
body.dark-mode .notif-full-unread { background: #1a2e4a; }
body.dark-mode .activity-item { border-color: #334155; }
body.dark-mode .notif-feed-item { border-color: #334155; }
body.dark-mode .notif-feed-item:hover { background: #263548; }
body.dark-mode .user-dropdown-divider { background: #334155; }
body.dark-mode .coming-soon-card { background: #1e293b; border-color: #334155; }
body.dark-mode .modal         { background: #1e293b; }
body.dark-mode .modal-header,
body.dark-mode .modal-footer  { border-color: #334155; }
body.dark-mode .toggle-slider { background: #475569; }
body.dark-mode .row-inactive td { opacity: 0.4; }
body.dark-mode .form-hint     { color: #64748b; }

/* Dark mode button */
.dark-mode-btn svg { width: 18px; height: 18px; }
.moon-icon { display: none; }
.sun-icon  { display: block; }
body.dark-mode .moon-icon { display: block; }
body.dark-mode .sun-icon  { display: none; }

/* =============================================================
   SIDEBAR SLIDER (collapse / icon-only)
   ============================================================= */
--sidebar-collapsed-width: 64px;

.sidebar { transition: width 0.22s ease; overflow: hidden; }
.app-main { transition: margin-left 0.22s ease; }

body.sidebar-collapsed .sidebar   { width: 64px; }
body.sidebar-collapsed .app-main  { margin-left: 64px; }

/* Ukryj teksty gdy zwinięty */
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .sidebar-company,
body.sidebar-collapsed .logo-sub { opacity: 0; width: 0; overflow: hidden; transition: opacity 0.15s; }
body.sidebar-collapsed .logo-main { font-size: 12px; letter-spacing: 0; }
body.sidebar-collapsed .sidebar-logo-link { justify-content: center; }
body.sidebar-collapsed .sidebar-logo-img  { height: 26px; }
body.sidebar-collapsed .nav-item  { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .nav-icon  { margin: 0; }
body.sidebar-collapsed .nav-badge { position: absolute; top: 4px; right: 6px; min-width: 14px; padding: 0 3px; font-size: 9px; }

/* Tooltip przy zwiniętym sidebarze */
body.sidebar-collapsed .nav-item { position: relative; }
body.sidebar-collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 70px;
  top: 50%;
  transform: translateY(-50%);
  background: #1a2332;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  pointer-events: none;
}
body.dark-mode.sidebar-collapsed .nav-item:hover::after {
  background: #334155;
}

/* Przycisk collapse */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  background: none;
  border: none;
  border-top: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-collapse-btn svg { width: 16px; height: 16px; transition: transform 0.22s; }
body.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* =============================================================
   STATUS BADGE — ładunki
   ============================================================= */
.load-status-new        { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.load-status-confirmed  { background: var(--blue-bg);   color: var(--blue);   border: 1px solid var(--blue-border); }
.load-status-in_loading { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.load-status-loaded     { background: #fef9c3;          color: #854d0e;       border: 1px solid #fde047; }
.load-status-in_transit { background: var(--blue-bg);   color: #1d4ed8;       border: 1px solid #93c5fd; }
.load-status-delivered  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.load-status-completed  { background: #dcfce7;          color: #166534;       border: 1px solid #86efac; }
.load-status-cancelled  { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.load-status-problem    { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }

/* =============================================================
   TABELA ŁADUNKÓW — kolumny
   ============================================================= */
.load-route { font-size: 13px; }
.load-route-from { font-weight: 600; }
.load-route-arrow { color: var(--text-muted); margin: 0 6px; }
.load-route-to   { color: var(--text-secondary); }
.load-flag { font-size: 14px; margin-right: 3px; }
.col-load-number { font-family: monospace; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.contractor-cell { font-size: 13px; }
.contractor-type { font-size: 10px; color: var(--text-muted); }

/* =============================================================
   FORMULARZ ŁADUNKU — sekcje
   ============================================================= */
.load-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.load-form-col {
  padding: 20px 24px;
  border-right: 1px solid var(--border);
}
.load-form-col:last-child { border-right: none; }
.load-form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.load-form-section-title svg { width: 14px; height: 14px; }

/* Detail view */
.load-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-secondary); flex-shrink: 0; min-width: 120px; }
.detail-value { font-weight: 500; text-align: right; }

/* Contractor card */
.contractor-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}
.type-client   { background: var(--blue-bg);   color: var(--blue); }
.type-carrier  { background: var(--green-bg);  color: var(--green); }
.type-supplier { background: var(--gray-bg);   color: var(--gray); }
.type-both     { background: var(--purple-bg); color: var(--purple); }

/* Dictionary category cards */
.dict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.dict-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}
.dict-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }
.dict-card-icon { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dict-card-icon svg { width: 20px; height: 20px; }
.dict-card-label { font-weight: 600; font-size: 14px; }
.dict-card-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Inline edit dla słowników */
.dict-value-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.dict-value-row:last-child { border-bottom: none; }
.dict-value-drag { color: var(--text-muted); cursor: grab; padding: 0 4px; }
.dict-value-row .form-input { margin-bottom: 0; }

@media (max-width: 900px) {
  body.sidebar-collapsed .app-main { margin-left: 0; }
  .load-form-grid { grid-template-columns: 1fr; }
  .load-form-col { border-right: none; border-bottom: 1px solid var(--border); }
  .load-detail-grid { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════
   TABELE — STICKY + RESPONSIVE + DENSE
═══════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
.data-table th,
.data-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--content-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}
/* Sticky first column */
.data-table .col-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card-bg);
}
.data-table th.col-sticky {
  z-index: 3;
  background: var(--content-bg);
}
.data-table tbody tr:hover td { background: var(--content-bg); }
.data-table tbody tr:hover .col-sticky { background: var(--content-bg); }

/* Dense mode */
body.dense .data-table th,
body.dense .data-table td {
  padding: 4px 10px;
  font-size: 11.5px;
}
body.dense .data-table { font-size: 11.5px; }

/* ═══════════════════════════════════════
   LOAD DETAIL VIEW
═══════════════════════════════════════ */
.load-view-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 12px;
  align-items: start;
}
.load-point-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.load-point-card.done {
  border-color: #16a34a;
  background: #f0fdf4;
}
.load-point-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 12.5px;
}
.load-point-body {
  padding: 8px 12px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lv-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.lv-label {
  font-size: 10.5px;
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.lv-val { font-weight: 500; color: var(--text); }
.fin-summary-box {
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
@media (max-width: 900px) {
  .load-view-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .app-content { padding: 10px; }
  .data-table th, .data-table td { padding: 7px 8px; }
}

/* ═══════════════════════════════════════════════════════════════════
   GAME-CHANGER REDESIGN — dodano  2026-05-07
   Nowy design system: app-shell + sb (sidebar) + tb (topbar)
   Klasy mockup_form.html / mockup_view.html są teraz dostępne globalnie.
   ═══════════════════════════════════════════════════════════════════ */
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── DESIGN TOKENS ────────────────────────────────────────────────── */
:root {
    /* Brand */
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-light: #eff6ff;

    /* Sidebar global (granatowy) */
    --sb-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --sb-text: #cbd5e1;
    --sb-text-muted: #64748b;
    --sb-active: #3b82f6;
    --sb-active-bg: rgba(59, 130, 246, 0.15);
    --sb-hover-bg: rgba(255, 255, 255, 0.06);
    --sb-border: rgba(255, 255, 255, 0.08);

    /* Surfaces */
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;

    /* Text */
    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;

    /* Borders */
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Status colors */
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;

    /* Direction colors (kierunek ładunku) */
    --dir-export: #16a34a;
    --dir-import: #2563eb;
    --dir-transfer: #b45309;
    --dir-draft: #6b7280;

    /* Status pills */
    --st-new: #6b7280;
    --st-confirmed: #2563eb;
    --st-loading: #b45309;
    --st-loaded: #0d9488;
    --st-transit: #1d4ed8;
    --st-delivery: #1d4ed8;
    --st-delivered: #16a34a;
    --st-completed: #15803d;
    --st-accounted: #0891b2;
    --st-cancelled: #dc2626;
    --st-problem: #ea580c;

    /* Cargo ratio */
    --cargo-ok: #16a34a;
    --cargo-warn: #d97706;
    --cargo-bad: #dc2626;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.18);

    /* Radius */
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 999px;

    /* Spacing */
    --gap-1: 4px;
    --gap-2: 8px;
    --gap-3: 12px;
    --gap-4: 16px;
    --gap-5: 20px;
    --gap-6: 24px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT GŁÓWNY (sidebar global + content)
   ═══════════════════════════════════════════════════════════════════════════ */
.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}
.app-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface-3);
}

/* ── SIDEBAR GLOBAL ───────────────────────────────────────────────── */
.sb {
    background: var(--sb-bg);
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--sb-border);
}
.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--sb-border);
}
.sb-brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
}
.sb-brand-text {
    color: #fff;
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 15px;
}
.sb-brand-sub {
    font-size: 9.5px;
    color: var(--sb-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.sb-section {
    padding: 14px 12px 4px 14px;
    font-size: 9.5px;
    color: var(--sb-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
}
.sb-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--sb-text);
    font-size: 12.5px;
    font-weight: 500;
    transition: background .12s, color .12s;
    border-left: 3px solid transparent;
}
.sb-link:hover {
    background: var(--sb-hover-bg);
    color: #fff;
}
.sb-link.active {
    background: var(--sb-active-bg);
    color: #fff;
    border-left-color: var(--sb-active);
    font-weight: 700;
}
.sb-link .ico {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sb-link .badge-num {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 9.5px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 800;
}
.sb-divider {
    border-top: 1px solid var(--sb-border);
    margin: 12px 14px;
}
.sb-bottom {
    margin-top: auto;
    padding: 12px 14px;
    border-top: 1px solid var(--sb-border);
}
.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}
.sb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    flex-shrink: 0;
}
.sb-user-name { color: #fff; font-size: 12.5px; font-weight: 700; }
.sb-user-role { color: var(--sb-text-muted); font-size: 10.5px; }

/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR (powiadomienia, kursy, search)
   ═══════════════════════════════════════════════════════════════════════════ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 50;
}
/* ── GOOGLE-STYLE UNIVERSAL SEARCH ── */
.tb-search {
    flex: 1;
    max-width: 720px;
    position: relative;
}
.tb-search-input {
    width: 100%;
    padding: 11px 90px 11px 44px;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    background: var(--surface-2);
    transition: all .15s;
    color: var(--text);
}
.tb-search-input::placeholder { color: var(--text-muted); }
.tb-search-input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.18), 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.tb-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.tb-search-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
}
.tb-kbd {
    font-size: 10px;
    padding: 3px 7px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: monospace;
    font-weight: 700;
}
.tb-search-mic {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    font-size: 14px;
    cursor: pointer;
    transition: background .12s;
}
.tb-search-mic:hover { background: var(--brand-light); }

/* ── SEARCH DROPDOWN (wyniki) ── */
.tb-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
    max-height: 460px;
    overflow-y: auto;
    display: none;
}
.tb-search-dropdown.show { display: block; }
.tb-sd-section {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.tb-sd-section:last-child { border-bottom: none; }
.tb-sd-title {
    padding: 8px 16px 4px;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.tb-sd-title .count { color: var(--text-soft); font-weight: 600; }
.tb-sd-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background .1s;
}
.tb-sd-item:hover, .tb-sd-item.kbd-active { background: var(--brand-light); }
.tb-sd-item-ico {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.tb-sd-item-ico.load { background: var(--brand-light); color: var(--brand); }
.tb-sd-item-ico.contractor { background: var(--success-light); color: var(--success); }
.tb-sd-item-ico.contact { background: #fef3c7; color: #92400e; }
.tb-sd-item-ico.address { background: #fdf4ff; color: #a21caf; }
.tb-sd-item-ico.vehicle { background: #cffafe; color: var(--info); }
.tb-sd-item-ico.driver { background: #fee2e2; color: var(--danger); }
.tb-sd-item-ico.dict { background: #f3f4f6; color: var(--text); }
.tb-sd-item-text { flex: 1; min-width: 0; }
.tb-sd-item-text strong { font-size: 13px; color: var(--text); display: block; line-height: 1.3; font-weight: 700; }
.tb-sd-item-text small { font-size: 11px; color: var(--text-muted); display: block; line-height: 1.3; margin-top: 1px; }
.tb-sd-item-meta {
    font-size: 10.5px;
    color: var(--text-muted);
    background: var(--surface-3);
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-weight: 700;
    flex-shrink: 0;
}
.tb-sd-item mark { background: #fef9c3; color: var(--text); font-weight: 800; padding: 0 2px; border-radius: 2px; }
.tb-sd-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 12px; }
.tb-sd-footer {
    padding: 8px 16px;
    background: var(--surface-2);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border);
}
.tb-sd-footer kbd {
    font-family: monospace;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    color: var(--text);
    font-weight: 700;
}

/* ── KURSY WALUT (kolorowe z trendem) ── */
.tb-rates {
    display: flex;
    gap: 6px;
    margin-left: 8px;
    align-items: center;
}
.tb-rate {
    background: var(--surface);
    border: 1.5px solid var(--border);
    padding: 5px 10px;
    border-radius: var(--r-md);
    font-size: 11.5px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all .12s;
    cursor: default;
    position: relative;
}
.tb-rate:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tb-rate-flag { font-size: 13px; }
.tb-rate-code {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.4px;
}
.tb-rate-val {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 12.5px;
    color: var(--text);
}
.tb-rate-trend {
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.tb-rate-trend.up { background: var(--success-light); color: var(--success); }
.tb-rate-trend.down { background: var(--danger-light); color: var(--danger); }
.tb-rate-trend.flat { background: var(--surface-3); color: var(--text-muted); }
.tb-rate.eur { border-left: 4px solid #003399; }
.tb-rate.gbp { border-left: 4px solid #c8102e; }
.tb-rate.usd { border-left: 4px solid #16a34a; }
.tb-rate.chf { border-left: 4px solid #ef4444; }

.tb-icon-btn {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    position: relative;
    transition: all .15s;
    font-size: 15px;
}
.tb-icon-btn:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.tb-icon-btn .dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 9px;
    height: 9px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface);
}
.tb-icon-btn .dot-num {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE HEADER (numer ładunku + akcje)
   ═══════════════════════════════════════════════════════════════════════════ */
.ph {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    position: sticky;
    top: 53px;
    z-index: 49;
    box-shadow: var(--shadow-xs);
}
.ph-back {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    transition: all .12s;
}
.ph-back:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.ph-title {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}
.ph-title .pencil { color: var(--text-muted); font-size: 14px; font-weight: 400; }
.ph-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}
.ph-meta .pill {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-weight: 700;
    color: var(--text);
}
.ph-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 800;
    border: 1.5px solid;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all .12s;
}
.ph-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.ph-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}
.ph-btn {
    padding: 8px 14px;
    border-radius: var(--r-md);
    font-size: 12.5px;
    font-weight: 700;
    border: 1px solid;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
}
.ph-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ph-btn.primary { background: var(--success-light); color: var(--success); border-color: #86efac; }
.ph-btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.ph-btn.brand-blue { background: var(--brand-light); color: var(--brand); border-color: #bfdbfe; }
.ph-btn.more {
    width: 38px;
    padding: 0;
    justify-content: center;
    height: 38px;
    background: var(--surface-2);
    border-color: var(--border);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATUS TIMELINE + SECTION TABS (sticky pod headerem)
   ═══════════════════════════════════════════════════════════════════════════ */
.tline-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 22px;
    display: flex;
    gap: 16px;
    align-items: center;
    position: sticky;
    top: 124px;
    z-index: 48;
    box-shadow: var(--shadow-xs);
    overflow-x: auto;
}
.tline {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.tline-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    white-space: nowrap;
}
.tline-step.done {
    background: var(--success-light);
    color: var(--success);
    border-color: #86efac;
}
.tline-step.current {
    background: var(--brand-light);
    color: var(--brand);
    border-color: var(--brand);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.tline-arrow {
    color: var(--text-soft);
    font-size: 13px;
    margin: 0 -1px;
}
.tline-step .check {
    background: currentColor;
    color: #fff;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    font-size: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Section tabs */
.sect-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.sect-tab {
    padding: 5px 11px;
    border-radius: var(--r-pill);
    font-size: 11.5px;
    font-weight: 700;
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid transparent;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.sect-tab:hover { background: var(--brand-light); color: var(--brand); }
.sect-tab .num {
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 9.5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}
.sect-tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.sect-tab.alert .num { background: var(--danger); color: #fff; }
.sect-tab.ok .num { background: var(--success); color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   CONTENT 3-COLUMN (alerts sidebar | main | finanse)
   ═══════════════════════════════════════════════════════════════════════════ */
.content {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 360px;
    gap: 14px;
    padding: 14px 22px;
    align-items: start;
}

/* Lewa kolumna: ALERTS + szybkie akcje */
.left-rail {
    position: sticky;
    top: 184px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.alert-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    box-shadow: var(--shadow-xs);
}
.alert-card-title {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.alert-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    border-top: 1px solid var(--border);
}
.alert-row:first-of-type { border-top: none; padding-top: 0; }
.alert-row .ico {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #fff;
    flex-shrink: 0;
}
.alert-row.warn .ico { background: var(--warning); }
.alert-row.bad .ico { background: var(--danger); }
.alert-row.ok .ico { background: var(--success); }
.alert-row .label { flex: 1; }
.alert-row .label small { color: var(--text-muted); display: block; font-size: 10.5px; }

.quick-actions { display: flex; flex-direction: column; gap: 6px; }
.qa-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-align: left;
    transition: all .12s;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-xs);
}
.qa-btn:hover { transform: translateX(2px); border-color: var(--brand); color: var(--brand); }
.qa-btn .ico { font-size: 16px; }

/* Środkowa kolumna: sekcje */
.main-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* Sekcja card */
.sect {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    scroll-margin-top: 200px;
}
.sect-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}
.sect-header .ico {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.sect-header .num {
    background: var(--brand);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}
.sect-header h3 { font-size: 14px; font-weight: 800; color: var(--text); flex: 1; }
.sect-header .sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.sect-header .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.sect-body { padding: 16px; }
.sect-body.tight { padding: 10px 14px; }

/* Prawa kolumna: FINANSE + SAVE */
.right-rail {
    position: sticky;
    top: 184px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.fin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.fin-header {
    background: linear-gradient(135deg, #1e3a8a, #3730a3);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fin-header .ico { font-size: 18px; }
.fin-header h3 { font-size: 13px; font-weight: 800; flex: 1; }
.fin-cur {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}
.fin-body { padding: 14px 16px; }
.fin-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}
.fin-row:last-child { border-bottom: none; }
.fin-row .lbl { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.fin-row .val { font-size: 14px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.fin-row .val.income { color: var(--success); }
.fin-row .val.cost { color: var(--danger); }
.fin-row .val.margin { color: var(--brand); font-size: 18px; }
.fin-divider { border-top: 2px solid var(--border); margin: 6px 0; }
.fin-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    transition: all .12s;
    font-variant-numeric: tabular-nums;
}
.fin-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

.save-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px;
    box-shadow: var(--shadow-md);
    position: sticky;
    bottom: 14px;
}
.save-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .15s;
}
.save-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45); }
.save-hint { font-size: 10.5px; color: var(--text-muted); text-align: center; margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld-label {
    font-size: 10.5px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.fld-label .req { color: var(--danger); }
.input, .select {
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 12.5px;
    background: var(--surface);
    color: var(--text);
    transition: all .12s;
    font-family: inherit;
    width: 100%;
}
.input:focus, .select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.input.invalid { border-color: var(--danger); background: var(--danger-light); }
.input.success { border-color: var(--success); background: #f0fdf4; }
.fld-grid { display: grid; gap: 10px; }

/* Direction radio (dyrekcja) */
.dir-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.dir-pill {
    padding: 7px 14px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 700;
    border: 2px solid;
    background: var(--surface);
    transition: all .15s;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.dir-pill.export { color: var(--dir-export); border-color: var(--dir-export); }
.dir-pill.import { color: var(--dir-import); border-color: var(--dir-import); }
.dir-pill.transfer { color: var(--dir-transfer); border-color: var(--dir-transfer); }
.dir-pill.draft { color: var(--dir-draft); border-color: var(--dir-draft); }
.dir-pill.active.export { background: var(--dir-export); color: #fff; box-shadow: 0 2px 8px rgba(22,163,74,0.4); }
.dir-pill.active.import { background: var(--dir-import); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.4); }
.dir-pill.active.transfer { background: var(--dir-transfer); color: #fff; box-shadow: 0 2px 8px rgba(180,83,9,0.4); }
.dir-pill.active.draft { background: var(--dir-draft); color: #fff; box-shadow: 0 2px 8px rgba(107,114,128,0.4); }

/* Pills (sposób załadunku, broker, type) */
.pill-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.pill-tag.broker { background: var(--warning-light); color: #92400e; border-color: #fbbf24; }
.pill-tag.export { background: var(--dir-export); color: #fff; border: none; box-shadow: 0 2px 6px rgba(22,163,74,0.3); }
.pill-tag.fix { background: var(--danger); color: #fff; border: none; }
.pill-tag.fragile { background: #fdf4ff; color: #a21caf; border-color: #e9d5ff; }
.pill-tag.cargo { padding: 4px 12px; font-size: 12px; }

/* ═══════════════════════════════════════════════════════════════════════════
   ZLECENIODAWCA / NASZA FIRMA grid 2-kol
   ═══════════════════════════════════════════════════════════════════════════ */
.duo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.contractor-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.contractor-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: 6px;
}
.contractor-name a { color: inherit; text-decoration: none; border-bottom: 1px dashed transparent; }
.contractor-name a:hover { border-bottom-color: var(--brand); }
.contractor-line { font-size: 12px; color: var(--text); }
.contractor-line .lbl { color: var(--text-muted); font-weight: 700; font-size: 10.5px; text-transform: uppercase; margin-right: 4px; }
.contractor-line a { color: var(--brand); }
.contractor-line .flag { font-size: 14px; margin-right: 3px; }

/* Detail collapse */
.disc { margin-top: 8px; }
.disc summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--brand);
    font-weight: 700;
    user-select: none;
    list-style: none;
    padding: 6px 10px;
    border: 1px dashed #bfdbfe;
    border-radius: var(--r-md);
    background: var(--brand-light);
    display: flex;
    align-items: center;
    gap: 6px;
}
.disc summary::-webkit-details-marker { display: none; }
.disc summary::before { content: '▶'; font-size: 9px; transition: transform .15s; }
.disc[open] summary::before { transform: rotate(90deg); }
.disc-body { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

.contact-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--r-sm);
    padding: 8px 10px;
}
.contact-card strong { font-size: 12.5px; color: var(--brand); display: block; }
.contact-card small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.contact-card a { display: block; color: var(--brand); font-size: 11.5px; margin-top: 2px; }

/* Broker section (gdy nasza firma to broker) */
.broker-section {
    background: linear-gradient(135deg, #fef3c7, #fef9c3);
    border: 1.5px solid #fbbf24;
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-top: 10px;
}
.broker-section h4 {
    font-size: 11.5px;
    font-weight: 800;
    color: #92400e;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.broker-grid { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr; gap: 10px; }
.broker-fin {
    border-top: 1px dashed #fbbf24;
    margin-top: 10px;
    padding-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-items: center;
}
.broker-fin .lbl { font-size: 10.5px; color: #92400e; font-weight: 700; text-transform: uppercase; }
.broker-fin .val {
    background: var(--surface);
    border: 1px solid #fbbf24;
    border-radius: var(--r-md);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 800;
    color: #92400e;
    font-variant-numeric: tabular-nums;
}
.broker-fin .val.income { color: var(--success); }
.broker-fin .val.margin { color: #92400e; }

/* ═══════════════════════════════════════════════════════════════════════════
   TRASA — pozioma mapa punktów
   ═══════════════════════════════════════════════════════════════════════════ */
.route-map {
    overflow-x: auto;
    padding: 10px 4px 12px;
}
.route-line {
    display: flex;
    gap: 0;
    align-items: stretch;
    min-width: max-content;
    position: relative;
}
.route-pt {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 14px;
    min-width: 220px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    transition: all .15s;
    box-shadow: var(--shadow-xs);
}
.route-pt:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.route-pt.loading { border-left: 5px solid var(--success); }
.route-pt.unloading { border-left: 5px solid var(--danger); }
.route-pt.customs { border-left: 5px solid #7c3aed; }
.route-pt.done { background: var(--success-light); border-color: var(--success); }
.route-pt.fix .pt-date { background: var(--danger-light); color: var(--danger); border-color: var(--danger); font-weight: 800; }
.route-pt-head {
    display: flex;
    align-items: center;
    gap: 6px;
}
.route-pt-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}
.route-pt.loading .route-pt-num { background: var(--success); }
.route-pt.unloading .route-pt-num { background: var(--danger); }
.route-pt.customs .route-pt-num { background: #7c3aed; }
.route-pt-type { font-size: 10.5px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.route-pt-name { font-size: 12.5px; font-weight: 800; color: var(--text); line-height: 1.3; }
.route-pt-addr { font-size: 11px; color: var(--text-muted); }
.route-pt-addr .flag { font-size: 13px; margin-right: 3px; }
.route-pt-date {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.route-pt-actions { display: flex; gap: 4px; margin-top: 4px; }
.route-pt-actions .mini-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
}
.route-pt-actions .mini-btn:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.route-pt-actions .mini-btn.done {
    background: var(--success-light);
    color: var(--success);
    border-color: #86efac;
}
.route-arrow {
    align-self: center;
    padding: 0 4px;
    color: var(--text-soft);
    font-size: 22px;
    font-weight: 700;
}
.route-add {
    background: transparent;
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    padding: 12px 18px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    min-width: 120px;
}
.route-add:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

/* ═══════════════════════════════════════════════════════════════════════════
   TOWAR — tabelka kolumnowa
   ═══════════════════════════════════════════════════════════════════════════ */
.cargo-table {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.cargo-row {
    display: grid;
    grid-template-columns: 32px 1fr 110px 110px 80px 100px 80px 40px;
    gap: 10px;
    padding: 10px 14px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    transition: background .12s;
}
.cargo-row:last-child { border-bottom: none; }
.cargo-row.head {
    background: var(--surface-2);
    font-size: 10.5px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cargo-row.head .right { text-align: right; }
.cargo-row.row .num {
    background: #111827;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}
.cargo-row.row.cargo-ok { background: rgba(22, 163, 74, 0.05); border-left: 3px solid var(--cargo-ok); }
.cargo-row.row.cargo-warn { background: rgba(217, 119, 6, 0.06); border-left: 3px solid var(--cargo-warn); }
.cargo-row.row.cargo-bad { background: rgba(220, 38, 38, 0.06); border-left: 3px solid var(--cargo-bad); }
.cargo-row .ldm, .cargo-row .wg { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.cargo-row.summary {
    background: var(--surface-2);
    font-weight: 800;
    border-top: 2px solid var(--border-strong);
}
.cargo-row.summary .ldm, .cargo-row.summary .wg { font-size: 14px; color: var(--text); }
.ratio-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: var(--r-pill);
    font-size: 10px;
    font-weight: 800;
    color: #fff;
}
.ratio-badge.ok { background: var(--cargo-ok); }
.ratio-badge.warn { background: var(--cargo-warn); }
.ratio-badge.bad { background: var(--cargo-bad); }

/* ═══════════════════════════════════════════════════════════════════════════
   ODPRAWY — akordeon
   ═══════════════════════════════════════════════════════════════════════════ */
.customs-list { display: flex; flex-direction: column; gap: 8px; }
.customs-item {
    border: 1.5px solid #e9d5ff;
    border-left: 4px solid #7c3aed;
    border-radius: var(--r-md);
    overflow: hidden;
    background: #faf7ff;
}
.customs-item.done { background: var(--success-light); border-color: #86efac; border-left-color: var(--success); }
.customs-item-head {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.5);
}
.customs-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #7c3aed;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}
.customs-summary { font-size: 13px; font-weight: 800; color: #5b21b6; }
.customs-meta { font-size: 11px; color: var(--text-muted); }
.customs-meta strong { color: var(--text); font-family: monospace; }
.customs-item-body {
    padding: 12px 14px;
    border-top: 1px dashed #e9d5ff;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: var(--surface);
}
.customs-add-btn {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.35);
}

/* ═══════════════════════════════════════════════════════════════════════════
   DOKUMENTY — siatka kompaktowa
   ═══════════════════════════════════════════════════════════════════════════ */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}
.doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-soft);
    border-radius: var(--r-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all .12s;
    cursor: grab;
}
.doc-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.doc-card.confirmed { border-left-color: var(--success); background: var(--success-light); }
.doc-card.file { border-left-color: var(--brand); background: var(--brand-light); }
.doc-card.required { border-left-color: var(--danger); }
.doc-card.warn { border-left-color: var(--warning); background: var(--warning-light); }
.doc-card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 800;
}
.doc-card-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.doc-card-status.confirmed { background: var(--success); }
.doc-card-status.required { background: var(--danger); }
.doc-card-status.file { background: var(--brand); }
.doc-card-status.warn { background: var(--warning); }
.doc-card-type { font-size: 10px; color: var(--text-muted); font-family: monospace; }
.doc-card-num {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    font-family: monospace;
}
.doc-card-actions { display: flex; gap: 4px; }
.doc-card-actions .mini-btn { font-size: 10px; padding: 3px 7px; border-radius: 4px; font-weight: 700; }

.doc-add {
    border: 2px dashed var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--r-md);
    padding: 18px;
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: all .12s;
}
.doc-add:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

/* ═══════════════════════════════════════════════════════════════════════════
   HERO BAR (podgląd ładunku)
   ═══════════════════════════════════════════════════════════════════════════ */
.hero {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 124px;
    z-index: 47;
}
.hero-row1 {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.hero-chain {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 800;
}
.hero-chain .arrow { color: var(--text-soft); font-size: 18px; }
.hero-chain .party { color: var(--text); }
.hero-chain .party.broker { color: #92400e; }
.hero-meta {
    margin-left: auto;
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}
.hero-meta strong { color: var(--text); font-family: monospace; }
.hero-row2 {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.hero-quick {
    display: flex;
    gap: 6px;
}
.hero-quick .qbtn {
    padding: 7px 14px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 700;
    border: 1.5px solid;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.hero-quick .qbtn.done { background: var(--success-light); color: var(--success); border-color: #86efac; }
.hero-quick .qbtn.pending { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.hero-quick .qbtn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ═══════════════════════════════════════════════════════════════════════════
   TABS (Ładunek / Pliki / Historia)
   ═══════════════════════════════════════════════════════════════════════════ */
.tabs-bar {
    display: flex;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 22px;
    position: sticky;
    top: 53px;
    z-index: 49;
    box-shadow: var(--shadow-xs);
}
.tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab-btn:hover { color: var(--text); background: var(--surface-2); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-btn .badge {
    background: var(--surface-2);
    color: var(--text-muted);
    padding: 1px 8px;
    border-radius: var(--r-pill);
    font-size: 10.5px;
    font-weight: 800;
}
.tab-btn.active .badge { background: var(--brand-light); color: var(--brand); }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1600px) {
    .content { grid-template-columns: 220px minmax(0, 1fr) 320px; gap: 12px; }
}
@media (max-width: 1366px) {
    .content { grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; }
    .left-rail { display: none; }
    .duo-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sb { position: relative; height: auto; max-height: none; }
    .content { grid-template-columns: 1fr; }
    .right-rail { position: relative; top: auto; }
    .hero { position: relative; top: auto; }
    .ph { position: relative; top: auto; }
    .tline-bar { position: relative; top: auto; flex-wrap: wrap; }
}
@media (max-width: 760px) {
    .ph-actions .ph-btn:not(.more) { display: none; }
    .topbar .tb-rates { display: none; }
    .ph-meta { display: none; }
    .broker-grid { grid-template-columns: 1fr; }
    .broker-fin { grid-template-columns: 1fr; }
    .customs-item-body { grid-template-columns: 1fr; }
}

/* ─ Utilities ─ */
.muted { color: var(--text-muted); }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.f-grow { flex: 1; }

/* ═══════════════════════════════════════════════════════════════════
   GAME-CHANGER — przejęcie body w layout-app
   ═══════════════════════════════════════════════════════════════════ */
body.layout-app {
    margin: 0;
    padding: 0;
    background: var(--surface-3);
    color: var(--text);
}

/* Wyłącz stary sidebar/topbar/app-main (nie używane już) — bezpieczeństwo */
body.layout-app > nav.sidebar,
body.layout-app > .app-main { display: none; }

/* Główny content w app-shell — padding wewnętrzny */
.shell-page {
    padding: 14px 22px;
    flex: 1;
    min-height: 0;
}
@media (max-width: 1100px) {
    .shell-page { padding: 12px 14px; }
}
@media (max-width: 760px) {
    .shell-page { padding: 10px 8px; }
}

/* Unikaj kolizji starej klasy .app-content (była padding:16px) gdy używamy nowej */
body.layout-app main.app-content { padding: 0; }

/* Topbar — w nowym layoucie ma być pełnej szerokości i sticky */
body.layout-app .topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Notif bell w topbar — kompatybilne z istniejącym JS-em */
.tb-notif-wrap { position: relative; }
.tb-notif-wrap .notif-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 380px;
    max-height: 480px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

/* User menu w topbar — minimalne style */
.tb-user-wrap { position: relative; }
.tb-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    padding: 5px 10px 5px 5px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    transition: all .12s;
    cursor: pointer;
}
.tb-user-btn:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.tb-user-btn .av {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}
.tb-user-wrap .user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
}
.tb-user-wrap .user-dropdown-header {
    padding: 12px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.tb-user-wrap .user-dropdown-name { font-size: 13px; font-weight: 800; color: var(--text); }
.tb-user-wrap .user-dropdown-role { margin-top: 4px; }
.tb-user-wrap .user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    transition: background .1s;
}
.tb-user-wrap .user-dropdown-item:hover { background: var(--brand-light); color: var(--brand); }
.tb-user-wrap .user-dropdown-item svg { width: 16px; height: 16px; }
.tb-user-wrap .user-dropdown-divider { border-top: 1px solid var(--border); }
.tb-user-wrap .user-dropdown-logout { color: var(--danger); }
.tb-user-wrap .user-dropdown-logout:hover { background: var(--danger-light); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR — desktop collapse + mobile slide
   ═══════════════════════════════════════════════════════════════════ */

/* Smooth transitions */
.app-shell {
    transition: grid-template-columns .25s ease;
}
.sb {
    transition: width .25s ease, transform .25s ease;
    overflow: hidden;
    width: 220px;
}

/* ── DESKTOP COLLAPSED (sidebar zwinięty do ~64px) ── */
body.sb-collapsed .app-shell {
    grid-template-columns: 64px 1fr;
}
body.sb-collapsed .sb {
    width: 64px;
}
body.sb-collapsed .sb-brand-text,
body.sb-collapsed .sb-brand-sub,
body.sb-collapsed .sb-section,
body.sb-collapsed .sb-link,
body.sb-collapsed .sb-user-name,
body.sb-collapsed .sb-user-role {
    /* W stanie collapsed: ukryj teksty, zostaw same ikony */
}
body.sb-collapsed .sb-brand {
    padding: 14px 12px;
    justify-content: center;
}
body.sb-collapsed .sb-brand > div:nth-child(2) {
    display: none;
}
body.sb-collapsed .sb-section {
    font-size: 0;
    border-top: 1px solid var(--sb-border);
    margin: 8px 0;
    padding: 0;
    height: 1px;
}
body.sb-collapsed .sb-link {
    padding: 10px 0;
    justify-content: center;
    border-left: none;
    position: relative;
}
body.sb-collapsed .sb-link > .ico {
    margin: 0;
    font-size: 18px;
}
/* Ukryj label tekstowy w sb-link gdy collapsed (ale nie ico) */
body.sb-collapsed .sb-link {
    color: transparent;     /* tekst (label) niewidoczny */
    overflow: hidden;
    text-indent: -9999px;
}
body.sb-collapsed .sb-link .ico {
    text-indent: 0;
    color: var(--sb-text);
}
body.sb-collapsed .sb-link.active {
    background: var(--sb-active-bg);
    border-left: 3px solid var(--sb-active);
    padding-left: 0;
}
body.sb-collapsed .sb-link.active .ico {
    color: #fff;
}
body.sb-collapsed .sb-link .badge-num {
    position: absolute;
    top: 4px;
    right: 4px;
    margin: 0;
    text-indent: 0;
}
body.sb-collapsed .sb-bottom {
    padding: 10px 8px;
}
body.sb-collapsed .sb-user {
    padding: 4px;
    justify-content: center;
}
body.sb-collapsed .sb-user > div:last-child {
    display: none;
}

/* TOOLTIP po hoverze gdy collapsed (label pojawia się obok ikony) */
body.sb-collapsed .sb-link:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    text-indent: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    pointer-events: none;
}

/* ── COLLAPSE BUTTON (mała ikonka pływająca w prawym górnym rogu sidebar) ── */
.sb-collapse-btn {
    position: absolute;
    top: 14px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    z-index: 60;
    transition: all .15s;
}
.sb-collapse-btn:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    transform: scale(1.15);
}
/* Gdy collapsed — przycisk pojawia się na środku, na dole, obrócony (>) i wyraźny */
body.sb-collapsed .sb-collapse-btn {
    right: 50%;
    transform: translateX(50%) rotate(180deg);
    top: auto;
    bottom: 80px;
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    width: 24px;
    height: 24px;
}
body.sb-collapsed .sb-collapse-btn:hover {
    transform: translateX(50%) rotate(180deg) scale(1.15);
}

/* ── MOBILE / TABLET (max 1100px) — slide-in sidebar ── */
@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr !important;
    }
    .sb {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        z-index: 1000;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
    }
    body.sb-mobile-open .sb {
        transform: translateX(0);
    }
    .sb-collapse-btn {
        display: none !important;  /* na mobile zamiast collapse — zamykanie przez overlay */
    }
    /* Hamburger button w topbar — visibility */
    .tb-hamburger {
        display: inline-flex !important;
    }
    /* Overlay gdy sidebar otwarty */
    .sb-mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    body.sb-mobile-open .sb-mobile-overlay {
        display: block;
        animation: sbFadeIn .2s ease;
    }
    @keyframes sbFadeIn { from{opacity:0} to{opacity:1} }
    /* Sidebar na mobile zawsze pełny — ignoruj sb-collapsed */
    body.sb-collapsed .sb {
        width: 240px !important;
    }
    body.sb-collapsed .sb-link {
        text-indent: 0 !important;
        color: var(--sb-text) !important;
        padding: 8px 14px !important;
        justify-content: flex-start !important;
    }
    body.sb-collapsed .sb-section { font-size: 9.5px !important; padding: 14px 12px 4px 14px !important; height: auto !important; border-top: none !important; margin: 0 !important; }
    body.sb-collapsed .sb-brand-text,
    body.sb-collapsed .sb-brand-sub,
    body.sb-collapsed .sb-user-name,
    body.sb-collapsed .sb-user-role { display: block !important; }
    body.sb-collapsed .sb-brand > div:nth-child(2) { display: block !important; }
    body.sb-collapsed .sb-user > div:last-child { display: block !important; }
}

/* Hamburger button w topbar — domyślnie ukryty na desktop */
.tb-hamburger {
    display: none;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    transition: all .15s;
}
.tb-hamburger:hover {
    background: var(--brand-light);
    border-color: var(--brand);
    color: var(--brand);
}

/* ═══════════════════════════════════════════════════════════════════
   HERO CHAIN — wspólne dla view.php i form.php (spójność)
   ═══════════════════════════════════════════════════════════════════ */
.lv-hero-chain {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 8px; padding: 8px 12px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0; border-radius: 10px;
    font-size: 13px; font-weight: 700;
}
.lv-hero-chain .party {
    color: #0f172a; padding: 4px 12px;
    background: #fff; border: 1px solid #cbd5e1;
    border-radius: 999px; font-weight: 800;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    display: inline-flex; align-items: center; gap: 4px;
}
.lv-hero-chain .party.client { border-color: #2563eb; color: #1e40af; background: #eff6ff; }
.lv-hero-chain .party.broker { border-color: #fbbf24; color: #92400e; background: #fef3c7; }
.lv-hero-chain .party.our    { border-color: #16a34a; color: #15803d; background: #f0fdf4; }
.lv-hero-chain .arrow { color: #94a3b8; font-size: 18px; font-weight: 800; }
.lv-hero-chain .pill-broker {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 7px; background: #fbbf24; color: #fff;
    border-radius: 8px; font-size: 9.5px; font-weight: 800;
    text-transform: uppercase; margin-left: 4px;
}
