*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --ink: #1d1b18;
  --muted: #6f6a61;
  --line: #e5dfd4;
  --panel: #ffffff;
  --surface: #f6f7f8;
  --gold: #c6a15b;
  --gold-dark: #8a672a;
  --red: #9e2020;
  --red-soft: #fff1f1;
  --green: #128153;
  --green-soft: #eef9f3;
  --black: #11100f;
  --shadow: 0 18px 48px rgba(38, 31, 19, .08);
  --sidebar-w: 250px;
  --topbar-h: 78px;
}

html,
body {
  min-height: 100vh;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar__left,
.topbar__user,
.page-actions,
.form-actions,
.actions-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__user {
  color: var(--muted);
  font-size: 14px;
}

.brand {
  display: flex;
  align-items: center;
  height: 52px;
}

.brand img {
  width: 172px;
  max-height: 54px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.layout {
  width: min(1500px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  flex: 1;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  min-height: calc(100vh - var(--topbar-h) - 64px);
  padding: 18px;
  background: var(--black);
  color: #fff;
  border: 1px solid rgba(198, 161, 91, .42);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar__brand {
  padding: 6px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  margin-bottom: 14px;
}

.sidebar__brand img {
  width: 190px;
  max-width: 100%;
  display: block;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .78);
  font-size: 14px;
}

.nav-item i {
  color: var(--gold);
  font-size: 18px;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(198, 161, 91, .14);
  color: #fff;
}

.main {
  min-width: 0;
  display: grid;
  gap: 20px;
  align-content: start;
}

.page-header,
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-header {
  min-height: 58px;
}

.page-header h1,
.panel h2,
.modal h2 {
  margin: 0;
}

.page-header h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel h2 {
  font-size: 20px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.panel__header--compact {
  margin-bottom: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  min-height: 112px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.btn,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  white-space: nowrap;
}

.btn {
  border-color: var(--line);
}

.btn--primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn--ghost {
  background: #fff;
  border-color: var(--line);
}

.btn--danger {
  background: var(--red-soft);
  border-color: #f0c5c5;
  color: var(--red);
}

.btn--sm {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.btn--block {
  width: 100%;
}

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
}

.topbar__menu {
  display: none;
}

.field {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea.field {
  resize: vertical;
}

.field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, .16);
}

.field--readonly {
  background: #f8f8f8;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.login-form label {
  display: grid;
  gap: 7px;
}

.form-grid label span,
.login-form label span,
.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.check-row {
  min-height: 42px;
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.data-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.actions-cell {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.actions-cell--wide {
  min-width: 430px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.count-badge {
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(198, 161, 91, .14);
  color: var(--gold-dark);
  font-weight: 800;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.notice--success {
  background: var(--green-soft);
  border-color: #c9ecd9;
  color: var(--green);
}

.notice--error {
  background: var(--red-soft);
  border-color: #f0c5c5;
  color: var(--red);
}

.empty {
  color: var(--muted);
  margin: 8px 0 0;
}

.status-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status-pill--novo {
  color: var(--red);
  background: var(--red-soft);
}

.status-pill--preparando {
  color: var(--gold-dark);
  background: rgba(198, 161, 91, .16);
}

.status-pill--enviado {
  color: #1a5679;
  background: #eef7ff;
}

.status-pill--finalizado {
  color: var(--green);
  background: var(--green-soft);
}

.order-form {
  display: grid;
  gap: 20px;
}

.order-items {
  display: grid;
  gap: 10px;
}

.order-items__head,
.order-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) minmax(120px, .7fr) minmax(110px, .55fr) minmax(120px, .7fr) 44px;
  gap: 10px;
  align-items: center;
}

.order-items__head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.product-field {
  position: relative;
}

.autocomplete {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.autocomplete button,
.modal-results button {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  text-align: left;
}

.autocomplete button:hover,
.modal-results button:hover {
  background: #fbf7ef;
}

.totals-bar {
  position: sticky;
  bottom: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(198, 161, 91, .55);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.totals-bar div,
.order-summary div {
  display: grid;
  gap: 3px;
}

.totals-bar span,
.order-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.totals-bar strong,
.order-summary strong {
  font-size: 20px;
}

.totals-bar__grand strong {
  color: var(--red);
  font-size: 24px;
}

.modal-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 16, 15, .62);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(620px, 100%);
  max-height: min(680px, calc(100vh - 48px));
  overflow-y: auto;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  display: grid;
  gap: 14px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-results {
  display: grid;
  gap: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 20px;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
}

.order-summary {
  max-width: 360px;
  margin: 18px 0 0 auto;
  display: grid;
  gap: 10px;
}

.order-summary div {
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.product-supplies,
.supply-lines {
  display: grid;
  gap: 10px;
}

.supply-line {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 180px) 42px;
  gap: 10px;
}

.login-body {
  background: #11100f;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(198, 161, 91, .48);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .35);
}

.login-logo {
  width: min(300px, 100%);
  display: block;
  margin: 0 auto 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--black);
  color: #fff;
}

.toast--error {
  background: var(--red);
}

.toast--success {
  background: var(--green);
}

@media (max-width: 980px) {
  .topbar__menu {
    display: inline-flex;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .sidebar {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    z-index: 50;
    width: min(86vw, var(--sidebar-w));
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform .2s ease;
    min-height: auto;
    overflow-y: auto;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .metric-grid,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .totals-bar {
    grid-template-columns: 1fr;
  }

  .order-items__head {
    display: none;
  }

  .order-item-row {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

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

@media (max-width: 620px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand img {
    width: 130px;
  }

  .page-header,
  .panel__header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions,
  .form-actions,
  .actions-cell {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .actions-cell .btn,
  .actions-cell form,
  .actions-cell button {
    width: 100%;
  }

  .order-item-row,
  .supply-line {
    grid-template-columns: 1fr;
  }

  .product-field {
    grid-column: auto;
  }
}

