:root{
  --asoft:#e8675b;
  --asoft-dark:#d9554a;
  --asoft-soft:#fff1ef;
  --ink:#172033;
  --muted:#697386;
  --line:#e8ebf1;
  --bg:#f5f7fb;
  --white:#fff;
  --green:#16a36a;
  --green-soft:#eaf8f2;
  --amber:#e29225;
  --amber-soft:#fff7e8;
  --shadow:0 12px 35px rgba(26,35,55,.08);
  --radius:20px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Inter,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink)}
body{padding-bottom:84px}
button,input{font:inherit}
button{cursor:pointer}
.hidden{display:none!important}

.topbar{
  position:sticky;top:0;z-index:50;
  height:68px;padding:0 18px;
  display:flex;align-items:center;justify-content:space-between;
  background:rgba(255,255,255,.96);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(12px)
}
.brand{display:flex;align-items:center;gap:11px}
.brand-logo{width:44px;height:44px;object-fit:contain}
.brand div{display:flex;flex-direction:column;line-height:1.1}
.brand strong{font-size:17px}
.brand span{font-size:12px;color:var(--muted);margin-top:4px}
.icon-btn{
  border:1px solid var(--line);background:#fff;border-radius:14px;
  display:flex;align-items:center;gap:7px;padding:9px 11px;color:var(--muted)
}
.device-dot{width:8px;height:8px;border-radius:50%;background:var(--green)}
#deviceShort{max-width:80px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

