/* SanWareTech OLT — mesma identidade do site (sanwaretech.com.br) e do painel de Backups.
   Neutros tingidos para o azul-marinho da marca, laranja da marca como único acento,
   status (verde / amarelo / vermelho) só onde é informação. Escuro é o padrão; o claro segue a mesma rampa.
   Ajustado com a skill unslop de Damir Sokolovsky (@heydamir), CC BY 4.0. */
@font-face { font-family: "IBM Plex Sans"; src: url(fonts/ibmplexsans-var.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/ibmplexmono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/ibmplexmono-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }

[hidden] { display: none !important; }
:root {
  /* claro (tingido de azul-marinho) */
  --bg: #f1f4f9;
  --panel: #ffffff;
  --panel-2: #f5f7fb;
  --field: #ffffff;
  --line: #dde3ee;
  --line-2: #cbd3e3;
  --ink: #0b1530;
  --ink-2: #3f4c6b;
  --ink-3: #66738f;
  --side: #081127;
  --side-ink: #a9b7d6;
  --side-active: #16264a;
  --fiber: #ff8a00;
  --fiber-hover: #ff9a26;
  --fiber-ink: #0b1530;
  --fiber-text: #b85f00;
  --aqua: #2f5fb3;
  --good: #1d8a58;
  --warn: #a86d00;
  --crit: #c8372d;
  --muted-badge: #e9edf5;
  --shadow: 0 1px 2px rgba(11, 21, 48, .05);
  --radius-s: 8px;
  --radius-m: 12px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  /* escuro = painel de Backups / site */
  --bg: #0b1530;
  --panel: #101d3c;
  --panel-2: #16264a;
  --field: #0a1430;
  --line: rgba(238, 242, 251, .08);
  --line-2: rgba(238, 242, 251, .14);
  --ink: #eef2fb;
  --ink-2: #a9b7d6;
  --ink-3: #8090b6;
  --side: #081127;
  --side-ink: #a9b7d6;
  --side-active: #16264a;
  --fiber-text: #ffad4d;
  --aqua: #7ea6ee;
  --good: #4cc38a;
  --warn: #e8b03a;
  --crit: #e5484d;
  --muted-badge: #16264a;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 14px; line-height: 20px;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
a { color: var(--aqua); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fiber); outline-offset: 2px; }

/* layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid rgba(238, 242, 251, .08); }
.brand { padding: 20px 20px 20px; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 32px; height: 32px; flex: none; display: block; border-radius: 8px; }
.brand-olt { color: var(--fiber); }
.brand-name { font-weight: 600; font-size: 15px; line-height: 18px; color: #eef2fb; letter-spacing: .02em; }
.brand-sub { font-size: 12px; line-height: 16px; color: #8090b6; }
.nav { padding: 0 12px 20px; display: flex; flex-direction: column; gap: 2px; }
.nav h6 { margin: 20px 10px 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: #8090b6; }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius-s); color: var(--side-ink); text-decoration: none;
  transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: rgba(238, 242, 251, .04); color: #eef2fb; }
.nav a.active { background: var(--side-active); color: #eef2fb; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
.nav a.active svg { color: var(--fiber); opacity: 1; }
.nav a .count { margin-left: auto; font: 500 11.5px/18px var(--mono); background: rgba(229, 72, 77, .18); color: #f4a3a5; border-radius: 6px; padding: 0 6px; }
.nav svg { width: 16px; height: 16px; flex: none; color: #8090b6; }
.side-foot { margin-top: auto; padding: 16px 20px; font-size: 12px; line-height: 18px; color: #8090b6; border-top: 1px solid rgba(238, 242, 251, .08); }
.side-foot a { color: #a9b7d6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 32px; background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0; letter-spacing: -.01em; }
.top .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.menu-btn { display: none; }
.view { padding: 28px 32px 64px; max-width: 1600px; width: 100%; }

/* blocos */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h2 { font-size: 15px; line-height: 22px; margin: 0; font-weight: 500; }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 16px 20px; }
.panel-b.flush { padding: 0; }
.hint { color: var(--ink-3); font-size: 12.5px; line-height: 18px; }
.lead { color: var(--ink-2); max-width: 75ch; margin: 0 0 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 16px; overflow: hidden; }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); cursor: default; transition: background-color .15s var(--ease); }
.stat:last-child { border-right: none; }
.stat.link { cursor: pointer; }
.stat.link:hover { background: var(--panel-2); }
.stat .v { font: 500 26px/34px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .l { color: var(--ink-2); font-size: 13px; }
.stat.good .v { color: var(--good); }
.stat.crit .v { color: var(--crit); }
.stat.warn .v { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .panel { margin-bottom: 0; }

/* painel inicial: janelas arrastáveis e redimensionáveis (grade de 12 colunas) */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dw { position: relative; min-width: 0; }
.dw > .panel, .dw > .stats { margin-bottom: 0; }
.dw.fixed-h { display: flex; flex-direction: column; overflow: hidden; }
.dw.fixed-h > .panel, .dw.fixed-h > .stats { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.dw.fixed-h > .stats { display: grid; overflow: auto; }
.dw.fixed-h .panel-b { flex: 1; min-height: 0; overflow: auto; }
.dw .panel-h { padding-right: 44px; }
.dw-grip { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--ink-3); font-size: 16px; line-height: 1; cursor: grab; touch-action: none; opacity: .45; }
.dw:hover .dw-grip, .dw-grip:focus-visible { opacity: 1; border-color: var(--line); background: var(--panel-2); }
.dw.dragging { opacity: .55; }
.dw.dragging .dw-grip { cursor: grabbing; }
.dw-rs { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; opacity: 0;
  background: linear-gradient(135deg, transparent 0 55%, var(--ink-3) 55% 62%, transparent 62% 74%, var(--ink-3) 74% 81%, transparent 81%); }
.dw:hover .dw-rs, .dw.resizing .dw-rs { opacity: .8; }
.dw.resizing { outline: 2px dashed var(--fiber); outline-offset: 2px; }
.dash-foot { margin-top: 12px; }
.dash-foot a { margin-left: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font: 500 12px/16px var(--sans); color: var(--ink-3); background: var(--panel); position: sticky; top: 0; padding-top: 9px; padding-bottom: 9px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--ink) 3%, transparent); }
tr.click { cursor: pointer; }
td.wrap { white-space: normal; min-width: 220px; }
.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px; font: 500 12px/1 var(--sans); background: var(--muted-badge); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.badge.online, .badge.up { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.los, .badge.offline, .badge.down, .badge.auth_fail, .badge.rogue { color: var(--crit); background: color-mix(in srgb, var(--crit) 12%, transparent); }
.badge.dying_gasp, .badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.badge.disabled, .badge.unknown { color: var(--ink-3); }
.badge.registering { color: var(--aqua); background: color-mix(in srgb, var(--aqua) 12%, transparent); }
.badge.role { background: color-mix(in srgb, var(--fiber) 14%, transparent); color: var(--fiber-text); }

/* régua de sinal óptico (-8 a -30 dBm) */
.sig { display: inline-flex; align-items: center; gap: 8px; }
.sig .ladder { position: relative; width: 92px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--crit) 0 12%, var(--good) 12% 77%, var(--warn) 77% 86%, var(--crit) 86% 100%); opacity: .4; }
.sig .ladder i { position: absolute; top: -4px; width: 3px; height: 14px; border-radius: 2px; background: var(--ink); }
.sig .val { font-family: var(--mono); font-size: 12.5px; min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.sig.good .val { color: var(--good); }
.sig.warn .val { color: var(--warn); }
.sig.crit .val, .sig.high .val { color: var(--crit); font-weight: 500; }
.sig.none .val { color: var(--ink-3); }

/* formulários */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .hint { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], select, textarea {
  padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--field); min-width: 0; width: 100%; line-height: 20px;
  transition: border-color .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--fiber); outline: 2px solid color-mix(in srgb, var(--fiber) 35%, transparent); outline-offset: 0; box-shadow: none; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input, input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--fiber); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius-s); border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease); }
