:root {
  --bg: #0b1220;
  --bg2: #121b2e;
  --card: #16223a;
  --line: #24344f;
  --text: #e6edf7;
  --muted: #8fa3c0;
  --accent: #38bdf8;
  --accent2: #22c55e;
  --danger: #f87171;
  --warn: #fbbf24;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
code { background: #0d1729; padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #17294a 0%, var(--bg) 60%);
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 72px; height: 72px; }
.login-card h1 { font-size: 22px; margin: 10px 0 4px; }
.login-card input {
  width: 100%; margin: 16px 0 12px; padding: 13px 14px; font-size: 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
}
.remember { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- layout ---------- */
.app { min-height: 100vh; padding-bottom: 72px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px calc(12px + env(safe-area-inset-top, 0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(11, 18, 32, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; }
.brand-title { font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); }
main { padding: 14px; max-width: 720px; margin: 0 auto; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}
.panel h2 { font-size: 15px; margin: 0 0 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #1b2942; color: var(--text);
  padding: 11px 14px; border-radius: 11px; font-size: 14px; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #062033; font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 7px 10px; font-size: 13px; }
.icon-btn {
  border: 1px solid var(--line); background: #1b2942; color: var(--text);
  width: 38px; height: 38px; border-radius: 11px; font-size: 17px; cursor: pointer;
}
input, select {
  flex: 1 1 140px; min-width: 0; background: #0f1a2e; color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; font-size: 15px;
}
select { flex: 0 0 auto; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.card.w2 { grid-column: span 2; }
.card.w3 { grid-column: span 3; }
.card.w6 { grid-column: span 6; }
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 16px; font-weight: 600; margin-top: 3px; word-break: break-word; }
.card .value.ok { color: var(--accent2); }
.card .value.bad { color: var(--danger); }
.card .value.warn { color: var(--warn); }
.bar { height: 6px; border-radius: 4px; background: #0f1a2e; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--danger); }

/* ---------- activity ---------- */
.activity { font-size: 14px; }
.act-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.act-row:last-child { border-bottom: 0; }
.act-name { font-weight: 600; min-width: 84px; }
.act-count { color: var(--accent); font-variant-numeric: tabular-nums; }
.act-last { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ---------- users ---------- */
.user {
  display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.user:last-child { border-bottom: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; }
.user-id { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- icon actions ---------- */
.icon-action {
  appearance: none; border: 0; background: transparent; padding: 0; margin: 0;
  width: 34px; height: 38px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); flex: 0 0 auto;
}
.icon-action svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.icon-action:active { background: #1b2942; }
.icon-action.edit { color: var(--text); }
.icon-action.del { color: var(--danger); }
.link-actions { display: inline-flex; align-items: center; gap: 2px; }

/* ---------- rename ---------- */
#rename-input { width: 100%; margin: 2px 0 4px; }
#rename-modal .row { justify-content: center; margin-top: 12px; }

/* ---------- links ---------- */
.links .link-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.links .link-row:last-child { border-bottom: 0; }
.link-name { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.link-url { font-size: 11px; color: var(--muted); word-break: break-all; }

.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #0f1a2e; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 13px; }
.chip.on { border-color: var(--accent); color: var(--accent); }

.out { background: #0d1729; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; overflow: auto; max-height: 240px; white-space: pre-wrap; }



/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15, 26, 46, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 9px 4px 10px; font-size: 11px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-btn span { font-size: 17px; }
.tab-btn.active { color: var(--accent); }

/* ---------- modal / toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(3, 7, 15, .72); padding: 20px;
}
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 340px; text-align: center; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.qr-box {
  width: 256px; height: 256px; margin: 0 auto; background: #fff; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.qr-box img, .qr-box canvas { display: block; width: 240px !important; height: 240px !important; }
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: #1b2942; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
