/* ── Variáveis ─────────────────────────────────────────── */
:root {
  --yellow: #f4e400;
  --black:  #1a1a1a;
  --gray:   #c8c8c8;
  --light:  #f6f6f4;
  --white:  #ffffff;
  --gray100: #eeeeee;
  --gray500: #7a7a7a;
  --gray700: #4a4a4a;
  --red:    #721c24;
  --red-bg: #f8d7da;
  --green:  #155724;
  --green-bg: #d4edda;
  --warn:   #856404;
  --warn-bg: #fff3cd;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Base ──────────────────────────────────────────────── */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--light);
  color: var(--black);
  font-size: 14px;
  line-height: 1.4;
}

/* ── Header ────────────────────────────────────────────── */
header {
  background: var(--black);
  color: white;
  border-bottom: 3px solid var(--yellow);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 36px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}
header > div { flex: 1; }
header strong {
  display: block;
  color: var(--yellow);
  font-size: 15px;
  letter-spacing: -.01em;
}
header span {
  font-size: 11px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: .06em;
}
button.logout {
  background: transparent;
  color: white;
  border: 1px solid #555;
  box-shadow: none;
  padding: 8px 14px;
  font-size: 13px;
  transition: border-color .15s, color .15s;
}
button.logout:hover { border-color: white; color: white; }
.header-link {
  color: #aaa;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid #555;
  padding: 6px 12px;
  white-space: nowrap;
}
.header-link:hover { color: white; border-color: white; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  padding: 13px 36px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(-110%);
  transition: transform .22s ease;
}
.toast.show { transform: translateY(0); }
.toast.ok   { background: var(--green-bg); color: var(--green); border-bottom: 3px solid #28a745; }
.toast.err  { background: var(--red-bg);   color: var(--red);   border-bottom: 3px solid #dc3545; }
.toast.load { background: var(--warn-bg);  color: var(--warn);  border-bottom: 3px solid #ffc107; }
.toast-links { margin-left: auto; display: flex; gap: 12px; }
.toast-links a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap;
}

/* ── Layout principal ──────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 24px auto 60px;
  padding: 0 28px;
}

/* ── Dashboard ─────────────────────────────────────────── */
.dashboard-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.dash-card {
  background: var(--white);
  border: 1px solid var(--gray100);
  box-shadow: 4px 4px 0 var(--gray100);
  padding: 24px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.dash-card:hover,
.dash-card:focus-visible {
  border-color: var(--black);
  box-shadow: 5px 5px 0 var(--yellow);
  outline: none;
}
.dash-icon {
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--yellow);
  display: inline-block;
  width: max-content;
  padding: 5px 8px;
  margin-bottom: 16px;
}
.dash-card h2 { font-size: 20px; margin: 0 0 8px; }
.dash-card p  { font-size: 14px; line-height: 1.45; color: #555; margin: 0 0 20px; }
.dash-card button { align-self: flex-start; }

/* ── View – emissão ────────────────────────────────────── */
.app-view {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto;
  gap: 14px;
  align-items: start;
}
.left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.view-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 2px;
}
.view-head h1 { font-size: 22px; margin: 0; }
.view-head p  { margin: 3px 0 0; color: #666; font-size: 13px; }
.back-btn { font-size: 13px; white-space: nowrap; }

/* ── View – registros ──────────────────────────────────── */
.records-view { display: grid; gap: 14px; }

/* ── Painel ────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border: 1px solid var(--gray100);
  box-shadow: 3px 3px 0 var(--gray100);
}
.wide {
  grid-column: 2;
  grid-row: auto;
}
.title {
  background: var(--black);
  color: var(--yellow);
  font-family: monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 12px;
}
.title.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.panel > *:not(.title) { margin: 12px; }

/* ── Labels e inputs ───────────────────────────────────── */
label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #555;
  margin: 10px 0 4px;
  letter-spacing: .06em;
}
input[type="text"],
input[type="date"],
input[type="password"],
input:not([type="checkbox"]):not([type="file"]):not([type="radio"]) {
  width: 100%;
  border: 1px solid var(--gray);
  background: var(--light);
  padding: 9px 10px;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s, background .12s;
  font-family: inherit;
}
input:focus {
  outline: none;
  border-color: var(--black);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--yellow);
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Segmented control ─────────────────────────────────── */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.seg button {
  box-shadow: none;
  border: 1px solid var(--gray);
  border-left-width: 0;
  background: var(--white);
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: background .12s, border-color .12s;
  border-radius: 0;
}
.seg button:first-child { border-left-width: 1px; }
.seg button:hover:not(.active) { background: var(--light); border-color: var(--gray700); }
.seg button.active { background: var(--yellow); border-color: var(--black); }

/* ── Botões ────────────────────────────────────────────── */
button {
  cursor: pointer;
  border: 0;
  background: var(--yellow);
  font-weight: 700;
  padding: 11px 16px;
  box-shadow: 3px 3px 0 var(--black);
  font-family: inherit;
  font-size: 14px;
  transition: box-shadow .12s, transform .1s;
}
button:active:not(:disabled) {
  box-shadow: 1px 1px 0 var(--black);
  transform: translate(2px, 2px);
}
button:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}
button.ghost, button.small {
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 2px 2px 0 var(--black);
  font-size: 12px;
  padding: 7px 10px;
}
button.ghost:active:not(:disabled),
button.small:active:not(:disabled) {
  box-shadow: 0px 0px 0 var(--black);
  transform: translate(2px, 2px);
}

/* ── Toolbar trafos ────────────────────────────────────── */
.trafo-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.count-badge {
  background: var(--yellow);
  color: var(--black);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  font-family: monospace;
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Trafo item ─────────────────────────────────────────── */
.trafo {
  border-top: 1px solid var(--gray100);
  padding: 14px 12px 8px;
}
.trafo:first-child { border-top: 0; }
.trafo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tag {
  background: var(--yellow);
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  letter-spacing: .04em;
}
button.remove {
  background: transparent;
  color: #c00;
  border: 1px solid #f5c6cb;
  box-shadow: none;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}
button.remove:hover { background: var(--red-bg); border-color: #c00; }

/* ── Logo section ───────────────────────────────────────── */

/* ── Terceiro ───────────────────────────────────────────── */
.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  cursor: pointer;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
#terceiroBox { border-top: 1px solid var(--gray100); margin-top: 10px; padding-top: 2px; }

/* ── Actions (rodapé emissão) ───────────────────────────── */
.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 14px;
  align-items: stretch;
  justify-content: flex-end;
  background: var(--white);
  border: 1px solid var(--gray100);
  box-shadow: 3px 3px 0 var(--gray100);
  padding: 12px 14px;
}
#msg {
  flex: 1;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
#msg.ok   { color: var(--green); }
#msg.err  { color: var(--red); font-weight: 600; }
#msg.load { color: var(--warn); }
#msg a { color: inherit; font-weight: 700; text-decoration: underline; }
#emitir { min-width: 140px; font-size: 14px; }
#emitir.loading {
  background: var(--gray100);
  color: var(--gray700);
  box-shadow: none;
  cursor: wait;
}

/* ── Registros ──────────────────────────────────────────── */
.records-tools { padding-bottom: 4px; }
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.records { padding-bottom: 8px; }
.record {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--gray100);
  padding: 11px 14px;
  transition: background .1s;
}
.record:first-of-type { border-top: 0; }
.record:hover { background: var(--light); }
.record-main strong { font-size: 13px; display: block; }
.record-client { font-size: 13px; color: var(--black); font-weight: 600; margin-top: 1px; display: block; }
.record-meta { font-size: 11px; color: var(--gray500); margin-top: 3px; display: block; font-family: monospace; }
.record-detail { font-size: 12px; color: var(--gray700); line-height: 1.55; }
.record-detail span { display: block; }
.btn-pdf {
  background: var(--yellow);
  border: 0;
  box-shadow: 2px 2px 0 var(--black);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--black);
  font-family: inherit;
  display: inline-block;
  transition: box-shadow .1s, transform .1s;
}
.btn-pdf:hover {
  box-shadow: 3px 3px 0 var(--black);
}
.empty-state {
  padding: 32px 14px;
  text-align: center;
  color: var(--gray500);
  font-size: 13px;
}

