:root {
  --bg: #faf6ef;
  --ink: #231b15;
  --ink-soft: #4a4035;
  --line: #2e261f;
  --card: #fffaf2;
  --accent: #d97a16;
  --accent-strong: #a64f00;
  --muted: #f0e5d3;
  --ok: #0f6f3d;
  --radius: 16px;
  --shadow: 0 14px 36px rgba(40, 26, 12, 0.15);
  --sheet-shadow: 0 10px 24px rgba(31, 20, 10, 0.18);
  --line-soft: #eedfcb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 10%, #fff6e5 0%, var(--bg) 45%, #f5ecdf 100%);
  color: var(--ink);
  position: relative;
}

.ambient-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  opacity: 0.28;
}

.ambient-shape-a {
  width: 240px;
  height: 240px;
  background: linear-gradient(130deg, #ffd48e, #f9ad5a);
  top: -80px;
  right: -70px;
}

.ambient-shape-b {
  width: 280px;
  height: 280px;
  background: linear-gradient(120deg, #f5c991, #e39f63);
  bottom: -140px;
  left: -90px;
}

.app-shell {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 12px 22px;
}

.topbar {
  background: linear-gradient(140deg, #fff7ea, #ffe7c1);
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(74, 47, 22, 0.14);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-copy {
  text-align: center;
}

.brand-logo,
.brand-fallback {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 0;
  background: #fff;
  flex: 0 0 auto;
}

.brand-logo {
  object-fit: cover;
}

.brand-fallback {
  display: none;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
  font-family: "Merriweather", serif;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.15;
  text-transform: uppercase;
  font-family: "Merriweather", serif;
  letter-spacing: 0.02em;
  text-align: center;
}

.brand p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-align: center;
}

.paper-chip {
  padding: 8px 10px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 0 0 1px rgba(196, 144, 81, 0.35);
  font-size: 0.78rem;
  white-space: nowrap;
  font-weight: 700;
  align-self: center;
}

.tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab-btn {
  border: 0;
  background: rgba(255, 239, 215, 0.78);
  box-shadow: inset 0 0 0 1px rgba(206, 167, 117, 0.42);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tab-btn.active {
  background: linear-gradient(130deg, #f7b15a, #e48a2b);
  color: #1f1207;
  box-shadow: 0 8px 16px rgba(186, 107, 27, 0.35);
  transform: translateY(-1px);
}

.content-wrap {
  margin-top: 12px;
}

.panel[hidden] {
  display: none !important;
}

.card {
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(170deg, #fffdf8, var(--card));
  box-shadow: 0 10px 24px rgba(65, 44, 20, 0.09), inset 0 0 0 1px rgba(240, 222, 198, 0.65);
  padding: 12px;
  margin-bottom: 10px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .bi {
  color: var(--accent-strong);
  font-size: 1rem;
}

.grid-1,
.grid-2,
.grid-3 {
  display: grid;
  gap: 10px;
}

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

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

label {
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 2px rgba(67, 44, 21, 0.05);
  color: var(--ink);
  padding: 8px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: 2px solid #ffb051;
  outline-offset: 1px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.inline-check input {
  width: auto;
  min-height: 0;
}

.hint {
  margin: 7px 0 0;
  color: #6f5f4f;
  font-size: 0.77rem;
  line-height: 1.4;
}

.items-header {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.items-header h3 {
  margin: 0;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.items-header h3 .bi {
  color: var(--accent-strong);
}

.item-editor-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.item-row {
  border: 0;
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 0 0 1px rgba(225, 202, 171, 0.55);
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(54px, 0.6fr) minmax(92px, 0.9fr) minmax(92px, 0.9fr) auto;
  gap: 6px;
  align-items: end;
}

.item-subtotal {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: #fff2de;
  box-shadow: inset 0 0 0 1px rgba(216, 182, 139, 0.55);
  display: grid;
  place-items: center;
  font-size: 0.79rem;
  font-weight: 700;
}

.item-label {
  display: block;
  margin-bottom: 3px;
  font-size: 0.7rem;
  color: #5d4d3d;
  font-weight: 700;
}

.btn-primary,
.btn-dark,
.btn-light,
.btn-ghost {
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  min-height: 40px;
  padding: 8px 11px;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(130deg, #ffb057, #e07517);
  color: #261304;
}

.btn-dark {
  background: #2b1f16;
  border-color: #2b1f16;
  color: #fff;
}

.btn-light {
  background: #fff;
  color: #2f261d;
  box-shadow: inset 0 0 0 1px rgba(193, 152, 100, 0.55);
}

.btn-ghost {
  background: #fffaf2;
  color: #5b411f;
  box-shadow: inset 0 0 0 1px rgba(214, 177, 131, 0.5);
}

.icon-btn {
  min-height: 38px;
  width: 38px;
  padding: 0;
}

.action-bar {
  position: sticky;
  bottom: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  z-index: 3;
  margin: 8px 0 10px;
  padding: 8px;
  border-radius: 14px;
  border: 0;
  background: rgba(255, 248, 237, 0.88);
  box-shadow: 0 10px 24px rgba(69, 45, 23, 0.16);
  backdrop-filter: blur(5px);
}

.action-bar .btn {
  border-radius: 12px;
  border: 0;
  min-height: 42px;
  box-shadow: 0 8px 14px rgba(70, 46, 22, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-bar .btn-outline-dark {
  background: #fff;
  color: #2b1f16;
}

.action-bar .btn-outline-secondary {
  background: #fff;
  color: #5d4e40;
}

.history-card {
  margin-bottom: 4px;
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.history-head p {
  margin: 0;
}

.history-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.history-empty {
  border: 0;
  border-radius: 10px;
  padding: 12px;
  color: #6b5a4a;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: inset 0 0 0 1px rgba(220, 194, 160, 0.55);
  text-align: center;
  font-size: 0.8rem;
}

.history-item {
  border: 0;
  border-radius: 11px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(70, 47, 26, 0.08), inset 3px 0 0 #e79d4a;
}

.history-item strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 3px;
}

.history-item p {
  margin: 0;
  color: #675847;
  font-size: 0.75rem;
}

.history-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.history-actions button {
  min-height: 34px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.history-more {
  margin-top: 9px;
  width: 100%;
}

.preview-toolbar {
  margin-bottom: 10px;
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 248, 237, 0.86);
  box-shadow: 0 8px 18px rgba(70, 47, 26, 0.09);
  display: grid;
  gap: 8px;
}

.preview-toolbar-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #5c4937;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.preview-style-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.preview-export-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.preview-action-btn {
  border-radius: 11px;
  border: 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 14px rgba(70, 46, 22, 0.08);
}

.style-chip {
  border: 0;
  border-radius: 999px;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #5f4b37;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(196, 153, 99, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

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

.style-chip.active {
  box-shadow: 0 8px 16px rgba(68, 47, 23, 0.16);
}

.style-chip.active[data-preview-style="default"] {
  background: linear-gradient(140deg, #fff9ef, #ffefdb);
  color: #6a411c;
}

.style-chip.active[data-preview-style="clean"] {
  background: linear-gradient(140deg, #f8fcff, #eaf5ff);
  color: #1d4667;
}

.style-chip.active[data-preview-style="premium"] {
  background: linear-gradient(135deg, #2d1f12, #4d2f16);
  color: #fff8ef;
}

.style-chip.active[data-preview-style="cute"] {
  background: linear-gradient(135deg, #ffe4f3, #ffd4e9);
  color: #7c3f64;
}

.preview-stage {
  border-radius: var(--radius);
  background: linear-gradient(145deg, #f1dfc4, #ead1af);
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(206, 165, 112, 0.35);
  padding: 12px;
  min-height: 66vh;
  display: grid;
  place-items: start center;
}

.bi {
  line-height: 1;
}

.print-sheet {
  width: min(100%, 360px);
  aspect-ratio: 105 / 148;
  background: #fff;
  border: 1px solid #21170f;
  box-shadow: var(--sheet-shadow);
  color: #111;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  font-size: 10.5px;
  line-height: 1.25;
  overflow: hidden;
}

.print-sheet[data-paper="A7"] {
  width: min(100%, 278px);
  aspect-ratio: 74 / 105;
  font-size: 9px;
  padding: 6px;
}

.sheet-brand {
  border: 1px solid #000;
  padding: 4px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
  text-align: left;
}

.sheet-logo-box {
  width: 60px;
  height: 60px;
  border: 0;
  position: relative;
  overflow: hidden;
  background: #fff;
}

.print-sheet[data-paper="A7"] .sheet-logo-box {
  width: 48px;
  height: 48px;
}

.sheet-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sheet-logo-fallback {
  width: 100%;
  height: 100%;
  display: none;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-family: "Merriweather", serif;
}

.sheet-brand-name {
  margin: 0;
  font-family: "Merriweather", serif;
  font-size: 13px;
  line-height: 1.12;
  text-transform: uppercase;
  text-align: left;
}

.print-sheet[data-paper="A7"] .sheet-brand-name {
  font-size: 10.5px;
}

.sheet-brand-meta {
  margin: 2px 0 0;
  color: #222;
  font-size: 8.6px;
  line-height: 1.2;
  text-align: left;
}

.print-sheet[data-paper="A7"] .sheet-brand-meta {
  font-size: 7.5px;
}

.sheet-main-title {
  margin: 0;
  border: 1px solid #000;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.03em;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px;
}

.print-sheet[data-paper="A7"] .sheet-main-title {
  font-size: 10px;
}

.info-grid {
  border: 1px solid #000;
}

.info-row {
  display: grid;
  grid-template-columns: 33% 67%;
  border-bottom: 1px solid #000;
}

.info-row:last-child {
  border-bottom: 0;
}

.info-label,
.info-value {
  padding: 2px 4px;
}

.info-label {
  border-right: 1px solid #000;
  font-weight: 700;
}

.item-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-size: 9.5px;
}

.print-sheet[data-paper="A7"] .item-table {
  font-size: 8px;
}

.item-table th,
.item-table td {
  border: 1px solid #000;
  padding: 2px 3px;
  vertical-align: top;
  word-break: break-word;
}

.item-table th {
  text-align: left;
}

.align-center {
  text-align: center;
}

.align-right {
  text-align: right;
}

.summary {
  border: 1px solid #000;
  padding: 4px;
  display: grid;
  gap: 2px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 9.4px;
}

.summary-line strong {
  font-size: 10px;
}

.print-sheet[data-paper="A7"] .summary-line {
  font-size: 8px;
}

.note-box {
  border: 1px solid #000;
  padding: 3px 4px;
  min-height: 16px;
}

.footer-mini {
  margin-top: auto;
  text-align: right;
  font-size: 7.8px;
}

.print-sheet[data-style="default"] {
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

.print-sheet[data-style="default"] .sheet-main-title::before {
  content: "▣ ";
  font-size: 9px;
}

.print-sheet[data-style="clean"] {
  background: #fff;
  border: 0;
  color: #111;
  gap: 9px;
  padding: 10px;
  box-shadow: 0 14px 28px rgba(40, 58, 80, 0.15);
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

.print-sheet[data-style="clean"] .sheet-brand {
  border: 0;
  border-bottom: 1px solid #000;
  border-radius: 0;
  background: transparent;
  padding: 0 0 6px;
  grid-template-columns: 56px 1fr;
  gap: 8px;
}

.print-sheet[data-style="clean"] .sheet-logo-box {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px #000;
}

.print-sheet[data-style="clean"] .sheet-brand-name {
  font-size: 12.6px;
  letter-spacing: 0.02em;
}

.print-sheet[data-style="clean"] .sheet-main-title {
  border: 0;
  border-bottom: 2px solid #000;
  border-radius: 0;
  text-align: left;
  padding: 0 0 4px;
  font-size: 11.3px;
  letter-spacing: 0.02em;
}

.print-sheet[data-style="clean"] .sheet-main-title::before {
  content: "• ";
  font-weight: 900;
}

.print-sheet[data-style="clean"] .info-grid {
  border: 0;
}

.print-sheet[data-style="clean"] .info-row {
  grid-template-columns: 31% 69%;
  border-bottom: 1px solid #000;
}

.print-sheet[data-style="clean"] .info-label {
  border-right: 0;
  font-weight: 800;
  padding-left: 0;
}

.print-sheet[data-style="clean"] .info-value {
  padding-right: 0;
}

.print-sheet[data-style="clean"] .item-table th,
.print-sheet[data-style="clean"] .item-table td {
  border: 0;
  border-bottom: 1px solid #000;
  padding: 2px 0;
}

.print-sheet[data-style="clean"] .item-table th {
  border-bottom: 2px solid #000;
  text-transform: uppercase;
  font-size: 8.6px;
  letter-spacing: 0.02em;
}

.print-sheet[data-style="clean"] .summary {
  border: 0;
  border-top: 2px solid #000;
  border-bottom: 1px solid #000;
  border-radius: 0;
  padding: 4px 0;
}

.print-sheet[data-style="clean"] .note-box {
  border: 1px dashed #000;
  border-radius: 8px;
}

.print-sheet[data-style="clean"] .footer-mini {
  text-align: left;
  font-style: italic;
}

.print-sheet[data-style="premium"] {
  background: #fff;
  border: 2px solid #000;
  color: #111;
  box-shadow: 0 20px 32px rgba(28, 16, 8, 0.25);
  font-family: "Merriweather", serif;
  padding: 9px;
  gap: 7px;
}

.print-sheet[data-style="premium"] .sheet-brand {
  border: 2px double #000;
  border-radius: 0;
  background: transparent;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  padding: 6px;
  gap: 5px;
}

.print-sheet[data-style="premium"] .sheet-logo-box {
  width: 52px;
  height: 52px;
  border: 1px solid #000;
  border-radius: 0;
}

.print-sheet[data-style="premium"] .sheet-brand-name,
.print-sheet[data-style="premium"] .sheet-brand-meta {
  text-align: center;
}

.print-sheet[data-style="premium"] .sheet-brand-name {
  font-size: 12.8px;
  letter-spacing: 0.05em;
}

.print-sheet[data-style="premium"] .sheet-main-title {
  border: 2px solid #000;
  border-radius: 0;
  padding: 4px 3px;
  letter-spacing: 0.08em;
}

.print-sheet[data-style="premium"] .sheet-main-title::before {
  content: "◆ ";
  font-size: 9px;
}

.print-sheet[data-style="premium"] .info-grid,
.print-sheet[data-style="premium"] .summary,
.print-sheet[data-style="premium"] .note-box {
  border: 2px solid #000;
}

.print-sheet[data-style="premium"] .info-row {
  grid-template-columns: 32% 68%;
}

.print-sheet[data-style="premium"] .info-label {
  border-right: 1px solid #000;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 8px;
  font-weight: 900;
}

.print-sheet[data-style="premium"] .item-table th,
.print-sheet[data-style="premium"] .item-table td {
  border: 1px solid #000;
}

.print-sheet[data-style="premium"] .item-table th {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 8px;
}

.print-sheet[data-style="premium"] .summary-line {
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

.print-sheet[data-style="premium"] .note-box {
  border-style: double;
  border-width: 3px;
  font-style: italic;
}

.print-sheet[data-style="premium"] .footer-mini {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.print-sheet[data-style="cute"] {
  background: #fff;
  border: 1px dashed #000;
  color: #111;
  gap: 8px;
  padding: 10px;
  box-shadow: 0 18px 30px rgba(130, 74, 110, 0.22);
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

.print-sheet[data-style="cute"] .sheet-brand {
  border: 1px dashed #000;
  border-radius: 14px;
  background: transparent;
  padding: 7px;
  gap: 8px;
}

.print-sheet[data-style="cute"] .sheet-logo-box {
  width: 58px;
  height: 58px;
  border: 1px solid #000;
  border-radius: 14px;
  transform: rotate(-2deg);
}

.print-sheet[data-style="cute"] .sheet-brand-name {
  text-transform: none;
  font-size: 12.4px;
  letter-spacing: 0.02em;
}

.print-sheet[data-style="cute"] .sheet-main-title {
  border: 1px solid #000;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 11.6px;
  padding: 3px 8px;
}

.print-sheet[data-style="cute"] .sheet-main-title::before {
  content: "✿ ";
  font-size: 9px;
}

.print-sheet[data-style="cute"] .info-grid {
  border: 1px dashed #000;
  border-radius: 12px;
  overflow: hidden;
}

.print-sheet[data-style="cute"] .info-row {
  grid-template-columns: 36% 64%;
  border-bottom: 1px dashed #000;
}

.print-sheet[data-style="cute"] .info-label {
  border-right: 1px dashed #000;
}

.print-sheet[data-style="cute"] .info-label::before {
  content: "• ";
  font-weight: 900;
}

.print-sheet[data-style="cute"] .item-table th,
.print-sheet[data-style="cute"] .item-table td {
  border: 1px dashed #000;
}

.print-sheet[data-style="cute"] .item-table th {
  text-transform: none;
}

.print-sheet[data-style="cute"] .summary,
.print-sheet[data-style="cute"] .note-box {
  border: 1px dashed #000;
  border-radius: 12px;
  background: transparent;
}

.print-sheet[data-style="cute"] .summary-line:nth-child(odd) {
  font-weight: 800;
}

.print-sheet[data-style="cute"] .footer-mini {
  text-align: center;
}

.logo-hidden .sheet-logo-box {
  display: none;
}

.logo-hidden .sheet-brand {
  grid-template-columns: 1fr;
  text-align: center;
}

.logo-hidden .sheet-brand-name,
.logo-hidden .sheet-brand-meta {
  text-align: center;
}

#saveHistoryBtn {
  grid-column: span 2;
}

@media (min-width: 820px) {
  .content-wrap {
    display: grid;
    grid-template-columns: minmax(330px, 380px) 1fr;
    gap: 14px;
    align-items: start;
  }

  .panel {
    min-height: 0;
  }

  #previewPanel[hidden] {
    display: block !important;
    opacity: 0.5;
    pointer-events: none;
    filter: saturate(0.8);
  }

  .tabs {
    max-width: 300px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px 8px 16px;
  }

  .topbar {
    padding: 9px 10px;
    justify-content: center;
  }

  .brand {
    width: 100%;
  }

  .brand-logo,
  .brand-fallback {
    width: 42px;
    height: 42px;
  }

  .brand h1 {
    font-size: 0.98rem;
  }

  .brand p {
    font-size: 0.76rem;
  }

  .paper-chip {
    font-size: 0.73rem;
    padding: 7px 9px;
  }

  .card {
    padding: 10px;
  }

  label {
    font-size: 0.78rem;
  }

  input,
  textarea,
  select {
    min-height: 36px;
    padding: 7px 9px;
  }

  .action-bar {
    bottom: 6px;
    padding: 7px;
    gap: 6px;
  }

  .preview-stage {
    min-height: 52vh;
    padding: 8px;
  }

  .preview-toolbar {
    padding: 9px;
  }

  .style-chip {
    font-size: 0.74rem;
    padding: 8px 9px;
  }
}

@media (max-width: 560px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name name"
      "qty price"
      "subtotal remove";
    align-items: stretch;
  }

  .item-row > .item-name-cell {
    grid-area: name;
  }

  .item-row > .item-qty-cell {
    grid-area: qty;
  }

  .item-row > .item-price-cell {
    grid-area: price;
  }

  .item-subtotal {
    grid-area: subtotal;
  }

  .icon-btn {
    grid-area: remove;
    width: 100%;
    min-height: 36px;
  }

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

  .preview-style-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .preview-export-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
}

@media (max-width: 380px) {
  .tabs {
    gap: 6px;
  }

  .tab-btn {
    padding: 9px 8px;
    font-size: 0.83rem;
  }

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

  #saveHistoryBtn {
    grid-column: span 1;
  }

  .history-actions {
    flex-direction: column;
  }
}

@media print {
  html,
  body {
    width: 100%;
    height: 100%;
    background: #fff;
  }

  body * {
    visibility: hidden !important;
  }

  #previewPanel,
  #previewPanel * {
    visibility: visible !important;
  }

  .ambient-shape,
  .tabs,
  .topbar,
  #designPanel,
  .preview-toolbar {
    display: none !important;
  }

  .app-shell {
    padding: 0;
    margin: 0;
    max-width: none;
  }

  #previewPanel,
  #previewPanel[hidden] {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  .preview-stage {
    border: 0;
    padding: 0;
    background: #fff;
    min-height: 0;
  }

  .print-sheet,
  .print-sheet[data-paper="A7"] {
    border: 1px solid #000;
    box-shadow: none;
    width: 100%;
    aspect-ratio: auto;
    margin: 0;
    filter: grayscale(100%);
    page-break-inside: avoid;
  }

  .sheet-logo,
  .brand-logo {
    filter: grayscale(100%);
  }
}
