:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --navy: #0f172a;
  --crimson: #b91c1c;
  --crimson-hover: #991b1b;
  --blue: #1d4ed8;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red-bg: #fee2e2;
  --cyan-bg: #ecfeff;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: var(--crimson);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.subtitle {
  font-size: 13px;
  color: #cbd5e1;
}

.tabs {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  border-bottom-color: var(--crimson);
}

.container {
  max-width: 1120px;
  margin: 18px auto 48px;
  padding: 0 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-sm {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn-primary { background: var(--crimson); color: #fff; }
.btn-primary:hover { background: var(--crimson-hover); }
.btn-secondary { background: #e2e8f0; color: var(--navy); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-outline:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { background: #e2e8f0; }
.btn-success { background: var(--green); color: #fff; }
.btn-warn { background: #d97706; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-icon {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.pending-banner {
  background: var(--amber-bg);
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.pending-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(180, 83, 9, 0.2);
  flex-wrap: wrap;
}
.pending-item:first-of-type { border-top: none; }

.week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.week-nav-center { display: flex; align-items: center; gap: 10px; }
.week-range { font-weight: 700; font-size: 15px; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

@media (max-width: 900px) {
  .week-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.day-tile {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.day-tile:hover { border-color: #64748b; }
.day-tile.selected { border-color: var(--crimson); box-shadow: 0 2px 8px rgba(185, 28, 28, 0.16); }
.day-tile.today { background: #f8fafc; }

.day-tile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
}
.day-tile-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.day-tile-hours { font-size: 11px; color: var(--muted); margin-top: 6px; }
.day-tile-count {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
}

.mode-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.mode-strict { background: var(--red-bg); color: #991b1b; }
.mode-flexible { background: #dbeafe; color: #1e40af; }

.day-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.day-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.day-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.day-title-row h2 { margin: 0; font-size: 20px; }

.availability-line {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.day-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.day-alerts { margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }

.slot-card {
  border: 1px solid var(--border);
  border-left: 5px solid var(--navy);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}
.slot-card.pending { border-left-color: #d97706; background: #fffbeb; }
.slot-card.extra-guests { border-left-color: #dc2626; }
.slot-card.mine { box-shadow: inset 0 0 0 1px #93c5fd; }

.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.slot-time {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}
.slot-flex {
  font-size: 13px;
  color: var(--blue);
  font-weight: 600;
}

.slot-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.badge-fmt { background: #e2e8f0; color: var(--navy); }
.badge-cast { background: #e2e8f0; color: var(--navy); }
.badge-cast-warn { background: var(--red-bg); color: #991b1b; }
.badge-ryszard { background: var(--cyan-bg); color: #0e7490; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-pending { background: var(--amber-bg); color: #92400e; }
.badge-op { background: #ede9fe; color: #5b21b6; }

.slot-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.slot-chain-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.slot-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.alert-inline {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 8px;
}
.alert-inline.warn { background: var(--amber-bg); color: #92400e; border: 1px solid #f59e0b; }
.alert-inline.error { background: var(--red-bg); color: #991b1b; border: 1px solid #ef4444; }
.alert-inline.info { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.ignacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

label.checkbox-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  background: #fff;
}

.field-group { margin-top: 12px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 12px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.chip.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.preview-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.suggestions-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 660px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { background: #f8fafc; font-weight: 700; }

.ics-box {
  margin-top: 16px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ics-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  z-index: 100;
  font-size: 14px;
  font-weight: 600;
}

.hint { font-size: 13px; color: var(--muted); }
.empty-day {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
