*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg: #f4f4f8;
  --clr-surface: #ffffff;
  --clr-primary: #1a73e8;
  --clr-primary-dark: #1558b0;
  --clr-danger: #d93025;
  --clr-text: #202124;
  --clr-muted: #5f6368;
  --clr-border: #dadce0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
}

html, body {
  height: 100%;
  background: var(--clr-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--clr-text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------- sync banner ---------- */
#sync-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--clr-primary);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
}
#sync-banner.visible { display: block; }

/* ---------- offline banner (pod sync-bannerem gdy oba widoczne) ---------- */
#offline-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #d97706;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 99;
}
#offline-banner.visible { display: block; }

/* ---------- reauth banner (sesja wygasła, biometria była aktywna) ---------- */
#reauth-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #b91c1c;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 98;
}
#reauth-banner.visible { display: block; }

/* ---------- main content ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  padding-top: 60px;   /* zapas na bannery */
  padding-bottom: 220px; /* zapas na debug panel */
}

.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
}

h1 { font-size: 22px; margin-bottom: 20px; text-align: center; }
h2 { font-size: 18px; margin-bottom: 16px; }

/* ---------- tickets view header ---------- */
.tickets-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.tickets-header h2 { flex: 1; margin-bottom: 0; }
.btn-settings {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--clr-muted);
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s;
}
.btn-settings:hover { background: var(--clr-border); }

/* ---------- form ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--clr-muted); margin-bottom: 6px; }

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 12px;
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--clr-primary); }

/* ---------- buttons ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-dark); }
.btn-danger  { background: var(--clr-danger);  color: #fff; margin-top: 12px; }
.btn-buy     { background: #188038; color: #fff; margin-bottom: 16px; }

/* ---------- tickets list ---------- */
#tickets-list {
  list-style: none;
  margin-top: 16px;
}
#tickets-list li {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  align-items: center;
  gap: 12px;
}
#tickets-list li strong { font-size: 15px; }

.ticket-tap {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(26,115,232,.15);
}
.ticket-tap:active { opacity: .75; }

.btn-return {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--clr-danger);
  border-radius: 8px;
  background: transparent;
  color: var(--clr-danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-return:hover  { background: var(--clr-danger); color: #fff; }
.btn-return:active { opacity: .8; }
.btn-return:disabled { opacity: .4; cursor: default; }

.empty-state {
  text-align: center;
  color: var(--clr-muted);
  font-size: 14px;
  margin-top: 12px;
}

.user-info {
  font-size: 13px;
  color: var(--clr-muted);
  text-align: center;
  margin-bottom: 8px;
}

/* ---------- KC session status bar ---------- */
.kc-status {
  font-size: 12px;
  color: var(--clr-muted);
  text-align: center;
  margin-bottom: 16px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #f1f3f4;
  transition: background .2s, color .2s;
}
.kc-status.ok   { background: #e6f4ea; color: #1e8e3e; }
.kc-status.warn { background: #fce8e6; color: #c5221f; }

/* ---------- ticket number ---------- */
.ticket-number {
  font-size: 11px;
  color: var(--clr-muted);
  font-family: monospace;
  letter-spacing: .04em;
}

/* ---------- btn-back (powrót z QR) ---------- */
.btn-back {
  align-self: flex-start;
  padding: 8px 16px;
  border: 1.5px solid var(--clr-border);
  border-radius: 8px;
  background: transparent;
  color: var(--clr-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-back:hover  { background: var(--clr-bg); }
.btn-back:active { opacity: .8; }

/* ---------- QR view ---------- */
#qr-container {
  width: 100%;
  display: flex;
  justify-content: center;
}
#qr-img {
  width: 100%;
  max-width: 260px;
  border-radius: 8px;
  border: 1px solid var(--clr-border);
  background: #fff;
}

/* ---------- debug panel ---------- */
#debug-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  z-index: 200;
  border-top: 2px solid #444;
}
#debug-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #2d2d2d;
  border-bottom: 1px solid #444;
}
.debug-title { flex: 1; font-weight: bold; font-size: 12px; color: #ccc; }
.debug-btn {
  background: #3a3a3a;
  color: #ccc;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 11px;
}
.debug-btn:hover { background: #555; }
#debug-log {
  height: 160px;
  overflow-y: auto;
  padding: 4px 8px;
}
.dbg {
  padding: 2px 0;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dbg-out { color: #9cdcfe; }  /* web → native */
.dbg-in  { color: #4ec9b0; }  /* native → web */
.dbg-ts  { color: #6a9955; margin-right: 6px; }
