/* HopOn — Author: Stacklabs.nl - Ferry */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #16a34a;
  --off: #dc2626;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-2: #0f1628;
    --border: #22304d;
    --text: #e2e8f0;
    --muted: #8a99b5;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e2547;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #6366f1, #22d3ee); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid transparent; font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0b1020; } }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(220, 38, 38, .08); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 17px; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 127, 127, .15); }

/* forms */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
label.toggle { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 0; }
.code-input { font: 600 22px var(--mono); letter-spacing: .3em; text-align: center; }
.alert { background: rgba(220, 38, 38, .1); color: var(--danger); border-radius: 9px; padding: 9px 12px; margin-bottom: 14px; font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* auth pages */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(99, 102, 241, .18), transparent), radial-gradient(900px 500px at 110% 110%, rgba(34, 211, 238, .14), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.auth-card.auth-wide { max-width: 640px; }
.auth-sub { color: var(--muted); margin: 6px 0 22px; }
.auth-link { display: block; text-align: center; margin-top: 14px; font-size: 13px; }
.enrol-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.enrol-grid h3 { font-size: 14px; margin: 0 0 12px; }
.qr { display: block; border-radius: 10px; background: #fff; padding: 6px; margin-bottom: 8px; }
.secret { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.secret code { display: block; margin-top: 6px; word-break: break-all; }
@media (max-width: 600px) { .enrol-grid { grid-template-columns: 1fr; } }

/* app shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.who { color: var(--muted); font-weight: 600; }
.content { max-width: 1280px; margin: 0 auto; padding: 24px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.view-title { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.search { min-width: 320px; height: 38px; }
.search-sm { min-width: 220px; height: 34px; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* server cards */
.group { margin-bottom: 28px; }
.group-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-count { font-weight: 600; opacity: .7; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; }
.card:hover { transform: translateY(-1px); border-color: var(--accent); }
.card:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.card.not-ready { opacity: .72; }
.card-top { display: flex; align-items: center; gap: 9px; }
.card-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-edit { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .12s; color: var(--muted); }
.card:hover .card-edit, .card:focus-within .card-edit { opacity: 1; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge-warn { color: var(--warn); border-color: rgba(217, 119, 6, .35); background: rgba(217, 119, 6, .08); }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.dot.down { background: var(--off); box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }

/* keys */
.key-list { display: grid; gap: 12px; }
.key-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.key-head { display: flex; align-items: center; gap: 10px; }
.key-name { font-weight: 700; }
.key-meta { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.key-pub { display: block; font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; word-break: break-all; color: var(--muted); }

/* table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.td-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.td-mono { font-family: var(--mono); font-size: 12px; }
.ev { font-weight: 600; }
.ev-bad { color: var(--danger); }

/* dialogs */
.dialog { width: min(620px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 16px; padding: 24px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .35); }
.dialog-sm { width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8, 12, 24, .55); backdrop-filter: blur(2px); }
.dialog h3 { margin: 0 0 16px; font-size: 18px; }
.dialog label input, .dialog label select, .dialog label textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.dlg-note { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }
.dlg-section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dlg-section-head { width: 100%; font-weight: 700; font-size: 13px; }
.dlg-section .hint { width: 100%; margin: 0; }
.dlg-section code { font-size: 12px; color: var(--muted); word-break: break-all; }
.inline { display: flex; gap: 8px; width: 100%; }
.inline input { flex: 1; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 420px;
  animation: toast-in .18s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* terminal window: nothing but the terminal */
body.term { background: #0b1020; height: 100vh; overflow: hidden; }
#term { position: fixed; inset: 0; padding: 6px 0 0 8px; }
#term .xterm { height: 100%; }
#term .xterm-viewport::-webkit-scrollbar { width: 8px; }
#term .xterm-viewport::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 8px; }
.term-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8, 12, 24, .72); z-index: 20; }
.term-overlay-box { max-width: 460px; text-align: center; color: #e2e8f0; padding: 22px 26px; border-radius: 14px; background: #121a2e; border: 1px solid #22304d; }
.term-overlay-box p { margin: 6px 0; }
.term-overlay-box code { color: #a5b4fc; word-break: break-all; }
.term-overlay-box .muted { color: #8a99b5; font-size: 13px; }
.drop-hint { position: fixed; inset: 10px; border: 2px dashed #818cf8; border-radius: 14px; display: grid; place-items: center; color: #e2e8f0;
  font-weight: 600; background: rgba(79, 70, 229, .14); z-index: 15; pointer-events: none; }

/* file panel */
.files { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 12; display: flex; flex-direction: column;
  background: #121a2e; color: #e2e8f0; border-left: 1px solid #22304d; box-shadow: -12px 0 32px rgba(0, 0, 0, .35); }
.files-head { display: flex; align-items: center; gap: 6px; padding: 10px; border-bottom: 1px solid #22304d; }
.files-path { flex: 1; min-width: 0; background: #0b1020; color: #e2e8f0; border-color: #22304d; font: 12.5px var(--mono); padding: 6px 9px; }
.files-actions { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #22304d; }
.files .btn-secondary { background: #0f1628; color: #e2e8f0; border-color: #22304d; }
.files .btn-ghost { color: #8a99b5; }
.files .btn-ghost:hover { background: #0f1628; color: #e2e8f0; }
.files-list { list-style: none; margin: 0; padding: 4px 0; overflow: auto; flex: 1; }
.files-list li { display: flex; align-items: center; gap: 10px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.files-list li:hover { background: #1a2440; }
.files-list .f-ico { width: 16px; text-align: center; color: #8a99b5; }
.files-list .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list .is-dir .f-name { font-weight: 600; }
.files-list .f-size { color: #8a99b5; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.files-list .f-act { opacity: 0; display: flex; gap: 2px; }
.files-list li:hover .f-act { opacity: 1; }
.files-list .f-act button { border: 0; background: transparent; color: #8a99b5; cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 5px; }
.files-list .f-act button:hover { background: #22304d; color: #e2e8f0; }
.files-progress { padding: 10px; border-top: 1px solid #22304d; font-size: 12px; color: #8a99b5; }
.files-progress .bar { height: 4px; border-radius: 4px; background: #818cf8; width: 0; margin-bottom: 6px; transition: width .1s; }

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .who { display: none; }
  .content { padding: 16px; }
  .search { min-width: 0; flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
}
