:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2e3b;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --primary: #4f8cff;
  --danger: #ff5c5c;
  --ok: #3ecf8e;
  --warn: #ffb84d;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--text);
  background:
    radial-gradient(1100px 600px at 50% -15%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(900px 520px at 50% 115%, rgba(62, 207, 142, 0.12), transparent 60%),
    #0b0d12;
  background-attachment: fixed;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0.4rem 0 0; }
.ok-text { color: var(--ok); min-height: 1.2em; margin: 0.2rem 0 0; }

.centered { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.9rem; padding: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.25rem; }
#login-view .card {
  width: 400px; max-width: calc(100vw - 2rem); margin: 0;
  display: flex; flex-direction: column; gap: 0.85rem;
  padding: 2rem 2rem 1.6rem; border-radius: 18px;
  background: linear-gradient(180deg, #1b1f2b, #161922);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
#login-view .card > p { margin: 0; }
#login-view .card label { margin-bottom: 0; }       /* spacing comes from the card gap */
#login-view .card h1 + p { margin-top: -0.35rem; }  /* tighten subtitle under the title */
#authz-banner { font-size: 0.98rem; }
.row-links { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.3rem; }
.grid2-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.6rem; }
.captcha { min-height: 0; margin: 0.15rem 0; }
.captcha:empty { display: none; }

h1 { font-size: 1.55rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { margin: 0 0 1rem; }
h3 { margin: 0 0 0.75rem; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; font-weight: 500; color: var(--muted); margin-bottom: 0.85rem; }
input { background: #0e1016; border: 1px solid var(--border); border-radius: 10px; padding: 0.72rem 0.8rem; color: var(--text); font-size: 0.95rem; width: 100%; transition: border-color 0.15s, box-shadow 0.15s; }
input::placeholder { color: #5b6370; }
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22); }

button { background: linear-gradient(135deg, #4f8cff, #3ecf8e); color: #fff; border: none; border-radius: 10px; padding: 0.72rem 1rem; font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: filter 0.15s, transform 0.05s, box-shadow 0.15s; }
button:hover { filter: brightness(1.06); box-shadow: 0 8px 22px rgba(79, 140, 255, 0.22); }
button:active { transform: translateY(1px); }
button.secondary { background: #232838; border: 1px solid var(--border); color: var(--text); box-shadow: none; }
button.secondary:hover { background: #2c3242; filter: none; box-shadow: none; }
button.danger { background: var(--danger); }
button.danger:hover { box-shadow: 0 8px 22px rgba(255, 92, 92, 0.22); }
button.link { background: none; border: none; color: var(--primary); padding: 0; font-size: 0.85rem; font-weight: 500; align-self: flex-start; cursor: pointer; box-shadow: none; }
button.link:hover { filter: none; box-shadow: none; text-decoration: underline; }
button.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }

/* Button loading state — spinner overlay, text hidden, keeps width */
button[data-loading="1"] { color: transparent !important; pointer-events: none; position: relative; }
button[data-loading="1"]::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* App shell */
.app-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: #14161e; border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1.2rem 0.8rem; height: 100vh; position: sticky; top: 0; }
.brand { font-weight: 700; font-size: 1.2rem; padding: 0 0.6rem 1rem; display: flex; align-items: center; gap: 0.5rem; }
.brand-logo { width: 24px; height: 24px; object-fit: contain; }
.card-logo {
  width: 58px; height: 58px; object-fit: contain; align-self: center;
  margin: 0 auto 0.5rem; padding: 9px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.16), rgba(62, 207, 142, 0.16));
  border: 1px solid var(--border);
}
#nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item { background: none; border: none; color: var(--muted); text-align: left; padding: 0.6rem 0.7rem; border-radius: 8px; font-size: 0.95rem; }
.nav-item:hover { background: #1d2130; color: var(--text); filter: none; }
.nav-item.active { background: #232a3d; color: var(--text); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
.who-row { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.4rem; }

.content { padding: 2rem 2.5rem; max-width: 820px; }
.page { animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.9rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }

/* Avatars */
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #2a2e3b; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: #2a2e3b; }
.avatar-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 500; }
.badge { padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; }
.badge.on { background: rgba(62,207,142,0.15); color: var(--ok); }
.badge.off { background: rgba(255,92,92,0.15); color: var(--danger); }
.badge.cur { background: rgba(79,140,255,0.18); color: var(--primary); }

.danger-zone { border-color: rgba(255,92,92,0.3); }
.danger-zone .row-between { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.danger-zone .row-between:last-child { border-bottom: none; }

/* Dialog + toast */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; min-width: 360px; max-width: 460px; }
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog[open] { display: flex; flex-direction: column; gap: 0.6rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
#confirm-message { line-height: 1.5; }

#toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(2rem); background: var(--ok); color: #06281b; padding: 0.6rem 1.1rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }

@media (max-width: 680px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; height: auto; position: static; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 1.2rem; }
}
