:root {
  --azul: #2f5b9d;
  --azul-escuro: #1f4e79;
  --azul-claro: #dce6f5;
  --borda: #d7dce5;
  --texto: #1c2430;
  --cinza: #6b7686;
  --vermelho: #dc2626;
  --verde: #16a34a;
  --fundo: #f2f5f9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 14px;
}

.mobilebar { display: none; }

.tb-side {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 225px;
  background: var(--azul-escuro);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 12px;
  z-index: 90;
  overflow-y: auto;
}

.tb-head { padding: 0 8px; }

.brand { font-size: 19px; font-weight: 700; letter-spacing: .5px; }

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
}

.tb-side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.tb-side nav a {
  color: #cfdcf0;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.tb-side nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.tb-side nav a.active { background: rgba(255,255,255,.2); color: #fff; }

.userchip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: 12px;
  font-size: 13px;
}
.userchip .uname { font-weight: 600; }
.userchip .urole { font-size: 11px; background: rgba(255,255,255,.18); padding: 2px 9px; border-radius: 99px; align-self: flex-start; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 85;
}

.container { max-width: 1220px; margin: 0 auto 0 225px; padding: 22px 18px 60px; }

h1 { font-size: 21px; margin: 6px 0 16px; }
h2 { font-size: 14px; margin: 0 0 12px; color: var(--azul-escuro); text-transform: uppercase; letter-spacing: .4px; }

