html, body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100vw;
  overflow-x: hidden;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === RAMKA GŁÓWNA DASHBOARD/QR === */
#dashboardSection {
  display: none;
  background-color: #0d0d0d;
  border: 2px solid #b87333;
  border-radius: 16px;
  box-shadow: 0 6px 24px #00000024;
  text-align: center;
  padding: 22px 0;
  width: 80vw;
  margin-left: 10vw;
  margin-right: 10vw;
  margin-top: 56px;
  margin-bottom: 18px;
  min-width: 240px;
  max-width: 600px;
  box-sizing: border-box;
}
@media (max-width: 480px) {
  #dashboardSection {
    width: 98vw;
    margin-left: 1vw;
    margin-right: 1vw;
    border-radius: 10px;
    padding: 13px 0 15px 0;
    min-width: 0;
    max-width: 100vw;
    box-sizing: border-box;
  }
}

/* --- HISTORIA KREDYTÓW (TABELA) --- */
.table-wrapper {
  overflow-x: auto;
  margin-top: 9px;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}
.table-wrapper table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  table-layout: auto;
  margin: 0;
}
thead {
  background-color: #262626;
}
th, td {
  padding: 6px 3px;
  border: 1px solid #555;
  text-align: center;
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
}
th {
  color: #b87333;
}
@media (max-width: 600px) {
  .table-wrapper {
    padding-left: 8px;
    padding-right: 8px;
  }
  .table-wrapper table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }
  th, td {
    padding: 4px 1px;
    font-size: 14px;
  }
}

/* === LOGO + TEKST POWITALNY === */
.logo-container,
.logo-container-dashboard {
  text-align: center;
  width: 100%;
  margin-bottom: 15px;
}
.logo {
  max-width: 120px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.logo-dashboard {
  max-width: 160px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* === GRID MENU (KAFELKI) === */
#menuGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 16px;
  margin-left: 10%;
  margin-right: 10%;
}
@media (max-width: 480px) {
  #menuGrid {
    margin-left: 2vw;
    margin-right: 2vw;
  }
}

/* === PRZYCISK WYLOGUJ, IKONA KOMUNIKATORA === */
.user-actions {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
  margin-bottom: 4px;
  padding: 0 10%;
  box-sizing: border-box;
}
#logoutBtn, #messengerIconWrapper {
  flex: 1;
  max-width: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === QR sekcja === */
#qrSection.module-section {
  background-color: #0d0d0d;
  border: 2px solid #b87333;
  border-radius: 16px;
  text-align: left;
  padding: 22px 0;
  width: 60%;
  margin-left: 20%;
  margin-right: 20%;
  margin-bottom: 18px;
  box-sizing: border-box;
  position: relative;
}
@media (max-width: 480px) {
  #qrSection.module-section {
    width: auto;
    margin-left: 20px;
    margin-right: 20px;
    border-radius: 10px;
    padding: 12px 0 14px 0;
  }
}

.qr-header-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
  gap: 10px;
  position: relative;
}
.qr-header-row .back-btn {
  margin-left: 10%;
  min-width: 94px;
  font-size: 1.07rem;
}
.qr-title, .qr-header-row h2 {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 1.22rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.timer {
  font-size: 17px;
  color: #b87333;
  margin-bottom: 8px;
}
.qr-form-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  margin-bottom: 17px;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}
.qr-form-row select,
.qr-form-row button {
  height: 46px;
  line-height: 46px;
  padding: 0 20px;
  font-size: 1.09em;
  box-sizing: border-box;
  border-radius: 8px;
}
.qr-form-row select {
  flex: 2;
  max-width: 60%;
  border: 1px solid #555;
  background: #262626;
  color: #ecf0f1;
}
.qr-form-row button {
  flex: 1;
  max-width: 36%;
  background: #b87333;
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qrContainer {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 22px 0 18px 0;
}
#qrContainer canvas {
  display: block;
  width: 70vw !important;
  height: 70vw !important;
  max-width: 320px !important;
  min-width: 100px !important;
  min-height: 100px !important;
  aspect-ratio: 1/1 !important;
  margin: 0 auto;
  border-radius: 9px;
  box-shadow: 0 2px 14px #0004;
}
@media (min-width: 481px) {
  #qrContainer canvas {
    width: 210px !important;
    height: 210px !important;
    min-width: 100px !important;
    min-height: 100px !important;
  }
}

body {
  font-family: Arial, sans-serif;
  background-color: #1c1c1c;
  color: #ecf0f1;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#authSection {
  background-color: #0d0d0d;
  padding: 20px 14px;
  border: 2px solid #b87333;
  border-radius: 10px;
  width: 60vw;
  margin-left: 30vw;
  margin-right: 30vw;
  margin-top: 54px;
  text-align: center;
  box-shadow: 0 6px 24px #00000024;
  min-width: 220px;
  max-width: 410px;
}
@media (max-width: 480px) {
  #authSection {
    width: 96vw;
    margin-left: 3vw;
    margin-right: 3vw;
    border-radius: 0;
    padding: 14px 2vw 16px 2vw;
    min-width: 0;
    max-width: 100vw;
    box-sizing: border-box;
  }
}

