:root{
  --bg:#0f1e2b;
  --panel:#13283a;
  --panel2:#112334;
  --text:#e7eef6;
  --muted:#a9bfd3;
  --accent:#2aa3ff;
  --accent2:#46d4ff;
  --border:#264b66;
  --shadow: rgba(0,0,0,.35);
  --danger:#ff4d4d;
  --ok:#38d996;
  --radius:18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  /* Solid background to avoid gradient banding on some displays/GPUs */
  background: #0b1520;
  font: 14px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* No global overlays: keep background clean */

/* Top bar */
.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 18px;
  background: #0b1520;
  
  border-bottom:1px solid rgba(38,75,102,.55);
}

.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width:14px; height:14px; border-radius:6px;
  background: rgba(19,40,58,.96);
  box-shadow: 0 0 0 6px rgba(42,163,255,.12);
}
.brand-title{ font-weight:700; letter-spacing:.2px; }
.brand-sub{ color:var(--muted); font-size:12px; margin-top:2px; }

.topbar-actions{ display:flex; gap:10px; flex-wrap:wrap; }

/* Layout */
.wrap{
  max-width: 1220px;
  margin: 18px auto 40px;
  padding: 0 16px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:16px;
}

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

/* Cards */
.card{
  background: rgba(19,40,58,.96);
  border: 1px solid rgba(38,75,102,.65);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px var(--shadow);
  padding: 16px;
}

.card h2{
  margin:0 0 12px;
  font-size:15px;
  letter-spacing:.2px;
}

.card-wide{ grid-column: 1 / -1; }

/* Form rows */
.row{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap:14px;
  margin: 10px 0;
}

.row.row-actions{
  grid-template-columns: auto auto auto auto 1fr;
  align-items:center;
}

@media (max-width: 980px){
  .row.row-actions{
    grid-template-columns: 1fr 1fr;
  }
  .row.row-actions #status{ grid-column: 1 / -1; }
}

label{
  display:flex;
  flex-direction:column;
  gap:6px;
  color: var(--muted);
  font-size:12px;
}

input, select, textarea{
  width:100%;
  color: var(--text);
  background: rgba(7,15,24,.55);
  border: 1px solid rgba(38,75,102,.75);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus, textarea:focus{
  border-color: rgba(42,163,255,.95);
  box-shadow: 0 0 0 4px rgba(42,163,255,.14);
}

select{ padding-right: 36px; }
textarea{ min-height: 170px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: 12px; }
.output{ min-height: 260px; }

/* Checkbox */
label.checkbox{
  flex-direction:row;
  align-items:center;
  gap:10px;
  color: var(--text);
  font-size: 13px;
  padding-top: 0;
}
label.checkbox-inline{ margin-top: 22px; }
label.checkbox input{
  width:18px;
  height:18px;
  margin:0;
}
input[type="checkbox"]{ accent-color: var(--accent); }

/* Ports row: small count + PoE inline */
.ports-inline{
  display:flex;
  align-items:center;
  gap:14px;
}
.port-count input{ max-width: 84px; }

/* PoE checkbox in ports row */
.poe-inline{
  margin: 0;
  padding-top: 0;
}

/* Management row: IP + GW */
.mgmt-row{
  grid-template-columns: 1.35fr 1fr 160px;
}
@media (max-width: 720px){
  .mgmt-row{ grid-template-columns: 1fr; }
  .ports-inline{ align-items:stretch; }
}

/* VLAN section */
.vlan-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
}
@media (max-width: 980px){
  .vlan-grid{ grid-template-columns: 1fr; }
}
.label-inline{
  color: var(--muted);
  font-size:12px;
  margin: 0 0 6px;
}

/* Buttons */
.btn{
  appearance:none;
  border:1px solid rgba(38,75,102,.85);
  background: rgba(7,15,24,.35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}

.btn:hover{ border-color: rgba(42,163,255,.75); background: rgba(7,15,24,.55); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: var(--accent);
  border-color: rgba(42,163,255,.95);
  color: #06111a;
  font-weight:700;
}
.btn-primary:hover{ filter: brightness(1.08); }

.btn-ghost{ background: rgba(7,15,24,.25); }
.btn-disabled, .btn:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.btn-firmware{ text-decoration:none; display:inline-flex; align-items:center; justify-content:center; }

/* Status */
.status{
  justify-self:end;
  color: var(--muted);
  font-size: 12px;
  padding-left: 8px;
}
@media (max-width: 980px){
  .status{ justify-self:start; }
}

/* Small tweaks */
.pw-field label{ margin-bottom:6px; }
.pw-inline{ display:block; }

/* Force dark form controls (Chrome autofill etc.) */
:root{ color-scheme: dark; }

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus{
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  box-shadow: 0 0 0px 1000px rgba(7,15,24,.55) inset !important;
  border: 1px solid rgba(38,75,102,.75) !important;
}



/* Tabs */
.tabbar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:4px;
  margin: 10px auto 18px;
  padding:4px;
  width: fit-content;
  border-radius:999px;
  border:1px solid rgba(38,75,102,.75);
  background: rgba(10,25,38,.70);
}
.tabbtn{
  appearance:none;
  border:0;
  background: transparent;
  color: rgba(215,235,255,.90);
  padding:8px 16px;
  border-radius: 999px;
  cursor:pointer;
  font-weight:600;
  letter-spacing: .2px;
  opacity:.85;
}
.tabbtn.active{
  opacity:1;
  color: #fff;
  background: rgba(42,163,255,.18);
  box-shadow: none;
}
.tabbtn:hover{ opacity:1; }
.tabbtn:focus{ outline:none; }
.tabview{ display:none; }
.tabview.active{ display:block; }

/* Password inline button */
.pw-inline{
  display:flex;
  align-items:center;
  gap:10px;
}
.btn-inline{
  padding:10px 12px;
  white-space:nowrap;
}

/* Diff */
.diff-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
}
@media (max-width: 980px){
  .diff-grid{ grid-template-columns: 1fr; }
}
.diff-out{
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow:auto;
  max-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}
.diff-line{ display:block; padding:2px 6px; border-radius:8px; }
.diff-add{ background: rgba(56,217,150,.10); }
.diff-del{ background: rgba(255,77,77,.10); }
.diff-eq{ opacity:.85; }


/* Auth overlay */
.auth-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.auth-overlay.hidden{ display:none; }

body.auth-locked{ overflow:hidden; }
/* When auth is required, don't show the page background at all */
body.auth-locked{
  background: #050a0f !important;
  background-image: none !important;
}

body.auth-locked::before{ display:none !important; }

/* Hide the underlying UI completely before login */
body.auth-locked header.topbar,
body.auth-locked main.wrap{
  opacity: 0;
  pointer-events: none;
}
.auth-card{
  width: min(420px, calc(100vw - 32px));
  background: rgba(12, 30, 45, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  
}
.auth-title{
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}
.auth-row{ display:grid; gap:6px; margin-bottom:10px; }
.auth-row label{ opacity:.85; font-size:12px; }
.auth-actions{ display:flex; justify-content:flex-end; margin-top:8px; }
.auth-err{ margin-top:10px; color:#ffb3b3; font-size:12px; min-height:16px; }