/* ── Login ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--black);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--white);
  border-top: 4px solid var(--yellow);
  box-shadow: 8px 8px 0 rgba(244, 228, 0, .2);
}
.login-card .brand {
  background: var(--black);
  padding: 18px 20px;
  border-bottom: 1px solid #333;
}
.login-card .brand strong {
  display: block;
  color: var(--yellow);
  font-size: 16px;
  letter-spacing: -.01em;
}
.login-card .brand span {
  display: block;
  color: #aaa;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 3px;
}
.login-card form { padding: 22px 20px; }
.login-card label { margin-top: 14px; }
.login-card label:first-of-type { margin-top: 0; }
#loginMsg { margin-top: 12px; font-size: 13px; }
#loginMsg.err  { background: var(--red-bg);  color: var(--red);  padding: 10px; }
#loginMsg.load { background: var(--warn-bg); color: var(--warn); padding: 10px; }

/* ── Status badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  white-space: nowrap;
}
.badge-draft    { background: var(--gray100); color: var(--gray700); }
.badge-waiting  { background: var(--warn-bg); color: var(--warn); }
.badge-signed   { background: var(--green-bg); color: var(--green); }
.badge-prod     { background: #cfe2ff; color: #0a58ca; }
.badge-done     { background: #d4edda; color: #0f5132; border: 1px solid #badbcc; }
.badge-cancelled{ background: var(--red-bg); color: var(--red); }
.badge-role-admin   { background: var(--black); color: var(--yellow); }
.badge-role-vendedor{ background: #cfe2ff; color: #0a58ca; }
.badge-role-pcp     { background: #d4edda; color: var(--green); }

/* ── Orçamentos ──────────────────────────────────────────── */
.orc-view { display: grid; gap: 14px; }
.orc-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.orc-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px 18px;
  align-items: center;
  border-top: 1px solid var(--gray100);
  padding: 13px 14px;
  transition: background .1s;
}
.orc-card:first-of-type { border-top: 0; }
.orc-card:hover { background: var(--light); }
.orc-num { font-family: monospace; font-size: 11px; color: var(--gray500); white-space: nowrap; }
.orc-info strong { font-size: 14px; display: block; }
.orc-info span   { font-size: 12px; color: var(--gray500); display: block; margin-top: 2px; }
.orc-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn-action {
  background: var(--white);
  border: 1px solid var(--gray);
  box-shadow: 1px 1px 0 var(--gray);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn-action:hover { border-color: var(--black); box-shadow: 2px 2px 0 var(--black); }
.btn-action.primary { background: var(--yellow); border-color: var(--black); }
.btn-action.danger { color: var(--red); border-color: #f5c6cb; }
.btn-action.danger:hover { background: var(--red-bg); border-color: var(--red); }

/* Producao */
.producao-view { max-width: 1280px; display: grid; gap: 14px; }
.production-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.production-column {
  background: var(--white);
  border: 1px solid var(--gray100);
  box-shadow: 3px 3px 0 var(--gray100);
  min-height: 360px;
}
.production-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}
.production-card {
  border: 1px solid var(--gray100);
  background: var(--light);
  padding: 12px;
  display: grid;
  gap: 8px;
}
.production-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.production-card-head strong {
  font-family: monospace;
  font-size: 11px;
  color: var(--gray700);
}
.production-card h2 {
  font-size: 15px;
  margin: 0;
  line-height: 1.25;
}
.production-client {
  margin: 0;
  color: var(--gray700);
  font-size: 13px;
  font-weight: 700;
}
.production-meta {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 3px 8px;
  margin: 0;
  font-size: 12px;
}
.production-meta dt {
  color: var(--gray500);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
}
.production-meta dd { margin: 0; }
.production-note {
  margin: 0;
  color: var(--gray700);
  background: var(--white);
  border-left: 3px solid var(--yellow);
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
  min-height: 36px;
}
.empty-state.compact { padding: 18px 10px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--white);
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-top: 4px solid var(--yellow);
  box-shadow: 8px 8px 0 rgba(0,0,0,.2);
}
.modal-head {
  background: var(--black);
  color: var(--yellow);
  padding: 12px 16px;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body { padding: 16px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--gray100); display: flex; gap: 10px; justify-content: flex-end; }
