:root {
  --bg: #f5f1ea;
  --surface: #fffaf2;
  --surface-2: #ffffff;
  --ink: #18201f;
  --muted: #6f746e;
  --line: #e5dcca;
  --primary: #11675c;
  --primary-dark: #0b4b43;
  --accent: #d98b28;
  --danger: #b73737;
  --warning: #fff0ce;
  --shadow: 0 20px 55px rgba(38, 31, 20, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, #f4dfbd 0, transparent 34rem), var(--bg);
  color: var(--ink);
}

a { color: var(--primary); text-decoration: none; font-weight: 700; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.82rem 0.95rem;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(17, 103, 92, 0.12);
}

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

label { display: grid; gap: 0.42rem; color: #35403c; font-weight: 700; }

small { display: block; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 0.95rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }

th { color: #66706b; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }

.sortable-link { color: inherit; font-weight: 900; }
.sortable-link:hover { color: var(--primary); }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.35rem;
  background: #15231f;
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 2rem; }

.brand strong { display: block; font-size: 1.15rem; }

.brand small { color: #b7c9c2; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 45px;
  height: 45px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #f2c35a);
  color: #1d180d;
  font-weight: 900;
}

.brand-mark.large { width: 72px; height: 72px; border-radius: 24px; font-size: 1.4rem; }

.nav-link {
  display: block;
  padding: 0.9rem 1rem;
  margin-bottom: 0.35rem;
  border-radius: 16px;
  color: #dfe9e5;
  font-weight: 800;
}

.nav-link:hover, .nav-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; }

.nav-dropdown { margin-bottom: 0.35rem; }
.nav-dropdown summary {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  color: #dfe9e5;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: '▾'; float: right; opacity: 0.7; }
.nav-dropdown[open] summary, .nav-dropdown summary:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-child { margin-left: 0.8rem; padding-left: 1rem; font-size: 0.92rem; }

.main { padding: 1.5rem; overflow-x: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.topbar h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.7rem); letter-spacing: -0.04em; }

.eyebrow { margin: 0 0 0.28rem; color: var(--accent); font-size: 0.78rem; font-weight: 900; letter-spacing: 0.11em; text-transform: uppercase; }

.user-box {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.78);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
}

.user-box span { font-weight: 900; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 14px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--primary); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.full { width: 100%; }

.panel, .form-panel {
  background: rgba(255, 250, 242, 0.88);
  border: 1px solid rgba(229, 220, 202, 0.88);
  border-radius: 28px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
  overflow: auto;
}

.form-panel { background: linear-gradient(135deg, #fffaf2, #ffffff); }

.panel h2, .form-panel h2, .form-panel h3 { margin-top: 0; }

.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

.panel-title h2, .panel-title h3 { margin: 0; }

.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: end; }

.span-2 { grid-column: span 2; }

.cards-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }

.metric-card {
  min-height: 140px;
  padding: 1.25rem;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, #0f5f54, #12342f);
  box-shadow: var(--shadow);
}

