/* ─── ZMIENNE GLOBALNE ────────────────────────────────────────────────────── */
:root {
  --bg:     #f0f2f7;
  --bg2:    #ffffff;
  --bg3:    #f0f1f6;
  --bg4:    #e8eaf2;
  --border: #e2e4ef;
  --accent: #2b2fff;
  --accent2: #059669;
  --accent3: #b45309;
  --accent4: #dc2626;
  --text:  #111827;
  --text2: #4b5563;
  --text3: #9ca3af;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 14px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 6px rgba(0,0,0,0.04);
  --navbar-h: 52px;
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 60px;
  /* dark sidebar */
  --sidebar-bg:           #1a1d23;
  --sidebar-border:       rgba(255,255,255,0.06);
  --sidebar-text:         #c8cad0;
  --sidebar-text-active:  #ffffff;
  --sidebar-hover:        rgba(255,255,255,0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; font-size: 14px; line-height: 1.5; }

/* ── APP LAYOUT ── */
#app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}
#appBody {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  display: flex; flex-direction: column;
  box-sizing: border-box;
}

/* ── NAVBAR ── */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
  height: var(--navbar-h);
  padding: 0 20px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
  width: 100%;
}
.nav-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; margin: 0 4px; }
.filter-label { font-size: 12px; color: var(--text3); white-space: nowrap; flex-shrink: 0; }
select {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: 5px 10px; border-radius: 8px; font-size: 12px; outline: none;
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
select:hover, select:focus { border-color: rgba(31,0,255,0.4); color: var(--text); }
.clear-cat-btn {
  background: none; border: 1px solid var(--border); color: var(--text3);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 11px;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.clear-cat-btn:hover { border-color: var(--accent4); color: var(--accent4); }
/* ── PERIOD SELECTOR ── */
.period-selector { position: relative; flex-shrink: 0; }
.period-selector-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 12px;
  font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.period-selector-btn:hover { border-color: rgba(31,0,255,0.3); color: var(--text); }
.period-selector-btn.active { background: var(--bg3); border-color: var(--accent); color: var(--accent); }
.period-selector-badge {
  background: var(--accent); color: #fff; border-radius: 5px;
  padding: 1px 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
}

/* Period dropdown panel */
.period-panel {
  position: fixed; top: 0; right: 0;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; box-shadow: var(--shadow); z-index: 1000;
  display: none; gap: 0; width: max-content; min-width: 620px;
}
.period-panel.open { display: flex; }
.period-panel-col { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.period-panel-col--custom { flex: 1.1; }
.period-panel-col--months { flex: 0 0 148px; }
.period-months-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.period-months-list::-webkit-scrollbar { width: 4px; }
.period-months-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.period-months-loading { font-size: 12px; color: var(--text3); padding: 6px 2px; }
.period-month-btn { justify-content: flex-start; }
.period-panel-sep { width: 1px; background: var(--border); margin: 0 14px; flex-shrink: 0; }
.period-panel-header {
  font-size: 10px; font-weight: 700; color: var(--text3); letter-spacing: 0.6px;
  text-transform: uppercase; margin-bottom: 6px; padding: 0 2px;
}
.period-option {
  background: none; border: none; color: var(--text2); text-align: left;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 12px;
  font-weight: 500; transition: all 0.12s; white-space: nowrap;
}
.period-option:hover { background: var(--bg3); color: var(--text); }
.period-option.active { background: var(--accent); color: #fff; }

/* Custom date fields inside panel */
.period-custom-fields { display: flex; flex-direction: column; gap: 8px; }
.period-custom-row { display: flex; align-items: center; gap: 8px; }
.period-custom-label { font-size: 11px; color: var(--text3); white-space: nowrap; width: 18px; }
.period-custom-fields input[type="date"] {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 5px 8px; border-radius: 8px; font-size: 12px; outline: none; transition: border-color 0.15s;
}
.period-custom-fields input[type="date"]:focus { border-color: rgba(31,0,255,0.4); }
.period-apply-btn {
  align-self: stretch; background: var(--accent); border: none; color: #fff;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all 0.15s; margin-top: 4px;
}
.period-apply-btn:hover { background: #3d1fff; }

/* ── SEARCHBAR ── */
.searchbar {
  background: var(--bg3); border-bottom: 1px solid var(--border);
  padding: 8px 20px; display: flex; align-items: center; gap: 10px;
  position: sticky; top: var(--navbar-h); z-index: 99; flex-shrink: 0;
}
.searchbar-icon { color: var(--text3); display: flex; align-items: center; flex-shrink: 0; }
.searchbar .search-wrap { flex: 1; min-width: 0; }
.searchbar .search-tags { min-width: unset; max-width: unset; width: 100%; background: var(--bg2); }
.searchbar .search-dropdown { min-width: unset; width: 100%; }

/* MULTI-SELECT SEARCH */
.search-wrap { position: relative; }
.search-tags {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 5px 10px; cursor: text; transition: border-color 0.15s; min-height: 34px;
}
.search-tags:focus-within { border-color: rgba(31,0,255,0.4); box-shadow: 0 0 0 3px rgba(31,0,255,0.06); }
.search-tag {
  display: flex; align-items: center; gap: 4px; background: rgba(31,0,255,0.1);
  color: #2200cc; border-radius: 6px; padding: 2px 8px; font-size: 12px;
  white-space: nowrap; max-width: 180px; user-select: none;
}
.search-tag > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.search-tag-x { cursor: pointer; opacity: 0.7; font-size: 11px; flex-shrink: 0; }
.search-tag-x:hover { opacity: 1; color: var(--accent4); }
.search-input {
  background: none; border: none; color: var(--text); outline: none;
  font-size: 13px; min-width: 120px; flex: 1; padding: 2px 4px;
}
.search-input::placeholder { color: var(--text3); }
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 320px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 300;
  max-height: 300px; overflow-y: auto; display: none;
}
.search-dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--border);
}
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background: rgba(31,0,255,0.06); }
.search-dropdown-item.checked { background: rgba(31,0,255,0.05); }
.search-dropdown-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; }
.search-dropdown-item label { cursor: pointer; font-size: 13px; color: var(--text); flex: 1; line-height: 1.3; }
.search-no-results { padding: 20px; text-align: center; color: var(--text3); font-size: 13px; }
.search-dropdown-count { padding: 6px 14px; font-size: 11px; color: var(--text3); border-bottom: 1px solid var(--border); }

