:root {
  --bg: #1c1d20;
  --bg-2: #232427;
  --panel: #26282c;
  --panel-2: #2c2e33;
  --border: #34363b;
  --text: #e6e7ea;
  --text-dim: #9a9da3;
  --blue: #3a7afe;
  --ubnt-blue: #0559c9;
  --green: #34c759;
  --amber: #f5a623;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
a { color: var(--blue); cursor: pointer; text-decoration: none; }

/* ---------------- Login ---------------- */
#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 40px 36px;
  width: 360px;
  max-width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.login-logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
}
.login-brand {
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 4px;
  color: var(--text);
}
.login-sub { color: var(--text-dim); text-align: center; margin: 6px 0 28px; }
.login-footer { margin-top: 26px; }
.login-footer p { color: var(--text-dim); font-size: 12px; line-height: 1.5; text-align: center; margin: 0 0 14px; }
.login-copyright { margin-top: 18px; }
.login-contact { margin-bottom: 0; }
.login-contact a { color: var(--blue); }
.app-copyright { text-align: center; color: var(--text-dim); font-size: 11px; opacity: .6;
  margin: 28px 0 8px; }
label { display: block; font-size: 12px; color: var(--text-dim); margin: 16px 0 7px; }
label:first-child { margin-top: 0; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--blue); }

