:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --surface: #131a2a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #243049;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-soft: #1e2347;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --ok: #34d399;
    --ok-soft: #0f2e25;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.inline { display: inline; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.25rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 1.1rem;
}
.brand-center { justify-content: center; width: 100%; margin-bottom: 1.5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* Topbar + home */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.topnav { display: flex; gap: .5rem; align-items: center; }
.hero { padding: 96px 0 72px; background: radial-gradient(1200px 400px at 50% -10%, var(--primary-soft), transparent); }
.hero-inner { text-align: center; max-width: 760px; }
.eyebrow { display: inline-block; font-weight: 600; font-size: .85rem; color: var(--primary); background: var(--primary-soft); padding: .25rem .75rem; border-radius: 999px; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.02em; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 1rem auto 2rem; max-width: 600px; }
.hero-actions { display: flex; justify-content: center; gap: .75rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; padding-bottom: 80px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.feature p { color: var(--muted); margin: 0; }
.feature-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); margin-bottom: 1rem; }
.footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: .9rem; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.5rem; }
.back-link { display: block; text-align: center; margin-top: 1.25rem; font-size: .9rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.card.form { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .92rem; }
.field small { font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
input:disabled, select:disabled { opacity: .6; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: .5rem; }
.narrow { max-width: 560px; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* Panel shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.25rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.sidenav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sidenav a { color: var(--text); padding: .55rem .75rem; border-radius: 8px; font-weight: 500; }
.sidenav a:hover { background: var(--primary-soft); text-decoration: none; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); }
.sidenav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .75rem .75rem .25rem; }
.sidebar-foot { display: flex; flex-direction: column; gap: .75rem; }
.who { display: flex; flex-direction: column; font-size: .9rem; }
.who span { color: var(--muted); font-size: .82rem; }
.content { padding: 2rem; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* Cards */
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-value.small { font-size: 1.05rem; word-break: break-all; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.table td { padding: .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th.right { text-align: right; }
.actions { white-space: nowrap; }
.search { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.search input { max-width: 360px; }

/* Badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-admin { background: var(--primary-soft); color: var(--primary); }
.badge-user { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidenav { flex-direction: row; flex-wrap: wrap; }
  .sidenav-label { display: none; }
  .content { padding: 1.25rem 16px; }
  .hero { padding: 64px 0 48px; }
}

/* Logowanie przez Google */
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { gap: .6rem; }
