@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;
}

: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;
  --ink: #0d1224;
  --muted: #5a6275;
  --line: #d9deea;
  --panel: #f6f8fb;
  --surface: #ffffff;
  --blue: #1537b2;
  --blue-deep: #071446;
  --blue-soft: #255df2;
  --focus: #4776ff;
  --success: #0e7a4f;
  --warning: #b91c1c;
  --shadow: 0 18px 48px rgba(13, 18, 36, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 32px;
  border-bottom: 1px solid #e7ebf2;
  background: #fff;
}

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

.brand-logo {
  width: 118px;
  height: 42px;
  object-fit: contain;
  object-position: left center;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 0.95rem;
  font-weight: 700;
}

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

.primary-button,
.ghost-button,
.small-button,
.segment,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  padding: 0 15px;
  background: var(--blue);
  color: #fff;
  font-weight: 720;
  box-shadow: none;
}

.ghost-button,
.small-button {
  padding: 0 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 680;
}

.primary-button:hover,
.ghost-button:hover,
.small-button:hover,
.segment:hover,
.icon-button:hover {
  border-color: #c8d0e1;
  box-shadow: 0 4px 12px rgba(13, 18, 36, 0.06);
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.small-button:focus-visible,
.segment:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(71, 118, 255, 0.28);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 32px;
  padding: 22px 32px 40px;
  align-items: start;
}

.editor-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 0;
  max-height: calc(100vh - 114px);
  overflow: auto;
  padding: 6px 18px;
  border: 1px solid #e1e6ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(13, 18, 36, 0.03);
}

.control-section {
  border: 0;
  border-bottom: 1px solid #edf1f6;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 17px 0;
}

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

.control-section h2,
.preview-toolbar h2 {
  color: #11182a;
  font-size: 0.9rem;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #f4f6fa;
  margin-top: 10px;
}

.segment {
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.segment.is-active {
  background: var(--surface);
  color: var(--blue);
  border-color: #dfe5f1;
  box-shadow: 0 1px 2px rgba(13, 18, 36, 0.06);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 11px;
}

label {
  display: grid;
  gap: 5px;
  color: #465065;
  font-size: 0.76rem;
  font-weight: 650;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #dde3ee;
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 0.9rem;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #c9d1df;
}

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

.items-editor {
  display: grid;
  gap: 10px;
  margin-top: 11px;
}

.item-card {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid #e6ebf3;
  border-radius: 8px;
  background: #f8fafc;
}

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

.item-card-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 740;
  color: var(--blue);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-color: #efd2d2;
  background: #fffafa;
  color: var(--warning);
  font-weight: 800;
}

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

.preview-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

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

.autosave-state {
  margin: 0;
  color: var(--success);
  padding: 5px 10px;
  border-radius: 999px;
  background: #eaf7f1;
  font-size: 0.78rem;
  font-weight: 700;
}

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

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

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

.doc-logo {
  width: 238px;
  height: 82px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 34px;
}

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

.customer-block {
  margin-bottom: 28px;
}

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

.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: 218px;
  overflow: hidden;
  background: #0b1c62;
  color: #fff;
  padding: 30px 54px 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 14px;
  font-size: 0.98rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.footer-side {
  display: grid;
  align-content: end;
  justify-items: end;
}

.tagline {
  margin: 0;
  color: #fff;
  font-family: var(--font-slogan);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

@media (max-width: 780px) {
  .topbar,
  .topbar-actions,
  .brand-lockup,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 16px;
    gap: 18px;
  }

  .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;
  }
}

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

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

  body {
    background: #fff;
    min-height: auto;
  }

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

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

  .preview-panel {
    display: block;
  }

  .document-page {
    width: 100%;
    min-height: 0;
    height: auto;
    box-shadow: none;
    margin: 0;
    overflow: visible;
  }

  .doc-inner {
    display: block;
    min-height: 0;
    height: auto;
  }

  .doc-main {
    padding: 12mm 14mm 70mm;
  }

  .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;
  }

  .doc-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64mm;
    min-height: 64mm;
    margin-top: 0;
    padding: 8mm 14mm 7mm;
  }

  .footer-content {
    gap: 12mm;
  }

  .footer-copy h3 {
    margin-bottom: 3mm;
    font-size: 0.88rem;
    line-height: 1;
  }

  .footer-copy p {
    max-width: 50ch;
    font-size: 0.78rem;
    line-height: 1.24;
  }

  .tagline {
    font-size: 0.62rem;
  }
}

@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;
  }
}
