:root {
  --blue: #1668A7;
  --blue-dark: #0D4266;
  --tan: #C99A6B;
  --tan-ink: #9A6E3F;
  --bg: #FAF5ED;
  --card: #FFFFFF;
  --line: #E6D9C5;
  --text: #0D4266;
  --muted: #4E6E8A;
  --ok: #1E7F3C;
  --bad: #B3261E;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
.top {
  background: #fff; border-bottom: 3px solid var(--tan);
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; flex-wrap: wrap;
}
.top .logo { height: 54px; }
.top .title { font-size: 20px; font-weight: 700; color: var(--blue); letter-spacing: .5px; }
.top .title span { color: var(--tan-ink); }
.top .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; background: #F3EADB; color: var(--muted);
}
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: #aaa; }
.pill.on { background: #E3F2E7; color: var(--ok); }
.pill.on .dot { background: var(--ok); }
.pill.off { background: #FBE7E5; color: var(--bad); }
.pill.off .dot { background: var(--bad); }

main { max-width: 1050px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 640px; margin: 40px auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
h1 { font-size: 26px; margin: 0 0 12px; color: var(--blue); }
h2 { font-size: 20px; margin: 0 0 12px; color: var(--blue); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }

.bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.bar label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
select, input[type=text], input[type=password] {
  font: inherit; padding: 9px 12px; border: 1px solid #D2C2A7; border-radius: 10px; background: #fff; color: var(--text);
  min-width: 0;
}
input[type=text]:focus, select:focus, input[type=password]:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 18px;
  background: var(--blue); color: #fff; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--blue-dark); }
button.secondary { background: #F3EADB; color: var(--blue-dark); }
button.secondary:hover { background: #E6D9C5; }
button.danger { background: #fff; color: var(--bad); border: 1px solid #E8B4AF; }
button.danger:hover { background: #FBE7E5; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.big { font-size: 18px; padding: 14px 26px; }

.tabs { display: flex; gap: 6px; margin: 18px 0 0; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border-radius: 10px 10px 0 0; padding: 10px 18px; }
.tabs button.active { background: #fff; color: var(--blue); border: 1px solid var(--line); border-bottom-color: #fff; margin-bottom: -1px; }
.panel { border-top-left-radius: 0; }
.hidden { display: none !important; }

.profiles { display: grid; gap: 12px; }
.profile {
  display: flex; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; flex-wrap: wrap;
}
.profile.on { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.profile .icon {
  width: 46px; height: 46px; border-radius: 10px; background: #F3EADB; display: grid; place-items: center;
  font-weight: 700; color: var(--tan-ink); font-size: 18px; flex: none; overflow: hidden;
}
.profile .icon img { width: 100%; height: 100%; object-fit: contain; }
.profile .info { flex: 1; min-width: 200px; }
.profile .name { font-weight: 700; font-size: 17px; }
.profile .sub { font-size: 13px; color: var(--muted); word-break: break-all; }
.profile .state { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #EEE; color: #666; }
.profile.on .state { background: #E3F2E7; color: var(--ok); }
.profile .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile .actions button { padding: 8px 14px; font-size: 14px; }

.grid2 { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; align-items: center; }
.grid2 .v { word-break: break-all; font-family: Consolas, monospace; font-size: 15px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.progress { height: 10px; background: #F3EADB; border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--tan)); transition: width .4s; }

.notice { padding: 12px 16px; border-radius: 10px; margin: 12px 0; }
.notice.ok { background: #E3F2E7; color: var(--ok); }
.notice.bad { background: #FBE7E5; color: var(--bad); }
.notice.info { background: #EAF2F9; color: var(--blue-dark); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: 14px; }

.busy {
  position: fixed; right: 18px; bottom: 18px; background: var(--blue-dark); color: #fff; padding: 12px 18px;
  border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.2); display: flex; gap: 10px; align-items: center; max-width: 90vw;
}
.spin { width: 16px; height: 16px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }

dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 460px; width: 92vw; color: var(--text); }
dialog::backdrop { background: rgba(13, 66, 102, .45); }

.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li { counter-increment: s; padding: 10px 0 10px 48px; position: relative; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 6px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--tan); color: #fff; display: grid; place-items: center; font-weight: 700;
}
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