.subtitle {
  margin-top: 2px;
  margin-bottom: 15px;
  color: #ecf0f1;
  font-size: 1.03rem;
  font-weight: 400;
  letter-spacing: 0.6px;
  opacity: 0.82;
}

#memberName {
  font-size: 1.13rem;
  color: #b87333;
  margin-bottom: 10px;
  font-weight: 500;
}
form {
  display: flex;
  flex-direction: column;
  margin-bottom: 13px;
}
input, select {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #555;
  background-color: #262626;
  color: #ecf0f1;
  font-size: 1rem;
}
button {
  padding: 9px;
  border: none;
  background-color: #b87333;
  color: #ecf0f1;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 5px;
  font-size: 1rem;
  font-weight: 600;
}
a {
  color: #b87333;
  text-decoration: none;
  font-size: 14px;
}
.menu-card {
  background-color: #262626;
  border: 2px solid #b87333;
  border-radius: 7px;
  padding: 13px 8px;
  cursor: pointer;
  transition: background 0.18s;
  min-height: 46px;
  position: relative;
  display: flex;
  align-items: center;
  font-size: 1.08rem;
  justify-content: center;
  font-weight: 500;
}
.menu-card:hover {
  background-color: #333;
}
.hidden {
  display: none !important;
}
.message {
  margin-top: 8px;
  color: #e74c3c;
}
.message.success {
  color: #2ecc71;
}

/* --- KOMUNIKATOR: chmurki --- */
#messengerList {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  margin-top: 8px;
  margin-bottom: 10px;
  list-style: none;
  max-height: 55vh;
  overflow-y: auto;
}
.bubble {
  display: inline-block;
  max-width: 75%;
  padding: 11px 16px;
  border-radius: 18px;
  margin: 3px 0;
  font-size: 1em;
  line-height: 1.4;
  box-shadow: 0 1px 5px rgba(0,0,0,0.10);
  word-break: break-word;
  position: relative;
}
.bubble.sent {
  background: #2087e2;   /* niebieski: member */
  color: #fff;
  align-self: flex-end;
  margin-left: auto;
  margin-right: 0;
  text-align: right;
}
.bubble.received {
  background: #b87333;   /* miedziany: admin */
  color: #fff;
  align-self: flex-start;
  margin-right: auto;
  margin-left: 0;
  text-align: left;
}
.bubble-date {
  font-size: 0.86em;
  color: #bbb;
  margin-top: 3px;
  opacity: 0.8;
  text-align: right;
}
@media (max-width: 600px) {
  #messengerList {
    padding-left: 8px;
    padding-right: 8px;
    box-sizing: border-box;
  }
}

/* --- Messenger Ikona na belce --- */
#messengerIcon {
  display: inline-block;
  position: relative;
  margin-left: 14px;
  vertical-align: middle;
}
#messengerIcon img {
  height: 32px !important;
  width: auto !important;
  display: block;
  aspect-ratio: auto;
}
#messengerBadge {
  position: absolute;
  right: -7px;
  top: -7px;
  background: #ff2b2b;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  border-radius: 15px;
  padding: 0 7px;
  display: none;
  z-index: 10;
  box-shadow: 0 0 0 2px #0d0d0d;
}

/* --- REZERWACJA: odstęp i wyśrodkowanie --- */
#bookingForm label[for="bookingDate"] {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
}
#bookingDate {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 16px; /* Odstęp pod inputem daty */
  min-width: 180px;
  max-width: 260px;
  width: 100%;
}
#bookingSlot {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 14px;
  min-width: 180px;
  max-width: 260px;
  width: 100%;
}
#bookingForm label[for="bookingSlot"] {
  display: block;
  margin-bottom: 16px;
  font-weight: 500;
}
#bookingSlot {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 14px;
  min-width: 180px;
  max-width: 260px;
  width: 100%;
  text-align: center;
  text-align-last: center;
}
#bookingDate,
#bookingSlot {
  text-align: center;
  text-align-last: center;
}
#profileSection h2,
#balanceSection h2 {
  margin-bottom: 18px;
}
#qrInsufficientMsg {
  margin-top: 12px;
  color: #e74c3c;
  min-height: 22px;
  text-align: center;
  font-size: 1em;
  line-height: 1.3;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  word-break: break-word;
}
:root { --safe-bottom: env(safe-area-inset-bottom, 0px); }
.version-footer { bottom: calc(var(--safe-bottom) + 10px) !important; }
.update-toast   { bottom: calc(var(--safe-bottom) + 18px) !important; }
