:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #5b6477;
  --line: #dde2ef;
  --brand: #0a7ea4;
  --brand-strong: #075f7d;
  --ok: #1f9254;
  --error: #b53939;
  --shadow: 0 20px 50px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 85% -5%, #b8ebf9 0%, transparent 40%),
    radial-gradient(circle at -10% 10%, #ffe9c2 0%, transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: "Candara", "Trebuchet MS", "Segoe UI", sans-serif;
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(45px);
  z-index: -1;
}

.shape-a {
  width: 380px;
  height: 380px;
  right: -120px;
  top: -120px;
  background: rgba(72, 171, 206, 0.2);
}

.shape-b {
  width: 260px;
  height: 260px;
  left: -100px;
  bottom: -90px;
  background: rgba(255, 173, 86, 0.2);
}

.layout {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 20px 1.5vw 40px;
  min-height: 100vh;
}

.hero {
  padding: 14px;
}

.kicker {
  margin: 0;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 600;
}

h1 {
  margin: 10px 0 14px;
  font-family: "Cambria", "Palatino Linotype", serif;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.05;
}

.lead {
  margin: 0;
  color: var(--muted);
  max-width: none;
}

.hint {
  margin-top: 16px;
  font-size: 13px;
  color: #4a556e;
  max-width: 55ch;
}

.badge-row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  border: 1px solid rgba(10, 126, 164, 0.2);
  color: var(--brand-strong);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 500;
}

.card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 22px;
  backdrop-filter: blur(6px);
}

.app-shell {
  padding-top: 18px;
}

#invoice-form {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

#invoice-form.layout-split {
  max-width: 1360px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}

.tab {
  border: 1px solid #c9d8ea;
  background: #f8fbff;
  color: #24405d;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.tab.is-active {
  background: linear-gradient(90deg, #0b7ea5 0%, #1f9b8e 100%);
  border-color: transparent;
  color: #fff;
}

.tab-panel {
  display: none;
}

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

.tab-panel {
  animation: fadein 180ms ease;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card .kicker {
  margin-bottom: 6px;
}

.card .lead {
  margin-bottom: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 210px;
  max-width: 45vw;
  height: auto;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 6px;
}

.section-title span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff4fb;
  color: var(--brand-strong);
  font-family: "Cambria", "Palatino Linotype", serif;
  font-weight: 700;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.grid {
  display: grid;
  gap: 10px;
}

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

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

.field {
  display: grid;
  gap: 6px;
}

.settings-group {
  border: 1px solid #dbe6f5;
  border-radius: 14px;
  background: #fbfdff;
  padding: 12px;
  margin-bottom: 12px;
}

.settings-group h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #244361;
}

label {
  font-size: 12px;
  color: #3f4e63;
  font-weight: 600;
}

.small-note {
  margin: 6px 0 0;
  font-size: 12px;
}

input {
  width: 100%;
  border: 1px solid #c9d7ea;
  background: #fcfdff;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: "Candara", "Trebuchet MS", "Segoe UI", sans-serif;
}

select,
textarea {
  width: 100%;
  border: 1px solid #c9d7ea;
  background: #fcfdff;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: "Candara", "Trebuchet MS", "Segoe UI", sans-serif;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: #6fc5df;
  box-shadow: 0 0 0 4px rgba(111, 197, 223, 0.2);
}

.grow-2 {
  grid-column: span 2;
}

input:focus {
  outline: none;
  border-color: #6fc5df;
  box-shadow: 0 0 0 4px rgba(111, 197, 223, 0.2);
}

.autocomplete-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  display: none;
  z-index: 40;
}

.suggestions button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef2fb;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.suggestions button:hover {
  background: #f8fbfe;
}

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

.item-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1fr auto;
  gap: 10px;
}

.item-desc-wrap {
  position: relative;
}

.product-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #d7e1f0;
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  display: none;
  z-index: 45;
}

.product-suggestions button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef2fb;
  background: #fff;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.product-suggestions button:hover {
  background: #f7fbff;
}

.ghost {
  border: 1px solid #cbd4e3;
  border-radius: 12px;
  background: #fff;
  color: #38445a;
  padding: 9px 12px;
  cursor: pointer;
  transition: all 120ms ease;
}

.ghost:hover {
  background: #eef4ff;
  border-color: #8fb2de;
  color: #1e3f68;
}

.actions-row {
  margin: 8px 0;
}

.totals {
  margin: 12px 0 16px;
  border: 1px solid #dbe6f0;
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  display: grid;
  gap: 8px;
}

.totals > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.totals span {
  color: var(--muted);
}

.totals .grand {
  border-top: 1px dashed #c9d7e7;
  padding-top: 8px;
}

