:root{
  --bg:#0a0e17;--bg2:#0f1524;--card:#131b2e;--line:#1e2a44;
  --brand:#3b82f6;--brand2:#06b6d4;--grad:linear-gradient(135deg,#3b82f6,#06b6d4);
  --text:#eef2f9;--muted:#9fb0cc;--ok:#22c55e;--off:#64748b;--danger:#ef4444;--radius:14px;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Inter',system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);line-height:1.55;-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
.wrap{max-width:1040px;margin:0 auto;padding:0 22px}

/* topbar */
.top{position:sticky;top:0;z-index:5;background:rgba(10,14,23,.85);backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.top .bar{display:flex;align-items:center;justify-content:space-between;height:62px}
.brand{display:flex;align-items:center;gap:11px;font-weight:800;font-size:18px}
.logo{width:34px;height:34px;border-radius:9px;background:var(--grad);display:grid;place-items:center;color:#fff;font-weight:800;font-size:15px;box-shadow:0 5px 16px rgba(59,130,246,.4)}
.brand small{display:block;font-size:10px;font-weight:500;color:var(--muted);letter-spacing:.08em;text-transform:uppercase;margin-top:-2px}
.top nav{display:flex;align-items:center;gap:18px;font-size:14px;color:var(--muted)}
.top nav a:hover{color:var(--text)}

/* buttons */
.btn{display:inline-flex;align-items:center;gap:8px;font-weight:600;font-size:14px;padding:10px 18px;border-radius:9px;cursor:pointer;border:none;transition:transform .15s,box-shadow .2s,background .2s;font-family:inherit}
.btn-primary{background:var(--grad);color:#fff;box-shadow:0 6px 18px rgba(59,130,246,.35)}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 9px 22px rgba(59,130,246,.5)}
.btn-ghost{background:transparent;color:var(--text);border:1px solid var(--line)}
.btn-ghost:hover{border-color:var(--brand)}
.btn-danger{background:transparent;color:var(--danger);border:1px solid rgba(239,68,68,.4)}
.btn-sm{padding:7px 13px;font-size:13px}

/* layout */
main{padding:34px 0 60px}
.page-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:26px;flex-wrap:wrap}
.page-head h1{font-size:26px;font-weight:800;letter-spacing:-.02em}
.page-head p{color:var(--muted);font-size:14px;margin-top:3px}

/* cards / table */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:22px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}
.client{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:20px;transition:transform .18s,border-color .18s;display:block}
.client:hover{transform:translateY(-3px);border-color:rgba(59,130,246,.45)}
.client h3{font-size:17px;font-weight:700;margin-bottom:6px}
.client .desc{color:var(--muted);font-size:13px;min-height:18px}
.client .meta{margin-top:14px;display:flex;gap:14px;color:var(--muted);font-size:13px}

.empty{text-align:center;padding:60px 20px;color:var(--muted)}
.empty svg{width:54px;height:54px;stroke:var(--line);margin-bottom:16px}

/* device list */
.dev{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border:1px solid var(--line);border-radius:11px;background:var(--bg2);margin-bottom:10px}
.dev .name{display:flex;align-items:center;gap:11px;font-weight:600}
.status{display:inline-flex;align-items:center;gap:7px;font-size:13px;color:var(--muted)}
.dot{width:9px;height:9px;border-radius:50%}
.dot.on{background:var(--ok);box-shadow:0 0 9px var(--ok)}
.dot.off{background:var(--off)}

/* forms */
form.stack{display:flex;flex-direction:column;gap:16px;max-width:520px}
label{font-size:14px;font-weight:600;display:block;margin-bottom:7px}
label .hint{font-weight:400;color:var(--muted);font-size:12px}
input[type=text],input[type=email],input[type=password]{width:100%;padding:11px 13px;background:var(--bg2);border:1px solid var(--line);border-radius:9px;color:var(--text);font-size:15px;font-family:inherit}
input:focus{outline:none;border-color:var(--brand)}

/* alerts */
.alert{padding:13px 16px;border-radius:10px;font-size:14px;margin-bottom:20px}
.alert-err{background:rgba(239,68,68,.12);border:1px solid rgba(239,68,68,.35);color:#fecaca}
.alert-ok{background:rgba(34,197,94,.12);border:1px solid rgba(34,197,94,.35);color:#bbf7d0}
.creds{background:var(--bg2);border:1px solid var(--line);border-radius:11px;padding:18px;margin:18px 0}
.creds .row{display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:14px}
.creds .row:last-child{border-bottom:none}
.creds code{background:#0a1120;padding:3px 9px;border-radius:6px;color:var(--brand2);font-size:14px}
.linkbox{word-break:break-all;background:#0a1120;border:1px solid var(--line);border-radius:9px;padding:12px 14px;font-size:13px;color:var(--brand2);margin-top:8px}

/* login */
.login-wrap{min-height:100vh;display:grid;place-items:center;padding:20px}
.login-card{width:100%;max-width:380px;background:var(--card);border:1px solid var(--line);border-radius:18px;padding:34px}
.login-card .brand{justify-content:center;margin-bottom:8px}
.login-card h1{text-align:center;font-size:20px;margin-bottom:4px}
.login-card p.sub{text-align:center;color:var(--muted);font-size:13px;margin-bottom:24px}
.muted{color:var(--muted)}
.mt{margin-top:22px}

/* ============ APP SHELL (portal do cliente) ============ */
.app{display:grid;grid-template-columns:248px 1fr;min-height:100vh}
.sidebar{background:var(--bg2);border-right:1px solid var(--line);padding:22px 16px;display:flex;flex-direction:column;gap:6px;position:sticky;top:0;height:100vh}
.sidebar .brand{padding:4px 8px 20px}
.side-link{display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:10px;color:var(--muted);font-weight:500;font-size:14.5px;transition:background .15s,color .15s}
.side-link svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:2}
.side-link:hover{background:rgba(59,130,246,.08);color:var(--text)}
.side-link.active{background:var(--grad);color:#fff;box-shadow:0 6px 16px rgba(59,130,246,.35)}
.side-sep{flex:1}
.side-foot{padding:12px 13px;border-top:1px solid var(--line);color:var(--muted);font-size:13px}
.main{min-width:0;display:flex;flex-direction:column}
.apptop{height:62px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 26px;position:sticky;top:0;background:rgba(10,14,23,.85);backdrop-filter:blur(10px);z-index:5}
.apptop .who{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:14px}
.avatar{width:32px;height:32px;border-radius:50%;background:var(--grad);display:grid;place-items:center;color:#fff;font-weight:700;font-size:13px}
.content{padding:28px 26px 60px;max-width:1080px;width:100%}

/* metrics */
.metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px;margin-bottom:26px}
.metric{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:20px}
.metric .mlabel{color:var(--muted);font-size:13px;display:flex;align-items:center;gap:8px;margin-bottom:10px}
.metric .mlabel svg{width:16px;height:16px;stroke:var(--brand2);fill:none;stroke-width:2}
.metric .mval{font-size:32px;font-weight:800;letter-spacing:-.02em;line-height:1}
.metric .msub{color:var(--muted);font-size:12px;margin-top:6px}
.metric.ok .mval{color:var(--ok)} .metric.off .mval{color:var(--off)}

/* table */
.tbl{width:100%;border-collapse:collapse;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.tbl th{text-align:left;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:13px 16px;border-bottom:1px solid var(--line);font-weight:600}
.tbl td{padding:13px 16px;border-bottom:1px solid var(--line);font-size:14px}
.tbl tr:last-child td{border-bottom:none}
.tbl tr:hover td{background:rgba(59,130,246,.04)}
.pill-status{display:inline-flex;align-items:center;gap:7px;font-size:13px}
.sec-title{font-size:15px;font-weight:700;margin:26px 0 12px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
.chk{width:18px;height:18px;accent-color:var(--brand);cursor:pointer}
.badge{display:inline-block;padding:3px 9px;border-radius:999px;font-size:12px;font-weight:600;background:rgba(59,130,246,.14);color:#bcd4ff}

@media(max-width:820px){
  .app{grid-template-columns:1fr}
  .sidebar{position:static;height:auto;flex-direction:row;flex-wrap:wrap;gap:6px}
  .sidebar .brand{width:100%;padding:4px 8px 12px}
  .side-sep,.side-foot{display:none}
  .side-link{flex:1;justify-content:center}
}

/* ============ MODAL / POPUP ============ */
.modal-overlay{position:fixed;inset:0;background:rgba(5,8,15,.7);backdrop-filter:blur(3px);display:none;align-items:flex-start;justify-content:center;z-index:60;padding:60px 20px;overflow:auto}
.modal-overlay.open{display:flex}
.modal{background:var(--card);border:1px solid var(--line);border-radius:16px;width:100%;max-width:460px;padding:28px;position:relative;box-shadow:0 24px 70px rgba(0,0,0,.5)}
.modal h2{font-size:19px;font-weight:800;letter-spacing:-.02em;margin-bottom:4px}
.modal p.sub{color:var(--muted);font-size:13px;margin-bottom:20px}
.modal-close{position:absolute;top:16px;right:16px;width:34px;height:34px;border-radius:9px;background:var(--bg2);border:1px solid var(--line);color:var(--muted);cursor:pointer;font-size:20px;line-height:1;display:grid;place-items:center;transition:.15s}
.modal-close:hover{color:#fff;border-color:var(--brand);background:rgba(59,130,246,.12)}

/* ============ MINIATURAS (thumbnails de acesso) ============ */
.thumbs{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:16px;margin-bottom:28px}
.thumb-card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;transition:transform .18s,border-color .18s}
.thumb-card:hover{transform:translateY(-3px);border-color:rgba(59,130,246,.45)}
.thumb-img{width:100%;aspect-ratio:16/10;object-fit:cover;background:#0a1120;display:block}
.thumb-ph{width:100%;aspect-ratio:16/10;background:#0a1120;display:grid;place-items:center;color:var(--off)}
.thumb-ph svg{width:40px;height:40px;stroke:var(--line);fill:none;stroke-width:1.5}
.thumb-body{padding:12px 14px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.thumb-body .tn{min-width:0}
.thumb-body .tn strong{display:block;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thumb-body .tn span{font-size:12px;color:var(--muted)}
/* mini thumb na lista de maquinas */
.mini-thumb{width:56px;height:36px;border-radius:6px;object-fit:cover;background:#0a1120;border:1px solid var(--line);vertical-align:middle;margin-right:11px}
.mini-ph{width:56px;height:36px;border-radius:6px;background:#0a1120;border:1px solid var(--line);display:inline-grid;place-items:center;vertical-align:middle;margin-right:11px}
.mini-ph svg{width:18px;height:18px;stroke:var(--off);fill:none;stroke-width:2}

/* ============ ICONES (sem emojis) ============ */
.btn svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;flex:none;stroke-linecap:round;stroke-linejoin:round}
.ico{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;flex:none;stroke-linecap:round;stroke-linejoin:round;vertical-align:-3px}

/* ============ SELETOR SEGMENTADO (tipo de cliente) ============ */
.segmented{display:inline-flex;gap:6px;background:var(--bg2);border:1px solid var(--line);border-radius:11px;padding:5px}
.segmented .seg{display:inline-flex;align-items:center;gap:8px;cursor:pointer;padding:9px 16px;border-radius:8px;font-size:14px;font-weight:600;color:var(--muted);user-select:none;transition:.15s}
.segmented .seg input{position:absolute;opacity:0;width:0;height:0}
.segmented .seg.on{background:var(--grad);color:#fff}
.segmented .seg:not(.on):hover{color:var(--text)}

/* Submenu da sidebar (ex.: Configuracoes > API) */
.side-link.side-sub{margin-left:16px;padding-left:12px;border-left:1px solid var(--line);font-size:14px;opacity:.92}
.side-link.side-sub svg{width:15px;height:15px}

/* Submenu horizontal (Configuracoes) */
.subnav{display:flex;gap:6px;border-bottom:1px solid var(--line);margin:0 0 18px}
.subnav-item{padding:9px 15px;font-size:14px;font-weight:600;color:var(--muted);border-bottom:2px solid transparent;margin-bottom:-1px}
.subnav-item:hover{color:var(--text)}
.subnav-item.active{color:var(--text);border-bottom-color:var(--brand)}

/* Editor da landingpage (codigo + preview) */
.landing-edit{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.landing-code textarea{width:100%;height:62vh;min-height:380px;background:#0b1120;border:1px solid var(--line);border-radius:10px;color:#dbeafe;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12.5px;line-height:1.5;padding:12px;resize:vertical;white-space:pre;overflow:auto}
.landing-prev iframe{width:100%;height:62vh;min-height:380px;background:#fff;border:1px solid var(--line);border-radius:10px}
@media(max-width:900px){.landing-edit{grid-template-columns:1fr}}

/* Faixa superior removida em todo o sistema (a pedido) */
.apptop{display:none !important}
