@font-face {
  font-family: "YoeShin";
  src: url("assets/fonts/YoeShin-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "YoeShin";
  src: url("assets/fonts/YoeShin-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sahara";
  src: url("assets/fonts/Sahara-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sahara";
  src: url("assets/fonts/Sahara-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "NextSphere";
  src: url("assets/fonts/NextSphere-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ─── Design tokens ─── */
:root {
  --font-heading: "Sahara", "YoeShin", system-ui, sans-serif;
  --font-body: "YoeShin", "Avenir Next", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-slogan: "NextSphere", "YoeShin", system-ui, sans-serif;

  /* Document paper tokens - untouched */
  --ink: #0d1224;
  --muted: #5a6275;
  --line: #d9deea;
  --surface: #ffffff;
  --blue: #1537b2;
  --blue-deep: #071446;
  --blue-soft: #255df2;
  --success: #0e7a4f;
  --warning: #b91c1c;
  --shadow: 0 20px 52px rgba(10, 15, 40, 0.16);
  --radius: 8px;

  /* App chrome tokens */
  --topbar-bg: #06102b;
  --topbar-border: rgba(255, 255, 255, 0.06);
  --sidebar-bg: #0d1847;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-text: rgba(255, 255, 255, 0.88);
  --sidebar-label: rgba(255, 255, 255, 0.5);
  --sidebar-heading: rgba(255, 255, 255, 0.92);
  --sidebar-muted: rgba(255, 255, 255, 0.38);
  --sidebar-input-bg: rgba(255, 255, 255, 0.055);
  --sidebar-input-border: rgba(255, 255, 255, 0.1);
  --sidebar-input-border-hover: rgba(255, 255, 255, 0.2);
  --sidebar-input-focus-border: rgba(99, 142, 255, 0.7);
  --sidebar-input-focus-ring: rgba(99, 142, 255, 0.18);
  --accent: #4776ff;
  --accent-muted: rgba(71, 118, 255, 0.14);
  --canvas-bg: #e8ecf5;

  color-scheme: light;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas-bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

h1,
h2 {
  margin: 0;
}

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

/* ─── Topbar ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
  padding: 0 28px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: 106px;
  height: 36px;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.eyebrow {
  margin: 0 0 2px;
  color: rgba(120, 158, 255, 0.75);
  font-size: 0.63rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 0.86rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0;
}

/* Divider in brand lockup */
.brand-lockup > div::before {
  content: "";
  display: block;
  width: 1px;
  height: 26px;
  background: rgba(255, 255, 255, 0.1);
  position: absolute;
  left: 0;
}

.topbar-actions,
.section-row,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ─── Buttons ─── */
.primary-button,
.ghost-button,
.small-button,
.segment,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 130ms ease, border-color 130ms ease, box-shadow 130ms ease, color 130ms ease, transform 100ms ease;
}

/* Primary: pill, vivid blue */
.primary-button {
  background: var(--accent);
  color: #fff;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(71, 118, 255, 0.32), 0 1px 2px rgba(71, 118, 255, 0.2);
}

.primary-button:hover {
  background: #5c8aff;
  box-shadow: 0 4px 16px rgba(71, 118, 255, 0.42), 0 1px 3px rgba(71, 118, 255, 0.2);
}

.primary-button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(71, 118, 255, 0.2);
}

/* Ghost button - topbar: minimal text-only with hairline border */
.topbar .ghost-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.55);
}

.topbar .ghost-button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.82);
}

/* Small button - on dark sidebar */
.small-button {
  min-height: 30px;
  padding: 0 11px;
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.11);
  color: rgba(255, 255, 255, 0.7);
}

.small-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

/* Icon button (remove item) - on dark sidebar */
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.18);
  color: rgba(248, 113, 113, 0.85);
  font-size: 0.76rem;
  font-weight: 800;
  border-radius: 999px;
}

.icon-button:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Focus rings */
.primary-button:focus-visible,
.ghost-button:focus-visible,
.small-button:focus-visible,
.segment:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid rgba(99, 142, 255, 0.5);
  outline-offset: 2px;
}

/* ─── Workspace ─── */
.workspace {
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr);
  gap: 28px;
  padding: 20px 28px 48px;
  align-items: start;
  flex: 1;
}

/* ─── Editor panel (dark sidebar) ─── */
.editor-panel {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 0;
  max-height: calc(100vh - 104px);
  overflow: auto;
  border-radius: 12px;
  background: var(--sidebar-bg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 8px 32px rgba(6, 12, 36, 0.22);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  color-scheme: dark;
}

.editor-panel::-webkit-scrollbar {
  width: 4px;
}

.editor-panel::-webkit-scrollbar-track {
  background: transparent;
}

.editor-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.editor-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ─── Control sections ─── */
.control-section {
  border: 0;
  border-bottom: 1px solid var(--sidebar-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 16px 18px;
}

.control-section:last-child {
  border-bottom: 0;
}

.control-section h2 {
  color: var(--sidebar-heading);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.control-section summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.control-section summary::-webkit-details-marker {
  display: none;
}

.control-section summary h2 {
  flex: 1;
}

.control-section summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.35);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
  flex-shrink: 0;
  margin-right: 3px;
}

.control-section[open] summary::after {
  transform: rotate(45deg);
}

.control-section[open] summary {
  margin-bottom: 12px;
}

.control-section summary:hover h2 {
  color: #fff;
}

/* ─── Segmented control ─── */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.segment {
  background: transparent;
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.8rem;
  font-weight: 400;
  border-radius: 999px;
  min-height: 30px;
  border-color: transparent;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.segment:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.62);
}

