:root {
  --ink: #17211d;
  --muted: #66746d;
  --line: #dce4df;
  --paper: #ffffff;
  --bg: #eef3ef;
  --primary: #136b4b;
  --primary-dark: #0d4b36;
  --accent: #d6a442;
  --danger: #a73535;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(19, 107, 75, .10), transparent 35%),
    linear-gradient(315deg, rgba(214, 164, 66, .14), transparent 30%),
    var(--bg);
  font-family: "Trebuchet MS", Verdana, sans-serif;
}
a { color: inherit; text-decoration: none; }

.topbar {
  position: fixed;
  top: 18px;
  left: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  width: 250px;
  align-items: center;
  justify-content: flex-start;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 45px rgba(23, 33, 29, .08);
}
.brand { display: flex; align-items: center; gap: 10px; width: 100%; font-weight: 800; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  background: var(--primary);
  border-radius: 8px;
  letter-spacing: 0;
}
.brand-mark.large { width: 58px; height: 58px; font-size: 20px; }
.brand-text { font-size: 18px; }
.nav { display: flex; width: 100%; align-items: stretch; gap: 8px; flex-direction: column; }
.nav a, .link-button, .nav-disabled {
  border: 0;
  background: transparent;
  width: 100%;
  padding: 11px 12px;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav a.active, .nav a:hover, .link-button:hover { color: var(--primary); background: #e8f2ed; }
.nav-disabled { opacity: .55; cursor: default; }
.nav form { margin-top: auto; }

.shell { width: min(1120px, calc(100% - 318px)); margin: 28px 28px 28px 290px; }
.shell.narrow { width: min(760px, calc(100% - 318px)); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 33, 29, .08);
}
.auth-card { width: min(430px, 100%); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 4px; }
h2 { font-size: 20px; margin-bottom: 0; }
.eyebrow { color: var(--primary); font-size: 12px; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; margin-bottom: 5px; }
.page-title { margin-bottom: 22px; }
.page-title.split, .panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel { padding: 20px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.metric {
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metric strong { font-size: 28px; }

.form { display: grid; gap: 14px; }
.form.grid { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 13px;
  font: inherit;
  background: #fbfdfb;
}
input:focus, textarea:focus { outline: 2px solid rgba(19, 107, 75, .22); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 24px; }
.check input { width: auto; }
.check span { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
.button.primary { color: white; border-color: var(--primary); background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.danger { color: white; border-color: var(--danger); background: var(--danger); }
.button.full { width: 100%; }
.danger-form { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.actions { text-align: right; font-weight: 800; color: var(--primary); }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status.ok { background: #e2f4e9; color: #12643d; }
.status.muted { background: #eef0ef; color: #68736d; }
.status.rascunho { background: #eef0ef; color: #68736d; }
.status.enviado { background: #e8f2ff; color: #245ea8; }
.status.aprovado { background: #e2f4e9; color: #12643d; }
.status.recusado { background: #fbe8e8; color: #8f2e2e; }
.status.cancelado { background: #f1ebe4; color: #765433; }
.flash { margin-bottom: 16px; padding: 12px 14px; border-radius: 6px; font-weight: 700; }
.flash.error { background: #fbe8e8; color: #8f2e2e; }
.flash.success { background: #e6f5ea; color: #12643d; }
.hint { color: var(--muted); font-size: 13px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.product-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fbfdfb; }
.product-card span { color: var(--primary); font-weight: 800; font-size: 12px; }
.product-card h3 { margin: 8px 0 6px; }
.product-card p { color: var(--muted); font-size: 13px; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); }

.quote-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.quote-panel { grid-column: 1; }
.quote-summary {
  position: sticky;
  top: 28px;
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 18px;
  background: var(--ink);
  color: white;
  border-radius: 12px;
  box-shadow: 0 18px 45px rgba(23, 33, 29, .18);
}
.quote-summary div, .quote-totals div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.quote-summary .grand, .quote-totals .grand { font-size: 20px; border-bottom: 0; }
.quote-summary .button { margin-top: 16px; }
.product-search { position: relative; margin: 14px 0; }
.search-results {
  position: absolute;
  z-index: 20;
  width: 100%;
  max-height: 330px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 33, 29, .14);
}
.search-result {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  text-align: left;
  cursor: pointer;
}
.search-result:hover { background: #f5faf7; }
.search-result span, .search-result em { color: var(--muted); font-style: normal; font-size: 12px; }
.quote-items { display: grid; gap: 10px; }
.quote-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 100px 150px auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}
.quote-item strong, .quote-item small { display: block; }
.quote-item small, .item-code, .item-total span { color: var(--muted); font-size: 12px; }
.item-code { color: var(--primary); font-weight: 800; }
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
}
.quote-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quote-totals { margin-left: auto; width: min(420px, 100%); }
.quote-totals div { border-color: var(--line); }
.inline-status { display: flex; gap: 10px; align-items: center; }

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    left: 0;
    bottom: auto;
    width: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .nav { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); }
  .nav form { margin-top: 0; }
  .nav a, .link-button { padding: 9px 8px; }
  .metrics, .cards-grid, .form.grid { grid-template-columns: 1fr; }
  .shell, .shell.narrow { width: min(100% - 28px, 1120px); margin: 18px auto; }
  .span-2 { grid-column: span 1; }
  .page-title.split, .panel-header { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 25px; }
  .quote-form { grid-template-columns: 1fr; }
  .quote-panel, .quote-summary { grid-column: 1; }
  .quote-summary { position: static; grid-row: auto; }
  .quote-item { grid-template-columns: 1fr 1fr; }
  .quote-item > div:first-child, .item-total { grid-column: span 2; }
  .quote-detail-grid { grid-template-columns: 1fr; }
}
