/* === Częstochowa — pastelowy design system (szaro-pomarańczowo-biało-niebieski) === */
:root {
  /* Tła pastelowe */
  --bg: #f7f9fc;            /* delikatne biel-niebieskie tło */
  --bg-2: #ffffff;          /* czystaa biel — sidebar, topbar */
  --bg-3: #f0f3f8;          /* jasne tło dla pól */
  --bg-card: #ffffff;
  --bg-hover: #eef3fa;

  /* Akcenty pastelowe */
  --primary: #5b9bd5;       /* niebieski pastelowy */
  --primary-soft: #d8e7f5;  /* jasny niebieski */
  --primary-2: #8bb8e0;
  --orange: #f5a05f;        /* pomarańczowy pastelowy */
  --orange-soft: #fde4ce;
  --orange-2: #f7b884;
  --gray: #6b7a8f;          /* szary dla tekstu */
  --gray-soft: #aab5c5;
  --gray-3: #e3e8ef;        /* obwódki */

  /* Status pastelowe */
  --green: #7ac7a4;         /* pastelowy zielony */
  --green-soft: #d6efe2;
  --yellow: #f4c66a;
  --yellow-soft: #fbecc8;
  --red: #e88894;           /* pastelowy łososiowy */
  --red-soft: #fadfe3;
  --purple: #b39ddb;        /* pastelowy fiolet */
  --purple-soft: #e6dffa;

  /* Tekst */
  --text: #2d3748;
  --text-dim: #6b7a8f;
  --text-muted: #a0aec0;

  /* Inne */
  --border: #e3e8ef;
  --shadow-sm: 0 1px 2px rgba(67, 90, 111, 0.08);
  --shadow: 0 4px 12px rgba(67, 90, 111, 0.10);
  --shadow-lg: 0 12px 32px rgba(67, 90, 111, 0.14);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  color-scheme: light only;  /* WYMUS jasny motyw - bez dark mode */
}
body {
  font: 14px/1.5 -apple-system, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;  /* dynamic viewport height - uwzględnia chowanie się Safari address bar */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;  /* wyłącz pull-to-refresh przeglądarki */
}

/* CSS View Transitions API - smooth animacje między widokami (Chrome/Safari 18+) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-fade-out 0.2s ease-out; }
::view-transition-new(root) { animation: vt-fade-in 0.25s ease-in; }
@keyframes vt-fade-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-fade-in { from { opacity: 0; transform: translateY(4px); } }

#app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 70px 1fr; min-height: 100vh; }

/* === Topbar === */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 220px; }
.brand h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; color: var(--text); font-weight: 700; }
.brand .sub { color: var(--text-dim); font-size: 11px; margin: 0; }
.brand .logo {
  font-size: 26px; width: 44px; height: 44px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--orange));
  border-radius: 12px;
  color: white;
  box-shadow: var(--shadow);
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 0%,100% {transform: scale(1);} 50% {transform: scale(1.04);} }

#globalSearch {
  flex: 1; max-width: 480px;
  height: 38px; padding: 0 16px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px;
  transition: all 0.2s;
}
#globalSearch:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-soft); }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.status-pill {
  font-size: 11px; padding: 5px 12px;
  background: var(--green-soft); color: #3d8166;
  border-radius: 14px; font-weight: 600;
}

