:root {
  --bg-deep:     #2c2a6e;
  --bg:          #3f3d8c;
  --bg-light:    #4f4d9c;
  --sidebar:     #2a2870;
  --accent:      #b04386;
  --accent-soft: #8e3a6f;
  --text:        #ffffff;
  --text-muted:  #cfcde3;
  --error:       #ff6b8e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-deep), var(--bg)) fixed;
  color: var(--text);
  display: flex;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar);
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.05rem; margin-bottom: 2rem;
}
.brand svg { width: 56px; height: 56px; }
.sidebar nav { display: flex; flex-direction: column; gap: .5rem; }
.sidebar nav a {
  color: var(--text); text-decoration: none;
  padding: .7rem 1rem; border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover { background: var(--bg-light); }
.sidebar nav a.active { background: var(--accent); }
.sidebar .user {
  margin-top: auto; padding-top: 1rem; border-top: 1px solid #ffffff22;
  font-size: .85rem; color: var(--text-muted);
}
.sidebar .user form button {
  margin-top: .5rem; background: transparent; color: var(--text-muted);
  border: 1px solid #ffffff44; padding: .35rem .8rem; border-radius: 6px; cursor: pointer;
}

/* ── Main content ────────────────────────────────────── */
main { flex: 1; padding: 2.5rem 3rem; }
.page-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.5rem; }

