/* Szponga — główny arkusz stylów */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #F7F5F0;
  --surface:  #FFFFFF;
  --border:   #E4E0D8;
  --text:     #1A1814;
  --muted:    #7A7670;
  --accent:   #2D5A3D;
  --accent-bg:#EAF2EC;
  --accent-t: #1E3E2A;
  --warn-bg:  #FDF3E3;
  --warn-t:   #7A4F1A;
  --danger-bg:#FDECEA;
  --danger-t: #8B2020;
  --success-bg:#E8F5E9;
  --success-t:#1B5E20;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Ikony — sprite SVG wstrzykiwany przez js/icons.js (zamiast webfontu Tabler z CDN).
   Rozmiar dziedziczy z font-size (width/height: 1em), kolor z color — jak przy webfoncie */
svg.ti {
  width: 1em; height: 1em;
  display: inline-block; vertical-align: -0.125em; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
svg.ti.ti-filled { fill: currentColor; stroke: none; }
@keyframes ti-spin { to { transform: rotate(360deg); } }
svg.ti.ti-spin { animation: ti-spin 0.9s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  svg.ti.ti-spin { animation: none; }
}

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.logo { padding: 0 0.5rem 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }
.logo h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--accent); }
.logo small { font-size: 11px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 13px; color: var(--muted); cursor: pointer;
  text-decoration: none; transition: all 0.12s;
  border: none; background: none; width: 100%; font-family: inherit;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-bg); color: var(--accent-t); font-weight: 500; }
.nav-link .ti { font-size: 17px; }
.nav-spacer { margin-top: auto; }

