:root {
  --bg: #efe7db;
  --bg-2: #f9f5ee;
  --ink: #1e2329;
  --muted: #6e6358;
  --accent: #a73c21;
  --accent-2: #234f45;
  --card: rgba(255, 250, 242, 0.9);
  --line: #d7cab8;
  --shadow: 0 18px 48px rgba(84, 60, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 247, 230, 0.95) 0, rgba(255, 247, 230, 0) 35%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
}

.hero,
.container {
  width: min(1100px, 92%);
  margin: 1.2rem auto;
}

.sheet {
  display: grid;
  gap: 1rem;
  padding-bottom: 2rem;
}

.hero {
  background: linear-gradient(135deg, #fbf7f0 0%, #efe4d3 60%, #e7dac8 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.4rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  box-shadow: var(--shadow);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent-2);
  font-weight: 700;
}

h1,
h2 {
  margin: 0 0 0.8rem;
  font-family: Georgia, "Times New Roman", serif;
}

h3 {
  margin: 0;
}

p {
  color: var(--muted);
}

.grid {
  width: min(1100px, 92%);
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  border-bottom: 1px dashed var(--line);
  padding: 0.65rem 0;
}

.list li:last-child {
  border-bottom: 0;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.btn,
button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: #8a2e17;
}

.btn-danger {
  background: #fff2ee;
  color: #962d1a;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.flash {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.7rem 0.9rem;
  margin: 0.7rem 0;
  font-weight: 600;
}

.flash-success {
  background: #eaf7ee;
  border-color: #9fcdad;
  color: #1b5e20;
}

.flash-error {
  background: #fff1ef;
  border-color: #ebb3a8;
  color: #8a2e17;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.workspace-form {
  gap: 1rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.form-section {
  display: grid;
  gap: 1rem;
}

.preview-panel {
  position: sticky;
  top: 1rem;
}

.preview-sheet {
  display: grid;
  gap: 1rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(35, 79, 69, 0.1);
  color: var(--accent-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
}

.preview-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-block {
  display: grid;
  gap: 0.75rem;
}

.preview-block h3,
.preview-header h3 {
  font-family: Georgia, "Times New Roman", serif;
}

.preview-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.5rem;
}

.preview-list li,
.preview-block p {
  color: var(--ink);
}

.preview-line-items-table {
  min-width: 100%;
}

.preview-totals-box {
  margin-top: 0.4rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--line);
}

.section-head p {
  margin: 0;
}

.split-grid {
  display: grid;
  gap: 0.9rem;
}

.split-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(167, 60, 33, 0.15);
  border-color: var(--accent);
}

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

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

pre {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  white-space: pre-wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.detail-grid div {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
}

.detail-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.line-items-panel {
  display: grid;
  gap: 0.85rem;
}

.line-items-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.line-items-table {
  min-width: 760px;
}

.line-items-table th {
  background: rgba(35, 79, 69, 0.08);
  color: var(--accent-2);
}

.line-items-table td input {
  min-width: 100%;
}

.line-total-cell {
  white-space: nowrap;
  font-weight: 700;
}

.totals-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(167, 60, 33, 0.08), rgba(35, 79, 69, 0.08));
  border: 1px solid var(--line);
}

.totals-box strong {
  font-size: 1.1rem;
}

@media (max-width: 700px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-head,
  .section-head,
  .line-items-head,
  .totals-box,
  .preview-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  .split-grid-2,
  .split-grid-3,
  .preview-detail-grid {
    grid-template-columns: 1fr;
  }

  table,
  thead,
  tbody,
  tr,
  td,
  th {
    display: block;
  }

  th {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 0.6rem;
    padding: 0.55rem;
  }

  td {
    border: 0;
    padding: 0.3rem 0;
  }
}
