:root {
  --ink: #1C1F24;
  --bg: #F3F2EE;
  --card: #FFFFFF;
  --line: #E2E0D9;
  --line-soft: #ECEBE6;
  --muted: #5B5F66;
  --teal: #0E5F5B;
  --teal-dark: #093F3C;
  --teal-soft: #E3EFEE;
  --red: #9B1C12;
  --red-bg: #FDE7E4;
  --orange: #8A3B06;
  --orange-bg: #FDEBD8;
  --green: #0B5A44;
  --green-bg: #DDF1EA;
  --gray: #3F4349;
  --gray-bg: #E7E6E1;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- Przyciski i pola ---------- */
.btn { min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid #C9C7BF; background: #fff; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #FAFAF8; color: var(--ink); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #E8B4AE; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-link { background: none; border: none; padding: 0; color: var(--teal); font-weight: 600; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.field input, .field select, .field textarea, .search {
  width: 100%; padding: 9px 12px; border: 1px solid #BDBBB3; border-radius: 8px; background: #fff; outline: none;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,95,91,.18); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.quick button:hover { border-color: var(--teal); color: var(--teal); }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.radio-row input { width: auto; margin: 0; accent-color: var(--teal); }
.error { color: var(--red); font-size: 14px; min-height: 18px; margin-bottom: 8px; }

/* ---------- Logowanie ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 14px; padding: 36px 32px; border: 1px solid var(--line); }
.auth-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--teal); color: #fff; font-weight: 700; font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth h1 { text-align: center; font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.btn-block { width: 100%; justify-content: center; min-height: 46px; font-size: 16px; }

/* ---------- Układ ---------- */
.topbar { background: var(--ink); color: var(--bg); padding: 0 24px; }
.topbar-in { max-width: 1360px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; min-height: 64px; padding: 10px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--bg); text-decoration: none; letter-spacing: -0.01em; }
.brand:hover { color: #fff; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { color: #D9D8D2; text-decoration: none; padding: 8px 14px; border-radius: 6px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: var(--bg); color: var(--ink); font-weight: 600; }
.me-btn { background: none; border: 1px solid rgba(255,255,255,.2); color: #D9D8D2; border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.me-btn:hover { background: rgba(255,255,255,.08); }
.main { max-width: 1360px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { margin: 4px 0 0; font-size: 28px; letter-spacing: -0.02em; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel h2 { margin: 0; font-size: 18px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- Pulpit ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
button.kpi:hover { border-color: var(--teal); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.kpi.red .value { color: var(--red); }
.kpi.orange .value { color: var(--orange); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Tabele ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; padding: 8px; white-space: nowrap; }
table.t td { padding: 11px 8px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
table.t th:first-child, table.t td:first-child { padding-left: 0; }
table.t th:last-child, table.t td:last-child { padding-right: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #FAFAF8; }
table.t tr.inactive td { color: var(--muted); }
.who { font-weight: 600; }
.who small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.right { text-align: right; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.gray { background: var(--gray-bg); color: var(--gray); }

/* ---------- Karta pracownika ---------- */
.emp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.ini { border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.ini.s34 { width: 34px; height: 34px; font-size: 13px; }
.ini.s72 { width: 72px; height: 72px; font-size: 26px; }
.emp-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.emp-head .sub { margin-top: 4px; font-size: 14px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px 24px; flex: 1 1 380px; }
.facts .k { font-size: 12px; color: var(--muted); }
.facts .v { font-weight: 700; font-size: 16px; margin-top: 2px; }
.back { font-size: 14px; font-weight: 600; text-decoration: none; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.rec { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.rec .name { flex: 1 1 220px; min-width: 0; }
.rec .name b { font-weight: 600; font-size: 14px; }
.rec .name small { display: block; font-size: 12px; color: var(--muted); }
.rec.old { opacity: .6; }
.rec .acts { display: flex; gap: 12px; }
.kind-h { margin: 18px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.kind-h:first-of-type { margin-top: 4px; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.hist li { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.hist li small { display: block; color: var(--muted); font-size: 12px; }
.notes { white-space: pre-wrap; font-size: 14px; }

/* ---------- Okna ---------- */
.overlay { position: fixed; inset: 0; background: rgba(28,31,36,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 14px; padding: 24px; }
.modal h3 { margin: 0 0 16px; font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 16px; }
  .main { padding: 20px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .page-head h1, .emp-head h1 { font-size: 24px; }
}