/* Main */
.main { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 1.5rem 1.75rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: all 0.12s; border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-t); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger-bg); color: var(--danger-t); border-color: #F5C2C2; }
.btn-danger:hover { background: #FADDDD; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.125rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.stat-value.green { color: var(--accent); }
.stat-value.amber { color: #B07A20; }
.stat-value.blue  { color: #1E4A7A; }

/* Filters */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 13px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); transition: all 0.12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-bg); color: var(--accent-t); border-color: #A8CBB0; }
.chip-fav .ti { font-size: 12px; margin-right: 2px; }
.chip-fav.active { background: var(--warn-bg); color: var(--warn-t); border-color: var(--warn-t); }
.search-wrap { position: relative; margin-left: auto; }
.search-wrap .ti { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.search-wrap input { padding: 7px 10px 7px 30px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; width: 200px; }

/* Table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 16px; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); background: var(--bg); }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFAF8; cursor: pointer; }
.row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; }
tbody tr:hover .row-actions { opacity: 1; }

/* Status select inline */
.status-sel {
  font-size: 12px; padding: 4px 8px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  cursor: pointer; font-family: inherit;
}

/* Avatar */
.av { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.av-a { background: #E3EEFF; color: #1A3A7A; }
.av-b { background: var(--accent-bg); color: var(--accent-t); }
.av-c { background: var(--warn-bg); color: var(--warn-t); }
.av-d { background: #FBEAF0; color: #7A2040; }
.av-e { background: #EEEDFE; color: #3A2A9A; }
.cpill { display: inline-flex; align-items: center; gap: 8px; }

/* Paid status */
.paid-ok   { color: var(--success-t); font-size: 12px; font-weight: 500; }
.paid-no   { color: var(--muted); font-size: 12px; }

/* Modal / Drawer */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 2rem 1rem; overflow-y: auto;
}
.overlay.open { display: flex; }
.drawer {
  background: var(--surface); border-radius: 12px;
  border: 1px solid var(--border); width: 100%; max-width: 580px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.drawer-brand { font-size: 10px; font-weight: 700; letter-spacing: 2.5px; color: var(--accent); margin-bottom: 3px; }
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.125rem; }
.drawer-foot { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Form fields */
.form-section { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding-top: 0.25rem; border-top: 1px solid var(--border); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea,
.note-add-row input, .note-add-row select, .note-add-row textarea {
  font-size: 13px; padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-family: inherit; width: 100%;
  transition: border-color 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.note-add-row input:focus, .note-add-row select:focus, .note-add-row textarea:focus { outline: none; border-color: var(--accent); }
.field input[readonly] { background: #F0EEE8; color: var(--muted); }
.field textarea { resize: vertical; min-height: 64px; }
.field-hint { font-size: 11px; color: var(--muted); }

/* Wybór klienta przy nowym projekcie */
.client-mode-toggle { display: flex; gap: 6px; }
.client-readonly-box { background: #F0EEE8; color: var(--text); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; line-height: 1.6; }
.client-readonly-box a { color: var(--accent); text-decoration: none; }

/* Material rows */
.mat-header { display: grid; grid-template-columns: 18px minmax(0,1fr) 72px 90px 28px; gap: 8px; font-size: 11px; color: var(--muted); font-weight: 500; padding: 0 0 4px; }
.mat-row { display: grid; grid-template-columns: 18px minmax(0,1fr) 72px 90px 28px; gap: 8px; align-items: center; margin-bottom: 6px; position: relative; }
.mat-row input[type="text"], .mat-row input[type="number"] { font-size: 12px; padding: 6px 8px; width: 100%; box-sizing: border-box; }
.mat-check { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; justify-self: center; }
.ico-del { color: var(--muted); cursor: pointer; background: none; border: none; padding: 2px; line-height: 1; border-radius: 4px; }
.ico-del:hover { color: var(--danger-t); background: var(--danger-bg); }

.ico-fav { color: var(--muted); cursor: pointer; background: none; border: none; padding: 2px; line-height: 1; border-radius: 4px; font-size: 15px; }
.ico-fav:hover { color: var(--warn-t); background: var(--warn-bg); }
.ico-fav.active { color: var(--warn-t); }
.add-row { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--accent); cursor: pointer; background: none; border: none; font-family: inherit; font-weight: 500; padding: 0; }
.add-row:hover { text-decoration: underline; }

/* Autouzupełnianie wyceny z Cenników — dropdown pod aktywnym wierszem materiału */
.mat-ac {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin-top: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  max-height: 264px; overflow-y: auto;
}
.mat-ac-item { padding: 7px 10px; cursor: pointer; }
.mat-ac-item + .mat-ac-item { border-top: 1px solid var(--border); }
.mat-ac-item:hover, .mat-ac-item.active { background: var(--accent-bg); }
.mat-ac-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mat-ac-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-ac-price { font-size: 12px; font-weight: 600; white-space: nowrap; }
.mat-ac-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-ac-fav { color: var(--warn-t); }

/* Notes panel */
.notes-panel { display: flex; flex-direction: column; gap: 10px; }
.notes-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.notes-empty { text-align: center; color: var(--muted); font-size: 12px; padding: 1rem 0; }
.note-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); }
.note-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.note-author { font-size: 11px; color: var(--muted); font-weight: 500; }
.note-date { font-size: 11px; color: var(--muted); flex: 1; }
.note-content { font-size: 13px; line-height: 1.45; white-space: pre-wrap; cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.note-content:hover { background: var(--accent-bg); }
.note-tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding: 2px 7px; border-radius: 20px; }
.note-tag-info      { background: #E3EEFF; color: #1A3A7A; }
.note-tag-important { background: var(--danger-bg); color: var(--danger-t); }
.note-tag-todo      { background: var(--warn-bg); color: var(--warn-t); }
.note-tag-done      { background: var(--success-bg); color: var(--success-t); }

/* Odznaka podsumowania notatek w tabeli projektów — kolor przejęty z .note-tag-* */
.notes-badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 20px; cursor: pointer; border: none; font-family: inherit; }
.notes-badge:hover { filter: brightness(0.96); }

.note-add-row { display: flex; flex-direction: column; gap: 6px; border-bottom: 1px dashed var(--border); padding-bottom: 10px; }
.note-add-row textarea { resize: vertical; min-height: 56px; }
.chip-count { opacity: 0.6; font-weight: 600; }
.note-item-editing { border-color: var(--accent); }
.note-edit-content { width: 100%; resize: vertical; min-height: 56px; font-size: 13px; font-family: inherit; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; box-sizing: border-box; }
.note-edit-content:focus { outline: none; border-color: var(--accent); }
.note-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* Total box */
.total-box { display: flex; justify-content: space-between; align-items: center; background: var(--accent-bg); border: 1px solid #A8CBB0; border-radius: var(--radius); padding: 12px 14px; }
.total-label { font-size: 13px; color: var(--accent-t); font-weight: 500; }
.total-val { font-size: 20px; font-weight: 700; color: var(--accent-t); letter-spacing: -0.5px; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--text); color: #fff; padding: 10px 18px;
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  z-index: 999; opacity: 0; transform: translateY(8px);
  transition: all 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8B2020; }

/* Column picker */
.col-picker {
  position: absolute; z-index: 200; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; min-width: 190px;
}
.col-picker-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  font-size: 13px; border-radius: 6px; cursor: pointer; user-select: none;
}
.col-picker-item:hover { background: var(--accent-bg); }
.col-picker-item input { cursor: pointer; }

/* Loading */
.loading { text-align: center; padding: 3rem; color: var(--muted); font-size: 13px; }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .ti { font-size: 36px; margin-bottom: 0.75rem; display: block; margin-inline: auto; }
.empty p { font-size: 14px; }

/* Tracking page */
.track-page { max-width: 560px; margin: 3rem auto; padding: 1rem; }
.track-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.track-header { background: var(--accent); color: #fff; padding: 1.5rem; }
.track-header .brand { font-size: 13px; opacity: 0.7; margin-bottom: 6px; }
.track-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.track-header .sub { font-size: 13px; opacity: 0.8; }
.track-body { padding: 1.5rem; }
.track-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 1.5rem; }
.track-meta-item { background: var(--bg); border-radius: var(--radius); padding: 0.875rem 1rem; }
.track-meta-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.track-meta-val { font-size: 15px; font-weight: 600; }
.tl { display: flex; flex-direction: column; }
.tl-step { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.tl-step:last-child { padding-bottom: 0; }
.tl-line { position: absolute; left: 13px; top: 28px; width: 1px; height: calc(100% - 8px); background: var(--border); }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; font-size: 13px; }
.tl-dot.done { background: var(--success-bg); color: var(--success-t); }
.tl-dot.active { background: var(--accent-bg); color: var(--accent-t); }
.tl-dot.todo { background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.tl-info { padding-top: 4px; }
.tl-name { font-size: 14px; font-weight: 600; }
.tl-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-date { font-size: 11px; color: var(--muted); margin-top: 3px; }
.track-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); text-align: center; }

/* Projekty — drawer transakcji */
.pd-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.pd-sum-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.pd-sum-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.pd-sum-val   { font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }

.pd-tx-list { display: flex; flex-direction: column; }
.pd-tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.pd-tx-row:last-child { border-bottom: none; }
.pd-tx-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.pd-tx-icon.deposit { background: var(--success-bg); color: var(--success-t); }
.pd-tx-icon.expense { background: var(--danger-bg);  color: var(--danger-t);  }
.pd-tx-info  { flex: 1; min-width: 0; }
.pd-tx-desc  { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-tx-desc.editable { cursor: pointer; }
.pd-tx-desc.editable:hover { text-decoration: underline dotted; }
.pd-tx-edit {
  width: 100%; font-size: 13px; font-family: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 8px; box-sizing: border-box; background: var(--surface);
}
.pd-tx-edit:focus { outline: none; border-color: var(--accent); }
.pd-tx-date  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.pd-tx-amount { font-size: 13px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.pd-tx-amount.deposit { color: var(--success-t); }
.pd-tx-amount.expense { color: var(--danger-t);  }
.pd-empty { text-align: center; padding: 1.5rem 0; color: var(--muted); font-size: 13px; }
.pd-add-btns { display: flex; gap: 8px; }

/* Sekretarzyk */
.secretariat-list { display: flex; flex-direction: column; gap: 8px; }
.secretariat-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface);
}
.secretariat-item-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; background: var(--accent-bg); color: var(--accent-t);
}
.secretariat-item-info  { flex: 1; min-width: 0; }
.secretariat-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secretariat-item-meta  { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 3px; }
.secretariat-category   { background: var(--accent-bg); color: var(--accent-t); padding: 2px 8px; border-radius: 20px; font-weight: 500; }

/* czerwony stat (saldo ujemne) */
.stat-value.red { color: var(--danger-t); }

/* Login */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-logo {
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: 3px; color: var(--accent); }
.login-logo small { font-size: 12px; color: var(--muted); }
.login-error {
  background: var(--danger-bg);
  color: var(--danger-t);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* Pracownia — wyróżniony wiersz */
.overhead-row { background: #FFFDF5; }
.overhead-row:hover td { background: #FDF8E8 !important; }
.overhead-row .av { display: flex; align-items: center; justify-content: center; }

/* Wykres miesięczny */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin-top: 1.25rem;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.chart-title { font-size: 14px; font-weight: 600; }
.chart-nav { display: flex; align-items: center; gap: 10px; }
.chart-nav-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
}
.chart-nav-btn:hover { background: var(--border); }
.chart-nav span { font-size: 14px; font-weight: 600; min-width: 44px; text-align: center; }

.chart-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  border-bottom: 2px solid var(--border);
  padding: 0 2px;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.chart-bar-area {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  transition: opacity 0.15s;
  cursor: default;
}
.chart-bar:hover { opacity: 0.75; }
.chart-bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 100%;
}
.chart-bar-pair .chart-bar { flex: 1; }
.dep-bar { flex: 1; background: var(--success-t); opacity: 0.8; border-radius: 3px 3px 0 0; }
.bar-seg { width: 100%; flex-shrink: 0; }
.bar-seg.overhead { background: #B07A20; }
.bar-seg.project  { background: var(--danger-t); opacity: 0.8; }
.chart-lbl { font-size: 10px; color: var(--muted); margin-top: 6px; }

.chart-legend { display: flex; gap: 20px; margin-top: 0.75rem; font-size: 12px; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: middle; }
.legend-dot.proj-dot { background: var(--danger-t); opacity: 0.8; }
.legend-dot.ovhd-dot { background: #B07A20; }
.legend-dot.dep-dot  { background: var(--success-t); opacity: 0.8; }

/* Dolna nawigacja — ukryta na desktopie */
.mobile-bottomnav { display: none; }
.settings-logout { display: none; }

/* Responsive */
/* ── Zadania ─────────────────────────────────────────────── */

/* Kontenery sekcji drawera projektu (przestawiane per użytkownik) — gap jak w .drawer-body */
.drawer-section { display: flex; flex-direction: column; gap: 1.125rem; }

.todo-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); }
.todo-check { width: 15px; height: 15px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.todo-main { flex: 1; min-width: 0; }
.todo-content { font-size: 13px; line-height: 1.45; cursor: pointer; }
.todo-item.done .todo-content { text-decoration: line-through; color: var(--muted); cursor: default; }
.todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 5px; font-size: 11px; color: var(--muted); }
.todo-meta .ico-del { margin-left: auto; }
.todo-person { background: var(--accent-bg); color: var(--accent-t); }
.todo-due { display: inline-flex; align-items: center; gap: 4px; }
.todo-due-fallback { font-style: italic; }
.todo-overdue .todo-due { color: var(--danger-t); font-weight: 600; }
.todo-done-info { display: inline-flex; align-items: center; gap: 4px; color: var(--success-t); }
.todo-project { background: var(--accent-bg); color: var(--accent-t); padding: 2px 8px; border-radius: 20px; font-weight: 500; font-size: 11px; cursor: pointer; border: none; font-family: inherit; }
.todo-project:hover { filter: brightness(0.96); }
.todo-project-general { background: var(--border); color: var(--muted); cursor: default; }
.todo-project-general:hover { filter: none; }
.todo-done-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  background: none; border: none; border-top: 1px solid var(--border);
  padding: 10px 0 4px; margin-top: 4px; cursor: pointer; font-family: inherit;
}
.todo-done-toggle:hover { color: var(--text); }
.todo-badge-open    { background: var(--accent-bg); color: var(--accent-t); }
.todo-badge-overdue { background: var(--danger-bg); color: var(--danger-t); }

/* Zbiorcza strona Zadania — lista bez limitu wysokości drawera */
.todo-list-page { max-height: none; max-width: 760px; }

/* Licznik moich otwartych zadań przy pozycji nawigacji */
.nav-count { margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 1px 7px; }

/* Ustawienia: kolejność sekcji drawera */
.sec-order-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); margin-bottom: 6px; font-size: 13px; }
.sec-order-label { flex: 1; }
.sec-order-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 14px; line-height: 1; }
.sec-order-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-bg); }
.sec-order-btn:disabled { opacity: 0.3; cursor: default; }

