:root {
  --bg: #f1f5fb;
  --panel: #ffffff;
  --ink: #101a2e;
  --muted: #64748b;
  --line: #e3e9f3;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #e9f9ef;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 15% -10%, #e0e7ff, transparent),
              radial-gradient(1000px 500px at 110% 110%, #ede9fe, transparent), var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 34px 32px;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px;
  margin-bottom: 6px; letter-spacing: -.2px;
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 18px;
}
.auth-card h1 { font-size: 20px; margin: 6px 0 2px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fbfcfe; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); background: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: filter .15s, transform .05s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #eef1f8; color: #334155; font-weight: 600; }
.btn.ghost:hover { background: #e2e7f3; filter: none; }
.btn.danger { background: #fee2e2; color: var(--danger); font-weight: 600; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.alert { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* ---------- dashboard ---------- */
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 22px; height: 62px; display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; }
.tabs { display: flex; gap: 4px; height: 62px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.chip { background: #eef1f8; color: #334155; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: #fef3c7; color: #b45309; }
main.app { padding: 24px 26px; max-width: 1280px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head h2 { font-size: 19px; letter-spacing: -.2px; }
.panel-head .dim { color: var(--muted); font-size: 13.5px; font-weight: 400; margin-top: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.avatar {
  width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; position: relative;
  background: linear-gradient(160deg, #eef2ff, #f5f3ff); display: grid; place-items: center;
  font-size: 44px; font-weight: 800; color: #6366f1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.card .name { font-weight: 800; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card .actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.uid-row {
  display: flex; align-items: center; gap: 8px; background: #f8fafc; border: 1px dashed #cbd5e1;
  border-radius: 9px; padding: 7px 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: #475569; overflow: hidden;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  background: var(--brand-soft); color: var(--brand); border-radius: 8px; padding: 4px 9px;
  font-size: 12.5px; font-weight: 700;
}
.empty { color: var(--muted); text-align: center; padding: 46px 10px; font-size: 14px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px; backdrop-filter: blur(3px); }
.modal-back.open { display: flex; }
.modal {
  background: var(--panel); border-radius: 18px; max-width: 480px; width: 100%;
  padding: 24px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.img-pick { display: flex; gap: 14px; align-items: center; margin: 12px 0 16px; }
.img-pick .thumb { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: #eef1f8;
  display: grid; place-items: center; color: #94a3b8; position: relative; }
.img-pick .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.lasttap {
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hint { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .25s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }
.device-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; max-width: 760px; }
.kbd { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; word-break: break-all; }
ol.steps { margin: 12px 0 0 20px; color: #334155; font-size: 14px; display: grid; gap: 8px; }
.spin { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color:#fff;
  border-radius: 50%; animation: rot .7s linear infinite; display:none; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (max-width: 700px) { .tabs { display: none; } .grid2 { grid-template-columns: 1fr; } }