/* ── Dashboard fence buttons ─────────────────────────── */
.fence-buttons { display: flex; gap: 1rem; flex-wrap: wrap; }
.fence-btn {
  background: var(--accent); color: white; border: none;
  font-size: 1.05rem; font-weight: 700; letter-spacing: .03em;
  padding: 1.5rem 2rem; border-radius: 14px; cursor: pointer;
  min-width: 200px; box-shadow: 0 4px 14px #00000022;
  transition: transform .08s ease, background .15s ease;
}
.fence-btn:hover:not(:disabled) { background: var(--accent-soft); }
.fence-btn:active:not(:disabled) { transform: translateY(2px); }
.fence-btn:disabled { opacity: .45; cursor: not-allowed; }
.status { margin-top: 1.5rem; color: var(--text-muted); font-size: .95rem; }
.status.success { color: #80f1a8; }
.status.error   { color: var(--error); }
.spinner { color: var(--text-muted); margin-top: .5rem; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }

/* ── Tables ──────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #ffffff0d; border: 1px solid #ffffff22; border-radius: 10px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: .85rem 1rem; text-align: left;
}
.data-table thead { background: #ffffff14; }
.data-table tbody tr { border-top: 1px solid #ffffff14; }
.data-table tbody tr:hover { background: #ffffff10; }
.data-table a, .data-table button {
  background: none; border: none; color: var(--text); cursor: pointer;
  font-size: 1.05rem; padding: 0 .35rem;
}
.btn-add {
  display: inline-block; background: var(--accent); color: white;
  padding: .55rem 1rem; border-radius: 8px; text-decoration: none;
  margin-bottom: 1rem; font-weight: 600;
}

/* ── Forms ───────────────────────────────────────────── */
.form { max-width: 520px; display: flex; flex-direction: column; gap: 1rem; }
.form.inline-form { flex-direction: row; align-items: center; gap: .75rem; max-width: none; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--text-muted); }
.form label.inline { flex-direction: row; align-items: center; gap: .4rem; margin-right: 1rem; }
.form input, .form select {
  padding: .55rem .75rem; border-radius: 6px; border: 1px solid #ffffff33;
  background: #ffffff10; color: var(--text); font: inherit;
}
.form input:focus, .form select:focus { outline: 2px solid var(--accent); }
.form fieldset { border: 1px solid #ffffff22; border-radius: 8px; padding: .75rem 1rem; }
.form fieldset legend { padding: 0 .4rem; color: var(--text-muted); }
.form .row { display: flex; gap: 1rem; }
.form .actions { display: flex; gap: 1rem; align-items: center; margin-top: .5rem; }
.form .actions a { color: var(--text-muted); text-decoration: none; }
.form .actions button.primary {
  background: var(--accent); color: white; border: none;
  padding: .6rem 1.4rem; border-radius: 8px; font-weight: 600; cursor: pointer;
}

/* ── Login ───────────────────────────────────────────── */
.login-page {
  align-items: center; justify-content: center; min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(circle at 15% 20%, #ffffff15 0, transparent 40%),
    radial-gradient(circle at 85% 80%, var(--accent) 0, transparent 45%),
    linear-gradient(135deg, var(--bg-deep), var(--bg));
  background-attachment: fixed;
}
.login-shell {
  display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; max-width: 900px;
  background: #ffffff0d; backdrop-filter: blur(20px);
  border: 1px solid #ffffff22; border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 80px #00000066;
  animation: rise .5s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.login-hero {
  padding: 3rem 2.5rem;
  background: linear-gradient(160deg, var(--accent), var(--accent-soft) 70%, #5b2353);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1rem;
  text-align: center;
}
.login-hero svg { width: 110px; height: 110px; opacity: .95; filter: drop-shadow(0 4px 12px #00000033); }
.login-hero h1 { margin: 0; font-size: 1.6rem; letter-spacing: .04em; }
.login-hero p { margin: 0; color: #ffffffcc; font-size: .92rem; line-height: 1.5; }

.login-card {
  padding: 3rem 2.5rem; display: flex; flex-direction: column; gap: 1rem;
  background: transparent; border: none; border-radius: 0;
}
.login-card h2 { margin: 0; font-size: 1.4rem; }
.login-card .sub { margin: 0 0 .5rem; color: var(--text-muted); font-size: .9rem; }
.login-card label span {
  display: block; margin-bottom: .35rem; font-size: .82rem;
  color: var(--text-muted); letter-spacing: .03em;
}
.login-card input {
  width: 100%; padding: .75rem .9rem; border-radius: 10px;
  border: 1px solid #ffffff33; background: #ffffff15; color: var(--text); font: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.login-card input:focus {
  outline: none; border-color: var(--accent); background: #ffffff22;
}
.login-card button {
  margin-top: .5rem;
  background: var(--accent); color: white; border: none;
  padding: .85rem; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: background .15s ease, transform .08s ease;
}
.login-card button:hover { background: var(--accent-soft); }
.login-card button:active { transform: translateY(1px); }
.login-card .footnote { margin: 1rem 0 0; text-align: center; color: var(--text-muted); font-size: .75rem; }

@media (max-width: 720px) {
  .login-shell { grid-template-columns: 1fr; max-width: 420px; }
  .login-hero { padding: 2rem; }
  .login-card { padding: 2rem; }
}
.error {
  background: #ff6b8e22; border: 1px solid var(--error); color: var(--error);
  padding: .55rem .75rem; border-radius: 6px; font-size: .9rem;
}

/* ── Cards + key/value for settings ──────────────────── */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.card {
  background: #ffffff0d; border: 1px solid #ffffff22; border-radius: 12px;
  padding: 1.25rem 1.5rem;
}
.card h3 { margin: 0 0 .75rem; font-size: 1rem; color: var(--text); }
.card p { margin: .25rem 0; }
.card .muted { color: var(--text-muted); font-size: .85rem; }
.card .form { gap: .5rem; }
.card button.primary, .card button.ghost {
  background: var(--accent); color: white; border: none;
  padding: .55rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.card button.ghost { background: transparent; color: var(--text); border: 1px solid #ffffff44; }
.card button.ghost:hover { background: #ffffff15; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; }
.dot.ok  { background: #80f1a8; box-shadow: 0 0 8px #80f1a888; }
.dot.bad { background: var(--error); box-shadow: 0 0 8px #ff6b8e88; }
.status-row { font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; font-size: .9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-all; }
.kv code { background: #00000033; padding: 2px 6px; border-radius: 4px; font-size: .85em; }
.good { color: #80f1a8; }
.warn { color: #ffcc66; }
.muted { color: var(--text-muted); }

/* ── Temp-access public page (rustig, mobile-first) ──── */
.temp-card {
  width: 100%; max-width: 420px;
  background: #ffffff0d; backdrop-filter: blur(12px);
  border: 1px solid #ffffff22; border-radius: 18px;
  padding: 2rem 1.75rem 1.5rem;
  color: var(--text); text-align: center;
  box-shadow: 0 20px 60px #00000055;
}
.temp-logo { width: 48px; height: 56px; margin: 0 auto .5rem; display: block; opacity: .9; }
.temp-card h1 {
  margin: .25rem 0; font-size: 1.35rem; font-weight: 600;
}
.temp-sub {
  color: var(--text-muted); font-size: .9rem; margin: 0 0 1.5rem;
}
.temp-card .fence-buttons {
  flex-direction: column; gap: .65rem; align-items: stretch;
}
.temp-card .fence-btn {
  min-width: 0; width: 100%; padding: 1.1rem;
  font-size: 1rem;
}
.temp-card .status { min-height: 1.2em; margin-top: 1rem; }
.temp-route {
  display: inline-block; margin-top: 1.25rem;
  color: var(--text-muted); font-size: .85rem;
  text-decoration: none; border-bottom: 1px dashed #ffffff55;
}
.temp-route:hover { color: var(--text); border-bottom-color: var(--text); }

/* ── Temp-access link cell ───────────────────────────── */
.link-cell { display: flex; align-items: center; gap: .5rem; }
.link-url {
  background: #00000033; color: var(--text-muted);
  padding: .25rem .5rem; border-radius: 4px; font-size: .8em;
  max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-copy {
  background: var(--accent); color: white; border: none;
  padding: .35rem .7rem; border-radius: 6px; font-weight: 600;
  font-size: .8rem; cursor: pointer;
  transition: background .15s ease;
}
.link-copy:hover { background: var(--accent-soft); }
.link-copy.ok { background: #2c7d4f; }