/* ── MAIN CONTENT ── */
.main { padding: 28px 32px; max-width: 1800px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* ── KPI STRIP ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px; margin-bottom: 12px;
}
.nieroty-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s; cursor: default;
}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--card-color, var(--accent)); }
.kpi-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--card-color, var(--accent)) 30%, transparent); }
.kpi-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text3); margin-bottom: 6px; font-weight: 500;
}
.kpi-value {
  font-size: 14px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.2; letter-spacing: -0.3px;
}
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── KPI ACCORDION (mobile) ── */
.kpi-show-more-btn {
  display: none; width: 100%; margin-top: 4px; padding: 10px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; color: var(--text2); cursor: pointer; font-weight: 500;
  transition: background 0.15s; grid-column: 1 / -1;
}
.kpi-show-more-btn:hover { background: var(--bg4); }
.kpi-extra { display: contents; }

/* ── DYNAMICS STRIP ── */
.dynamics-section { margin-bottom: 24px; }
.dynamics-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.dynamics-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text3); font-weight: 600;
}
.dynamics-toggle { display: flex; gap: 2px; background: var(--bg3); border-radius: 10px; padding: 3px; margin-bottom: 8px; }
.dyn-btn {
  background: none; border: none; color: var(--text3);
  padding: 4px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.dyn-btn:hover { color: var(--text2); background: rgba(0,0,0,0.04); }
.dyn-btn.active { background: var(--accent); color: #fff; box-shadow: 0 0 12px rgba(31,0,255,0.22); }
.dynamics-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.dyn-card {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; min-width: 160px; flex: 1;
}
.dyn-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); }
.dyn-value { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.dyn-arrow { font-size: 12px; }
.dyn-up    { color: #059669; }
.dyn-down  { color: #dc2626; }
.dyn-neutral { color: var(--text3); }
.dyn-sub   { font-size: 10px; color: var(--text3); }
.dyn-nodata { font-size: 11px; color: var(--text3); font-style: italic; }

/* ── DYNAMICS ACCORDION (mobile) ── */
.dynamics-collapse-btn {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--text3); padding: 0; margin-left: auto;
}

/* ── CHART CARD ── */
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap; row-gap: 10px;
}
.chart-toggle {
  display: flex; gap: 2px;
  background: var(--bg3); border-radius: 10px; padding: 3px;
  overflow-x: auto; scrollbar-width: none;
}
.chart-toggle::-webkit-scrollbar { display: none; }
.toggle-btn {
  background: none; border: none; color: var(--text3);
  padding: 4px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.toggle-btn:hover { color: var(--text2); background: rgba(0,0,0,0.04); }
.toggle-btn.active { background: var(--accent); color: #fff; box-shadow: 0 0 12px rgba(31,0,255,0.22); }
.chart-controls { display: flex; align-items: center; gap: 8px; }
.chart-ctrl-label { font-size: 11px; color: var(--text3); white-space: nowrap; }
.chart-wrap { position: relative; }
.chart-wrap canvas { display: block; }
.chart-footer { display: flex; align-items: center; justify-content: center; gap: 5px; padding-top: 16px; flex-wrap: wrap; }
.chart-page-btn {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; transition: all 0.15s;
}
.chart-page-btn:hover:not(:disabled) { border-color: rgba(31,0,255,0.4); color: var(--accent); }
.chart-page-btn:disabled { opacity: 0.35; cursor: default; }
.chart-page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chart-page-info { font-size: 11px; color: var(--text3); padding: 0 8px; white-space: nowrap; }

/* ── MOBILE SUBNAV ── */
.mobile-subnav { display: none; }
.mobile-cat-bar { padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.mobile-cat-bar select { width: 100%; max-width: unset; height: 44px; font-size: 14px; padding: 0 12px; }
.mobile-period-bar {
  display: flex; gap: 6px; padding: 8px 12px;
  background: var(--bg3); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.mobile-period-bar::-webkit-scrollbar { display: none; }
.mobile-period-btn {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-weight: 500; white-space: nowrap; min-height: 36px;
}
.mobile-period-btn .period-selector-badge { font-size: 10px; }
.nav-mobile-brand { display: none; font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; flex: 1; text-align: center; }

/* ── DATA TABLES ── */
.table-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.view-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 20px; }
.view-tab {
  background: none; border: none; color: var(--text2);
  padding: 13px 18px; cursor: pointer; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s;
}
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.table-controls { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.table-info { font-size: 12px; color: var(--text3); }
.pagination { display: flex; align-items: center; gap: 5px; }
.page-btn { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.page-btn:hover:not(:disabled) { border-color: rgba(31,0,255,0.4); color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Podpowiedź scrollowania — domyślnie ukryta, pokazywana na mobile przez mobile.css */
.table-scroll-hint { display: none; }

/* Wrapper tabeli z poziomym scrollowaniem */
.table-wrap {
  display: block;
  overflow-x: auto;
  width: 100%;
  position: relative;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
/* Cień po prawej stronie sygnalizujący że można scrollować */
.table-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 28px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.07));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.table-wrap.scroll-right::after { opacity: 1; }

table { border-collapse: collapse; width: 100%; }
#dataTable    { table-layout: fixed;  min-width: 1310px; }
#nierotyTable { table-layout: fixed; width: 100%; }
.nieroty-nazwa { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nierotyPagination { margin-left: auto; }
th {
  background: var(--bg3); color: var(--text2); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; padding: 9px 12px;
  text-align: left; white-space: nowrap; vertical-align: middle;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border);
}
th:hover { color: var(--text); background: rgba(31,0,255,0.05); }
th.sort-asc::after  { content: ''; }
th.sort-desc::after { content: ''; }
.sort-arrow { margin-left: 4px; font-size: 10px; color: var(--text2); opacity: 0.65; display: inline-block; }
.sort-arrow--active { color: var(--accent); opacity: 1; }
th.th-num { text-align: right; }
th.th-num .sort-arrow { margin-left: 4px; margin-right: 0; }
td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
tr:hover td { background: rgba(31,0,255,0.03); }
tr:last-child td { border-bottom: none; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-cat { background: rgba(31,0,255,0.08); color: #2200cc; }
.stock-high { color: var(--accent2); }
.stock-med  { color: var(--accent3); }
.stock-low  { color: var(--accent4); }

/* ── LOADING ── */
#loading { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1000; gap: 16px; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-text { color: var(--text2); font-size: 13px; }

/* ── EMPTY ── */
.empty { text-align: center; padding: 60px 20px; color: var(--text3); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── LOGIN ── */
#loginScreen { position: fixed; inset: 0; background: var(--bg); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; padding: 48px 44px; width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); }
.login-logo { font-size: 26px; font-weight: 800; color: var(--accent); text-align: center; }
.login-subtitle { font-size: 13px; color: var(--text3); text-align: center; margin-top: 4px; margin-bottom: 36px; }
.login-field { margin-bottom: 18px; }
.login-field label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 7px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.6px; }
.login-field input { width: 100%; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: 10px; font-size: 14px; outline: none; transition: all 0.15s; }
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,0,255,0.12); }
.login-field input::placeholder { color: var(--text3); }
.login-error { font-size: 13px; color: var(--accent4); min-height: 20px; margin-bottom: 14px; text-align: center; }
.login-btn { width: 100%; background: var(--accent); border: none; color: #fff; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.login-btn:hover { background: #3d1fff; box-shadow: 0 0 20px rgba(31,0,255,0.2); }
.login-btn:active { transform: scale(0.98); }

/* ── HAMBURGER ── */
.hamburger { background: none; border: none; color: var(--text2); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; transition: all 0.15s; flex-shrink: 0; }
.hamburger:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.hamburger span { display: block; width: 16px; height: 1.5px; background: currentColor; border-radius: 2px; }

/* ── SIDEBAR ── */
#sideOverlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 500; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
#sideOverlay.open { opacity: 1; pointer-events: all; }
#sidebar {
  flex-shrink: 0;
  width: 220px;
  position: sticky; top: 0; height: 100vh; align-self: flex-start;
  background: var(--sidebar-bg); border-right: none;
  display: none; flex-direction: column;
  transition: width 200ms ease;
  overflow: visible;
  z-index: 200;
  box-shadow: 4px 0 24px rgba(0,0,0,0.18);
}
#sidebar.app-visible { display: flex; }
body.sidebar-collapsed #sidebar { width: 60px; }
body:not(.sidebar-collapsed) #sidebar { width: 240px; }

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 14px 16px 20px;
  border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
body.sidebar-collapsed .sidebar-head { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 9px; overflow: hidden; min-width: 0; }
.sidebar-logo-img { height: 28px; width: auto; flex-shrink: 0; display: block; }
.sidebar-logo-text { overflow: hidden; transition: opacity 150ms, max-width 200ms; max-width: 160px; }
.sidebar-logo-name { font-size: 18px; font-weight: 700; color: #fff; white-space: nowrap; line-height: 1; }
.sidebar-logo-sub { font-size: 10px; color: rgba(255,255,255,0.4); white-space: nowrap; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
body.sidebar-collapsed .sidebar-logo-text { opacity: 0; max-width: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar-logo { gap: 0; }
.sidebar-tab {
  position: absolute; right: -14px; top: 24px;
  width: 14px; height: 36px;
  background: var(--sidebar-bg); border: 1px solid rgba(255,255,255,0.12); border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.5); transition: background 0.15s, color 0.15s;
  box-shadow: 3px 0 8px rgba(0,0,0,0.25);
  padding: 0;
}
.sidebar-tab:hover { background: #1e2640; color: #fff; }
body.sidebar-collapsed .sidebar-tab-arrow { transform: rotate(180deg); }
.sidebar-tab-arrow { transition: transform 200ms ease; display: block; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; overflow-x: hidden; }
.sidebar-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
  color: var(--sidebar-text); font-size: 14px; font-weight: 500;
  user-select: none; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
  position: relative;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.sidebar-item.active { background: var(--accent); color: #fff; }
.sidebar-item.soon { opacity: 0.35; cursor: default; }
.sidebar-item.soon:hover { background: none; color: var(--sidebar-text); }
.sidebar-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: inherit; }
.sidebar-label { overflow: hidden; text-overflow: ellipsis; transition: opacity 150ms, max-width 200ms; max-width: 160px; }
.sidebar-badge { margin-left: auto; font-size: 10px; padding: 2px 7px; border-radius: 20px; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.45); border: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; transition: opacity 150ms; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--sidebar-border); display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.sidebar-user { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.5px;
}
.sidebar-user-info { overflow: hidden; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.sidebar-user-role { font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 1px; text-transform: capitalize; }
.sidebar-logout {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 8px 12px;
  border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 700;
  color: #fff; background: #e03c4a; border: none;
  transition: filter 0.18s; white-space: nowrap;
}
.sidebar-logout:hover { filter: brightness(0.85); }
.sidebar-logout-icon { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Collapsed sidebar state */
body.sidebar-collapsed .sidebar-badge { opacity: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar-label { opacity: 0; max-width: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar-nav { padding: 16px 6px; }
body.sidebar-collapsed .sidebar-item { justify-content: center; padding: 8px; gap: 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; gap: 0; }
body.sidebar-collapsed .sidebar-user-info { opacity: 0; max-width: 0; overflow: hidden; pointer-events: none; transition: opacity 150ms, max-width 200ms; }
body.sidebar-collapsed .sidebar-logout .sidebar-label { opacity: 0; max-width: 0; }
body.sidebar-collapsed .sidebar-logout { justify-content: center; padding: 8px; gap: 0; }
body.sidebar-collapsed .sidebar-footer { padding: 12px 6px; }

/* Tooltip on hover in collapsed mode */
body.sidebar-collapsed .sidebar-item[data-view]::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--sidebar-bg); color: #fff; font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
  box-shadow: var(--shadow); z-index: 700;
  border: 1px solid var(--sidebar-border);
}
body.sidebar-collapsed .sidebar-item[data-view]:hover::after { opacity: 1; }

/* ── PLACEHOLDER VIEWS ── */
.view-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 16px; color: var(--text3); }
.view-placeholder-icon { font-size: 52px; opacity: 0.25; }
.view-placeholder h2 { font-size: 20px; font-weight: 700; color: var(--text2); }
.view-placeholder p { font-size: 14px; }

/* ── MULTI-SELECT: CHECKBOX COLUMN ── */
.th-check, .td-check {
  width: 36px; min-width: 36px; max-width: 36px;
  padding: 0 8px; text-align: center; border-right: 1px solid var(--border);
}
.th-check input[type="checkbox"],
.td-check input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent);
  flex-shrink: 0;
}
tr.row-selected td { background: rgba(43,47,255,0.05); }
tr.row-selected:hover td { background: rgba(43,47,255,0.09); }

/* ── SELECTION BAR ── */
.selection-bar {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1a1d23; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px; padding: 10px 16px 10px 20px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28); z-index: 500;
  white-space: nowrap; animation: selBarIn 0.2s ease;
}
@keyframes selBarIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.sel-bar-count {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.85);
  padding-right: 4px; border-right: 1px solid rgba(255,255,255,0.12);
}
.sel-bar-actions { display: flex; align-items: center; gap: 6px; }
.sel-bar-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 50px; cursor: pointer; transition: all 0.15s;
}
.sel-bar-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.sel-bar-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.sel-bar-btn:first-child { background: var(--accent); border-color: var(--accent); color: #fff; }
.sel-bar-btn:first-child:hover { filter: brightness(1.15); }
.sel-bar-clear { background: transparent !important; border-color: transparent !important; color: rgba(255,255,255,0.4) !important; padding: 6px 8px; }
.sel-bar-clear:hover { color: rgba(255,255,255,0.75) !important; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 600;
}
.modal-box {
  background: var(--bg2); border-radius: var(--radius);
  padding: 28px 32px 32px; min-width: 420px; max-width: 92vw; max-height: 82vh;
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22); border: 1px solid var(--border);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
#modalContent { overflow-y: auto; flex: 1; padding-right: 4px; }
#modalContent h2 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.modal-scroll { overflow-x: auto; }
.modal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal-table th { background: var(--bg3); color: var(--text2); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px;
  text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.modal-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.modal-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.modal-table th.num { text-align: right; }
.modal-table tbody tr:last-child td { border-bottom: none; }
.modal-table tbody tr:hover td { background: var(--bg3); }
.compare-table th:first-child { min-width: 140px; }
.compare-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; min-width: 120px; }