.panel {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.span3 { grid-column: span 3; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; color: var(--cinza); }
label .cap { display: block; line-height: 1.25; }
label.obr .cap::after { content: " *"; color: var(--vermelho); font-weight: 700; }

input, select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--borda);
  border-radius: 7px;
  background: #fff;
  color: var(--texto);
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); border-color: var(--azul); }
input:disabled, select:disabled, textarea:disabled { background: #eef1f6; color: var(--cinza); }

textarea { resize: vertical; min-height: 60px; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e5e9f0;
  color: var(--texto);
}

.btn.primary { background: var(--azul); color: #fff; }
.btn.primary:hover { background: var(--azul-escuro); }
.btn.ok { background: var(--verde); color: #fff; }
.btn.warn { background: var(--vermelho); color: #fff; }
.btn.ghost { background: #fff; border-color: var(--borda); }
.btn.ghost:hover { border-color: var(--azul); color: var(--azul); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

.form-actions { display: flex; gap: 10px; margin-top: 16px; align-items: center; }

table { width: 100%; border-collapse: collapse; background: #fff; }

th {
  background: var(--azul);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

td { padding: 8px 10px; border-bottom: 1px solid var(--borda); vertical-align: middle; }

tr:hover td { background: #f7f9fc; }
td .btn { margin-right: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--borda); border-radius: 10px; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.b-ABERTO { background: #b45309; }
.b-LIBERADO { background: #2563eb; }
.b-PRODUCAO { background: #7c3aed; }
.b-FINALIZADO { background: #059669; }
.b-EXPEDICAO { background: #0891b2; }
.b-CONCLUIDO { background: #15803d; }
.b-CANCELADO { background: #9ca3af; }
.i-AGUARDANDO { background: #b45309; }
.i-PRODUCAO { background: #7c3aed; }
.i-FINALIZADO { background: #059669; }
.i-EXPEDICAO { background: #0891b2; }

.prioridade { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.p-ALTA { background: #fee2e2; color: #b91c1c; }
.p-NORMAL { background: #e2e8f0; color: #475569; }
.p-BAIXA { background: #f1f5f9; color: #94a3b8; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px; margin-bottom: 18px; }

.card {
  border-radius: 10px;
  padding: 14px 16px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 76px;
}

.card .n { font-size: 26px; font-weight: 800; line-height: 1; }
.card .t { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; opacity: .9; }
.c-TOTAL { background: var(--azul-escuro); }
.c-ABERTO { background: #b45309; }
.c-LIBERADO { background: #2563eb; }
.c-PRODUCAO { background: #7c3aed; }
.c-FINALIZADO { background: #059669; }
.c-EXPEDICAO { background: #0891b2; }
.c-CONCLUIDO { background: #15803d; }
.c-CANCELADO { background: #9ca3af; }
.c-NEUTRO { background: #475569; }

.aviso {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.hidden { display: none !important; }
.req { color: var(--vermelho); }
.hint { color: var(--cinza); font-size: 12px; margin: 6px 0 0; }
.err-msg { color: var(--vermelho); font-weight: 600; min-height: 18px; margin: 10px 0 0; }

.autocomplete { position: relative; }
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15,35,70,.14);
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
}

.suggestions div { padding: 9px 12px; cursor: pointer; }
.suggestions div:hover { background: var(--azul-claro); }
.suggestions .none { color: var(--cinza); cursor: default; }
.suggestions .none:hover { background: none; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 11px; }
.checkbox { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 9px; }

.img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.img-item { position: relative; width: 150px; height: 150px; border: 1px solid var(--borda); border-radius: 8px; overflow: hidden; background: #fff; }
.img-item img { width: 100%; height: 100%; object-fit: contain; }
.img-item .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--vermelho);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}
.filelabel { cursor: pointer; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2430;
  color: #fff;
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.err { background: var(--vermelho); }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, var(--azul-escuro), #35619f);
}

.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 34px 30px;
  width: 340px;
  box-shadow: 0 18px 50px rgba(10,25,55,.35);
}

.login-card h1 { text-align: center; color: var(--azul-escuro); margin: 0; }
.login-card .sub { text-align: center; color: var(--cinza); margin: 4px 0 22px; font-size: 13px; }
.login-card label { margin-bottom: 12px; }

.os-sheet { background: #fff; border: 1px solid #9db2cf; border-radius: 8px; overflow: hidden; }

.sheet-title {
  background: var(--azul);
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 10px;
}

.sheet-info { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-bottom: 1px solid #9db2cf; }
.sheet-info > div { display: grid; grid-template-columns: 130px 1fr; border-bottom: 1px solid #cfd8e6; }
.sheet-info > div:nth-last-child(-n+2) { border-bottom: none; }
.sheet-info .lbl { background: var(--azul-claro); font-weight: 700; padding: 7px 10px; border-right: 1px solid #cfd8e6; font-size: 12px; }
.sheet-info .val { padding: 7px 10px; font-size: 13px; }

.sec-bar {
  background: var(--azul);
  color: #fff;
  text-align: center;
  font-weight: 800;
  letter-spacing: .8px;
  padding: 7px;
  font-size: 14px;
}

.sheet-table th { background: var(--azul-escuro); border: 1px solid #45659b; text-align: center; }
.sheet-table td { border: 1px solid #b9c6da; text-align: center; }
.sheet-table td.left { text-align: left; }

.obs-block { padding: 12px; min-height: 48px; white-space: pre-wrap; border-bottom: 1px solid #9db2cf; }

.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 7px 4px; border-bottom: 1px dashed var(--borda); font-size: 13px; }
.hist .who { font-weight: 700; color: var(--azul-escuro); }
.hist .quando { color: var(--cinza); font-size: 12px; }

.item-form .grid { margin-bottom: 10px; }
.item-form input, .item-form select { width: 100%; }
.item-form label { font-size: 12px; }

.lista-itens { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.item-linha {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f7f9fc;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 9px 12px;
  flex-wrap: wrap;
}
.item-linha.editando { border-color: var(--azul); background: var(--azul-claro); }
.item-linha .il-main { font-weight: 700; font-size: 14px; flex: 1 1 220px; }
.item-linha .il-dim { color: var(--cinza); font-size: 13px; }
.item-linha .il-acoes { margin-left: auto; display: flex; gap: 6px; }

.chip {
  background: #e2e8f0;
  color: #334155;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.lista-arquivos { display: flex; flex-direction: column; gap: 6px; }

.arq-linha {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f7f9fc;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.arq-linha .nome { font-weight: 600; word-break: break-all; }
.arq-linha a { text-decoration: none; }
.arq-linha .btn { margin-left: auto; }

.logo-box {
  width: 100%;
  height: 110px;
  border: 2px dashed var(--borda);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

.sheet-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.sheet-logo {
  height: 44px;
  max-width: 170px;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-f {
  border: 1px solid var(--borda);
  background: #fff;
  border-radius: 99px;
  padding: 6px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--cinza);
}
.chip-f:hover { border-color: var(--azul); color: var(--azul); }
.chip-f.ativo { background: var(--azul); color: #fff; border-color: var(--azul); }

.fila-titulo {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--cinza);
}
.fila-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--borda);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  flex-wrap: wrap;
}
.fila-item .fi-main { flex: 1 1 250px; }
.fi-os { font-weight: 700; }
.fi-os a { color: var(--azul-escuro); text-decoration: none; }
.fi-prod { font-size: 13px; color: var(--cinza); margin-top: 2px; }
.prazo-tag {
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  background: #fff7ed;
  border-radius: 99px;
  padding: 2px 8px;
  margin-left: 6px;
  white-space: nowrap;
}
.prazo-tag.atrasado { color: #b91c1c; background: #fee2e2; }

@media (max-width: 900px) {
  .btn.sm { padding: 10px 14px; font-size: 13px; }
  .fila-item .btn { flex: 1 1 100%; justify-content: center; padding: 12px; }
}

.emp-rodape {
  border-top: 1px solid #9db2cf;
  padding: 9px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #45659b;
}

.matriz td, .matriz th { text-align: center; }
.matriz td:first-child, .matriz th:first-child { text-align: left; }

@media (max-width: 900px) {
  .container { margin-left: 0; padding-top: 64px; }
  .mobilebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: var(--azul-escuro);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 0 6px;
    z-index: 95;
  }
  .mobilebar .brand { font-size: 17px; }
  .menu-btn { display: inline-flex; }
  .tb-side { width: 265px; transform: translateX(-105%); transition: transform .22s ease; }
  .tb-side.open { transform: none; box-shadow: 14px 0 40px rgba(10,25,55,.35); }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .userchip { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .userchip .btn { margin-left: auto; }
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .span3 { grid-column: span 2; }
  .g2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .sheet-info { grid-template-columns: 1fr; }
  .sheet-info > div:nth-last-child(-n+2) { border-bottom: 1px solid #cfd8e6; }
}

@media (max-width: 560px) {
  .g3, .g4 { grid-template-columns: 1fr; }
  .span3 { grid-column: span 1; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { background: #fff; }
  .tb-side, .mobilebar, .scrim, .no-print, .aviso, .toast, .filters { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .os-sheet { border: 1px solid #333; border-radius: 0; }
  .panel { border: none; padding: 0; margin: 0; }
}