/* password show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 0;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; }
input[readonly] { color: var(--text-dim); }
.btn-primary {
  margin-top: 20px;
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.form-error { color: #ff6b6b; min-height: 18px; margin: 12px 0 0; font-size: 13px; }
.form-msg { min-height: 18px; margin: 10px 0 0; font-size: 13px; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: #ff6b6b; }
.form-warn { background: rgba(245,166,35,.12); border: 1px solid rgba(245,166,35,.4);
  color: #f3c178; padding: 10px 12px; border-radius: 8px; font-size: 12px; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 18px; background: var(--bg-2);
  border-bottom: 1px solid var(--border); position: relative;
}
.topbar-left { display: flex; align-items: center; gap: 0; }
.site-select {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 8px; font-weight: 600;
}
.site-select .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.site-select .caret { color: var(--text-dim); }
.net-tab { display: flex; align-items: center; gap: 8px; padding: 8px 18px; color: var(--blue); font-weight: 600; }
.net-ico { width: 18px; height: 18px; color: var(--blue); }
.topbar-center {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 18px; font-weight: 600; color: var(--text-dim);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.ico-btn { color: var(--text-dim); font-size: 18px; cursor: pointer; position: relative; }
.badge-num {
  position: absolute; top: -6px; right: -8px; background: var(--blue); color: #fff;
  font-size: 9px; border-radius: 8px; padding: 1px 4px;
}

/* ---------------- Body / sidebar ---------------- */
.body-row { display: flex; height: calc(100% - 56px); }
.sidebar {
  width: 290px; background: var(--bg-2); border-right: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column; position: relative;
}
.side-top-ico { color: var(--text-dim); font-size: 18px; margin-bottom: 18px; }
.side-title { font-weight: 600; margin-bottom: 14px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.side-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.side-item.active { background: var(--panel-2); color: var(--blue); }
.side-ico { width: 18px; height: 18px; flex: 0 0 18px; color: currentColor; }
.feedback-box { margin-top: 18px; }
.feedback-box p { color: var(--text-dim); margin: 0 0 12px; }
.feedback-actions { display: flex; align-items: center; justify-content: space-between; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.info-ico { width: 15px; height: 15px; color: var(--text-dim); }
.send-ico { background: none; border: none; cursor: pointer; color: var(--blue); padding: 0;
  display: flex; align-items: center; }
.send-ico svg { width: 18px; height: 18px; }
.support-card {
  margin-top: 18px; display: flex; gap: 10px; padding: 12px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px;
}
.support-ico { width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-dim); margin-top: 1px; }
.support-card p { margin: 0; color: var(--text-dim); font-size: 12px; }
.sidebar-spacer { flex: 1; }
.side-bottom-rail { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding: 12px 0 4px 12px; }
.rail-ico { background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 0;
  display: flex; align-items: center; }
.rail-ico svg { width: 20px; height: 20px; }
.rail-ico:hover { color: var(--text); }
#open-settings:hover { color: var(--blue); }

/* ---------------- Main ---------------- */
.main { flex: 1; padding: 20px 28px; overflow-y: auto; }
.tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 10px; width: max-content; }
.tab { padding: 7px 16px; border-radius: 7px; color: var(--text-dim); cursor: pointer; }
.tab.active { background: var(--panel-2); color: var(--text); }
.warn-banner {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px;
}
.warn-ico { color: var(--amber); }
.warn-banner span:nth-child(2) { flex: 1; }
.warn-link { white-space: nowrap; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 22px; margin-bottom: 18px; }
.upd-table { width: 100%; border-collapse: collapse; }
.upd-table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.upd-table td { padding: 14px 8px; border-bottom: 1px solid var(--border); }
.upd-table tbody tr:last-child td { border-bottom: none; }
.install { color: var(--blue); }
.cell-ico { width: 18px; height: 18px; color: #fff; vertical-align: -4px; margin-right: 9px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* hamburger + drawer backdrop (hidden on desktop) */
.menu-toggle { display: none; font-size: 20px; color: var(--text-dim); cursor: pointer; margin-right: 6px; }
.sidebar-backdrop { display: none; }

/* ---------------- Settings overlay ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.settings-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: 460px; max-height: 88vh; overflow-y: auto; padding: 24px 26px;
}
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.settings-head h2 { margin: 0; font-size: 20px; }
.close-x { cursor: pointer; color: var(--text-dim); font-size: 18px; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 18px; cursor: pointer; font-weight: 600; }
.btn-secondary:hover { border-color: var(--blue); }
.btn-inline { width: auto; margin-top: 0; padding: 11px 22px; }

/* settings tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 16px; cursor: pointer; color: var(--text); font: inherit;
  transition: border-color .15s, transform .05s;
}
.tile:hover { border-color: var(--blue); }
.tile:active { transform: scale(.99); }
.tile-ico { width: 26px; height: 26px; color: #fff; }
.tile-title { font-size: 14px; font-weight: 600; }
.tile-sub { font-size: 12px; color: var(--text-dim); word-break: break-word; }

/* generic change dialog */
.dialog {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: 420px; max-width: 92vw; padding: 22px 24px;
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dialog-head h3 { margin: 0; font-size: 17px; }
.dialog-body { padding-top: 6px; }
.dialog-hint { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
.dialog-preview { font-size: 13px; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.dialog-preview code { color: var(--blue); }
.dialog-note { font-size: 12px; color: var(--text-dim); margin: 14px 0 0;
  border-top: 1px solid var(--border); padding-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.restricted-ico { width: 40px; height: 40px; color: var(--amber); display: block; margin: 4px auto 14px; }
.restricted-msg { color: var(--text-dim); font-size: 13px; line-height: 1.55; text-align: center; margin: 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  body { font-size: 13px; }
  .topbar { padding: 0 12px; }
  .topbar-center { display: none; }
  .net-tab { padding: 8px 10px; }
  .site-select { padding: 8px 10px; }
  .menu-toggle { display: inline-block; }

  /* sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 40;
    width: 280px; max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 56px 0 0 0; z-index: 35;
    background: rgba(0,0,0,.5);
  }

  /* main takes full width */
  .body-row { display: block; height: calc(100% - 56px); overflow-y: auto; }
  .main { padding: 16px 14px; height: auto; }
  .tabs { width: 100%; overflow-x: auto; }
  .warn-banner { flex-wrap: wrap; }
  .warn-link { margin-left: auto; }
  .panel { padding: 14px; }
  .upd-table th, .upd-table td { white-space: nowrap; }

  /* settings modal fills the screen */
  .settings-panel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .tiles { grid-template-columns: 1fr; }
  .dialog { width: calc(100% - 28px); max-width: none; }
}
