:root {
  --primary: #e02928;
  --text: #222;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #fafafa;
  --card: #ffffff;
  --accent: #005eaa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font:
    14px/1.45 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial;
}

.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.company h1 {
  font-size: 18px;
  margin: 0 0 2px;
}
.company small {
  color: var(--muted);
}
.header-right {
  text-align: right;
}
.divider {
  height: 1px;
  background: var(--line);
  margin: 8px 0 20px;
}

/* Cards */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.field {
  flex: 1;
  min-width: 160px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.switch input {
  width: 18px;
  height: 18px;
}

/* Table */
.table-card {
  grid-column: 1 / 3;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

thead th {
  background: #f7f7f7;
  color: #555;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 0;
  border-top: 1px solid var(--line);
}
tbody tr:nth-child(even) {
  background: #fafafa;
}

.cell {
  display: flex;
  align-items: center;
}
.cell input {
  width: 100%;
  padding: 12px;
  border: 0;
  background: transparent;
  font: inherit;
}

.cell--qty {
  max-width: 88px;
}
.cell--price,
.cell--disc {
  max-width: 140px;
}
.cell--total {
  justify-content: flex-end;
  padding-right: 12px;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 0;
}

.btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

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

/* Summary */
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  margin-top: 16px;
}

.summary {
  position: sticky;
  top: 12px;
}
.summary .line {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
}
.summary .total {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  display: flex;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  margin-top: 8px;
}

/* Signature */
.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.sign-box {
  height: 110px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 12px;
}

.sign-box span {
  color: var(--muted);
  font-size: 12px;
}

/* Footer tools */
.foot-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0;
}
.badge {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

/* Responsive */
@media (max-width: 880px) {
  .grid,
  .layout,
  .signatures {
    grid-template-columns: 1fr;
  }
  .table-card {
    grid-column: auto;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    text-align: left;
  }
}
