:root {
  --bg: #f5f7fc; --surface: #ffffff; --text: #1e2a3b; --muted: #6a7790;
  --line: #e7ecf5; --line-strong: #d7dfec;
  --brand: #3f6fe8; --brand-2: #5f8df8; --brand-dark: #2f5bd0; --brand-soft: #e8efff;
  --ok: #168a55; --ok-bg: #e2f7ec; --warn: #9a6200; --warn-bg: #fff2d6;
  --danger: #c2362c; --danger-bg: #ffe6e3; --info: #2f5bd6; --info-bg: #e7eeff; --grey-bg: #eef1f7;
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(30, 42, 59, .04), 0 8px 24px rgba(30, 42, 59, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text);
  background: linear-gradient(180deg, #f1f5fe 0%, #f8fafd 320px) fixed, var(--bg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.015em; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 1.8rem 0 .7rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.4rem 3rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }

/* ---- menu lateral ---- */
body.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
}
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1.2rem 1.2rem 1rem; font-weight: 700; font-size: 1.08rem; color: var(--text); }
.sidebar .brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 12px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); box-shadow: 0 4px 12px rgba(63, 111, 232, .3); font-size: 1.05rem; }
.sidebar nav { flex: 1; padding: .3rem .8rem 1rem; }
.nav-group { color: #8a96ad; font-size: .68rem; font-weight: 650; text-transform: uppercase; letter-spacing: .09em; padding: 1.2rem .8rem .35rem; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; color: #3b4960; padding: .5rem .8rem; border-radius: 12px; transition: background .15s, color .15s; }
.sidebar nav a:hover { background: var(--grey-bg); text-decoration: none; }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 650; }
.sidebar .ico { width: 1.4rem; text-align: center; flex-shrink: 0; }
.user-box { display: flex; align-items: center; gap: .75rem; margin: .4rem .8rem .9rem; padding: .7rem .8rem; border-radius: 16px; background: #f5f8ff; border: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.avatar { width: 2.3rem; height: 2.3rem; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--brand-dark); background: var(--brand-soft); }
.user-box .nome { color: var(--text); font-weight: 650; display: block; word-break: break-word; line-height: 1.25; }
.user-box .links { display: flex; gap: .7rem; margin-top: .15rem; }
.main-col { flex: 1; min-width: 0; }
.mobilebar, .backdrop { display: none; }
@media (max-width: 860px) {
  body.layout { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .22s ease, box-shadow .22s ease; box-shadow: none; background: #fff; }
  body.menu-aberto .sidebar { transform: none; box-shadow: 0 0 40px rgba(30, 42, 59, .2); }
  body.menu-aberto .backdrop { display: block; position: fixed; inset: 0; background: rgba(30, 42, 59, .3); z-index: 20; }
  .mobilebar { display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; font-weight: 700; }
  .mobilebar button { background: #fff; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 1.15rem; line-height: 1; padding: .4rem .8rem; cursor: pointer; color: var(--text); }
  .container { padding: 1.1rem 1rem 3rem; }
}

form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
button.link:hover { text-decoration: underline; }

/* ---- avisos ---- */
.flash { padding: .8rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; box-shadow: var(--shadow); }
.flash.success { background: var(--ok-bg); border-color: #bfe8d1; color: #136b45; }
.flash.error, .flash.danger { background: var(--danger-bg); border-color: #f7c9c4; color: #a52d24; }
.flash.warning { background: var(--warn-bg); border-color: #f4dfa8; color: #86540a; }
.flash.info { background: #eef4ff; border-color: #c9dafc; color: #1d4ea8; }
.flash ul { margin: .4rem 0 0 1.2rem; }

/* ---- cartões e painéis ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .15rem; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
a.card:hover { text-decoration: none; transform: translateY(-2px); border-color: #c9d8fb; box-shadow: 0 12px 30px rgba(63, 111, 232, .12); }
.card .num { font-size: 2rem; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.card > span:last-child { color: var(--muted); font-size: .9rem; }
.card.ok .num { color: var(--ok); } .card.warn .num { color: #b97300; }
.card.info .num { color: var(--info); } .card.danger .num { color: var(--danger); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .73rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: #7b88a0; background: #f8faff; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #fafcff; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.atrasada td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.inativo td { color: var(--muted); }
.muted { color: var(--muted); font-size: .9rem; }
.empty { padding: 1.6rem; color: var(--muted); text-align: center; }

/* ---- selos ---- */
.badge { display: inline-block; padding: .15rem .7rem; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.badge.disponivel, .badge.est-ok, .badge.mov-entrada { background: var(--ok-bg); color: var(--ok); }
.badge.emprestado, .badge.est-baixo, .badge.mov-saida { background: var(--warn-bg); color: var(--warn); }
.badge.manutencao, .badge.mov-ajuste { background: var(--info-bg); color: var(--info); }
.badge.baixado { background: var(--grey-bg); color: var(--muted); }
.badge.atrasado, .badge.est-zerado { background: var(--danger-bg); color: var(--danger); }

/* ---- formulários ---- */
label { display: block; font-weight: 600; font-size: .86rem; color: #3b4960; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .62rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #a3adc0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(95, 141, 248, .18); }
select { appearance: none; -webkit-appearance: none; padding-right: 2.4rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236a7790' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .95rem center; }
textarea { min-height: 90px; resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 1.1rem; }
.grid .full { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1.1rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters > div { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
.check-inline { display: flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0; padding-bottom: .6rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.toolbar h1 { margin: 0; }
.toolbar > div { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- botões arredondados ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; border: 1px solid transparent;
  padding: .56rem 1.25rem; border-radius: 999px; font: inherit; font-weight: 650; line-height: 1.3;
  box-shadow: 0 3px 10px rgba(63, 111, 232, .26); transition: transform .12s, box-shadow .12s, background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 18px rgba(63, 111, 232, .32); }
.btn:active { transform: none; box-shadow: 0 2px 6px rgba(63, 111, 232, .25); }
.btn.secondary { background: #fff; color: #33425a; border-color: var(--line-strong); box-shadow: none; }
.btn.secondary:hover { background: var(--brand-soft); border-color: #c5d4fb; color: var(--brand-dark); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #f08a80, #dc4a3f); box-shadow: 0 3px 10px rgba(220, 74, 63, .25); }
.btn.danger:hover { box-shadow: 0 8px 18px rgba(220, 74, 63, .3); }
.btn.small { padding: .28rem .9rem; font-size: .84rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- listas de seleção (saída / devolução / estoque) ---- */
.check-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: .7rem; background: #fff; }
.check-item { display: flex; gap: .8rem; align-items: flex-start; padding: .65rem 1rem; border-bottom: 1px solid var(--line); font-weight: 400; margin: 0; cursor: pointer; color: var(--text); transition: background .12s; }
.check-item:last-child { border-bottom: 0; }
.check-item:hover { background: #f5f8ff; }
.check-item input[type=checkbox], .check-item input[type=radio] { margin-top: .3rem; }
.check-item .extra { margin-left: auto; text-align: right; font-size: .85rem; color: var(--muted); }
.check-item .manut { font-size: .8rem; display: block; margin-top: .2rem; }

dl.info { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); } dl.info dd { margin: 0; }
.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; padding: 1rem; color: var(--muted); }
.login-box { max-width: 400px; margin: 9vh auto 0; }
.login-box h1 { text-align: center; }
.login-box .panel { padding: 1.6rem; box-shadow: 0 20px 50px rgba(63, 111, 232, .12); }
.login-box .btn { width: 100%; }
.stack > * + * { margin-top: .9rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.actions-row input[type=text] { min-width: 220px; }
.saldo-grande { font-size: 2.3rem; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.saldo-grande small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.qtd-pos { color: var(--ok); font-weight: 650; } .qtd-neg { color: #b97300; font-weight: 650; }
@media (max-width: 600px) { dl.info { grid-template-columns: 1fr; } .card .num { font-size: 1.7rem; } }

/* Fotos */
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: #f3f6fb; flex: none; }
.thumb.sm { width: 40px; height: 40px; border-radius: 10px; }
.thumb-vazio { display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; opacity: .45; }
.foto-linha { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.foto-previa { width: 120px; height: 120px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); }
.foto-previa.sm { width: 72px; height: 72px; border-radius: 10px; }
.foto-previa[hidden] { display: none; }
.detalhe-flex { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.detalhe-flex .info { flex: 1; min-width: 240px; }
.foto-detalhe { width: 200px; max-width: 100%; border-radius: 16px; border: 1px solid var(--line); display: block; }
.check-item.col { flex-direction: column; gap: .5rem; cursor: default; }
.check-main { display: flex; gap: .8rem; align-items: flex-start; width: 100%; cursor: pointer; margin: 0; font-weight: 400; color: var(--text); }
.check-main .thumb { margin-top: 0; }
.foto-mov { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; padding-left: 1.8rem; font-size: .85rem; }
.foto-mov label { margin: 0; font-weight: 500; }
.foto-mov input[type=file] { max-width: 260px; }
.foto-mov .manut { margin-left: auto; font-weight: 400; }
td .thumb { display: block; }

/* Logo */
.sidebar .brand { justify-content: center; }
.logo-img { display: block; height: 3rem; width: auto; max-width: 100%; }
.mobilebar .logo-img { height: 2rem; }
.logo-login { display: block; height: 5.5rem; width: auto; margin: 0 auto 1rem; }
.login-box h1 { font-size: 1.15rem; color: var(--muted); font-weight: 600; }

.user-box .links button.link[hidden] { display: none; }
.user-box .links button.link:disabled { color: var(--muted); cursor: default; }

/* Abas de administração */
.abas { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.1rem; padding: .35rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; box-shadow: var(--shadow); }
.abas a { padding: .45rem .95rem; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.abas a:hover { text-decoration: none; background: var(--brand-soft); color: var(--brand-dark); }
.abas a.ativa { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; }
@media (max-width: 600px) { .abas { border-radius: 18px; } }
.user-box .links { flex-wrap: wrap; }
.user-box .links button.link { flex-basis: 100%; text-align: left; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Impressão */
.print-only { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff !important; }
  .sidebar, .mobilebar, .backdrop, .no-print, .flash { display: none !important; }
  body.layout { display: block; }
  .container { padding: 0 !important; max-width: none !important; }
  .print-only { display: block; }
  .cab-impressao { margin-bottom: .6rem; }
  .cab-impressao img { height: 3.2rem; width: auto; display: block; }
  .table-wrap { box-shadow: none !important; border: 1px solid #cfd6e4; overflow: visible !important; break-inside: auto; }
  table { font-size: 10pt; }
  tr { break-inside: avoid; }
  .toolbar { break-after: avoid; }
}