@media (max-width: 768px) {
  /* Zapobiegaj poziomemu scrollowi strony — tabele scrollują wewnątrz .table-wrap */
  html, body { overflow-x: hidden; }

  /* Layout; min-width:0 na .main — grid item domyślnie ma min-width:auto i rozszerza się do treści */
  .app { grid-template-columns: 1fr; padding-bottom: 64px; }
  .main { min-width: 0; }
  .sidebar { display: none; }

  /* Dolna nawigacja */
  .mobile-bottomnav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--muted);
    font-family: inherit;
    cursor: pointer;
    padding: 8px 4px;
    transition: color 0.12s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-btn .ti { font-size: 22px; }
  /* 8 pozycji w wąskim pasku — długie etykiety (Sekretarzyk) przycinaj zamiast łamać na 2 linie */
  .mobile-nav-btn span { font-size: 10px; font-weight: 500; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .mobile-nav-btn.active { color: var(--accent); }

  /* Wyloguj w ustawieniach (widoczny na mobile) */
  .settings-logout { display: flex; width: 100%; }

  /* Topbar */
  .topbar { padding: 0.875rem 1rem; }
  .topbar-title { font-size: 15px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn-secondary { display: none; }
  .btn-label { display: none; }
  .topbar-actions .btn-primary { padding: 8px 12px; }

  /* Content */
  .content { padding: 1rem; gap: 1rem; }

  /* Stats */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 18px; }

  /* Filtry */
  .filters { gap: 6px; }
  .search-wrap { margin-left: 0; width: 100%; }
  .search-wrap input { width: 100%; }

  /* Tabele — poziomy scroll; min-width:0 żeby flex-item nie rozszerzał rodzica */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; min-width: 0; }
  table { min-width: 640px; }
  th, td { padding: 9px 12px; }

  /* Formularze — pola pełna szerokość */
  .row2 { grid-template-columns: 1fr; }

  /* Drawer — fullscreen na mobile */
  .overlay {
    padding: 0;
    align-items: flex-end;
  }
  .drawer {
    border-radius: 0;
    max-width: 100% !important;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }
  .drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Ukryj bottom nav gdy drawer otwarty */
  body.drawer-open .mobile-bottomnav { display: none; }
  body.drawer-open .app { padding-bottom: 0; }
  .drawer-head { padding: 1rem 1.25rem; }
  .drawer-body { padding: 1.25rem; gap: 1rem; }
  .drawer-foot { padding: 0.875rem 1.25rem; }

  /* Wiersze materiałów w drawerze */
  .mat-header { grid-template-columns: 16px minmax(0,1fr) 58px 72px 28px; font-size: 10px; }
  .mat-row    { grid-template-columns: 16px minmax(0,1fr) 58px 72px 28px; }
  /* Krótsza lista podpowiedzi (klawiatura zjada pół ekranu) + większe pola dotyku */
  .mat-ac      { max-height: 216px; }
  .mat-ac-item { padding: 10px; }

  /* Wykres */
  .chart-wrap { padding: 1rem; margin-top: 0; }
  .chart-area { height: 100px; }
  .chart-bar-area { height: 100px; }
  .chart-lbl { font-size: 9px; }
  .chart-legend { flex-wrap: wrap; gap: 8px; font-size: 11px; }

  /* Toast nad nav barem */
  .toast { bottom: 72px; right: 1rem; left: 1rem; text-align: center; }

  /* Zadania: gap sekcji jak mobilny gap .drawer-body, licznik jako kropka nad ikoną */
  .drawer-section { gap: 1rem; }
  .mobile-nav-btn { position: relative; }
  .mobile-nav-btn .nav-count { position: absolute; top: 3px; right: calc(50% - 21px); margin-left: 0; }
}