.btn:hover { background: color-mix(in srgb, var(--ink) 7%, var(--panel-2)); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--fiber); border-color: var(--fiber); color: var(--fiber-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn.primary:hover { background: var(--fiber-hover); border-color: var(--fiber-hover); }
.btn.danger { background: transparent; color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--crit) 10%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; height: 40px; padding: 0 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
  transition: color .15s var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--fiber); }

/* PON chips */
.pons { display: flex; flex-wrap: wrap; gap: 8px; }
.pon { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px; font-size: 12.5px; background: var(--panel-2); min-width: 108px; transition: border-color .15s var(--ease); }
a.pon:hover { border-color: var(--line-2); }
.pon b { font-family: var(--mono); font-weight: 500; }
.pon .bar { height: 4px; background: color-mix(in srgb, var(--ink) 10%, transparent); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.pon .bar span { display: block; height: 100%; background: var(--good); }
.pon.down { opacity: .6; }
label.pon { cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
label.pon.sel { border-color: var(--fiber); background: color-mix(in srgb, var(--fiber) 8%, var(--panel)); }
label.pon input[type=number] { width: 90px; padding: 4px 6px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 17, 39, .72); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 16px; width: min(760px, 100%); box-shadow: 0 24px 64px rgba(0, 0, 0, .45); border: 1px solid var(--line-2); }
.modal.wide { width: min(1100px, 100%); }
.modal-h { display: flex; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 500; flex: 1; }
.modal-b { padding: 20px 24px; max-height: 70vh; overflow-y: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }

pre.cli { background: #081127; color: #d6e0f5; border: 1px solid rgba(238, 242, 251, .08); font: 400 12.5px/20px var(--mono); padding: 14px 16px; border-radius: var(--radius-s); overflow: auto; max-height: 55vh; margin: 0; white-space: pre-wrap; word-break: break-word; }
pre.cli .err { color: #f4a3a5; }
pre.cli .cmd { color: #ffad4d; }
.result-line { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.result-line:last-child { border-bottom: none; }

.toast-box { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: #16264a; color: #eef2fb; padding: 12px 16px; border-radius: var(--radius-s); max-width: 420px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); border: 1px solid rgba(238, 242, 251, .1); border-left: 3px solid #4cc38a; }
.toast.err { border-left-color: #e5484d; }

.loading { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--fiber); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading { animation-duration: 3s; } * { transition: none !important; } }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.callout { padding: 12px 16px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--fiber) 8%, var(--panel)); border: 1px solid color-mix(in srgb, var(--fiber) 35%, transparent); margin-bottom: 16px; }
.callout.info { background: color-mix(in srgb, var(--aqua) 7%, var(--panel)); border-color: color-mix(in srgb, var(--aqua) 30%, transparent); }
.reason { color: var(--ink-2); font-size: 13px; }
.chart { width: 100%; height: 170px; }
.small { font-size: 12.5px; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: #081127; border-right: 1px solid rgba(238, 242, 251, .08); color: #eef2fb; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: 40px; line-height: 48px; margin: 0 0 16px; color: #eef2fb; font-weight: 500; letter-spacing: -.015em; max-width: 14ch; }
.login-art p { color: #a9b7d6; max-width: 44ch; font-size: 15px; line-height: 24px; }
.login-art svg { position: absolute; right: -40px; bottom: -30px; width: 520px; }
.login-box { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; line-height: 28px; font-weight: 500; }
.login-card .field { margin-top: 16px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 24px; height: 40px; }
.login-err { color: var(--crit); margin-top: 12px; min-height: 20px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s var(--ease); }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(8, 17, 39, .6); }
  .menu-btn { display: inline-flex; }
  .grid2 { grid-template-columns: 1fr; }
  .dash > .dw { grid-column: 1 / -1 !important; }
  .dw-rs { display: none; }
  .view { padding: 16px; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .kv { grid-template-columns: 1fr; }
}

/* assistente de VLAN */
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--fiber); color: var(--fiber-ink); font: 600 12.5px/1 var(--mono); flex: none; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 16px; cursor: pointer; background: var(--panel); transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.choice:hover { border-color: var(--line-2); }
.choice.sel { border-color: var(--fiber); background: color-mix(in srgb, var(--fiber) 7%, var(--panel)); box-shadow: inset 0 0 0 1px var(--fiber); }
.choice.off { opacity: .5; cursor: not-allowed; }
.choice input { margin-top: 2px; accent-color: var(--fiber); }
.choice b { display: block; margin-bottom: 2px; font-weight: 500; }
.choice span { color: var(--ink-2); font-size: 12.5px; }
.sub { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 999px; height: 32px; padding: 0 12px; cursor: pointer; font-size: 13px; background: var(--panel); }
.chip.sel { border-color: var(--fiber); background: color-mix(in srgb, var(--fiber) 9%, var(--panel)); }
.chip input { accent-color: var(--fiber); }
.chip .hint { font-size: 11.5px; }
.onu-pick { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.onu-pick table th { z-index: 1; }
.onu-pick select { padding: 4px 6px; min-width: 170px; }
.summary { font-size: 14.5px; line-height: 24px; }
.summary b { color: var(--ink); font-weight: 500; }
.sticky-foot { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; z-index: 3; border-top: 1px solid var(--line); }
mark { background: color-mix(in srgb, var(--fiber) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.login-art > div { position: relative; z-index: 1; }
.login-art > svg { opacity: .55; }
