/* See /MASTER_PROMPT.md */
:root {
  --bg: #f5f7fb;
  --ink: #162033;
  --muted: #647084;
  --line: #dfe5ee;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #e6fffb;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(22, 32, 51, 0.12);
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(15, 118, 110, 0.16), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%);
}

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

.noscript {
  margin: 0;
  padding: 1rem;
  color: #fff;
  text-align: center;
  background: var(--ink);
}

.hero, main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.lang-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0.8rem 0 0;
}

.faq .lang-nav {
  width: 100%;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.lang-nav__label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.lang-nav__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.lang-nav__links a {
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
}

.lang-nav__links a.active,
.lang-nav__links a:hover {
  color: var(--brand-dark);
  border-color: rgba(15, 118, 110, 0.28);
  background: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.04em;
}

.brand span { color: var(--brand); }

.nav-cta, button, .back-link, .download-help {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: 0.18s ease;
}

button:hover, .nav-cta:hover, .back-link:hover, .download-help:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(22, 32, 51, 0.1);
}

.primary {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.primary:hover { background: var(--brand-dark); }
.ghost { color: var(--brand); border-color: rgba(15, 118, 110, 0.3); }
.danger { color: var(--danger); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: center;
  padding: 60px 0 40px;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2, h3, p, a, button, label, summary, td, th, strong {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 820px;
  margin-bottom: 1rem;
  font-size: clamp(2.45rem, 7vw, 5.4rem);
  line-height: 0.94;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 0.9rem;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: -0.04em;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.7;
}

.trust-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.4rem;
}

.trust-tags span {
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: var(--brand-dark);
  background: rgba(230, 255, 251, 0.78);
  font-weight: 700;
}

.hero-card {
  padding: 2rem;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.mini-label {
  display: inline-block;
  margin-bottom: 1.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--brand);
  background: var(--accent);
  font-weight: 800;
}

.hero-card strong {
  display: block;
  font-size: 2.5rem;
  letter-spacing: -0.06em;
}

.hero-card p { color: var(--muted); }

.mini-lines {
  display: grid;
  gap: 0.7rem;
  margin-top: 2rem;
}

.mini-lines i {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #ccfbf1);
}

.mini-lines i:nth-child(2) { width: 78%; opacity: 0.7; }
.mini-lines i:nth-child(3) { width: 55%; opacity: 0.45; }

.app-shell, .seo-block {
  margin: 42px 0;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.toolbar h2 { margin: 0; }

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1.18fr);
  gap: 24px;
  padding: 24px;
}

.workspace > * { min-width: 0; }

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
}

.form-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

legend {
  padding: 0 0.4rem;
  font-weight: 800;
}

label {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.78rem 0.85rem;
  color: var(--ink);
  background: #fff;
}

textarea { min-height: 84px; resize: vertical; }

.two-col, .four-col {
  display: grid;
  gap: 16px;
}

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

.items-head, .item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 82px 112px 44px;
  gap: 10px;
  align-items: center;
}

.items-head {
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.item-row { margin-bottom: 10px; }
.item-row button { padding: 0.68rem 0; border-radius: 12px; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#saveStatus {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-panel {
  padding: 18px;
  background: #eef3f8;
  overflow-x: auto;
}

.invoice-paper {
  min-height: 920px;
  padding: 44px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(22, 32, 51, 0.1);
}

.invoice-head, .bill-grid, .invoice-meta {
  display: grid;
  gap: 18px;
}

.invoice-head {
  grid-template-columns: 1fr 132px;
  align-items: start;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--ink);
}

.doc-type {
  margin: 0 0 0.5rem;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.invoice-head h2 {
  margin: 0 0 0.6rem;
  font-size: 2.1rem;
}

.invoice-paper p {
  color: var(--muted);
  line-height: 1.55;
}

.logo-box {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 1px dashed #b5bfcc;
  border-radius: 16px;
  color: var(--muted);
  overflow: hidden;
}

.logo-box img {
  max-width: 100%;
  max-height: 110px;
  object-fit: contain;
}

.invoice-meta {
  grid-template-columns: repeat(4, 1fr);
  margin: 24px 0;
}

.invoice-meta div, .bill-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.invoice-meta span, .bill-grid span, .invoice-notes span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bill-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

th {
  padding: 12px;
  color: #fff;
  background: var(--ink);
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th:not(:first-child), td:not(:first-child) { text-align: right; }

.totals {
  width: min(340px, 100%);
  margin-left: auto;
  display: grid;
  gap: 0.35rem;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
}

.grand, .balance {
  border-top: 2px solid var(--ink);
  font-size: 1.08rem;
}

.balance strong { color: var(--brand-dark); }

.invoice-notes {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.signature {
  margin-top: 32px;
  color: var(--ink) !important;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
}

.seo-block {
  padding: 34px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.feature-grid article, .callout {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
}

.feature-grid p, .split p, .faq p { color: var(--muted); line-height: 1.7; }

.download-guide {
  scroll-margin-top: 24px;
  border-color: rgba(15, 118, 110, 0.2);
  background: linear-gradient(135deg, rgba(230, 255, 251, 0.94), rgba(255, 255, 255, 0.9));
}

.download-guide ol {
  display: grid;
  gap: 0.85rem;
  margin: 1.1rem 0;
  padding-left: 1.25rem;
  color: var(--ink);
  font-weight: 700;
}

.download-guide li {
  padding-left: 0.35rem;
  line-height: 1.55;
}

.download-tip {
  margin: 0;
  color: var(--brand-dark);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.callout {
  color: var(--brand-dark);
  background: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.tool-card {
  display: grid;
  gap: 0.55rem;
  padding: 22px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 24px;
  color: var(--ink);
  background: linear-gradient(135deg, #ffffff, var(--accent));
  text-decoration: none;
  transition: 0.18s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(22, 32, 51, 0.12);
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: var(--brand);
}

.tool-card strong { font-size: 1.08rem; }
.tool-card p { margin: 0; color: var(--muted); line-height: 1.6; }

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 1rem 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 800;
}

.back-link {
  display: inline-block;
  margin-top: 22px;
}

.legal-note {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 18px;
  color: #7a271a;
  background: #fff7ed;
  line-height: 1.6;
}

.app-footer {
  margin-top: 24px;
  color: var(--muted);
}

.app-footer a {
  color: var(--brand-dark);
  font-weight: 800;
}

@media (max-width: 1020px) {
  .hero-grid, .workspace, .split { grid-template-columns: minmax(0, 1fr); }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-paper { min-height: auto; }
}

@media (max-width: 680px) {
  .hero, main, .lang-nav { width: min(100% - 20px, 1180px); }
  .hero-grid { padding-top: 28px; gap: 24px; }
  .toolbar, .form-actions { align-items: stretch; flex-direction: column; }
  .toolbar-actions, .toolbar-actions button, .toolbar-actions a { width: 100%; }
  .toolbar-actions a { text-align: center; }
  .two-col, .four-col, .feature-grid, .invoice-head, .invoice-meta, .bill-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace, .seo-block, .invoice-paper, .form-panel { padding: 14px; }
  .app-shell, .seo-block { border-radius: 22px; }
  .items-head { display: none; }
  .item-row { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { padding: 10px; }
  .invoice-paper { width: 100%; min-width: 0; }
  table { min-width: 520px; }
  h1 { font-size: clamp(2.35rem, 15vw, 4rem); }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #invoicePreview, #invoicePreview * { visibility: visible; }
  #invoicePreview {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 0;
    padding: 28px;
    border-radius: 0;
    box-shadow: none;
  }
  @page { margin: 12mm; }
}
