:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --panel-2: #1e2438;
  --line: #2a3150;
  --txt: #e7eaf3;
  --muted: #9aa3c0;
  --accent: #6c8cff;
  --ok: #3ecf8e;
  --warn: #ff6b6b;
  --raw: #f0a35e;
  --clean: #56b3f5;
  --posted: #3ecf8e;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .3px; margin-bottom: 24px; }
.brand span { color: var(--accent); }
.brand.big { font-size: 30px; text-align: center; margin-bottom: 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: var(--muted); padding: 10px 12px; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.sidebar nav a:hover { background: var(--panel-2); color: var(--txt); }
.sidebar nav a.on { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.side-foot .who { font-size: 12px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.side-foot .logout { font-size: 13px; color: var(--warn); }
.content { flex: 1; padding: 28px 34px; max-width: 1200px; }

h1 { font-size: 26px; margin: 0 0 20px; }
h2 { font-size: 18px; margin: 30px 0 14px; color: var(--muted); }
.count { color: var(--muted); font-weight: 400; font-size: 18px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.card-label { color: var(--muted); font-size: 13px; }
.card-num { font-size: 34px; font-weight: 800; margin: 4px 0; }
.card-num .of { font-size: 16px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.card-num.warn { color: var(--warn); }
.card-sub { color: var(--muted); font-size: 12px; }

/* Estoque */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.stock-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stock-head { font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.stock-total { color: var(--muted); font-size: 12px; font-weight: 500; }
.stages { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stage { flex: 1; text-align: center; background: var(--panel-2); border-radius: 11px; padding: 14px 6px; border: 1px solid var(--line); }
.stage-num { font-size: 26px; font-weight: 800; }
.stage-lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }
.s-raw .stage-num { color: var(--raw); }
.s-clean .stage-num { color: var(--clean); }
.s-posted .stage-num { color: var(--posted); }
.arrow { color: var(--muted); font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 18px; }
.soon { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 40px; text-align: center; color: var(--muted); }

/* Tabelas */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
table.grid th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; padding: 12px 14px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
.fbid { font-size: 11px; color: var(--muted); }
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.on { background: rgba(62,207,142,.15); color: var(--ok); }
.badge.off { background: rgba(154,163,192,.15); color: var(--muted); }

/* Forms */
input, button { font-family: inherit; font-size: 14px; }
input[type=text], input[type=number], input[type=email], input[type=password] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 8px 10px;
}
input.mini { width: 60px; } input.wide { width: 190px; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 4px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ok { background: var(--ok); } .btn.warn { background: var(--warn); }

/* Flash */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 8px; font-size: 14px; }
.flash.ok { background: rgba(62,207,142,.15); color: var(--ok); }
.flash.erro { background: rgba(255,107,107,.15); color: var(--warn); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px; width: 360px; display: flex; flex-direction: column; }
.login-card .sub { color: var(--muted); text-align: center; font-size: 13px; margin: 4px 0 20px; }
.login-card label { font-size: 13px; color: var(--muted); margin: 10px 0 5px; }
.login-card button { margin-top: 20px; background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 12px; font-weight: 700; cursor: pointer; }

/* Mídia / Estoque */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { padding: 8px 16px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 20px; }
.panel-box h3 { margin: 0 0 14px; font-size: 15px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row select, .row input[type=file] { background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); border-radius: 8px; padding: 8px 10px; }
.stage-tabs { display: flex; gap: 10px; margin: 18px 0; }
.stab { flex: 1; text-align: center; padding: 14px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.stab b { display: block; font-size: 24px; color: var(--txt); margin-top: 4px; }
.stab.on { border-width: 2px; }
.stab.s-raw.on { border-color: var(--raw); } .stab.s-clean.on { border-color: var(--clean); } .stab.s-posted.on { border-color: var(--posted); }
.faxina { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.right { text-align: right; } td.right form { margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* Avatar da página */
.pag-cell { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--line); flex-shrink: 0;
}
.avatar.sem-foto { background: var(--panel-2) linear-gradient(135deg, var(--panel-2), var(--line)); }

/* ─────────────────────────────────────────────────────────────
   RESPONSIVO — tablet e celular
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* Menu vira barra superior rolável */
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; flex-wrap: wrap; gap: 10px;
    padding: 12px 14px; border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand { margin-bottom: 0; font-size: 19px; }
  .sidebar nav {
    flex-direction: row; order: 3; width: 100%;
    overflow-x: auto; gap: 6px; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .side-foot {
    margin-top: 0; margin-left: auto; border-top: none; padding-top: 0;
    display: flex; align-items: center; gap: 12px;
  }
  .side-foot .who { display: none; }
  .content { padding: 18px 14px; }
  h1 { font-size: 21px; }

  /* Tabelas viram cartões empilhados */
  table.grid, table.grid thead, table.grid tbody,
  table.grid tr, table.grid th, table.grid td { display: block; width: 100%; }
  table.grid thead { display: none; }
  table.grid tr {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; margin-bottom: 12px; padding: 6px 4px;
  }
  table.grid td { border-bottom: 1px solid var(--line); padding: 10px 14px; }
  table.grid tr td:last-child { border-bottom: none; }
  table.grid td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 11px; text-transform: uppercase;
    color: var(--muted); margin-bottom: 4px; letter-spacing: .4px;
  }
  td.right { text-align: left; }
  td.right form { margin-left: 0; margin-right: 6px; }

  /* Blocos e formulários */
  .stages { flex-wrap: wrap; }
  .arrow { display: none; }
  .stage { min-width: 28%; }
  .stage-tabs { flex-direction: column; gap: 8px; }
  .row { flex-direction: column; align-items: stretch; }
  .row > * { width: 100%; }
  .row .btn { width: 100%; }
  .inline { display: flex; }
  input.wide { width: 100%; }
  .login-card { width: 92%; max-width: 380px; padding: 26px; }
  pre { font-size: 11px; overflow-x: auto; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card-num { font-size: 26px; }
  .stock-grid { grid-template-columns: 1fr; }
  .brand { font-size: 17px; }
  .content { padding: 14px 10px; }
}
