:root {
  --brand: #6f7a80;
  --brand-dark: #4a5357;
  --accent: #2f7d6d;
  --accent-soft: #e3f1ed;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --border: #e1e6e8;
  --text: #1f2a2e;
  --muted: #6b777c;
  --ok: #2f9e62;
  --ok-soft: #dff3e8;
  --warn: #d48a0c;
  --warn-soft: #fdf1d8;
  --crit: #d64545;
  --crit-soft: #fbe2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 35, .06), 0 4px 14px rgba(20, 30, 35, .05);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); overflow-x: hidden; }
body { font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { display: block; width: 168px; margin: 2px 8px 6px; }
.sidebar .logo-sub { margin: 0 8px 18px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-item .count { margin-left: auto; background: var(--crit); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .me { border-top: 1px solid var(--border); padding-top: 12px; display: flex; gap: 10px; align-items: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 26px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { flex: 1; }
.content { padding: 22px 26px 60px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Components ---------- */
.card { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { flex: 1; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--crit); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ok { color: #fff; background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: 50%; width: 38px; height: 38px; cursor: pointer; font-size: 17px; }
.icon-btn .dot { position: absolute; top: -3px; right: -3px; background: var(--crit); color: #fff; font-size: 10px; border-radius: 9px; padding: 1px 5px; font-weight: 700; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.pending { background: var(--warn-soft); color: #9a6200; }
.badge.approved { background: var(--ok-soft); color: #1f7a4a; }
.badge.rejected { background: var(--crit-soft); color: #a83232; }
.badge.cancelled { background: #eceff0; color: var(--muted); }
.badge.registered { background: #e8eef9; color: #2c5aa8; }
.badge.type { color: #fff; }
.badge.st-ok { background: var(--ok-soft); color: #1f7a4a; }
.badge.st-risk { background: var(--warn-soft); color: #9a6200; }
.badge.st-late { background: var(--crit-soft); color: #a83232; }
.badge.st-done { background: #e8eef9; color: #2c5aa8; }
.badge.st-hold { background: #eceff0; color: var(--muted); }
.badge.cat { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11.5px; font-weight: 700; flex: none; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.alert.info { background: #eaf2f9; color: #24527d; }
.alert.warn { background: var(--warn-soft); color: #7f5200; }
.alert.crit { background: var(--crit-soft); color: #8c2626; }
.alert.ok { background: var(--ok-soft); color: #1d6b42; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 8px 14px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .val { font-size: 26px; font-weight: 700; }
.kpi .lbl { font-size: 12px; color: var(--muted); }

.progress { height: 8px; background: #e9eef0; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 6px; }
.progress.risk > div { background: var(--warn); }
.progress.late > div { background: var(--crit); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }

/* ---------- Absence calendar (timeline) ---------- */
.cal-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cal-toolbar .month { font-size: 17px; font-weight: 700; min-width: 170px; text-align: center; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.striped { background-image: repeating-linear-gradient(45deg, #b8c2c6 0 3px, transparent 3px 6px); border: 1px solid #b8c2c6; }

.timeline-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.timeline { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
table.timeline th, table.timeline td { border-bottom: 1px solid #edf0f1; border-right: 1px solid #f1f3f4; padding: 0; height: 30px; text-align: center; font-size: 11px; }
table.timeline th.name, table.timeline td.name {
  position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 0 10px; min-width: 210px; max-width: 210px;
  border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px;
}
table.timeline thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); font-weight: 600; color: var(--muted); height: 40px; }
table.timeline thead th.name { z-index: 4; }
table.timeline th.day { min-width: 30px; width: 30px; line-height: 1.1; }
table.timeline th.day b { display: block; color: var(--text); font-size: 12px; }
table.timeline .we { background: #f3f5f6; }
table.timeline .hol { background: #fbeeee; }
table.timeline .today { box-shadow: inset 0 0 0 2px var(--accent); }
table.timeline tr.dept-row td { background: var(--surface-2); height: 28px; font-weight: 600; }
table.timeline tr.dept-row td.name { background: var(--surface-2); font-size: 12.5px; }
table.timeline tr.dept-row td.name .dept-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
table.timeline td.cap { font-size: 10.5px; font-weight: 700; cursor: default; }
table.timeline td.cap.ok { color: #1f7a4a; background: var(--ok-soft); }
table.timeline td.cap.warn { color: #8d5b00; background: var(--warn-soft); }
table.timeline td.cap.crit { color: #fff; background: var(--crit); }
table.timeline tr.note-row td { height: 22px; background: #fff; }
table.timeline tr.note-row td.name { font-size: 11.5px; color: var(--muted); font-weight: 500; padding-left: 26px; }
table.timeline td.note { cursor: pointer; font-size: 12px; }
table.timeline td.note.przestoj { background: #eceff0; }
table.timeline td.note.dotrudnienie { background: #e3f1ed; }
table.timeline td.note.info { background: #eaf2f9; }
table.timeline td.cell { cursor: pointer; }
table.timeline td.cell:hover { outline: 2px solid var(--accent-soft); outline-offset: -2px; }
table.timeline td.abs { color: #fff; font-weight: 700; font-size: 10px; }
table.timeline td.abs.pend { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 3px, transparent 3px 7px); }
table.timeline td.abs.wk { opacity: .45; }
table.timeline tr.me td.name { font-weight: 700; color: var(--accent); }
.emp-role { color: var(--muted); font-size: 11px; margin-left: 4px; }

/* Staffing bars */
.staff-grid { display: grid; grid-template-columns: 170px repeat(10, 1fr); gap: 3px; align-items: center; font-size: 11.5px; }
.staff-grid .hd { color: var(--muted); text-align: center; font-weight: 600; font-size: 11px; line-height: 1.1; }
.staff-grid .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { text-align: center; border-radius: 5px; padding: 4px 0; font-weight: 700; }
.chip.ok { background: var(--ok-soft); color: #1f7a4a; }
.chip.warn { background: var(--warn-soft); color: #8d5b00; }
.chip.crit { background: var(--crit); color: #fff; }

/* ---------- Projects ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.proj { cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; border-top: 4px solid var(--brand); }
.proj:hover { border-color: var(--accent); }
.proj.cat-produkcja { border-top-color: #c2410c; }
.proj.cat-handel { border-top-color: #2563eb; }
.proj.cat-rd { border-top-color: #7c3aed; }
.proj .meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.task { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task input { width: 16px; height: 16px; accent-color: var(--accent); }
.task .t { flex: 1; }
.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .body { flex: 1; }
.feed-item .when { font-size: 11.5px; color: var(--muted); }

/* ---------- Announcements ---------- */
.news { border-left: 4px solid var(--brand); }
.news.pinned { border-left-color: var(--accent); }
.news.unread { background: #fbfdfc; }
.news .body { white-space: pre-wrap; margin: 8px 0; }

/* ---------- Modal, toasts, notifications ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 35, .42); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 50px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1f2a2e; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; font-size: 13px; animation: slide .25s ease-out; }
.toast.err { background: var(--crit); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.notif-panel { position: absolute; right: 26px; top: 60px; width: 380px; max-height: 480px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 50; }
.notif-panel .n { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.notif-panel .n.unread { background: var(--accent-soft); }
.notif-panel .n .when { font-size: 11px; color: var(--muted); }

/* ---------- Wersja testowa ---------- */
.demo-banner { background: #fdf1d8; color: #7f5200; text-align: center; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-bottom: 1px solid #f0d9a8; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: linear-gradient(160deg, #eef2f3, #e2ebe8); }
.login-box { background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.1); padding: 30px; width: 100%; max-width: 860px; }
.login-box .logo { width: 230px; display: block; margin-bottom: 8px; }
.login-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 14px; }
.login-user { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); text-align: left; }
.login-user:hover { border-color: var(--accent); background: var(--accent-soft); }
.login-group { margin-top: 16px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .card-head { flex-wrap: wrap; }
  .modal-bg { padding: 12px 8px; }
  .topbar h1 { flex-basis: 100%; font-size: 19px; }
  .stack[style*="width:300px"] { width: 100% !important; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .sidebar .logo, .sidebar .logo-sub, .sidebar .spacer, .sidebar .me { display: none; }
  .nav-item { width: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .staff-grid { grid-template-columns: 110px repeat(10, 44px); width: max-content; }
  .notif-panel { right: 8px; left: 8px; width: auto; }
}
