:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --text: #202124;
  --text-muted: #5f6368;
  --border: #dadce0;
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --accent: #34a853;
  --warn: #d93025;
  --amber: #f9ab00;
  --shadow: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-lg: 0 2px 6px 2px rgba(60,64,67,.15), 0 1px 2px 0 rgba(60,64,67,.3);
  --radius: 16px;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #202124;
  --surface: #292a2d;
  --surface-2: #35363a;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --border: #3c4043;
  --primary: #8ab4f8;
  --primary-dark: #aecbfa;
  --accent: #81c995;
  --warn: #f28b82;
  --amber: #fdd663;
  --shadow: 0 1px 2px 0 rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
  --shadow-lg: 0 2px 6px 2px rgba(0,0,0,.4), 0 1px 2px 0 rgba(0,0,0,.5);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #202124;
    --surface: #292a2d;
    --surface-2: #35363a;
    --text: #e8eaed;
    --text-muted: #9aa0a6;
    --border: #3c4043;
    --primary: #8ab4f8;
    --primary-dark: #aecbfa;
    --accent: #81c995;
    --warn: #f28b82;
    --amber: #fdd663;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 20px; font-weight: 500; letter-spacing: .1px; }
.brand-accent { color: var(--primary); }
.topbar-nav { display: flex; gap: 4px; flex: 1; }
.topbar-nav a {
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.topbar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

.icon-btn {
  border: none; background: transparent; color: var(--text-muted);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; font-size: 14px; }
.icon-btn:active { transform: scale(.9); }

.text-btn {
  border: none; background: transparent; color: var(--primary);
  font-weight: 500; font-size: 14px; cursor: pointer; padding: 6px 10px; border-radius: 6px;
  transition: background-color .15s ease;
}
.text-btn:hover { background: var(--surface-2); }
.text-btn-warn { color: var(--warn); }

.inline-form { display: inline-block; margin: 0; }

/* Page layout */
.page { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
.page.with-nav { padding-top: 28px; }

.auth-body { background: linear-gradient(160deg, var(--bg), var(--surface-2)); }
.page:not(.with-nav) {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow .2s ease, background-color .25s ease, border-color .25s ease;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card h2 { margin: 0 0 12px; font-size: 18px; font-weight: 500; }

.grid { display: grid; gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }

/* Auth card */
.auth-card { width: 360px; text-align: center; }
.auth-logo { font-size: 26px; font-weight: 500; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

/* Forms - inputy i selecty w spojnym Material stylu, wszedzie (nie tylko w .field) */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
  cursor: pointer;
}
select::-ms-expand { display: none; }
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="date"]:focus, input[type="search"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.18);
}
input[readonly] { background: var(--surface-2); cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--text-muted); }
.field input, .field select { width: 100%; }
.field-check { justify-content: center; }
.field-grow { flex: 1; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; align-items: end; }
.form-grid .btn { grid-column: 1 / -1; justify-self: start; }

.btn {
  font: inherit; font-weight: 500; font-size: 14px;
  padding: 10px 22px; border-radius: 20px; border: none; cursor: pointer;
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { box-shadow: var(--shadow); }
.btn-block { width: 100%; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; }
.flash-success { background: rgba(52,168,83,.15); color: var(--accent); }
.flash-error { background: rgba(217,48,37,.15); color: var(--warn); }

/* Dashboard */
.week-card h2 { margin-bottom: 20px; }
.duty-pair { display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 20px; }
.duty-person { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px;
}
.avatar-primary { background: var(--primary); }
.avatar-backup { background: var(--amber); color: #202124; }
.duty-role { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.duty-name { font-size: 16px; font-weight: 500; }

.today-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 10px; padding: 12px 16px; font-size: 14px;
}
.today-banner-swapped { background: rgba(249,171,0,.15); }
.today-banner-alert { background: rgba(217,48,37,.15); color: var(--warn); font-weight: 500; margin-bottom: 12px; }

/* Widok tygodniowy dyzuru */
.week-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px;
}
.day-card { margin-bottom: 0; }
.day-card-holiday { background: var(--surface-2); }
.day-card-today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,.25); }
.day-card-header { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.day-card-title { font-weight: 500; font-size: 14px; }
.day-card-who { font-size: 12px; }
.day-badge {
  display: inline-block; background: var(--primary); color: #fff; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle;
}
.checkbox-readonly { cursor: default; opacity: .7; }
.checkbox-readonly .checkbox-box { cursor: default; }

.checklist-header { display: flex; align-items: center; justify-content: space-between; }
.progress-label { color: var(--text-muted); font-size: 13px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--surface-2); margin: 12px 0 18px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s cubic-bezier(.4,0,.2,1); }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.check-item { border-radius: 10px; transition: background-color .15s ease; }
.check-item:hover { background: var(--surface-2); }

