:root {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: #17202a;
  background: #f3f5f7;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
.container { max-width: 1250px; margin: 0 auto; padding: 24px; }
h1, h2 { margin: 0 0 8px; }
h2 { font-size: 1.15rem; }
.card { background: #fff; border: 1px solid #dfe4e8; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.login-card { max-width: 420px; margin: 10vh auto; padding: 28px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid #aeb7c0; border-radius: 8px; padding: 10px 12px; font: inherit; background: #fff; }
textarea { min-height: 95px; resize: vertical; }
button { border: 0; border-radius: 8px; padding: 10px 16px; background: #164e7a; color: #fff; font-weight: 700; cursor: pointer; }
button:hover { filter: brightness(.95); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary { background: #e7edf2; color: #1f2d3a; }
form { display: grid; gap: 15px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.muted { color: #66727e; margin: 0; }
.error { color: #a71919; min-height: 1.2em; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { background: #dfe6ec; color: #243746; }
.tab.active { background: #164e7a; color: #fff; }
.toolbar { display: flex; align-items: end; gap: 12px; padding: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar label { min-width: 170px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(150px, 220px)); gap: 12px; margin-bottom: 14px; }
.stat { padding: 18px; display: flex; flex-direction: column; }
.stat strong { font-size: 2rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e1e5e8; text-align: left; vertical-align: middle; }
th { background: #eef2f5; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: .8rem; font-weight: 800; }
.badge.present { background: #d9f2df; color: #17602a; }
.badge.absent { background: #eceff2; color: #465563; }
.badge.in { background: #dceefe; color: #0f4f7d; }
.badge.out { background: #f5e5d8; color: #783e15; }
.badge.offline { background: #fff0c7; color: #745309; }
.employee-form { grid-template-columns: repeat(4, 1fr) auto; align-items: end; padding: 16px; margin-bottom: 14px; }
.employee-form h2 { grid-column: 1 / -1; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { max-width: 130px; }
.message { padding: 12px 15px; margin-bottom: 14px; border-radius: 8px; background: #e6f2fb; border: 1px solid #a8cde7; }
.message.error { background: #fde8e8; border-color: #efb0b0; color: #841d1d; }
dialog { border: 0; border-radius: 12px; padding: 24px; width: min(500px, 92vw); box-shadow: 0 18px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.small-button { padding: 7px 10px; font-size: .82rem; }
@media (max-width: 850px) {
  .container { padding: 12px; }
  .employee-form { grid-template-columns: 1fr 1fr; }
  .employee-form h2 { grid-column: 1 / -1; }
  .topbar { align-items: flex-start; }
}
@media (max-width: 520px) {
  .employee-form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* Grupowanie i filtrowanie według działów */
.department-row td {
  padding: 10px 14px;
  background: #dfeaf3;
  color: #173f5f;
  border-top: 2px solid #b8cad8;
  border-bottom: 1px solid #c7d6e2;
  font-weight: 800;
}
.department-row td span { margin-right: 10px; }
.department-row td small { color: #587083; font-weight: 600; }
.empty-row td { padding: 28px 14px; text-align: center; color: #66727e; }
.department-editor input { min-width: 170px; max-width: 230px; }
@media (max-width: 850px) {
  .department-editor { align-items: stretch; flex-direction: column; }
  .department-editor input { min-width: 150px; max-width: none; }
}

/* Wersja 1.3 – segregowanie obecnych i raporty okresowe */
.stats { grid-template-columns: repeat(3, minmax(150px, 220px)); }
.presence-status-row td {
  padding: 8px 24px;
  font-weight: 800;
  border-bottom: 1px solid #dce3e8;
}
.presence-status-row td span { margin-right: 10px; }
.presence-status-row td small { font-weight: 600; }
.presence-status-row.present-group td { background: #edf8f0; color: #17602a; }
.presence-status-row.absent-group td { background: #f4f5f6; color: #465563; }
.report-card {
  margin-top: 14px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  flex-wrap: wrap;
}
.report-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.report-controls label { min-width: 165px; }
@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr; }
  .report-card { align-items: stretch; }
  .report-controls { flex-direction: column; align-items: stretch; width: 100%; }
  .report-controls label { min-width: 0; }
}

/* Wersja 1.4 – zakresy dostępu administratorów */
.scope-info {
  display: inline-block;
  margin: 5px 0 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: #e8f0f7;
  color: #244e6e;
  font-weight: 700;
  font-size: .9rem;
}
.account-form {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 1.2fr auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  padding: 18px;
}
.account-form h2 { grid-column: 1 / -1; margin: 0; }
.checkbox-label {
  min-height: 43px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.checkbox-label input { width: auto; }
button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 1000px) {
  .account-form { grid-template-columns: 1fr 1fr; }
  .account-form h2 { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .account-form { grid-template-columns: 1fr; }
}

.departments-field {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  min-width: 280px;
}
.departments-field legend { font-weight: 700; padding: 0 6px; }
.department-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 14px;
  margin: 6px 0;
}
.department-checkboxes label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.department-checkboxes input { width: auto; margin: 0; }
.account-scope-editor { min-width: 330px; }
.account-scope-editor .department-checkboxes { grid-template-columns: 1fr 1fr; }
.scope-badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* Wersja 1.6 – adresy e-mail i raporty kierowników */
.account-email-editor {
  min-width: 250px;
  display: grid;
  gap: 8px;
}
.checkbox-label.compact {
  min-height: auto;
  font-size: .9rem;
  font-weight: 600;
}
.account-email-editor .inline { flex-wrap: wrap; }


/* Wersja 1.7 – uwagi kierowników do zdarzeń */
.manager-note-cell { min-width: 220px; white-space: pre-wrap; }
.event-actions { display: flex; gap: 7px; flex-wrap: wrap; min-width: 170px; }
#noteDialog textarea { min-height: 140px; }
#noteEventLabel { margin-bottom: 14px; }


/* Wersja 1.8 – ręczne dodawanie zdarzeń */
.manual-event-form { display:grid; grid-template-columns:minmax(220px,1.4fr) minmax(150px,.7fr) minmax(210px,1fr) minmax(260px,1.5fr) auto; gap:14px; align-items:end; margin-bottom:16px; }
.manual-event-form .form-heading { grid-column:1 / -1; }
.manual-event-form .form-heading h2 { margin:0 0 4px; }
.manual-event-form .form-heading p { margin:0; }
.manual-event-form textarea { min-height:76px; resize:vertical; }
.badge.manual { background:#fff1cc; color:#6b4b00; }
@media (max-width:1100px) { .manual-event-form { grid-template-columns:1fr 1fr; } .manual-event-form button { width:100%; } }
@media (max-width:680px) { .manual-event-form { grid-template-columns:1fr; } }
.badge.auto { background:#e8ddff; color:#4c2b82; }
.badge.card { background:#e1f5f0; color:#00644f; }


/* Wersja 2.4 – publiczny panel obecności dla pracowników */
.public-presence-page { background:#f3f5f7; }
.public-container { max-width:1100px; margin:0 auto; padding:24px; }
.public-header { display:flex; justify-content:space-between; align-items:center; gap:18px; padding:22px; margin-bottom:16px; }
.public-header h1 { margin:0 0 6px; }
.public-header-right { text-align:right; display:grid; gap:6px; }
.public-stats { margin-bottom:16px; }
.public-filters { display:flex; align-items:end; gap:12px; padding:14px; margin-bottom:16px; flex-wrap:wrap; }
.public-filters label { min-width:190px; }
.public-presence-table { min-width:650px; }
.public-presence-table td:first-child { font-size:1.02rem; }
.public-note { margin:14px 4px 0; }
@media (max-width:700px) {
  .public-container { padding:12px; }
  .public-header { align-items:flex-start; flex-direction:column; }
  .public-header-right { text-align:left; }
  .public-filters { align-items:stretch; flex-direction:column; }
  .public-filters label { min-width:0; }
}
