:root {
  --bg: #000;
  --card: #09090a;
  --line: #1f1f23;
  --line-2: #2b2c2f;
  --btn: #1a1b1d;
  --btn-hover: #222326;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --green: #22c55e;
  --red: #ef4444;
  --accent: #8b5cf6;
}

* { box-sizing: border-box; margin: 0; }

html, body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  border-top: 1px solid #161618;
}

[hidden] { display: none !important; }

/* ---------- Ekran logowania ---------- */
.center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 31px 24px 24px;
  animation: fade-up .7s cubic-bezier(.16, 1, .3, 1) both;
}

.logo-wrap {
  height: 92px;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo { height: 100%; width: auto; display: block; }

.lead {
  color: var(--muted);
  font-size: 14px;
  line-height: 17px;
  margin-bottom: 33px;
}
.lead strong { color: var(--text); font-weight: 600; }

.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 47px;
  padding: 0 29px;
  border-radius: 999px;
  background: var(--btn);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background .2s, transform .2s, border-color .2s;
}
.btn-discord:hover { background: var(--btn-hover); border-color: #3a3b3f; transform: translateY(-1px); }
.btn-discord:active { transform: translateY(0); }

/* ---------- Boot (bez migotania przed sprawdzeniem sesji) ---------- */
body.boot #login,
body.boot #app { opacity: 0; }
#login, #app { transition: opacity .35s ease; }

/* ---------- Panel ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.brand img { height: 30px; width: auto; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.user img { width: 30px; height: 30px; border-radius: 50%; background: var(--btn); }
.user span { color: var(--text); font-weight: 500; }

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  max-width: 1040px;
  margin: 8px auto 48px;
  padding: 0 24px;
  align-items: start;
  animation: fade-up .6s cubic-bezier(.16, 1, .3, 1) both;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.card h2 { font-size: 16px; font-weight: 600; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.card > .muted { margin: 4px 0 18px; }

form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; }
label span { font-size: 12px; color: var(--muted); font-weight: 500; }

input, select, textarea {
  width: 100%;
  background: #0f0f11;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 120px; }
input::placeholder, textarea::placeholder { color: #5b5b63; }
input:focus, select:focus, textarea:focus {
  border-color: #52525b;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .05);
}

.btn-primary, .btn-ghost {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  transition: background .2s, transform .2s, opacity .2s;
}
.btn-primary {
  height: 44px;
  border: 1px solid var(--line-2);
  background: var(--btn);
  color: var(--text);
}
.btn-primary:hover { background: var(--btn-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost {
  height: 32px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); background: var(--btn); }

/* ---------- Lista zgłoszeń ---------- */
.tickets { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 36px 0; }

.ticket {
  border: 1px solid var(--line);
  background: #0c0c0e;
  border-radius: 12px;
  padding: 14px 16px;
  animation: fade-up .45s cubic-bezier(.16, 1, .3, 1) both;
}
.ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ticket-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid;
}
.chip.open { color: var(--green); border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .08); }
.chip.closed { color: var(--muted); border-color: var(--line-2); background: transparent; }
.ticket-desc { color: var(--muted); margin: 8px 0 10px; white-space: pre-wrap; word-break: break-word; }
.ticket-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #71717a; font-size: 12px; }
.ticket-meta .btn-ghost { height: 26px; padding: 0 11px; font-size: 12px; }

/* ---------- Powiadomienia ---------- */
#toasts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  position: relative;
  overflow: hidden;
  width: 350px;
  max-width: calc(100vw - 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px 18px;
  background: #0e0e10;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  pointer-events: auto;
  animation: toast-in .55s cubic-bezier(.16, 1, .3, 1) both;
}
.toast.success { --tone: var(--green); }
.toast.error { --tone: var(--red); }
.toast.leaving { animation: toast-out .45s cubic-bezier(.7, 0, .84, 0) both; }

.toast-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, transparent);
}
.toast-title { font-weight: 600; font-size: 14px; }
.toast-text { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* pasek na dole — odlicza 5 sekund */
.toast-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--tone);
  transform-origin: left center;
  animation: toast-bar linear forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateX(48px) scale(.95); }
}
@keyframes toast-bar {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  #toasts { top: 12px; right: 12px; }
  .user span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .toast-bar { animation-duration: 5s !important; }
}
