:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1f23;
  --muted: #5d6570;
  --border: #e4e1da;
  --accent: #0f7b5f;
  --accent-soft: #e3f3ed;
  --warn: #b25e09;
  --warn-soft: #fbeedd;
  --danger: #b3261e;
  --danger-soft: #fbe4e2;
  --neutral-soft: #eeece7;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1b1f23;
    --text: #e7e9ec;
    --muted: #9aa3ad;
    --border: #2c3238;
    --accent: #3ec59a;
    --accent-soft: #173229;
    --warn: #f0a44b;
    --warn-soft: #36291a;
    --danger: #f2837a;
    --danger-soft: #3a1f1d;
    --neutral-soft: #262b30;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--accent); }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 32px; padding-bottom: 64px; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 20px; }

/* Górny pasek */
.topbar { border-bottom: 1px solid var(--border); }
.topbar .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  gap: 12px;
}
.logo { font-family: var(--mono); font-weight: 700; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.who { color: var(--muted); font-size: 14px; }
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

/* Przyciski */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--accent);
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--bg); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

/* Lista terminów */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg); }
.name { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.kind { display: block; font-family: var(--sans); font-size: 13px; color: var(--muted); }

.pill {
  font-family: var(--mono);
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.unknown { background: var(--neutral-soft); color: var(--muted); }

.empty {
  padding: 32px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.empty p { margin: 0 0 8px; }
.empty .btn { margin-top: 12px; }

/* Formularze */
.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }
.form { display: grid; gap: 18px; max-width: 480px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.field small { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); }
.actions { display: flex; align-items: center; gap: 16px; }
.danger-link { color: var(--danger); font-size: 14px; }

.login { max-width: 400px; margin: 40px auto 0; }

/* Automatyczne sprawdzanie */
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }

.message {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 15px;
}
.message.success { background: var(--accent-soft); color: var(--accent); }
.message.error { background: var(--danger-soft); color: var(--danger); }

.check-error { color: var(--danger); }
.checked { color: var(--muted); }

.check-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 480px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.check-box form { margin: 0; }