.segment.is-active {
  background: rgba(255, 255, 255, 0.93);
  color: #0d1847;
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24), 0 1px 1px rgba(0, 0, 0, 0.12);
}

/* ─── Field grid & labels ─── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--sidebar-label);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

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

/* ─── Contextual fields per doc type ─── */
.editor-panel[data-doctype="receipt"] .hide-on-receipt,
.editor-panel[data-doctype="quotation"] .hide-on-quotation {
  display: none;
}

/* ─── Live validation ─── */
input.is-invalid,
textarea.is-invalid {
  border-color: rgba(248, 113, 113, 0.55);
}

input.is-invalid:focus-visible,
textarea.is-invalid:focus-visible {
  border-color: rgba(248, 113, 113, 0.8);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}

/* ─── Doc number compound field ─── */
.doc-num-compound {
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--sidebar-input-border);
  border-radius: 7px;
  background: var(--sidebar-input-bg);
  padding: 0 10px;
  gap: 0;
  transition: border-color 120ms ease;
}

.doc-num-compound:focus-within {
  border-color: var(--sidebar-input-focus-border);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--sidebar-input-focus-ring);
}

.doc-num-prefix {
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.doc-num-seq {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  min-height: auto !important;
  width: 52px;
  color: var(--sidebar-text);
  font-size: 0.86rem;
  box-shadow: none !important;
  outline: none !important;
}

/* ─── Form inputs on dark sidebar ─── */
input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--sidebar-input-border);
  border-radius: 7px;
  background: var(--sidebar-input-bg);
  color: var(--sidebar-text);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 400;
  transition: border-color 120ms ease, background 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--sidebar-muted);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--sidebar-input-border-hover);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--sidebar-input-focus-border);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--sidebar-input-focus-ring);
}

textarea {
  resize: vertical;
  line-height: 1.48;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ─── Items editor ─── */
.items-editor {
  display: grid;
  gap: 8px;
}

.item-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-card-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 400;
  color: rgba(120, 158, 255, 0.75);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.item-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 9px;
}

/* ─── Preview panel ─── */
.preview-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.preview-toolbar {
  border: 0;
  background: transparent;
  padding: 0 2px;
  box-shadow: none;
}

.preview-toolbar .eyebrow {
  color: #7a8fb0;
  margin-bottom: 3px;
}

.preview-toolbar h2 {
  font-size: 1.1rem;
  font-weight: 400;
  color: #1a2340;
  letter-spacing: -0.01em;
}

.preview-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-fit-state {
  margin: 0;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #47536e;
  background: rgba(26, 35, 64, 0.06);
  border: 1px solid rgba(26, 35, 64, 0.12);
}

.page-fit-state.is-overflow {
  color: var(--warning);
  background: rgba(185, 28, 28, 0.08);
  border-color: rgba(185, 28, 28, 0.18);
}

