:root {
  --bg: #d8d2c8;
  --bg-soft: #ebe7e0;
  --panel: rgba(255, 255, 255, 0.82);
  --text: #2d2925;
  --muted: #6f675f;
  --line: rgba(73, 56, 44, 0.14);
  --accent: #c56f3a;
  --accent-strong: #9f4d22;
  --shadow: 0 18px 45px rgba(72, 49, 33, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.6), transparent 32%),
    linear-gradient(135deg, #e4ddd4 0%, #cec4b8 48%, #c4b6a7 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.home-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.home-shell {
  width: min(1180px, 100%);
  padding: 52px;
  border-radius: 36px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.84), rgba(245, 240, 233, 0.72));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.eyebrow,
.menu-kicker,
.topbar-subtitle,
.section-heading p,
.subtitle {
  color: var(--muted);
}

.home-brand h1 {
  margin: 8px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 7vw, 88px);
  letter-spacing: 0.08em;
}

.subtitle {
  margin: 0 0 28px;
  max-width: 760px;
  font-size: 18px;
  line-height: 1.6;
}

.auth-card {
  display: grid;
  gap: 16px;
  margin: 0 0 28px;
  padding: 24px 26px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(197, 111, 58, 0.16);
}

.auth-title {
  display: block;
  font-size: 24px;
  font-family: Georgia, "Times New Roman", serif;
}

.auth-copy,
.setup-warning {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.auth-field {
  margin-bottom: 0;
}

.auth-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(243, 237, 231, 0.92);
}

.setup-warning {
  color: #8a4e2c;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 30px;
}

.menu-card {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 30px;
  border: 1px solid rgba(197, 111, 58, 0.24);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(83, 51, 26, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.menu-card strong {
  font-size: 30px;
  font-family: Georgia, "Times New Roman", serif;
}

.menu-card span:last-child {
  line-height: 1.55;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(83, 51, 26, 0.14);
  border-color: rgba(197, 111, 58, 0.48);
}

.menu-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 10px 30px rgba(83, 51, 26, 0.08);
}

.menu-card-muted {
  background: linear-gradient(180deg, rgba(246, 242, 237, 0.96), rgba(255, 255, 255, 0.84));
}

.home-footer {
  margin-top: 30px;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(244, 239, 233, 0.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-title {
  font-size: 26px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.topbar-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(390px, 470px) 1fr;
  gap: 24px;
  padding: 24px;
}

.side-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
  min-height: calc(100vh - 120px);
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 14px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
}

.panel-tab,
.type-pill,
.btn {
  border: none;
  border-radius: 999px;
}

.panel-tab,
.type-pill {
  padding: 12px 14px;
  background: rgba(112, 91, 73, 0.08);
  color: var(--muted);
  font-weight: 700;
}

.panel-tab.is-active,
.type-pill.is-active {
  background: var(--text);
  color: white;
}

.panel-view {
  display: none;
}

.panel-view.is-active {
  display: block;
}

.type-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 18px 20px 0;
}

.form-scroll,
.panel-view[data-panel="history"],
.panel-view[data-panel="settings"] {
  padding: 18px 20px 24px;
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.section-heading p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.section-heading-inline {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

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

.compact-grid {
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  font-weight: 700;
  color: #554d47;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(91, 68, 45, 0.14);
  border-radius: 14px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(197, 111, 58, 0.64);
  box-shadow: 0 0 0 3px rgba(197, 111, 58, 0.15);
}

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

.line-item {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(84, 63, 44, 0.08);
}

.line-item-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr 0.9fr 0.7fr;
  gap: 10px;
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  padding: 12px 18px;
  font-weight: 800;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-small {
  padding: 10px 12px;
  font-size: 12px;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

.btn-quiet {
  background: #ece6df;
  color: var(--text);
}

.btn-soft {
  background: #f3dad0;
  color: #743c32;
}

.btn-danger {
  background: #9b3d3d;
  color: white;
}

.preview-area {
  display: flex;
  justify-content: center;
  align-items: start;
}

.preview-sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  padding: 30mm 22mm 22mm 28mm;
  background: #fffdf9;
  box-shadow: var(--shadow);
  border-radius: 10px;
  overflow: hidden;
}

.preview-band {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), #854520);
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.preview-app-name {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.preview-sheet h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  letter-spacing: 0.08em;
}

.preview-meta {
  min-width: 220px;
  display: grid;
  gap: 10px;
  font-size: 13px;
}

.preview-meta div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #eee4d8;
  padding-bottom: 8px;
}

.preview-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 24px 0 18px;
}

.preview-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview-columns p:last-child {
  margin: 0;
  line-height: 1.7;
  white-space: pre-line;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid #e6ddd3;
  padding: 10px 8px;
  text-align: left;
  font-size: 13px;
}

.preview-table th {
  background: #f3ede7;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-table td:nth-child(3),
.preview-table td:nth-child(4),
.preview-table td:nth-child(5),
.preview-table th:nth-child(3),
.preview-table th:nth-child(4),
.preview-table th:nth-child(5) {
  text-align: right;
}

.preview-totals {
  width: min(360px, 100%);
  margin: 24px 0 0 auto;
  display: grid;
  gap: 8px;
}

.preview-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee4d8;
}

.grand-total {
  margin-top: 4px;
  font-size: 17px;
}

.preview-foot {
  margin-top: 34px;
  display: grid;
  gap: 26px;
}

.preview-foot p {
  margin: 0;
  line-height: 1.6;
}

.preview-signature {
  margin-left: auto;
  text-align: right;
  display: grid;
  gap: 8px;
}

.history-table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(91, 68, 45, 0.08);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.75);
}

.history-table th,
.history-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(91, 68, 45, 0.08);
  font-size: 12px;
  text-align: left;
}

.history-table th {
  background: #f3ede7;
}

.history-table .open-link {
  color: var(--accent-strong);
  text-decoration: underline;
  background: none;
  padding: 0;
  border: none;
  font-weight: 700;
}

.empty-state {
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
}

.no-screen {
  display: none;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-area {
    overflow: auto;
    padding-bottom: 24px;
  }
}

@media (max-width: 760px) {
  .home-shell {
    padding: 28px;
  }

  .home-grid,
  .grid-two,
  .line-item-grid,
  .preview-columns,
  .type-switch,
  .panel-tabs {
    grid-template-columns: 1fr;
  }

  .topbar,
  .topbar-buttons,
  .auth-session {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-form {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 14px;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    background: white !important;
  }

  .no-print {
    display: none !important;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .preview-area {
    display: block;
  }

  .preview-sheet {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .preview-band,
  .preview-table th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-screen {
    display: block;
  }
}
