:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2330; --border: #30363d;
  --text: #e6edf3; --muted: #8b949e; --accent: #2f81f7; --accent2: #1f6feb;
  --green: #3fb950; --amber: #d29922; --red: #f85149; --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }

header { display: flex; align-items: center; gap: 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.hostline { color: var(--muted); font-size: 12px; font-family: var(--mono); flex: 1; }

main { padding: 22px; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); max-width: 1100px; margin: 0 auto; }
.loading { color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.card h2 { margin: 0; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel2); }
.card-head .sub { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.card-body { padding: 16px; display: grid; gap: 14px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.small { font-size: 13px; font-family: var(--mono); font-weight: 500; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); display: inline-flex; gap: 6px; align-items: center; }
.badge.ok { color: var(--green); border-color: #2ea04366; }
.badge.bad { color: var(--red); border-color: #f8514966; }
.badge.warn { color: var(--amber); border-color: #d2992266; }
.badge .led { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; } .row.end { justify-content: flex-end; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sched { display: flex; align-items: center; gap: 8px; }
.sched label { color: var(--muted); font-size: 12px; }

select, input[type=password], input[type=text] { background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 13px; }
select:focus, input:focus { outline: none; border-color: var(--accent); }

.btn { border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 7px; padding: 7px 13px; font-size: 13px; cursor: pointer; transition: .12s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.muted { color: var(--muted); font-size: 12px; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted);
  border-top-color: var(--accent); border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -1px; }
@keyframes s { to { transform: rotate(360deg); } }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; width: min(720px, 92vw); }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 10px; font-size: 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
#secretsForm label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
#secretsForm input { width: 100%; margin-top: 5px; }
.gap { gap: 10px; }

.loghead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chk { color: var(--muted); font-size: 12px; }
.logbody { background: #0a0d12; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; height: 56vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
/* progress + status */
.progress { display: grid; gap: 6px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.bar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 999px; transition: width .4s ease; }
.fill.indet { width: 35% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.summary { font-size: 12px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); }
.summary.ok { color: var(--green); border-color: #2ea04366; }
.summary.bad { color: var(--red); border-color: #f8514966; }
.v.small.ok { color: var(--green); }
.v.small.warn { color: var(--amber); }
.v.small.bad { color: var(--red); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; font-size: 13px; z-index: 50; }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); }

/* ── Top bar brand (logo + slogan) ─────────────────────────────────────────── */
.brand { text-decoration: none; color: inherit; }
.brand .logo { width: 36px; height: 36px; flex: none; filter: drop-shadow(0 0 6px #2f81f766); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .slogan { color: var(--muted); font-size: 11px; letter-spacing: .02em; }
header nav { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
header .hostline { flex: 1 1 auto; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.userchip { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 999px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { padding: 10px 22px; font-size: 13px; border-bottom: 1px solid var(--border); }
.banner.warn { background: #d2992218; color: var(--amber); }
.banner a { color: inherit; font-weight: 600; }

/* ── Sign-in page ──────────────────────────────────────────────────────────── */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px 32px; }
.login { width: min(400px, 100%); display: grid; gap: 22px; }
.login-brand { text-align: center; display: grid; justify-items: center; gap: 6px; }
.login-brand .logo.lg { width: 72px; height: 72px; filter: drop-shadow(0 0 14px #2f81f766); }
.login-brand h1 { font-size: 20px; margin: 8px 0 0; font-weight: 600; }
.login-brand .slogan { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.login-card label, .form label { display: block; font-size: 12px; color: var(--muted); }
.login-card input, .form input { width: 100%; margin-top: 5px; font-size: 15px; padding: 10px 11px; }
.login-error { color: var(--red); font-size: 13px; border: 1px solid #f8514966; border-radius: 8px; padding: 8px 10px; background: #f851490f; }
.btn.wide { width: 100%; padding: 11px; font-size: 14px; }
.hint.center { text-align: center; margin: 0; }

/* ── Security page ─────────────────────────────────────────────────────────── */
main.security { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.card.wide { grid-column: 1 / -1; }
.form { display: grid; gap: 12px; }
.form h3 { margin: 4px 0 0; font-size: 13px; font-weight: 600; }
.policy { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: var(--text); }
.policy li { margin-bottom: 6px; } .policy i { color: var(--accent); font-style: normal; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: var(--mono); font-size: 12px; }
.table td.actions { white-space: nowrap; text-align: right; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.reveal { display: flex; align-items: center; gap: 10px; margin: 8px 0 16px; }
.reveal code { flex: 1; font-family: var(--mono); font-size: 18px; letter-spacing: .06em; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; user-select: all; }
select { max-width: 100%; }
#addForm label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
#addForm input, #addForm select { width: 100%; margin-top: 5px; }

/* ── Small screens (iPhone / home-screen app) ──────────────────────────────── */
main { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
@media (max-width: 640px) {
  header { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; gap: 10px; }
  header .hostline { display: none; }
  .brand-text h1 { font-size: 15px; }
  main { padding: 14px; gap: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .userchip { max-width: 150px; }
  dialog { padding: 16px; width: min(720px, 96vw); }
}

/* ── Microsoft 365 sign-in status page ─────────────────────────────────────── */
.login-status { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.login-who { font-size: 13px; color: var(--muted); }
.login-who b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.btn.ms { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.policy code { font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* ── Login screen (Magnus-style choices) ───────────────────────────────────── */
.login-points { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); }
.login-points .led { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.login-points .led.ok { background: var(--green); } .login-points .led.warn { background: var(--amber); }
.login-notice { font-size: 13px; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--panel2); }
.login-continue { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel2); color: var(--text); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; font: inherit; }
.login-continue:hover { background: #1f2a3a; } .login-continue:disabled { opacity: .6; cursor: default; }
.login-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; }
.login-who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.login-who b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-who .small { font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-go { font-size: 13px; color: var(--accent); font-weight: 600; }

/* hidden attribute must win over display:flex/inline-flex rules */
[hidden] { display: none !important; }