main{max-width:760px;margin:0 auto}
.screen{display:none;padding:20px 16px 28px}
.screen.active{display:block}
.hero{
  background:linear-gradient(140deg,var(--asoft),var(--asoft-dark));
  color:#fff;border-radius:26px;padding:23px 21px;
  display:flex;justify-content:space-between;gap:16px;align-items:flex-start;
  box-shadow:0 18px 35px rgba(232,103,91,.23)
}
.eyebrow{
  font-size:11px;font-weight:800;letter-spacing:.11em;text-transform:uppercase;
  opacity:.78
}
.hero h1{font-size:25px;line-height:1.08;margin:7px 0 8px}
.hero p{font-size:14px;margin:0;opacity:.88;max-width:300px;line-height:1.4}
.status-badge{
  flex:none;display:flex;align-items:center;gap:7px;border-radius:999px;
  font-size:11px;font-weight:700;background:rgba(255,255,255,.18);padding:8px 10px
}
.status-badge span{width:8px;height:8px;border-radius:50%;background:#fff}
.status-badge.offline span{background:#ffd36e}
.status-badge.online span{background:#a8ffd9}
.section-title{
  display:flex;align-items:flex-end;justify-content:space-between;gap:16px;
  margin:24px 3px 12px
}
.section-title h2{font-size:18px;margin:0 0 4px}
.section-title p{font-size:13px;color:var(--muted);margin:0}
.text-btn{border:0;background:transparent;color:var(--asoft-dark);font-weight:700;padding:8px}
.inventory-list{display:grid;gap:11px}
.inv-card{
  border:1px solid var(--line);background:#fff;border-radius:18px;padding:16px;
  display:grid;grid-template-columns:1fr auto;gap:12px;box-shadow:0 5px 18px rgba(25,35,55,.035)
}
.inv-card:active{transform:scale(.995)}
.inv-main{min-width:0}
.inv-top{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.type-badge{
  border-radius:999px;padding:5px 8px;background:var(--asoft-soft);
  color:var(--asoft-dark);font-size:10px;font-weight:800
}
.inv-id{font-size:12px;color:var(--muted)}
.inv-card h3{font-size:16px;margin:0 0 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.inv-card p{font-size:12px;color:var(--muted);margin:0}
.inv-arrow{
  align-self:center;width:36px;height:36px;border-radius:50%;
  display:grid;place-items:center;background:var(--bg);color:var(--asoft);font-size:22px;font-weight:600
}
.skeleton-card{
  height:96px;border-radius:18px;
  background:linear-gradient(90deg,#f0f2f5 25%,#fafbfc 37%,#f0f2f5 63%);
  background-size:400% 100%;animation:shimmer 1.4s infinite
}
@keyframes shimmer{0%{background-position:100% 0}100%{background-position:0 0}}

.count-head{display:grid;grid-template-columns:42px 1fr auto;gap:10px;align-items:center;margin-bottom:14px}
.back-btn{
  width:42px;height:42px;border:1px solid var(--line);border-radius:14px;background:#fff;
  color:var(--ink);font-size:28px;line-height:1
}
.count-head-info{display:flex;flex-direction:column;min-width:0}
.count-head-info strong{font-size:16px;margin-top:4px}
.count-head-info small{color:var(--muted);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill{align-self:flex-start;font-size:9px;font-weight:900;letter-spacing:.08em;color:var(--asoft-dark);background:var(--asoft-soft);padding:4px 7px;border-radius:999px}
.download-btn{border:1px solid var(--line);background:#fff;border-radius:12px;padding:10px;color:var(--muted);font-size:12px;font-weight:700}

.scanner-card{background:#fff;border:1px solid var(--line);border-radius:22px;overflow:hidden;box-shadow:var(--shadow)}
.camera-wrap{height:0;overflow:hidden;background:#111;position:relative;transition:.2s}
.camera-wrap.on{height:265px}
.camera-wrap video{width:100%;height:100%;object-fit:cover}
.scan-overlay{position:absolute;inset:0;display:grid;place-items:center;align-content:center;gap:12px;background:linear-gradient(rgba(0,0,0,.16),rgba(0,0,0,.16));color:#fff;font-size:12px}
.scan-frame{width:min(78%,310px);height:105px;border:2px solid rgba(255,255,255,.95);border-radius:16px;box-shadow:0 0 0 999px rgba(0,0,0,.28)}
.scanner-actions{padding:16px}
.primary-btn,.secondary-btn,.save-btn{
  border-radius:14px;border:0;font-weight:800;min-height:46px
}
.primary-btn{background:var(--asoft);color:#fff;padding:0 17px}
.camera-btn{width:100%;display:flex;align-items:center;justify-content:center;gap:9px}
.camera-symbol{font-size:19px}
.or{text-align:center;color:#a0a7b2;font-size:11px;text-transform:uppercase;margin:12px 0}
.manual-row{display:grid;grid-template-columns:1fr auto;gap:8px}
.manual-row input,.modal-card input{
  width:100%;border:1px solid #dfe3ea;border-radius:14px;background:#fbfcfd;
  padding:0 14px;height:48px;outline:none;color:var(--ink)
}
.manual-row input:focus,.modal-card input:focus{border-color:var(--asoft);box-shadow:0 0 0 3px rgba(232,103,91,.1)}
.secondary-btn{background:#f2f4f7;color:#364153;padding:0 16px;border:1px solid var(--line)}

.product-card{margin-top:14px;background:#fff;border:1px solid var(--line);border-radius:22px;padding:17px;box-shadow:var(--shadow)}
.product-top{display:grid;grid-template-columns:48px 1fr auto;gap:12px;align-items:start}
.product-icon{width:48px;height:48px;border-radius:14px;display:grid;place-items:center;background:var(--asoft-soft);color:var(--asoft);font-size:22px}
.product-info{min-width:0}
.product-info small{font-size:11px;color:var(--muted)}
.product-info h3{font-size:17px;line-height:1.2;margin:3px 0 7px}
.product-info span{font-size:12px;color:var(--muted)}
.found-badge{font-size:9px;font-weight:800;color:var(--green);background:var(--green-soft);padding:5px 7px;border-radius:999px}
.qty-area{margin-top:17px;border-top:1px solid var(--line);padding-top:15px}
.qty-label{display:block;font-size:12px;color:var(--muted);font-weight:700;margin-bottom:8px}
.qty-control{display:grid;grid-template-columns:50px 1fr 50px;gap:8px}
.qty-control button{height:50px;border:1px solid var(--line);background:#f7f8fa;border-radius:14px;font-size:23px;color:var(--ink)}
.qty-control input{height:50px;border:1px solid #dfe3ea;border-radius:14px;text-align:center;font-size:21px;font-weight:800;outline:none;width:100%}
.save-btn{width:100%;margin-top:10px;background:var(--asoft);color:#fff;box-shadow:0 8px 18px rgba(232,103,91,.2)}

.feedback{margin-top:12px;padding:13px 14px;border-radius:15px;font-size:13px;font-weight:700}
.feedback.success{background:var(--green-soft);color:#0a8151}
.feedback.error{background:#fff0ef;color:#c8453a}

.live-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:14px}
.summary-item{background:#fff;border:1px solid var(--line);border-radius:16px;padding:12px;text-align:center}
.summary-item span{display:block;font-size:10px;text-transform:uppercase;color:var(--muted);font-weight:800}
.summary-item strong{display:block;font-size:20px;margin-top:4px}
.summary-item.warning strong{color:var(--amber)}
.sync-panel{
  width:100%;margin-top:10px;border:1px solid #f0dfb8;background:var(--amber-soft);
  border-radius:16px;padding:14px;text-align:left;display:flex;justify-content:space-between;align-items:center;color:#875b12
}
.sync-panel div{display:flex;flex-direction:column}
.sync-panel strong{font-size:13px}
.sync-panel span{font-size:11px;margin-top:3px}
.sync-arrow{font-size:22px!important}

.status-title{align-items:flex-start}
.status-title h2{font-size:23px;margin-top:5px}
.status-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.metric{background:#fff;border:1px solid var(--line);border-radius:18px;padding:16px}
.metric.wide{grid-column:1/-1}
.metric span{font-size:11px;color:var(--muted);text-transform:uppercase;font-weight:800}
.metric strong{display:block;font-size:25px;margin-top:7px}
.devices-title{font-size:16px;margin:24px 2px 10px}
.device-list{display:grid;gap:9px}
.device-row{background:#fff;border:1px solid var(--line);border-radius:16px;padding:14px;display:flex;align-items:center;justify-content:space-between;gap:12px}
.device-row strong{font-size:13px}
.device-row span{font-size:11px;color:var(--muted)}
.empty-state{border:1px dashed #d9dee7;border-radius:20px;padding:35px 18px;text-align:center;color:var(--muted);background:rgba(255,255,255,.55)}

.bottom-nav{
  position:fixed;z-index:60;left:50%;bottom:0;transform:translateX(-50%);
  width:min(760px,100%);height:72px;padding:7px 22px calc(7px + env(safe-area-inset-bottom));
  background:rgba(255,255,255,.97);border-top:1px solid var(--line);
  display:grid;grid-template-columns:repeat(3,1fr);backdrop-filter:blur(14px)
}
.nav-btn{border:0;background:transparent;color:#8a93a2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px}
.nav-btn>span{font-size:21px;line-height:1}
.nav-btn small{font-size:10px;font-weight:700}
.nav-btn.active{color:var(--asoft)}
.scan-nav{width:36px;height:31px;display:grid;place-items:center;background:var(--asoft);color:white;border-radius:11px;font-size:16px!important}
.nav-btn.active .scan-nav{box-shadow:0 6px 14px rgba(232,103,91,.26)}

.modal{position:fixed;z-index:100;inset:0;background:rgba(18,27,42,.48);display:flex;align-items:flex-end;justify-content:center}
.modal-card{width:min(760px,100%);background:#fff;border-radius:24px 24px 0 0;padding:12px 19px 24px}
.modal-handle{width:42px;height:5px;background:#d8dde5;border-radius:99px;margin:0 auto 18px}
.modal-card h3{margin:0 0 5px}
.modal-card p{margin:0 0 18px;color:var(--muted);font-size:13px}
.modal-card label{display:block;font-size:12px;font-weight:800;margin-bottom:7px}
.modal-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:13px}
.toast{
  position:fixed;z-index:120;left:50%;bottom:88px;transform:translateX(-50%);
  max-width:calc(100% - 32px);background:#202938;color:#fff;border-radius:14px;padding:11px 14px;
  font-size:12px;box-shadow:var(--shadow)
}

@media(min-width:700px){
  .screen{padding:28px 24px}
  .hero{padding:29px 27px}
  .hero h1{font-size:30px}
  .camera-wrap.on{height:330px}
}


/* Configuração do servidor + criação de balanço */
.top-actions{display:flex;align-items:center;gap:7px}
.server-dot{width:8px;height:8px;border-radius:50%;background:var(--asoft)}
#serverShort{max-width:88px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.section-actions{display:flex;align-items:center;gap:7px}
.new-inventory-btn{
  border:0;background:var(--asoft);color:#fff;border-radius:12px;
  min-height:38px;padding:0 12px;font-size:12px;font-weight:800;
  box-shadow:0 6px 14px rgba(232,103,91,.18)
}

.server-config-row{
  display:grid;grid-template-columns:auto minmax(0,1fr) auto 74px;
  align-items:center;gap:7px;background:#fbfcfd;border:1px solid #dfe3ea;
  border-radius:14px;padding:0 10px
}
.server-config-row span{font-size:12px;color:var(--muted);font-weight:700}
.server-config-row input{
  border:0!important;background:transparent!important;box-shadow:none!important;
  padding:0 3px!important
}
.server-help{display:block;color:var(--muted);font-size:11px;margin-top:6px}
.server-test-result{margin-top:12px;padding:11px 12px;border-radius:12px;font-size:12px;font-weight:700}
.server-test-result.checking{background:#f3f5f8;color:#667085}
.server-test-result.success{background:var(--green-soft);color:#0a8151}
.server-test-result.error{background:#fff0ef;color:#c8453a}
.modal-actions.three{grid-template-columns:1fr 1fr 1fr}

.eyebrow.coral{color:var(--asoft-dark);opacity:1}
.balance-type-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin:8px 0 16px}
.balance-type{
  border:1px solid var(--line);background:#fff;border-radius:14px;
  min-height:72px;padding:10px 7px;color:var(--ink)
}
.balance-type strong{display:block;font-size:12px}
.balance-type small{display:block;font-size:9px;color:var(--muted);margin-top:4px;line-height:1.25}
.balance-type.active{
  border-color:var(--asoft);background:var(--asoft-soft);color:var(--asoft-dark);
  box-shadow:0 0 0 2px rgba(232,103,91,.07)
}
.form-field{margin-bottom:14px}
.modal-card select{
  width:100%;height:48px;border:1px solid #dfe3ea;background:#fbfcfd;color:var(--ink);
  border-radius:14px;padding:0 12px;outline:none;margin-bottom:14px
}
.modal-card select:focus{border-color:var(--asoft);box-shadow:0 0 0 3px rgba(232,103,91,.1)}

@media(max-width:520px){
  .topbar{padding:0 11px}
  .top-actions{gap:4px}
  .icon-btn{padding:8px}
  #serverShort,#deviceShort{max-width:58px;font-size:10px}
  .section-title{align-items:flex-start}
  .section-actions{flex-direction:column;align-items:flex-end;gap:2px}
  .new-inventory-btn{min-height:34px;padding:0 9px}
  .balance-type-grid{gap:5px}
}


/* Instalação do PWA */
.install-card{
  width:100%;
  margin-top:14px;
  border:1px solid #f1d4cf;
  background:linear-gradient(135deg,#fff7f5,#ffffff);
  border-radius:18px;
  padding:13px 14px;
  display:grid;
  grid-template-columns:42px 1fr auto;
  align-items:center;
  gap:10px;
  text-align:left;
  color:var(--ink);
  box-shadow:0 6px 18px rgba(25,35,55,.04);
}
.install-icon{
  width:42px;height:42px;border-radius:13px;
  display:grid;place-items:center;
  background:var(--asoft);
  color:#fff;
  font-size:21px;font-weight:900
}
.install-info{display:flex;flex-direction:column;min-width:0}
.install-info strong{font-size:13px}
.install-info span{font-size:10px;color:var(--muted);margin-top:3px}
.install-action{
  color:var(--asoft-dark);
  font-size:11px;
  font-weight:900;
  background:var(--asoft-soft);
  padding:8px 10px;
  border-radius:999px
}


/* Servidor local — versão compacta */
.server-config-card{
  width:100%;
  margin-top:14px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:16px;
  padding:12px 13px;
  display:grid;
  grid-template-columns:38px minmax(0,1fr) auto;
  align-items:center;
  gap:11px;
  text-align:left;
  color:var(--ink);
  box-shadow:0 4px 14px rgba(25,35,55,.035);
  transition:.16s ease;
}
.server-config-card:active{
  transform:scale(.992);
  background:#fcfcfd;
}
.server-config-status{
  width:38px;
  height:38px;
  border-radius:12px;
  display:grid;
  place-items:center;
  background:#f6f7f9;
}
.server-config-dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background:#d86b61;
  box-shadow:0 0 0 5px rgba(216,107,97,.10);
}
.server-config-card.configured .server-config-status{
  background:var(--green-soft);
}
.server-config-card.configured .server-config-dot{
  background:var(--green);
  box-shadow:0 0 0 5px rgba(22,163,106,.10);
}
.server-config-info{
  display:flex;
  flex-direction:column;
  min-width:0;
}
.server-config-label{
  font-size:10px;
  line-height:1;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--muted);
  font-weight:800;
  margin-bottom:5px;
}
.server-config-info strong{
  font-size:13px;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.server-config-action{
  display:flex;
  align-items:center;
  gap:5px;
  color:var(--asoft-dark);
  font-size:11px;
  font-weight:800;
  padding-left:8px;
}
.server-config-action b{
  font-size:20px;
  line-height:1;
  font-weight:500;
}

@media(max-width:520px){
  .server-config-card{
    margin-top:12px;
    padding:11px 12px;
    grid-template-columns:36px minmax(0,1fr) auto;
    gap:9px;
  }
  .server-config-status{
    width:36px;
    height:36px;
  }
  .server-config-action span{
    display:none;
  }
}