.autosave-state {
  margin: 0;
  color: var(--success);
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(14, 122, 79, 0.1);
  border: 1px solid rgba(14, 122, 79, 0.18);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ─── Document paper (UNTOUCHED) ─── */
.document-pages {
  display: grid;
  gap: 24px;
}

.document-page {
  width: min(100%, 794px);
  height: 1123px;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-inner {
  display: flex;
  flex-direction: column;
  height: 1123px;
}

.doc-main {
  flex: 0 0 auto;
  padding: 44px 48px 18px;
}

/* ─── Doc header: logo left, title block right ─── */
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.doc-logo {
  width: 200px;
  height: 64px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 0;
}

.doc-title-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
}

.doc-title {
  margin: 0 0 4px;
  color: #05070d;
  font-family: var(--font-heading);
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.doc-number {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

/* ─── Billing section ─── */
.doc-billing {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: start;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.doc-bill-label {
  margin: 0 0 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
}

.customer-name {
  margin: 0 0 3px;
  font-family: var(--font-heading);
  font-size: 1.32rem;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.doc-bill-company {
  margin: 2px 0 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}

.doc-bill-detail {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.doc-bill-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  min-width: 190px;
}

.doc-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  font-size: 0.78rem;
  line-height: 1.3;
}

.doc-meta-label {
  color: var(--muted);
}

.doc-meta-val {
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}

.doc-status-chip {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.doc-status-chip.is-unpaid {
  background: rgba(185, 28, 28, 0.07);
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.14);
}

.doc-status-chip.is-partial {
  background: rgba(160, 100, 0, 0.07);
  color: #a06400;
  border: 1px solid rgba(160, 100, 0, 0.14);
}

.doc-status-chip.is-paid {
  background: rgba(14, 122, 79, 0.07);
  color: #0e7a4f;
  border: 1px solid rgba(14, 122, 79, 0.14);
}

/* Legacy - kept for print compat */
.customer-block { margin-bottom: 0; }
.doc-date {
  margin: 0;
  color: #151a2b;
  font-size: 1.08rem;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.doc-table-wrap {
  position: relative;
  margin-top: 12px;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.doc-table-head-bg {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 46px;
  pointer-events: none;
  user-select: none;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.doc-table-header {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 40% 18% 12% 15% 15%;
  align-items: center;
  min-height: 46px;
  padding: 0 10px;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.doc-table-header span {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  white-space: nowrap;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.doc-table-header span:nth-child(n + 3) {
  text-align: right;
}

.doc-table {
  position: relative;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}

.col-product {
  width: 40%;
}

.col-duration {
  width: 18%;
}

.col-quantity {
  width: 12%;
}

.col-price,
.col-total {
  width: 15%;
}

.doc-table td {
  padding: 19px 10px;
  border-bottom: 1px solid #e5e9f2;
  vertical-align: top;
}

.doc-table .numeric {
  text-align: right;
  white-space: nowrap;
}

.product-cell strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.96rem;
}

.product-cell span {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 26px;
  align-items: start;
  margin-top: 24px;
}

.note-copy {
  color: #20283d;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-line;
}

.note-copy strong {
  color: var(--warning);
}

.totals-table {
  display: grid;
  gap: 8px;
  border-top: 1px solid #9aa3b7;
  padding-top: 14px;
}

.total-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  color: #263049;
  font-size: 0.9rem;
}

.total-line strong {
  color: #05070d;
}

.grand-total {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid #d7ddea;
  font-size: 1.08rem;
  font-weight: 900;
}

.doc-footer {
  position: relative;
  margin-top: auto;
  min-height: 210px;
  overflow: hidden;
  background: #0b1c62;
  color: #fff;
  padding: 26px 48px 24px;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.footer-bg-media,
.footer-pattern-media {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  user-select: none;
}

.footer-bg-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 72%;
  z-index: 0;
}

.footer-pattern-media {
  width: 340px;
  height: 340px;
  left: auto;
  right: -42px;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  filter: invert(1);
  opacity: 0.13;
  object-fit: contain;
  z-index: 0;
}

.footer-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  height: 100%;
}

.footer-copy h3 {
  margin: 0 0 8px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.footer-rule {
  width: 24px;
  height: 1px;
  background: rgba(255, 255, 255, 0.22);
  margin-bottom: 10px;
}

.footer-copy p {
  margin: 0;
  max-width: 46ch;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-line;
}

.footer-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
}

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

.footer-contact-item {
  margin: 0 0 3px;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.4;
}

.tagline {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-slogan);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Mobile view toggle ─── */
.mobile-view-toggle {
  display: none;
  grid-column: 1 / -1;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(13, 24, 71, 0.08);
  border: 1px solid rgba(13, 24, 71, 0.1);
}

.view-tab {
  flex: 1;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: rgba(13, 24, 71, 0.55);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 140ms ease, color 140ms ease;
}

.view-tab.is-active {
  background: #fff;
  color: #0d1847;
  box-shadow: 0 1px 4px rgba(10, 15, 40, 0.14);
}

.view-tab:focus-visible {
  outline: 2px solid rgba(99, 142, 255, 0.5);
  outline-offset: 2px;
}

/* ─── Responsive ─── */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
    max-height: none;
    overflow: visible;
    grid-template-columns: 1fr;
  }

  .mobile-view-toggle {
    display: flex;
  }

  .workspace[data-view="edit"] .preview-panel {
    display: none;
  }

  .workspace[data-view="preview"] .editor-panel {
    display: none;
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 18px;
    min-height: auto;
    gap: 12px;
  }

  .topbar-actions,
  .brand-lockup,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 14px 14px 32px;
    gap: 16px;
  }

  .editor-panel,
  .field-grid,
  .item-grid,
  .summary-grid,
  .footer-content {
    grid-template-columns: 1fr;
  }

  .document-page {
    width: 794px;
  }

  .preview-panel {
    overflow-x: auto;
    padding-bottom: 10px;
  }
}

/* ─── Print ─── */
@media print {
  @page {
    size: A4;
    margin: 0;
  }

  .document-page,
  .document-page * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html,
  body {
    height: auto;
    overflow: hidden;
    background: #fff;
    min-height: auto;
  }

  .topbar,
  .editor-panel,
  .preview-toolbar,
  .mobile-view-toggle {
    display: none !important;
  }

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

  .preview-panel {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  .document-pages {
    display: block;
    margin: 0;
    padding: 0;
  }

  .document-page {
    width: 100%;
    height: 297mm;
    box-shadow: none;
    margin: 0;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
  }

  .document-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .doc-inner {
    height: 100%;
  }

  .doc-table-header,
  .doc-table-header span {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 1;
  }

}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