/* === Buttons === */
.btn {
  height: 36px; padding: 0 16px;
  background: var(--primary); color: white;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--primary-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
/* Ghost = domyślny styl dla większości akcji w karcie klienta */
.btn.ghost {
  background: white; color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
  font-weight: 500;
}
.btn.ghost:hover { background: var(--bg-3); border-color: var(--primary); color: var(--primary); }
.btn.ghost:active { background: var(--primary-soft); }
/* Danger - tylko pastelowy czerwony, dyskretny */
.btn.danger {
  background: var(--red-soft); color: #9a3838;
  border: 1px solid var(--red);
}
.btn.danger:hover { background: var(--red); color: white; }
/* Success - pastelowy zielony */
.btn.success {
  background: var(--green-soft); color: #2e6e3f;
  border: 1px solid var(--green);
}
.btn.success:hover { background: var(--green); color: white; }
/* Warning - pomarańcz pastelowy */
.btn.warning {
  background: var(--orange-soft); color: #7a4419;
  border: 1px solid var(--orange);
}
.btn.warning:hover { background: var(--orange); color: white; }
.btn.small { height: 30px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Sidebar === */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  overflow-y: auto;
}
.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: transparent; color: var(--gray);
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
  margin-bottom: 3px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-soft), var(--orange-soft));
  color: var(--text); font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-item .badge {
  margin-left: auto;
  background: var(--gray-3); color: var(--gray);
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.nav-item .badge.danger { background: var(--red-soft); color: #b6485a; }
.nav-item.active .badge { background: white; color: var(--primary); }
.sidebar hr { border: none; border-top: 1px solid var(--border); margin: 14px 8px; }
.nav-section {
  font-size: 9px; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 14px 14px 6px 14px;
  text-transform: uppercase;
}
.nav-info { padding: 12px 14px; font-size: 11px; color: var(--text-muted); }
.nav-info p { margin: 4px 0; }
.nav-info strong { color: var(--text-dim); display: block; margin-top: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }

/* === Main === */
main {
  padding: 28px 32px;
  overflow-y: auto;
  max-height: calc(100vh - 70px);
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.loading { padding: 60px; text-align: center; color: var(--text-dim); }
h2 { margin: 0 0 18px 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
h3 { margin: 18px 0 14px 0; font-size: 16px; font-weight: 700; color: var(--text); }
h4 { margin: 0 0 10px 0; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}

/* === KPI Cards === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--primary);
}
.kpi.danger::before { background: var(--red); }
.kpi.warning::before { background: var(--orange); }
.kpi.success::before { background: var(--green); }
.kpi.purple::before { background: var(--purple); }
.kpi-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kpi-value { font-size: 32px; font-weight: 700; margin: 6px 0; letter-spacing: -0.02em; color: var(--text); }
.kpi-value.danger { color: #b6485a; }
.kpi-value.warning { color: #c97e3d; }
.kpi-value.success { color: #3d8166; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }

/* === Tile grid === */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.18s ease-out;
  position: relative;
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.4s ease-out backwards;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.tile-grid .tile:nth-child(1) { animation-delay: 0.02s; }
.tile-grid .tile:nth-child(2) { animation-delay: 0.04s; }
.tile-grid .tile:nth-child(3) { animation-delay: 0.06s; }
.tile-grid .tile:nth-child(4) { animation-delay: 0.08s; }
.tile-grid .tile:nth-child(5) { animation-delay: 0.10s; }
.tile-grid .tile:nth-child(6) { animation-delay: 0.12s; }
.tile-grid .tile:nth-child(n+7) { animation-delay: 0.14s; }

.tile:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, white, var(--primary-soft));
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.tile-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; gap: 10px; }
.tile-title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--text); }
.tile-id { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-family: ui-monospace, monospace; }
.tile-meta { font-size: 12px; color: var(--text-dim); margin: 6px 0; line-height: 1.4; }
.tile-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 10px; font-weight: 600;
  padding: 3px 9px; border-radius: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tag.tauron-aktywne { background: var(--green-soft); color: #3d8166; }
.tag.tauron-zatwierdzone { background: var(--primary-soft); color: #2d6ba6; }
.tag.tauron-zgloszone { background: var(--yellow-soft); color: #a07a2c; }
.tag.tauron-niezgloszone { background: var(--red-soft); color: #b6485a; }
.tag.status-rozliczone { background: var(--green-soft); color: #3d8166; }
.tag.status-odebrane { background: var(--primary-soft); color: #2d6ba6; }
.tag.status-w_montazu { background: var(--yellow-soft); color: #a07a2c; }
.tag.status-zaplanowane { background: var(--purple-soft); color: #6f5cb8; }

/* === Filter bar === */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px; padding: 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  height: 36px; padding: 0 12px;
  background: white; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  font-family: inherit;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--primary); }

/* === Tables === */
table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table thead { background: var(--bg-3); }
table th, table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
table th { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
table tbody tr { transition: background 0.1s; }
table tbody tr:hover { background: var(--bg-hover); cursor: pointer; }
table tbody tr:last-child td { border-bottom: none; }

/* === Modal === */
.modal {
  position: fixed; inset: 0;
  background: rgba(45, 55, 72, 0.5);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.2s ease-out;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-3); color: var(--text);
  border: none; border-radius: 10px;
  width: 36px; height: 36px;
  font-size: 22px; cursor: pointer;
  z-index: 5;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--red); color: white; transform: rotate(90deg); }

/* === Client detail === */
.client-detail { padding: 28px 32px; }
.client-header {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.client-avatar {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--orange));
  border-radius: 50%;
  font-size: 22px; font-weight: 700;
  color: white;
  box-shadow: var(--shadow);
}
.client-name { font-size: 24px; font-weight: 700; margin: 0; color: var(--text); }
.client-addr { color: var(--text-dim); margin: 4px 0 0 0; font-size: 13px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.detail-card .field { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: 10px; }
.detail-card .field:last-child { border-bottom: none; }
.detail-card .field-label { color: var(--text-dim); }
.detail-card .field-value { font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

.editable {
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  border: 1px dashed transparent;
}
.editable:hover { background: var(--orange-soft); border-color: var(--orange); }

/* === Checklist === */
.checklist { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background 0.1s;
}
.checklist-item:hover { background: var(--primary-soft); }
.checklist-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

/* === Documents === */
.docs-list { display: grid; gap: 10px; }
.doc-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.doc-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.doc-icon { font-size: 22px; }
.doc-name { flex: 1; line-height: 1.3; }
.doc-cat { font-size: 11px; padding: 3px 10px; border-radius: 10px; background: var(--orange-soft); color: #c97e3d; font-weight: 600; }
.doc-actions { display: flex; gap: 6px; }
.doc-actions button { background: white; color: var(--gray); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 11px; transition: all 0.15s; }
.doc-actions button:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* === Drag-drop zone === */
.dropzone {
  border: 2px dashed var(--primary-2);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  background: var(--primary-soft);
  color: var(--gray);
  margin-top: 14px;
  transition: all 0.2s;
  font-size: 14px;
}
.dropzone.dragover {
  border-color: var(--orange);
  background: var(--orange-soft);
  color: var(--text);
  transform: scale(1.02);
}

/* === Toast === */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: white; border: 1px solid var(--green);
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 13px;
  max-width: 380px;
  animation: slideInRight 0.3s ease-out;
}
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
.toast.hidden { display: none; }
.toast.error { border-color: var(--red); background: var(--red-soft); }
.toast.success { border-color: var(--green); background: var(--green-soft); color: #2c6850; }

/* === Tabs === */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 11px 18px;
  background: transparent; color: var(--text-dim);
  border: none; cursor: pointer;
  font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); background: var(--bg-hover); border-radius: 8px 8px 0 0; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-pane.hidden { display: none; }

/* === Luki === */
.luki-list { display: grid; gap: 10px; }
.luka-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid;
  border-radius: 10px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.luka-item:hover { transform: translateX(4px); box-shadow: var(--shadow); }
.luka-item.priorytet-KRYTYCZNY { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-soft), white 30%); }
.luka-item.priorytet-WYSOKI { border-left-color: var(--orange); background: linear-gradient(90deg, var(--orange-soft), white 30%); }
.luka-item.priorytet-ŚREDNI { border-left-color: var(--yellow); }
.luka-item.priorytet-NISKI { border-left-color: var(--gray-soft); }
.luka-priorytet { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 8px; border-radius: 6px; text-align: center; }
.luka-priorytet.priorytet-KRYTYCZNY { color: white; background: var(--red); }
.luka-priorytet.priorytet-WYSOKI { color: white; background: var(--orange); }
.luka-priorytet.priorytet-ŚREDNI { color: white; background: var(--yellow); }
.luka-priorytet.priorytet-NISKI { color: white; background: var(--gray-soft); }
.luka-detail { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

/* === Form === */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 13px;
  background: white; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit;
  transition: all 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* === Mail list === */
.mail-list { display: grid; gap: 8px; }
.mail-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.mail-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* === Integrations === */
.integration-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.integration {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.integration:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.integration-icon { font-size: 40px; margin-bottom: 10px; }
.integration h4 { margin: 8px 0 4px 0; font-size: 15px; color: var(--text); text-transform: none; letter-spacing: 0; }
.integration p { color: var(--text-dim); font-size: 12px; margin: 4px 0 14px 0; }
.integration .badge { padding: 6px 14px; border-radius: 14px; font-size: 11px; font-weight: 600; }
.integration .badge.connected { background: var(--green-soft); color: #3d8166; }
.integration .badge.disconnected { background: var(--red-soft); color: #b6485a; }

/* === Products === */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s;
  cursor: pointer;
}
.product-card:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: var(--shadow); }
.product-card .product-icon { font-size: 32px; }
.product-card h3 { margin: 8px 0 4px 0; }
.product-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.product-stat { text-align: center; padding: 10px; background: var(--bg-3); border-radius: 8px; }
.product-stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.product-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }
.progress-bar { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--orange)); transition: width 0.5s ease-out; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-3); }
::-webkit-scrollbar-thumb { background: var(--gray-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-soft); }

/* === Hamburger button (visible on mobile) === */
.hamburger {
  display: none;
  width: 44px; height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 22px; cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hamburger:active { transform: scale(0.95); }
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* === Tablet / iPad portrait (≤900px) === */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 56px 1fr; }
  .topbar { padding: 0 10px; gap: 6px; flex-wrap: nowrap; min-height: 56px; overflow: hidden; }
  .topbar h1 { font-size: 16px; }
  .topbar .sub { display: none; }
  .topbar .brand { gap: 6px; min-width: 0; flex-shrink: 1; overflow: hidden; }
  .topbar .brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .brand .logo { width: 30px; height: 30px; flex-shrink: 0; }
  .topbar .brand > span:last-of-type { display: none; }   /* strzałka ▼ schowana */
  #globalSearch { flex: 1 1 110px; min-width: 80px; max-width: 200px; padding: 7px 10px; font-size: 13px; }
  .topbar-actions { gap: 4px; flex-shrink: 0; }
  .topbar-actions .btn { padding: 7px 9px; font-size: 12px; }
  .topbar-actions .status-pill { display: none; }
  /* Auth user — tylko avatar (kółko z literą) */
  .topbar-actions #auth-user-info { padding: 4px !important; gap: 0 !important; }
  .topbar-actions #auth-user-info strong { display: none !important; }
  .topbar-actions #auth-user-info > span:last-child { display: none !important; }
  /* Offline badge - tylko liczba */
  .topbar-actions #offline-queue-badge { padding: 4px 8px !important; font-size: 10px !important; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hamburger { display: flex; }

  /* Sidebar = drawer od lewej */
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 78%; max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
    padding-top: 16px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .nav-item { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .sidebar .nav-section { font-size: 11px; padding: 12px 14px 6px; }

  main { padding: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .kpi-value { font-size: 20px; }
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-header > div:last-child { width: 100%; flex-wrap: wrap; }

  /* Tabele - poziomy scroll */
  table { font-size: 12px; }
  table td, table th { padding: 6px 8px; }
  .luka-item { grid-template-columns: 1fr !important; padding: 10px; gap: 6px; }

  /* Buttons - większe tap targets */
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn.small { min-height: 32px; padding: 6px 10px; }

  /* Modal pełny ekran */
  .modal-content { max-width: 100% !important; max-height: 100vh !important; border-radius: 0 !important; margin: 0 !important; }
}

/* === Bottom Tab Bar (iOS style) - default ukryty === */
.tabbar { display: none; }

/* === iOS 18 Liquid Glass - mobile (≤900px) === */
@media (max-width: 900px) {
  body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
    background: #f2f2f7;
    /* Subtle gradient mesh w tle - "Liquid Glass" */
    background-image:
      radial-gradient(at 20% 0%, color-mix(in oklch, #ffd84d 8%, transparent) 0%, transparent 40%),
      radial-gradient(at 80% 100%, color-mix(in oklch, #5b9bd5 8%, transparent) 0%, transparent 40%);
    background-attachment: fixed;
  }
  /* Dark mode WYŁĄCZONY - aplikacja zawsze w jasnym motywie */
  /* Topbar - iOS glass */
  .topbar {
    background: rgba(248, 248, 252, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
    box-shadow: none;
    position: sticky;
    top: 0; z-index: 50;
  }
  .topbar h1 { font-weight: 700; letter-spacing: -0.3px; }
  .logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #ffd84d, #ff9d27);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 6px rgba(255,157,39,0.3);
  }
  #globalSearch {
    background: rgba(118,118,128,0.12);
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
  }
  #globalSearch:focus { outline: 2px solid #007aff; outline-offset: -2px; }

  /* Bottom tab bar - widoczny tylko na mobile */
  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    background: rgba(248, 248, 252, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(0,0,0,0.15);
    padding: 6px 4px env(safe-area-inset-bottom, 8px);
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
  }
  .tabbar-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    background: transparent; border: none;
    padding: 4px 0;
    color: #8e8e93;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
    min-width: 0;
  }
  .tabbar-item:active { transform: scale(0.92); }
  .tabbar-item.active { color: #007aff; }
  .tabbar-icon { font-size: 22px; line-height: 1; }
  .tabbar-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.1px;
  }

  /* Main - dodaj padding-bottom na tabbar */
  main {
    padding-bottom: 80px !important;
    background: #f2f2f7;
  }

  /* Karty iOS-style: białe, rounded 14px, subtle shadow */
  .kpi, .detail-card, .luka-item, .product-card, .integration-card {
    background: #ffffff;
    border: none !important;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .kpi:hover { transform: none; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

  /* Buttons iOS-style: rounded pill */
  .btn {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: -0.1px;
    transition: opacity 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active { transform: scale(0.97); opacity: 0.7; }
  .btn.warning { background: #ff9500; }
  .btn.success { background: #34c759; }
  .btn.danger { background: #ff3b30; }
  .btn.ghost { background: rgba(118,118,128,0.12); color: #007aff; border: none; }

  /* Inputy iOS-style */
  input[type="text"], input[type="search"], input[type="tel"], input[type="email"],
  input[type="number"], input[type="date"], input[type="time"], select, textarea {
    background: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  input:focus, select:focus, textarea:focus {
    outline: 2px solid #007aff;
    outline-offset: -2px;
  }

  /* Tags iOS-style */
  .tag { border-radius: 6px; padding: 2px 8px; font-size: 10px; font-weight: 600; }

  /* Modal - jak iOS sheet */
  .modal-content {
    border-radius: 14px 14px 0 0 !important;
    margin-top: 60px !important;
  }
}

/* === iPhone portrait (≤480px) - kompaktowe kafelki === */
@media (max-width: 480px) {
  /* Topbar mocno minimalistyczny: hamburger + brand + tylko awatar/badge offline */
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar h1 { font-size: 14px; max-width: 130px; }
  /* Search w topbarze ukryty na portret iPhone (dostępny przez Cmd+K / sidebar) */
  #globalSearch { display: none; }
  /* Folder + Odświeź - schowane (są w sidebar pod hamburgerem) */
  .topbar-actions #btn-folder, .topbar-actions #btn-refresh { display: none; }
  /* Avatar usera - tylko kółko bez paddingu */
  .topbar-actions #auth-user-info { background: transparent !important; border: none !important; padding: 2px !important; }
  /* Brand strzałka schowana */
  .topbar .brand > span[title*="projekt"] { display: none; }

  /* Tabbar items mniej padding bo 6 elementów na 375px */
  .tabbar-item { padding: 4px 0 !important; gap: 1px !important; }
  .tabbar-icon { width: 22px !important; height: 22px !important; }
  .tabbar-icon svg { width: 22px; height: 22px; }
  .tabbar-label { font-size: 9px !important; letter-spacing: -0.2px; }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
    margin-bottom: 14px;
  }
  .kpi {
    padding: 8px 10px !important;
    border-radius: 10px;
  }
  .kpi::before { height: 2px; }
  .kpi-label {
    font-size: 9px !important;
    margin-bottom: 4px !important;
    line-height: 1.2;
  }
  .kpi-value {
    font-size: 16px !important;
    font-weight: 700;
    line-height: 1.1;
  }
  .kpi-sub {
    font-size: 9px !important;
    margin-top: 2px !important;
    line-height: 1.2;
    color: var(--text-muted);
  }

  .topbar h1 { font-size: 16px; }
  main { padding: 10px; }
  h2 { font-size: 17px; margin: 6px 0 8px; }
  h3 { font-size: 14px; margin: 12px 0 6px; }
  h4 { font-size: 13px; }

  .detail-card { padding: 12px !important; margin-bottom: 10px; }
  .luka-item {
    font-size: 11px !important;
    padding: 8px !important;
    grid-template-columns: 1fr !important;
    gap: 4px;
  }
  .luka-detail { font-size: 11px; }

  .integration-grid { grid-template-columns: 1fr; gap: 8px; }
  .tile-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .product-stats { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .product-stats .product-stat-value { font-size: 16px; }
  .product-stats .product-stat-label { font-size: 9px; }

  .section-header h2 { font-size: 17px; }
  .section-header p { font-size: 11px; }

  /* Tabele - minimum padding */
  table { font-size: 11px; }
  table td, table th { padding: 4px 6px; }
}

/* Safe area iPhone notch */
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { padding-top: env(safe-area-inset-top); }
}

/* ============================================================
   === iPhone OPTYMALIZACJA: bez scroll-x, wszystko mieści się ===
   ============================================================ */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  #app, main { max-width: 100vw; overflow-x: hidden; }
  * { max-width: 100%; box-sizing: border-box; }

  /* Topbar w 2 wierszach: hamburger+logo+akcje, search niżej osobno */
  .topbar {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: 50px auto;
    gap: 6px 8px;
    padding: 6px 10px 8px !important;
    height: auto !important;
  }
  .topbar .hamburger { grid-column: 1; grid-row: 1; }
  .topbar .brand { grid-column: 2; grid-row: 1; min-width: 0; overflow: hidden; }
  .topbar .brand h1 { font-size: 15px !important; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .brand .logo { width: 32px; height: 32px; font-size: 17px; }
  .topbar .topbar-actions { grid-column: 3; grid-row: 1; }
  .topbar .topbar-actions .btn { padding: 6px 8px; font-size: 11px; min-height: 32px; }
  .topbar #globalSearch {
    grid-column: 1 / -1; grid-row: 2;
    width: 100%; min-width: 0;
    font-size: 13px; padding: 7px 12px;
  }
  #app { grid-template-rows: auto 1fr; }

  /* Main - mniej paddingu, brak side-scroll */
  main { padding: 10px !important; padding-bottom: 76px !important; }

  /* H2/H3 - kompakt */
  h2 { font-size: 16px !important; margin: 4px 0 6px !important; }
  h3 { font-size: 13px !important; margin: 10px 0 4px !important; }
  h4 { font-size: 12px !important; }
  p { font-size: 12px; }

  /* KPI - obowiązkowo 2 kolumny minmax(0, 1fr) (zapobiega rozszerzaniu) */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin-bottom: 10px !important;
  }
  .kpi {
    padding: 8px 10px !important;
    min-width: 0;
    overflow: hidden;
  }
  .kpi-label { font-size: 9px !important; line-height: 1.15; word-wrap: break-word; }
  .kpi-value { font-size: 15px !important; line-height: 1.1; word-wrap: break-word; }
  .kpi-sub { font-size: 9px !important; line-height: 1.15; }

  /* Detail-card - kompaktowy */
  .detail-card {
    padding: 10px 12px !important;
    margin-bottom: 8px !important;
    border-radius: 12px !important;
  }

  /* Form-row - 1 kolumna zawsze */
  .form-row, .form-row.full {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .form-row > div, .form-row label { width: 100%; }
  label { font-size: 11px !important; margin-bottom: 4px; }

  /* Section header - vertical stack */
  .section-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    margin-bottom: 8px;
  }
  .section-header > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .section-header .btn { font-size: 11px; padding: 7px 10px; min-height: 32px; }

  /* Buttons na mobile - kompakt */
  .btn { padding: 8px 12px; font-size: 12px; min-height: 36px; }
  .btn.small { padding: 5px 8px; font-size: 10px; min-height: 28px; }

  /* Tile-grid (klienci, dostawcy, produkty) - 1 col na iPhone */
  .tile-grid, .integration-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Luka-item (wszystkie listy) - 1 kolumna, kompakt */
  .luka-item {
    grid-template-columns: 1fr !important;
    padding: 8px 10px !important;
    gap: 4px !important;
    font-size: 12px !important;
  }
  .luka-detail { font-size: 11px !important; }

  /* TABELE → konwersja na "data labels" kart - bez horizontal scroll */
  .table-wrap, table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
  }
  table thead { display: none; }  /* Ukryj nagłówki - na mobile pokazujemy data-label */
  table tbody { display: block; width: 100%; }
  table tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
    margin-bottom: 6px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: none !important;
  }
  table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0 !important;
    border: none !important;
    font-size: 12px;
    word-break: break-word;
  }
  table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
    margin-right: 8px;
    flex-shrink: 0;
  }
  table tfoot tr { background: var(--primary-soft); font-weight: 700; }

  /* Modal - pełnoekranowy */
  .modal { padding: 0 !important; }
  .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }
  .modal-content > div { padding: 12px !important; }

  /* Karta klienta - sekcje pełna szerokość */
  .client-detail .client-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px;
    text-align: center;
  }
  .client-name { font-size: 18px !important; }
  .client-addr { font-size: 12px !important; }

  /* Tabs - przewijalne poziomo (jak iOS Photos) */
  .tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { font-size: 12px; padding: 6px 10px; flex-shrink: 0; }

  /* Topbar zostaje sticky aż na mobile */
  .topbar { z-index: 50; }

  /* Tabbar - lekko niższy (więcej miejsca na content) */
  .tabbar { height: calc(54px + env(safe-area-inset-bottom, 0px)) !important; }
  .tabbar-icon { font-size: 19px !important; }
  .tabbar-label { font-size: 9px !important; }

  /* Topbar buttons hide na bardzo wąskim */
  .topbar-actions .btn:not(.hamburger) { padding: 6px 8px; font-size: 11px; }
}

/* === Modal faktury - 2-col → 1-col + iframe pełna szerokość === */
@media (max-width: 768px) {
  /* Wszystkie wewnętrzne grid-template-columns 1fr 1fr → 1 kolumna */
  .modal-content [style*="grid-template-columns:1fr 1fr"],
  .modal-content [style*="grid-template-columns: 1fr 1fr"],
  .modal-content [style*="grid-template-columns:repeat(2"],
  main [style*="grid-template-columns:1fr 1fr"],
  main [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* PDF iframe - dopasuj do mobile */
  .modal-content iframe {
    width: 100% !important;
    max-width: 100% !important;
    height: 60vh !important;
    min-height: 320px;
  }
  /* Detail-card wewnątrz modalu */
  .modal-content .detail-card { padding: 10px 12px !important; }
  /* Field rows w modalu (lista atrybutów) */
  .modal-content .field {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 10px;
    padding: 6px 0 !important;
    flex-wrap: wrap;
  }
  .modal-content .field-label { font-size: 11px; color: var(--text-dim); }
  .modal-content .field-value { font-size: 12px; word-break: break-word; text-align: right; }

  /* Wszystkie ":nth-child" 2-col fixy */
  .form-row[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Wymuś jasne tło na całość — gdy nadrzędny element ma color: white na czarnym tle */
  .modal-content { background: #ffffff !important; color: #1c1c1e !important; }
  .detail-card { background: #ffffff !important; color: #1c1c1e !important; }
  .detail-card h3, .detail-card h4 { color: #1c1c1e; }
  .field-label { color: #6b7a8f !important; }
  .field-value { color: #1c1c1e !important; }
}

/* ============= iPhone (≤430px - 14 Pro Max width) - jeszcze bardziej zwięzłe ============= */
@media (max-width: 430px) {
  .topbar h1 { font-size: 14px !important; }
  .topbar .topbar-actions .btn { padding: 5px 7px; font-size: 10px; min-height: 28px; }
  .kpi-value { font-size: 14px !important; }
  .kpi-label { font-size: 8px !important; }
  .btn { font-size: 11px; padding: 7px 10px; }
  main { padding: 8px !important; }
  h2 { font-size: 15px !important; }
}

/* === Pulse animation for danger === */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.pulse { animation: pulse 2s infinite; }

/* === Sparkle dla Top Luki === */
.sparkle { display: inline-block; animation: sparkle 1.5s ease-in-out infinite; }
@keyframes sparkle { 0%,100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.2) rotate(15deg); } }

/* ════════════════════════════════════════════════════════ */
/*  NEW DESIGN SYSTEM - SVG ikony, czysto, profesjonalnie   */
/* ════════════════════════════════════════════════════════ */

/* Ikony SVG w nawigacji - cienkie linie, dziedziczą kolor tekstu */
.nav-svg, [data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
  width: 20px;
  height: 20px;
}
.nav-svg svg, [data-icon] svg {
  display: block;
  stroke: currentColor;
  width: 100%;
  height: 100%;
}
/* Tabbar — wymuszony większy rozmiar ikon żeby były czytelne na iPhone */
.tabbar-icon { width: 24px !important; height: 24px !important; }
.tabbar-icon svg { width: 24px; height: 24px; }
/* Hamburger menu */
.hamburger.nav-svg-btn { width: 40px; height: 40px; }
.hamburger.nav-svg-btn svg { width: 22px; height: 22px; }

/* Logo w brand */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #ffd966, #ff9d27);
  border-radius: 10px;
  color: white;
  box-shadow: 0 2px 8px rgba(255,157,39,.25);
}
.logo svg {
  width: 22px; height: 22px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}

/* Hamburger nav-svg-btn */
.hamburger.nav-svg-btn {
  background: var(--bg-3);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.hamburger.nav-svg-btn:hover { background: var(--bg-hover); }

/* Topbar buttons z ikonami - dopasuj wysokość */
.topbar-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.topbar-actions .btn svg { display: inline-block; vertical-align: middle; }

/* Sidebar nav items - ikona + tekst + opcjonalny badge */
.nav-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  font-weight: 500;
}
.nav-item .nav-svg { color: var(--gray); }
.nav-item:hover { background: var(--bg-hover); }
.nav-item:hover .nav-svg { color: var(--primary); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active .nav-svg { color: var(--primary); }
.nav-item .badge {
  margin-left: auto;
  background: var(--gray-3);
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.nav-item .badge.danger { background: var(--red-soft); color: var(--red); }

/* Dodaj dokument - wyróżniony przycisk pomarańczowy */
.nav-item.nav-add-doc {
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: white;
  font-weight: 600;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(245,160,95,.25);
}
.nav-item.nav-add-doc .nav-svg { color: white; }
.nav-item.nav-add-doc:hover {
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245,160,95,.35);
}

/* Wyróżniony nav-item (Urząd Miasta) - subtelnie niebieskie tło */
.nav-item.nav-highlight {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.nav-highlight:hover {
  background: var(--primary);
  color: white;
}
.nav-item.nav-highlight:hover .nav-svg { color: white; }

/* Tabbar (mobile) */
.tabbar-icon { color: var(--gray); }
.tabbar-icon svg { display: block; margin: 0 auto; }
.tabbar-item.active .tabbar-icon { color: var(--primary); }
.tabbar-item.active .tabbar-label { color: var(--primary); font-weight: 600; }

/* Sekcje sidebara */
.nav-section {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin: 14px 14px 6px 14px;
}

/* Bardziej spójny design kafelków KPI */
.kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(67,90,111,.06);
  transition: all .15s;
}
.kpi:hover {
  border-color: var(--primary-2);
  box-shadow: 0 4px 12px rgba(91,155,213,.10);
}
.kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.kpi-value.success { color: #5fb389; }
.kpi-value.warning { color: var(--orange); }
.kpi-value.danger { color: var(--red); }
.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Detail card - jednorodny styl */
.detail-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(67,90,111,.06);
  margin-bottom: 14px;
}
.detail-card h3, .detail-card h4 {
  margin-top: 0;
  color: var(--text);
  font-weight: 700;
}

/* Tagi z pastelami */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--gray-3);
  color: var(--text-dim);
}
.tag.status-rozliczone { background: var(--green-soft); color: #5fb389; }
.tag.status-odebrane { background: var(--primary-soft); color: var(--primary); }
.tag.status-w_montazu { background: var(--yellow-soft); color: #d4a017; }
.tag.status-zaplanowane { background: var(--orange-soft); color: var(--orange); }
.tag.status-wstrzymane { background: var(--red-soft); color: var(--red); }
.tag.tauron-aktywne { background: var(--green-soft); color: #5fb389; }
.tag.tauron-zatwierdzone, .tag.tauron-zgloszone { background: var(--primary-soft); color: var(--primary); }
.tag.tauron-niezgloszone { background: var(--red-soft); color: var(--red); }

/* Lepsze tabele */
table {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(67,90,111,.07);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  overflow: hidden;
}
table th {
  background: var(--bg-3);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg-hover); }

/* H2/H3 z SVG ikonami (zamiast emoji) */
.h2-svg, .h3-svg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.h2-svg::before, .h3-svg::before {
  content: '';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  flex-shrink: 0;
}
.h3-svg::before {
  width: 22px;
  height: 22px;
  background: var(--bg-3);
  border-radius: 6px;
}

/* Dynamicznie wstawiane przez JS po DOM ready */
.h2-svg[data-h2-icon-rendered]::before { content: ''; }
.h3-svg[data-h2-icon-rendered]::before { content: ''; }

/* ============================================================
   INSTALLER MODE — pełnoekranowy widok kalendarza dla montażysty
   Ukrywa sidebar, topbar, tabbar - tylko #main z kalendarzem
   ============================================================ */
body.installer-mode .sidebar,
body.installer-mode .topbar,
body.installer-mode .tabbar,
body.installer-mode #sidebarOverlay { display: none !important; }
/* #app to grid 240px+1fr — w trybie montera robimy 1 kolumnę pełnoszerokościową */
body.installer-mode #app {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}
/* MOBILE FIX: używaj dvh (dynamic viewport - bez paska przeglądarki) gdzie wspierane,
   z fallback do svh i 100vh dla starszych przeglądarek (Android Chrome stara, etc.) */
body.installer-mode {
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
}
body.installer-mode main,
body.installer-mode #main {
  grid-column: 1 / -1 !important;
  grid-row: 1 / -1 !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  /* Trzy fallbacki: vh dla starych, svh, dvh dla nowych */
  min-height: 100vh !important;
  min-height: 100svh !important;
  min-height: 100dvh !important;
  max-height: none !important;
  /* Safe-area dla iPhone z notchem + Android z gestami */
  padding-bottom: env(safe-area-inset-bottom, 0) !important;
  overflow-x: hidden !important;
}
/* Header sticky żeby zostawał widoczny przy scrollu */
body.installer-mode .installer-header {
  padding-top: max(env(safe-area-inset-top, 12px), 12px) !important;
}
/* Treść kalendarza - zostaw miejsce na dole (Safari iPhone toolbar 80px + bezpieczna strefa) */
body.installer-mode .installer-calendar {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
}
/* Modal klienta montera musi być scrollowalny i mieć padding na dole */
body.installer-mode #modal {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
}

/* Header montażysty */
.installer-header {
  background: linear-gradient(135deg, #2d6ba6, #5b9bd5);
  color: white;
  padding: env(safe-area-inset-top, 12px) 16px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.installer-header .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.installer-header h1 { margin: 0; font-size: 18px; font-weight: 700; }
.installer-header .subline { font-size: 11px; opacity: 0.9; margin-top: 2px; }
.installer-header .btn-out { background: rgba(255,255,255,0.2); color: white; border: none; padding: 6px 12px; border-radius: 16px; font-size: 11px; cursor: pointer; }
.installer-header .week-nav { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.installer-header .week-nav button { background: rgba(255,255,255,0.18); color: white; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.installer-header .week-nav .week-label { flex: 1; text-align: center; font-weight: 600; font-size: 13px; }

/* Kalendarz - dni jako wiersze */
.installer-calendar { padding: 14px; max-width: 720px; margin: 0 auto; }
.installer-day {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  overflow: hidden;
}
.installer-day.today { border-color: #f0c050; box-shadow: 0 4px 12px rgba(240, 192, 80, 0.2); }
.installer-day.empty { background: #f6f6f8; opacity: 0.65; }
.installer-day-head {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #f8f9fb, white);
  border-bottom: 1px solid var(--border);
}
.installer-day.today .installer-day-head { background: linear-gradient(135deg, #fff8e1, #fffbed); }
.installer-day-head .name { font-weight: 700; font-size: 13px; }
.installer-day-head .date { font-size: 11px; color: var(--text-dim); }
.installer-day-head .count { background: #5b9bd5; color: white; font-size: 11px; padding: 2px 10px; border-radius: 10px; font-weight: 700; }
.installer-day.today .installer-day-head .count { background: #f0c050; color: #5a4400; }

.installer-client {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  transition: background 0.15s;
}
.installer-client:last-child { border-bottom: none; }
.installer-client:active { background: #e8f0f8; }
.installer-client .time {
  background: #2d6ba6;
  color: white;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  min-width: 50px;
  text-align: center;
}
.installer-client .info .name { font-weight: 700; font-size: 14px; }
.installer-client .info .meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.installer-client .badges { display: flex; gap: 4px; flex-direction: column; align-items: flex-end; }
.installer-client .badges .b { font-size: 9px; padding: 2px 6px; border-radius: 8px; font-weight: 700; }
.installer-client .badges .ok { background: #e8f5e9; color: #2e6e3f; }
.installer-client .badges .warn { background: #fff8e1; color: #7a5b00; }

/* Modal klienta - 3 sekcje */
.inst-section {
  background: white;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1.5px solid var(--border);
}
.inst-section h3 {
  margin: 0 0 10px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inst-data-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg-3);
  font-size: 13px;
}
.inst-data-row:last-child { border-bottom: none; }
.inst-data-row .label { color: var(--text-dim); }
.inst-data-row .value { font-weight: 600; text-align: right; }
.inst-decision-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.inst-decision-buttons button {
  padding: 14px 8px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: all 0.15s;
}
.inst-decision-buttons button.sel-chce { background: #34c759; color: white; border-color: #2e6e3f; }
.inst-decision-buttons button.sel-niechce { background: #9a3838; color: white; border-color: #7e2a2a; }
.inst-decision-buttons button.sel-zastanawia { background: #f0c050; color: #5a4400; border-color: #cca040; }