.submit {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, #0a7ea4 0%, #1c9e8e 100%);
  color: white;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.submit:hover {
  filter: brightness(1.04);
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 8px;
}

.preview-head h3 {
  margin: 0;
  font-size: 16px;
}

.inline-select {
  min-width: 220px;
}

.pdf-preview-wrap {
  border: 1px solid #d9e4f2;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 14px;
}

.preview-zone {
  margin: 0 0 10px;
}

.pdf-preview {
  width: 100%;
  min-height: 420px;
  border: 0;
  background: #f6f9ff;
}

@media (min-width: 1240px) {
  #invoice-form.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 22px;
    align-items: start;
  }

  #invoice-form.layout-split > * {
    grid-column: 1;
  }

  #invoice-form.layout-split .preview-zone {
    grid-column: 2;
    grid-row: 1 / span 50;
    position: sticky;
    top: 12px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #dbe6f5;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 10px 26px rgba(15, 32, 59, 0.08);
  }

  #invoice-form.layout-split .pdf-preview-wrap {
    margin-bottom: 0;
    height: calc(100vh - 210px);
  }

  #invoice-form.layout-split .pdf-preview {
    min-height: calc(100vh - 276px);
    height: calc(100vh - 276px);
  }
}

.pdf-preview-wrap .muted {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #edf2fb;
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.hidden {
  display: none;
}

.alert.error {
  border: 1px solid #f2c5c5;
  background: #fff5f5;
}

.alert.success {
  border: 1px solid #bde9cd;
  background: #f2fff7;
}

.alert p {
  margin: 8px 0 0;
}

.alert ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.alert a {
  color: #0f6b7f;
  margin-right: 12px;
}

.compliance-box {
  border: 1px solid #cbd9ee;
  border-radius: 14px;
  background: #f6f9ff;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.compliance-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.compliance-box ul {
  margin: 0;
  padding-left: 18px;
}

.compliance-box li {
  margin: 3px 0;
}

.check-ok {
  color: #136b3c;
}

.check-warn {
  color: #7a5a12;
}

.check-error {
  color: #9f2d2d;
}

.wide {
  grid-column: 1 / -1;
}

.file-inline {
  display: inline-block;
  cursor: pointer;
}

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

.history-search {
  margin-bottom: 10px;
}

.history-lift {
  margin-top: -10px;
}

.history-controls input,
.history-controls select {
  min-height: 38px;
}

.history-item {
  border: 1px solid #d8e2f1;
  background: #fbfdff;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.history-meta {
  display: grid;
  gap: 3px;
}

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

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

.seo-copy {
  border: 1px solid #dde6f5;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-radius: 20px;
  padding: 18px 20px;
}

.seo-copy h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.seo-copy h3 {
  margin: 14px 0 6px;
  font-size: 17px;
  color: #1d3552;
}

.seo-copy p {
  margin: 0 0 8px;
  color: #46556f;
  line-height: 1.65;
}

.seo-copy ul {
  margin: 0 0 12px 18px;
  color: #3f5069;
  line-height: 1.55;
}

.seo-copy li {
  margin: 5px 0;
}

.legal-links {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 10px;
}

.legal-links a {
  color: #2c5f87;
  text-decoration: none;
  font-size: 13px;
}

.legal-links a:hover {
  text-decoration: underline;
}

.byline {
  color: #55728f;
  font-size: 12px;
}

.byline a {
  font-size: 12px;
}

.consent-link {
  position: fixed;
  right: 14px;
  bottom: 12px;
  border: 1px solid #b9cbe2;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #20496d;
  cursor: pointer;
  z-index: 60;
}

.side-tab {
  position: fixed;
  right: -42px;
  transform: rotate(-90deg);
  transform-origin: bottom right;
  display: inline-block;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #b9cbe2;
  border-radius: 10px 10px 0 0;
  background: #fff;
  color: #20496d;
  padding: 6px 10px;
  text-decoration: none;
  cursor: pointer;
  z-index: 59;
}

.feedback-tab {
  bottom: 130px;
}

.help-tab {
  bottom: 190px;
}

.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 36, 0.38);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 12px;
}

.help-card {
  width: min(680px, 100%);
  background: #fff;
  border: 1px solid #d3e0f1;
  border-radius: 14px;
  padding: 14px;
}

.help-card h3 {
  margin: 0 0 8px;
}

.help-card ul {
  margin: 0 0 10px 18px;
}

.consent-banner {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 24px));
  background: #ffffff;
  border: 1px solid #cfe0f2;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  padding: 12px 14px;
  z-index: 70;
}

.consent-banner h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.consent-banner p {
  margin: 0 0 8px;
  color: #41536d;
}

.consent-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.consent-legal-links {
  margin: 0 0 10px;
  font-size: 13px;
  color: #41536d;
}

.consent-legal-links a {
  color: #20496d;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 20px 14px 30px;
  }
}

@media (max-width: 720px) {
  .brand-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo {
    width: 180px;
  }

  .cols-2,
  .cols-3,
  .item-row {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  .preview-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pdf-preview {
    min-height: 360px;
  }

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

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .side-tab {
    display: none;
  }
}