.metric-card.warning { background: linear-gradient(135deg, #c96f1c, #61390e); }
.metric-card.scenario-best { background: linear-gradient(135deg, #138a5b, #0c4d35); }
.metric-card.scenario-worst { background: linear-gradient(135deg, #d44747, #7a1d1d); }
.metric-card.scenario-single { background: linear-gradient(135deg, #1f73d1, #173f7a); }

.metric-card span { display: block; opacity: 0.82; font-weight: 800; }

.metric-card strong { display: block; margin-top: 1.2rem; font-size: 2.8rem; line-height: 1; }

.metric-card small { color: rgba(255, 255, 255, 0.78); margin-top: 0.7rem; }

.bar-list { display: grid; gap: 0.9rem; }

.bar-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr) auto; gap: 0.8rem; align-items: center; }

.bar-row span { color: #35403c; font-weight: 900; }

.bar-row strong { white-space: nowrap; }

.bar-track { height: 14px; overflow: hidden; border-radius: 999px; background: #eadfca; }

.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #30a08f); }

.bar-fill.alt { background: linear-gradient(90deg, var(--accent), #f0c069); }

.empty-state { margin: 0; color: var(--muted); font-weight: 800; }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

.accent-panel { background: linear-gradient(135deg, #fff6e8, #fff); }

.alert { padding: 0.95rem 1rem; border-radius: 16px; margin-bottom: 1rem; font-weight: 800; }
.alert-success { background: #dff3ea; color: #0d594b; }
.alert-danger { background: #ffe1de; color: #8c2626; }
.alert-warning { background: var(--warning); color: #7a4c0d; }

.pill, .status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 900;
}

.pill.good { background: #dff3ea; color: #0d594b; }
.pill.muted { background: #e9e4da; color: #686259; }
.status-rascunho { background: #e9e4da; color: #5e5b54; }
.status-aguardando_aprovacao { background: #fff0ce; color: #82520c; }
.status-aprovada { background: #dff3ea; color: #0d594b; }
.status-reprovada { background: #ffe1de; color: #8c2626; }
.status-concluida { background: #dbeafe; color: #1d4f91; }

.actions { display: flex; gap: 0.8rem; white-space: nowrap; }

.inline-form { margin: 0; }

.link-danger {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
}

.stacked-line {
  display: block;
  margin-bottom: 0.45rem;
}

.stacked-line:last-child { margin-bottom: 0; }

@media print {
  body { background: #fff; }
  .sidebar, .topbar .user-box, .no-print, .btn { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .panel, .form-panel { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #10231f, #0f5f54 52%, #f0c069);
}

.login-card {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
  border-radius: 34px;
  background: #fffaf2;
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.28);
}

.login-art { padding: clamp(2rem, 5vw, 4rem); color: #fff; background: radial-gradient(circle at top left, #e7a13c, transparent 22rem), #15231f; }
.login-art h1 { max-width: 560px; font-size: clamp(2rem, 5vw, 4.1rem); line-height: 0.95; letter-spacing: -0.06em; }
.login-art p { max-width: 440px; color: #dce9e4; font-size: 1.08rem; }
.login-form { display: grid; align-content: center; gap: 0.85rem; padding: clamp(1.5rem, 4vw, 3rem); }
.login-form h2 { margin: 0 0 0.7rem; font-size: 2rem; letter-spacing: -0.04em; }

.supplier-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.quote-table-wrap { overflow: auto; margin-bottom: 1rem; }
.quote-table { min-width: 920px; }
.quote-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.quote-item-card { border: 1px solid var(--line); border-radius: 24px; padding: 1rem; margin-bottom: 1rem; background: #fff; }
.quote-item-top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.quote-item-top h3 { margin: 0 0 0.25rem; }
.last-box { border-radius: 18px; padding: 0.8rem; background: #f8f0e0; min-width: 240px; }
.offer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.offer-card { border: 1px solid var(--line); border-radius: 18px; padding: 0.9rem; background: #fffaf2; cursor: pointer; }
.offer-card.selected { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(17, 103, 92, 0.12); }
.offer-card.best-offer { border-color: var(--accent); background: #fff4d8; }
.offer-card input { width: auto; margin-right: 0.4rem; }
.offer-card strong, .offer-card span { display: block; margin-top: 0.35rem; }
.offer-card span { font-size: 1.4rem; font-weight: 950; color: var(--primary); }
.action-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.inline-action-panel { margin: 1rem 0 0; box-shadow: none; }
.muted-panel { background: #f8fafc; border: 1px dashed #cbd5e1; color: #64748b; }
.toggle { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 0.7rem; margin-bottom: 1rem; }
.toggle input { width: 22px; height: 22px; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.6rem; }
.check-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0.55rem 0.8rem;
}
.check-option input { width: auto; }
.best-scenario-panel { background: linear-gradient(135deg, #f3fff8, #fffaf2); }
.scenario-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.scenario-grid .metric-card strong { font-size: 2rem; }
.scenario-grid .metric-card small { color: rgba(255, 255, 255, 0.78); margin-top: 0.7rem; }
.scenario-subtitle { margin-top: 1.2rem; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { display: flex; gap: 0.5rem; overflow: auto; }
  .nav-link { white-space: nowrap; }
  .cards-grid, .scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .grid-form, .supplier-grid, .offer-grid, .login-card { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

@media (max-width: 720px) {
  .main { padding: 1rem; }
  .topbar, .user-box, .quote-head, .quote-item-top, .action-panel { align-items: stretch; flex-direction: column; }
  .cards-grid, .scenario-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 0.45rem; }
  th, td { padding: 0.78rem; }
  .login-art { display: none; }
}
