:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5eaf2;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --green: #16a34a;
  --green-soft: #e7f8ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fff4e0;
  --shadow: 0 10px 30px rgba(15, 23, 42, .07);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #131c2e;
    --text: #e6edf7;
    --muted: #93a2b8;
    --line: #223047;
    --blue-soft: #16233d;
    --green-soft: #102a1e;
    --red-soft: #2b1414;
    --amber-soft: #2b2110;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--blue); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 390px; background: var(--panel); border-radius: 22px;
  padding: 30px; box-shadow: var(--shadow);
}
.login__logo { width: 56px; height: 56px; border-radius: 16px; display: block; margin-bottom: 18px; }
.login h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: -.02em; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg);
  border-radius: 12px; height: 44px; padding: 0 13px; outline: none;
}
.textarea { height: auto; min-height: 80px; padding: 10px 13px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); }
.btn {
  height: 42px; padding: 0 16px; border-radius: 11px; font-weight: 650; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--ghost { background: var(--blue-soft); color: var(--text); }
.btn--danger { background: var(--red); color: #fff; }
.btn--sm { height: 34px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn--block { width: 100%; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.brand b { font-size: 15px; display: block; }
.brand span { font-size: 11.5px; color: var(--muted); }
.nav { display: grid; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 13.5px; text-align: left;
}
.nav button:hover { background: var(--blue-soft); }
.nav button.active { background: var(--blue); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar__bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.user { display: flex; align-items: center; gap: 9px; padding: 0 6px 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.user__name { font-size: 13px; font-weight: 700; }
.user__ip { font-size: 11px; color: var(--muted); }

.main { padding: 26px 30px 48px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (min-width: 1200px) { .cards { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card__label { color: var(--muted); font-size: 12px; font-weight: 600; }
.card__value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; }
.card__meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel__head h2 { margin: 0; font-size: 15px; }
.panel__body { padding: 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--blue-soft) 35%, transparent); }
td.addr { white-space: normal; min-width: 220px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill--on { background: var(--green-soft); color: var(--green); }
.pill--off { background: var(--red-soft); color: var(--red); }
.pill--unknown { background: var(--line); color: var(--muted); }
.pill--planned { background: var(--amber-soft); color: var(--amber); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .input, .toolbar .select { width: auto; height: 36px; border-radius: 9px; font-size: 13px; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.spinner { padding: 40px; text-align: center; color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: grid; place-items: center; z-index: 60; padding: 18px; }
.modal__card { width: 100%; max-width: 470px; background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal__card h3 { margin: 0 0 14px; font-size: 18px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 12px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 80;
  max-width: calc(100vw - 32px); box-shadow: 0 12px 34px rgba(0,0,0,.35);
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .brand { padding-bottom: 12px; }
  .nav { display: flex; overflow-x: auto; gap: 6px; }
  .nav button { white-space: nowrap; padding: 8px 12px; }
  .sidebar__bottom { display: none; }
  .main { padding: 18px 16px 40px; }
  .user-mobile { display: flex; align-items: center; gap: 8px; }
}
.user-mobile { display: none; }
