:root {
  --brand: #1f5ea8;
  --brand-dark: #16467f;
  --brand-red: #e3262d;
  --sidebar-w: 250px;
  --bg: #f3f5f9;
}
body { background: var(--bg); font-size: .925rem; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: #0f2c52; color: #c9d6e8; display: flex; flex-direction: column; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
}
.sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: #0f2c52; }
.sidebar-brand { background: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand img { max-height: 54px; max-width: 200px; }
.sidebar-brand .btn-close { filter: invert(1); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7d93b3; padding: 10px 20px 3px; }
.sidebar .nav-link { color: #d6e1f0; display: flex; align-items: center; gap: 10px; padding: 6px 20px; border-left: 3px solid transparent; }
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #4aa3ff; font-weight: 600; }
.sidebar-foot { padding: 10px 20px; color: #7d93b3; border-top: 1px solid rgba(255,255,255,.08); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e3e8ef; padding: 10px 20px; display: flex; align-items: center; position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.15rem; margin: 0; font-weight: 600; color: #1d2b3f; }
.top-search { width: 300px; }
.content { padding: 20px; }
@media (max-width: 576px) { .content { padding: 12px; } }

.card { border: 1px solid #e3e8ef; border-radius: 10px; box-shadow: 0 1px 2px rgba(16,30,54,.04); }
.card-header { background: #fff; border-bottom: 1px solid #edf0f5; font-weight: 600; }
.table { --bs-table-hover-bg: #f2f7ff; }
.table > :not(caption) > * > * { padding: .5rem .6rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #5a6b82; background: #f7f9fc; white-space: nowrap; }
.table-sm > :not(caption) > * > * { padding: .35rem .5rem; }
.form-label { font-size: .8rem; font-weight: 600; color: #44546a; margin-bottom: .25rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); }

/* KPIs */
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px; height: 100%; min-height: 98px; }
.kpi .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi .val { font-size: 1.55rem; font-weight: 700; line-height: 1.1; color: #172437; }
.kpi .lbl { font-size: .8rem; color: #66768c; }
a.kpi-link { text-decoration: none; color: inherit; display: block; height: 100%; }
a.kpi-link > .card { height: 100%; }   /* todos os quadrados com a mesma altura */
a.kpi-link .card { transition: transform .1s, box-shadow .1s; }
a.kpi-link:hover .card { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,30,54,.1); }
.bg-soft-blue { background: #e7f0fc; color: var(--brand); }
.bg-soft-green { background: #e4f6ec; color: #198754; }
.bg-soft-gray { background: #eef0f3; color: #6c757d; }
.bg-soft-orange { background: #fff1e0; color: #d9730d; }
.bg-soft-red { background: #fde8e8; color: #dc3545; }

/* celulares muito estreitos: encolhe um pouco para o rotulo caber em 2 linhas */
@media (max-width: 339.98px) {
  .kpi { gap: 10px; padding: 14px; }
  .kpi .ic { width: 40px; height: 40px; font-size: 1.2rem; }
  .kpi .val { font-size: 1.35rem; }
  .kpi .lbl { font-size: .72rem; }
}

.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .b .s { width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b .s.out { background: #e3262d; opacity: .85; }
.bars .b .s.in { background: #1f9d55; opacity: .85; }
.bars .b .d { font-size: .62rem; color: #8090a5; margin-top: 3px; white-space: nowrap; }
.bars .pair { display: flex; gap: 1px; width: 100%; align-items: flex-end; height: 100%; }

/* Produtos */
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #f0f2f5; border: 1px solid #e5e8ee; }
.thumb-lg { width: 64px; height: 64px; }
.foto-prev { width: 100%; max-width: 280px; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: #f6f7f9; border: 1px solid #e5e8ee; }
.qtd-zero { color: #dc3545; font-weight: 700; }
.qtd-baixo { color: #d9730d; font-weight: 700; }

/* Movimentação (baixa/entrada) */
.mode-tabs .nav-link { font-weight: 600; }
.terminal { background: #0e1726; border-radius: 10px; padding: 16px; color: #cfe3ff; }
.terminal label { color: #8fb3e3; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.terminal input { background: #16233a; border: 1px solid #2b3d5c; color: #fff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.35rem; }
.terminal input:focus { background: #1a2a45; color: #fff; border-color: #4aa3ff; box-shadow: 0 0 0 .2rem rgba(74,163,255,.25); }
.terminal input:disabled { background: #111b2c; color: #5d6f8c; }
.terminal .prod-info { min-height: 64px; display: flex; gap: 12px; align-items: center; }
.terminal .prod-info img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; background: #fff; }
.terminal .hint { color: #6f86a8; font-size: .78rem; }
.terminal .msg-erro { color: #ff8a8a; font-weight: 600; }
.terminal-log { max-height: 120px; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; color: #9bd59b; }

.search-wrap { position: relative; }
.search-results { position: absolute; z-index: 1050; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #d8dee8; border-radius: 0 0 8px 8px; max-height: 360px; overflow-y: auto; box-shadow: 0 10px 24px rgba(16,30,54,.15); }
.search-results .it { display: flex; gap: 10px; align-items: center; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #f0f2f5; }
.search-results .it:hover, .search-results .it.sel { background: #eaf3ff; }
.search-results .it.inativo { opacity: .55; }
.search-results .cod { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--brand); }

.cart td { vertical-align: middle; }
.cart .qtd-input { width: 90px; }
.cart tr.excede { background: #fff0f0; }
.total-box { background: #0f2c52; color: #fff; border-radius: 10px; padding: 12px 16px; }
.total-box .n { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.motivos .btn-check + .btn { min-width: 110px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding-top: 14px; padding-bottom: 6px; z-index: 5; }

.perm-grid .form-check { margin-bottom: .35rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* Login (mesmo visual do sistema Diamante Azul) */
body.login-page { margin: 0; background: #fff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }
body.login-page *, body.login-page *::before, body.login-page *::after { box-sizing: border-box; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fff 0%, #EAF1FF 100%); padding: 20px; }
.login-box { background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(10,61,145,.18);
  padding: 34px 30px; width: 100%; max-width: 380px; text-align: center; }
.login-box .disco { width: 150px; height: 150px; margin: 0 auto 10px; display: block; animation: girar 4s linear infinite; }
@keyframes girar { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .login-box .disco { animation: none; } }
.login-box .logo { width: 72%; margin: 6px auto 2px; display: block; }
.login-box .sub { color: #5A6472; margin: 2px 0 18px; font-size: 14px; }
.login-box label { display: block; text-align: left; font-size: 13px; color: #5A6472; margin: 10px 0 4px; }
.login-box input { width: 100%; padding: 12px; border: 1px solid #E2E6EE; border-radius: 10px; font-size: 15px; font-family: inherit; }
.login-box input:focus { outline: 2px solid #2F6BE0; outline-offset: 1px; border-color: #2F6BE0; }
.login-box .btn { display: block; width: 100%; margin-top: 18px; padding: 13px; background: #0A3D91; color: #fff;
  border: 0; border-radius: 9px; font-weight: 700; font-size: 14px; font-family: inherit; cursor: pointer; letter-spacing: .3px; }
.login-box .btn:hover { opacity: .93; }
.login-box .erro { color: #E2231A; font-size: 13px; margin-top: 10px; }

@media print {
  .sidebar, .topbar, .no-print, .sticky-actions { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
#area-produtos.bloqueada .tab-content { opacity: .45; pointer-events: none; }
@media (min-width: 992px) {
  .sidebar.offcanvas-lg { background-color: #0f2c52 !important; }
}
@media (max-width: 767.98px) {
  .sticky-actions { position: static; background: none; }
  .sticky-actions .total-box { flex: 1; }
  .sticky-actions #btn-confirmar { width: 100%; }
}