.btn-close {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--yellow);
  font-size: 18px;
  padding: 0 4px;
  cursor: pointer;
  line-height: 1;
}
.btn-close:hover { color: white; }

/* ── Página pública (assinar / verificar) ────────────────── */
.public-page { background: var(--light); min-height: 100vh; }
.public-header {
  background: var(--black);
  border-bottom: 3px solid var(--yellow);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.public-header img { width: 40px; height: 40px; object-fit: contain; }
.public-header strong { color: var(--yellow); font-size: 15px; display: block; }
.public-header span { color: #aaa; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.public-main { max-width: 860px; margin: 28px auto 60px; padding: 0 20px; display: grid; gap: 16px; }
.public-card {
  background: var(--white);
  border: 1px solid var(--gray100);
  box-shadow: 3px 3px 0 var(--gray100);
}
.public-title {
  background: var(--black);
  color: var(--yellow);
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 9px 14px;
}
.public-body { padding: 16px 14px; }
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.info-grid dt { font-weight: 700; font-size: 10px; text-transform: uppercase; color: var(--gray500); letter-spacing: .05em; padding-top: 2px; }
.info-grid dd { margin: 0; word-break: break-all; }
.pdf-frame { width: 100%; height: 480px; border: 1px solid var(--gray100); }
.sign-result {
  text-align: center;
  padding: 32px 14px;
}
.sign-result .icon { font-size: 48px; margin-bottom: 12px; }
.sign-result h2 { font-size: 22px; margin: 0 0 8px; }
.sign-result p { color: var(--gray700); margin: 0 0 20px; }
.verify-valid { border-left: 5px solid #28a745; }
.verify-invalid { border-left: 5px solid #dc3545; }

/* ── Usuários ────────────────────────────────────────────── */
.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--gray100);
  padding: 11px 14px;
}
.user-row:first-of-type { border-top: 0; }
.user-info strong { font-size: 14px; display: block; }
.user-info span   { font-size: 12px; color: var(--gray500); }
.user-inactive { opacity: .5; }

/* ── select ─────────────────────────────────────────────── */
select {
  width: 100%;
  border: 1px solid var(--gray);
  background: var(--light);
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a4a4a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
select:focus {
  outline: none;
  border-color: var(--black);
  background-color: var(--white);
  box-shadow: 3px 3px 0 var(--yellow);
}
textarea {
  width: 100%;
  border: 1px solid var(--gray);
  background: var(--light);
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
}
textarea:focus {
  outline: none;
  border-color: var(--black);
  background: var(--white);
  box-shadow: 3px 3px 0 var(--yellow);
}

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 960px) {
  main { padding: 0 14px; }
  .app-view { grid-template-columns: 1fr; }
  .wide { grid-column: auto; grid-row: auto; }
  .actions { grid-column: auto; }
  header { padding: 12px 14px; }
  .view-head { align-items: flex-start; }
  .production-board { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .dashboard-view { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .search-row { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
  .trafo-toolbar { justify-content: flex-start; }
}