.checkbox { display: flex; align-items: center; gap: 12px; padding: 10px 8px; cursor: pointer; user-select: none; }
.checkbox-solo { padding: 2px; display: inline-flex; }
.checkbox input { display: none; }
.checkbox-box {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: background-color .2s ease, border-color .2s ease, transform .15s ease;
}
.checkbox-tick {
  width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 24; stroke-dashoffset: 24;
  transition: stroke-dashoffset .25s ease .05s;
}
.checkbox input:checked + .checkbox-box {
  background: var(--accent); border-color: var(--accent);
  animation: pop .25s ease;
}
.checkbox input:checked + .checkbox-box .checkbox-tick { stroke-dashoffset: 0; }
.checkbox-text { font-size: 14px; transition: color .2s ease, opacity .2s ease; }
.checkbox input:checked ~ .checkbox-text { color: var(--text-muted); text-decoration: line-through; opacity: .75; }

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr { transition: background-color .15s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.row-actions { display: flex; gap: 4px; white-space: nowrap; }

/* Admin task list */
.task-admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-admin-row {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border-radius: 10px; background: var(--surface-2);
  transition: opacity .2s ease;
}
.task-admin-row-top { display: flex; align-items: center; gap: 12px; }
.task-inactive { opacity: .5; }
.task-move { display: flex; flex-direction: column; gap: 2px; }
.task-title { flex: 1; font-size: 14px; }
.task-schedule-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-left: 44px; }

.status-ok { color: var(--accent); font-weight: 500; }
.status-bad { color: var(--warn); font-weight: 500; }

/* Weekday chip picker (harmonogram obowiazkow) */
.weekday-picker { display: flex; gap: 4px; }
.day-chip input { display: none; }
.day-chip span {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted);
  font-size: 12px; font-weight: 500; cursor: pointer; user-select: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.day-chip span:hover { border-color: var(--primary); }
.day-chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; animation: pop .2s ease; }
.day-chip span:active { transform: scale(.92); }

/* Calendar */
.calendar { max-width: 320px; user-select: none; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 14px; font-weight: 500; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  border: none; background: transparent; color: var(--text);
  aspect-ratio: 1; border-radius: 50%; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day:active { transform: scale(.9); }
.cal-day-blank { cursor: default; }
.cal-day-blank:hover { background: transparent; }
.cal-day-disabled { cursor: not-allowed; opacity: .3; }
.cal-day-disabled:hover { background: transparent; }
.cal-day-in-range { background: rgba(26,115,232,.15); border-radius: 0; }
.cal-day-start, .cal-day-end {
  background: var(--primary); color: #fff; font-weight: 600;
  animation: pop .2s ease;
}
.calendar-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.range-label { font-size: 13px; color: var(--text-muted); }
.absence-form { display: flex; flex-direction: column; gap: 4px; }

/* Animations */
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Truncate long text (np. user-agent) w wąskich komorkach tabeli */
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Nawigacja mobilna (burger + off-canvas drawer) */
.nav-burger { display: none; }
.nav-mobile-only { display: none; }
.nav-scrim { display: none; }

@media (max-width: 880px) {
  .topbar { gap: 12px; padding: 10px 14px; }
  .nav-burger { display: flex; flex: none; }
  .nav-mobile-only { display: block; }
  .nav-desktop-only { display: none; }

  .topbar-nav {
    position: fixed;
    top: 0; left: 0;
    height: 100vh; width: min(280px, 80vw);
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 76px 14px 16px;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 30;
    overflow-y: auto;
  }
  body.nav-open .topbar-nav { transform: translateX(0); }

  .nav-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
    z-index: 25;
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

  .topbar-nav a { padding: 13px 14px; border-radius: 10px; }
  .page { padding: 16px 14px 48px; }
  .card { padding: 18px; }
  .duty-pair { gap: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}
