:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #172033;
  background: #f3f6fb;
  --primary: #1769e0;
  --primary-dark: #0f52b8;
  --border: #dfe6f1;
  --muted: #718096;
  --success: #12805c;
  --danger: #c23934;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1080px; background: #f3f6fb; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #edf4ff; }
.login-panel { width: 390px; padding: 36px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 18px 44px rgba(42, 75, 120, .14); display: grid; gap: 18px; }
.login-panel h1 { margin: 4px 0 6px; font-size: 25px; }
.login-panel label { display: grid; gap: 8px; color: #42516a; font-size: 14px; }
input { height: 42px; border: 1px solid #cfd8e8; border-radius: 5px; padding: 0 12px; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 105, 224, .1); }

.brand-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; background: var(--primary); color: white; font-weight: 800; font-size: 19px; }
.eyebrow { margin: 0; color: var(--primary); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.muted { color: var(--muted); margin: 0; }
.form-error { color: var(--danger); min-height: 18px; margin: 0; font-size: 13px; }

button { min-height: 36px; padding: 0 16px; border-radius: 5px; background: var(--primary); color: #fff; font-weight: 600; }
button:hover { background: var(--primary-dark); }
button.secondary { background: #fff; color: #315173; border: 1px solid #cfd8e8; }
button.secondary:hover { background: #f5f8fc; }
button.danger { background: #fff; color: var(--danger); border: 1px solid #efc7c5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px 1fr; }
.sidebar { background: #102d5c; color: white; padding: 22px 14px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand div { display: grid; gap: 2px; }
.brand small { color: #9fb7da; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item, .logout { text-align: left; background: transparent; color: #cbd8eb; padding: 0 14px; }
.nav-item:hover, .nav-item.active { background: #1d56a6; color: #fff; }
.logout { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); border-radius: 0; }

main { min-width: 0; }
.topbar { min-height: 86px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 3px 0 0; font-size: 23px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions span { color: var(--muted); font-size: 13px; }

.page { display: none; padding: 24px 28px 40px; }
.page.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric { background: #fff; border: 1px solid var(--border); border-radius: 7px; padding: 17px 18px; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 27px; }
.section-title { margin: 4px 0 12px; display: flex; align-items: end; justify-content: space-between; }
.section-title h2 { margin: 0 0 4px; font-size: 17px; }
.section-title p { margin: 0; color: var(--muted); font-size: 13px; }

.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 14px; border-bottom: 1px solid #edf1f6; text-align: left; font-size: 13px; vertical-align: middle; word-break: break-word; }
th { color: #66758b; background: #f8fafc; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.cell-primary { font-weight: 650; color: #25364e; }
.cell-secondary { color: var(--muted); font-size: 12px; margin-top: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; background: #eef2f7; color: #53627a; font-size: 12px; }
.status.active, .status.online, .status.bound { background: #e6f6ef; color: var(--success); }
.status.suspended, .status.offline { background: #fff0ef; color: var(--danger); }
.status.unused { background: #eaf2ff; color: var(--primary); }
.inline-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.inline-actions button { min-height: 30px; padding: 0 10px; font-size: 12px; }

dialog { border: 0; border-radius: 8px; padding: 0; width: min(520px, calc(100vw - 40px)); box-shadow: 0 24px 70px rgba(18, 44, 78, .25); }
dialog::backdrop { background: rgba(15, 30, 50, .42); }
.dialog-body { padding: 24px; display: grid; gap: 18px; }
.dialog-body header { display: flex; align-items: start; justify-content: space-between; }
.dialog-body h2 { margin: 3px 0 0; }
.icon-button { width: 34px; min-height: 34px; padding: 0; border-radius: 50%; background: #eff3f8; color: #526278; font-size: 20px; }
.secret-box { display: flex; align-items: center; gap: 10px; }
.secret-box code { min-height: 42px; flex: 1; display: flex; align-items: center; padding: 0 12px; background: #f2f5f9; border: 1px solid var(--border); border-radius: 5px; overflow-wrap: anywhere; }
.dialog-body footer, .dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.pairing-dialog { text-align: center; }
.pairing-dialog header { text-align: left; }
.pairing-dialog img { width: 260px; height: 260px; margin: 0 auto; }
.pairing-code { font-size: 22px; color: var(--primary); }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 13px 17px; color: #fff; background: #233852; border-radius: 6px; box-shadow: 0 12px 34px rgba(0,0,0,.2); }
