:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef5fb;
  --nav: #07182a;
  --nav-2: #0b2744;
  --primary: #0877d1;
  --primary-dark: #055aa1;
  --text: #142033;
  --muted: #64748b;
  --border: #d9e2ec;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --info: #0369a1;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.layout { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: linear-gradient(180deg, var(--nav), var(--nav-2)); color: #d8e8f7; padding: 20px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { background: #fff; border-radius: 14px; padding: 10px 12px; margin-bottom: 20px; display:flex; align-items:center; justify-content:center; min-height: 110px; }
.brand img { width: 100%; max-width: 190px; max-height: 90px; object-fit: contain; display: block; }
.nav-label { padding: 8px 12px; font-size: 11px; font-weight: 800; color: #7fa4c5; letter-spacing: .12em; text-transform: uppercase; }
.nav a { display: flex; gap: 10px; align-items: center; color: #d8e8f7; padding: 11px 12px; border-radius: 9px; margin: 3px 0; font-weight: 650; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer { margin-top: 24px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; }
.user-mini { font-size: 13px; margin-bottom: 10px; }
.user-mini strong { display: block; color: white; }
.main { min-width: 0; overflow-x: hidden; }
.topbar { height: 68px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 20px; margin: 0; }
.content { padding: 26px 28px 50px; max-width: 1700px; margin: 0 auto; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow); padding: 20px; }
.card h2, .card h3 { margin: 0 0 14px; }
.metric { position: relative; overflow: hidden; }
.metric .label { color: var(--muted); font-weight: 700; font-size: 13px; }
.metric .value { font-size: 34px; font-weight: 850; margin-top: 7px; }
.metric .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.metric::after { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; right: -22px; top: -22px; background: rgba(8,119,209,.08); }
.metric.danger::after { background: rgba(185,28,28,.09); }
.metric.warning::after { background: rgba(180,83,9,.09); }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-muted { background: #e2e8f0; color: #475569; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; color: #475569; text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfdff; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 750; color: #475569; margin-bottom: 6px; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8,119,209,.12); }
textarea { min-height: 110px; resize: vertical; }
.btn { border: 0; border-radius: 9px; padding: 10px 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-sm { padding: 7px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: #f59e0b; color: #422006; }
.btn-outline { background: white; color: var(--primary); border: 1px solid var(--primary); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar { display: flex; gap: 10px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar .filters > div { min-width: 145px; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-weight: 650; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); font-weight: 700; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 36px; align-items: center; gap: 10px; margin: 10px 0; font-size: 13px; }
.bar { height: 10px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at top left, #0f548c, #07182a 52%, #030b13); }
.login-card { width: min(430px, 100%); background: white; padding: 30px; border-radius: 20px; box-shadow: 0 25px 70px rgba(0,0,0,.35); }
.login-logo { margin: 0 auto 20px; max-width: 330px; max-height: 150px; object-fit: contain; display:block; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 5px; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #0f172a; color: #dbeafe; border-radius: 10px; padding: 14px; white-space: pre-wrap; overflow-x: auto; font-size: 12px; }
.modal-details summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.inline-form { display: inline; }
.footer-note { margin-top: 24px; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 1150px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 850px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .nav { display: flex; flex-wrap: wrap; } .nav a { flex: 1 1 130px; } .sidebar-footer { display: flex; justify-content: space-between; align-items: center; } .topbar { position: static; padding: 0 18px; } .content { padding: 18px; } }
@media (max-width: 650px) { .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; } .form-grid .full { grid-column: auto; } .kv { grid-template-columns: 1fr; } .kv div:nth-child(odd) { margin-top: 6px; } }

.metric.compact .value { font-size: 28px; }
.danger-zone { border-color: #fecaca; background: #fffafa; }

/* OLT management cards: keeps actions visible without horizontal scrolling. */
.olt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.olt-card { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.olt-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.olt-card-header h3 { margin: 0 0 9px; overflow-wrap: anywhere; }
.olt-vendor { text-align: right; font-weight: 850; white-space: nowrap; }
.olt-vendor span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; margin-top: 3px; }
.olt-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.olt-meta-grid > div { border: 1px solid var(--border); background: #f8fafc; border-radius: 10px; padding: 11px 12px; min-width: 0; }
.olt-meta-grid span, .olt-meta-grid small { display: block; color: var(--muted); font-size: 11px; }
.olt-meta-grid strong { display: block; margin: 4px 0; overflow-wrap: anywhere; font-size: 13px; }
.olt-result { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #f8fafc; min-height: 62px; }
.olt-result strong, .olt-result > span { display: block; }
.olt-result > span { color: var(--muted); font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
.olt-result-ok { background: #f0fdf4; border-color: #bbf7d0; }
.olt-result-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.result-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.result-chips span { background: white; border: 1px solid var(--border); border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 750; }
.olt-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: auto; }
.olt-actions form { margin: 0; }
.advanced-settings { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #f8fafc; }
.advanced-settings summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.advanced-grid { margin-top: 14px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #e2e8f0; padding: 2px 5px; border-radius: 5px; }
@media (max-width: 1200px) { .olt-grid { grid-template-columns: 1fr; } }
@media (max-width: 650px) {
  .olt-card-header { flex-direction: column; }
  .olt-vendor { text-align: left; }
  .olt-meta-grid { grid-template-columns: 1fr; }
  .olt-actions .btn, .olt-actions form { width: 100%; }
}
.diagnostic-paths { display: grid; gap: 10px; }
.diagnostic-paths > div { display: grid; gap: 4px; }
.path-code { display: block; white-space: normal; overflow-wrap: anywhere; background: #f1f5f9; border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; color: #0f3d68; font-size: 12px; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(.92); }
.management-warning { border: 1px solid #fed7aa; background: #fff7ed; border-radius: 9px; padding: 10px 12px; }
.management-warning label { margin: 0; color: #9a3412; }
.management-warning input[type="checkbox"] { width: auto; margin-right: 7px; }

.inline-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.inline-actions form { margin:0; }

.binding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.binding-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 600;
}
.binding-option input { width: auto; }
.binding-option.binding-recommended { border-color: #60a5fa; background: #eff6ff; }

.grid-span-2 { grid-column: 1 / -1; }
.ssid-section-card {
  min-width: 0;
  overflow: hidden;
}
.ssid-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 16px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.ssid-card {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.ssid-card > * { min-width: 0; max-width: 100%; }
.ssid-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.ssid-card-header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.ssid-field { min-width: 0; width: 100%; }
.ssid-card input,
.ssid-card select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.ssid-tech-details {
  min-width: 0;
  border: 1px dashed #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  padding: 9px 11px;
}
.ssid-tech-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.ssid-tech-details > div { display: grid; gap: 5px; margin-top: 9px; min-width: 0; }
.ssid-tech-details span { color: var(--muted); font-size: 11px; font-weight: 750; }
.ssid-tech-details .path-code {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 10px;
}
.ssid-card-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  min-width: 0;
  width: 100%;
}
.ssid-card-footer .btn {
  display: flex;
  width: 100%;
  min-width: 0;
}
.ssid-card-footer .muted { overflow-wrap: anywhere; text-align: center; }
@media (max-width: 1150px) {
  .ssid-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .grid-span-2 { grid-column: auto; }
  .ssid-card { padding: 13px; }
}

.ssid-summary-list {
  display: grid;
  gap: 6px;
  min-width: 190px;
}
.ssid-summary-list > div {
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--border, #d9e1e8);
}
.ssid-summary-list > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

/* White-label branding */
.brand { flex-direction: column; gap: 7px; }
.brand span { color: #0f2740; font-size: 12px; font-weight: 850; text-align: center; overflow-wrap: anywhere; }
.branding-preview { text-align: center; }
.branding-preview-logo { min-height: 180px; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: 12px; background: #f8fafc; padding: 18px; margin-bottom: 16px; }
.branding-preview-logo img { max-width: 100%; max-height: 150px; object-fit: contain; }

.secret-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.secret-control input {
  min-width: 0;
  flex: 1 1 auto;
}
.secret-control .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