/* ── Dark mode ────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121110;
    --surface:   #1C1A16;
    --border:    #2C2922;
    --text:      #EDE9E1;
    --muted:     #88847E;
    --accent:    #5A9A68;
    --accent-bg: #162419;
    --accent-t:  #8FCA9A;
    --warn-bg:   #251D0E;
    --warn-t:    #D4A050;
    --danger-bg: #251010;
    --danger-t:  #D97070;
    --success-bg:#102414;
    --success-t: #70C07E;
    --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  }

  /* Row hover */
  tbody tr:hover td { background: #222018; }

  /* Stat values */
  .stat-value.amber { color: #D4A050; }
  .stat-value.blue  { color: #6A9AD8; }

  /* Readonly input */
  .field input[readonly] { background: #181614; color: var(--muted); }
  .client-readonly-box   { background: #181614; }

  /* Pracownia row */
  .overhead-row          { background: #1A1808; }
  .overhead-row:hover td { background: #22200A !important; }

  /* Danger button */
  .btn-danger       { border-color: #5A2020; }
  .btn-danger:hover { background: #321414; }

  /* Active chip border */
  .chip.active { border-color: #2C4E34; }

  /* Avatar colors */
  .av-a { background: #0E1A2E; color: #7AA4D8; }
  .av-d { background: #2A1020; color: #D890B0; }
  .av-e { background: #1A1830; color: #9890E8; }

  /* Total box border */
  .total-box { border-color: #2C4E34; }

  /* Drawer shadow */
  .drawer { box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
  .mat-ac { box-shadow: 0 12px 32px rgba(0,0,0,0.55); }

  /* Chart bars */
  .bar-seg.overhead { background: #D4A050; }

  /* Search input */
  .search-wrap input { background: var(--surface); }

  /* Status select */
  .status-sel { background: var(--surface); }
}

/* Cenniki */
.pl-sources-wrap { margin-bottom: 1.25rem; }
.pl-sources-head { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

.pl-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.pl-badge-neutral { background: var(--accent-bg); color: var(--accent-t); }
.pl-badge-ok      { background: var(--success-bg); color: var(--success-t); }
.pl-badge-error   { background: var(--danger-bg); color: var(--danger-t); cursor: help; }
.pl-badge-muted   { background: var(--warn-bg); color: var(--muted); }

.pl-delta-up   { color: var(--danger-t); font-weight: 600; font-size: 12px; white-space: nowrap; }
.pl-delta-down { color: var(--success-t); font-weight: 600; font-size: 12px; white-space: nowrap; }
.pl-delta-flat { color: var(--muted); font-size: 12px; white-space: nowrap; }

.src-active-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.src-active-toggle input { width: auto; }

.pl-history-row { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.pl-history-row:last-child { border-bottom: none; }
.pl-history-date { color: var(--muted); font-size: 12px; }

/* Materiały */
.src-mattype-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 2px 0 6px; }
.src-mattype-checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.src-mattype-checks input { width: auto; }

.mc-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--surface-2, var(--surface)); display: block; }
.mc-thumb-empty { width: 36px; height: 36px; border-radius: 6px; background: var(--surface-2, var(--surface)); border: 1px solid var(--border); }

.mcd-picture-wrap { text-align: center; margin-bottom: 1rem; }
.mcd-picture-wrap img { max-width: 100%; max-height: 260px; border-radius: 10px; object-fit: contain; }
.mcd-attrs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; font-size: 13px; }
.mcd-attrs .mcd-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.mcd-attrs .mcd-full { grid-column: 1 / -1; }
