:root {
  color-scheme: light;
  --ink: #172923;
  --muted: #52635a;
  --line: #dce5de;
  --green: #216344;
  --lime: #c8ef8a;
  --paper: #fff;
  --bg: #f2f5f1;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .47; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #57962b; outline-offset: 3px; }
.topbar { background: #14271e; color: white; }
.top-inner { width: min(1512px, 100%); padding: 0 42px; margin: auto; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: max-content; text-decoration: none; }
.brand img { border-radius: 10px; border: 1px solid #526452; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -.01em; }
.brand small { color: #b5c8bb; font-size: .75rem; margin-top: 2px; }
nav { display: flex; gap: 5px; align-items: center; }
nav a { color: #d7e4da; font-size: .875rem; font-weight: 600; padding: 10px 15px; border-radius: 7px; white-space: nowrap; text-decoration: none; }
nav a:hover { background: #253c30; }
nav a[aria-current] { background: #304d3d; color: #e4ffbe; }
.workspace { width: min(1512px, 100%); margin: auto; padding: 30px 42px 0; }
.workspace-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 22px; }
.eyebrow { font-size: .75rem; font-weight: 750; letter-spacing: .16em; color: var(--green); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 750; line-height: 1.05; letter-spacing: -.055em; margin: 7px 0 10px; }
#draft-status { color: var(--muted); font-size: .875rem; }
.status-dot { display: inline-block; width: .5rem; height: .5rem; background: #599739; border-radius: 50%; margin-right: .4rem; vertical-align: .08em; }
.actions, .inline-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.button, .icon-button { border: 1px solid transparent; border-radius: 8px; min-height: 42px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 650; font-size: .875rem; }
.button.mobile-preview { display: none; }
.button.primary { background: var(--lime); color: #192e1a; border-color: #badd83; }
.button.primary:hover:enabled { background: #bde873; }
.button.secondary, .icon-button { background: white; border-color: #cfdbd1; color: var(--ink); }
.button.secondary:hover:enabled, .icon-button:hover:enabled { background: #edf5ed; }
.button.compact { min-height: 35px; padding: 0 10px; }
.button.danger { background: #a02637; color: white; }
.text-button { border: 0; background: transparent; padding: 6px 0; color: var(--green); font-weight: 650; font-size: .875rem; }
.text-button:hover:enabled { text-decoration: underline; }
[data-icon] { display: inline-flex; flex-shrink: 0; }
[data-icon] svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
.editor, .preview { min-width: 0; }
.card, .preview { border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 3px 10px #18302607; }
.card { padding: 19px; margin-bottom: 13px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.card-title > div { flex: 1; min-width: 0; }
.card-title h2, .preview-head h2 { font-size: 1.05rem; letter-spacing: -.015em; line-height: 1.25; }
.card-title p, .preview-head p, .help { color: var(--muted); font-size: .8125rem; margin-top: 3px; line-height: 1.45; }
.section-icon, .preview-icon { align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; color: var(--green); background: #eaf3e9; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; font-size: .875rem; font-weight: 600; }
.field.full, .full { grid-column: 1 / -1; }
input, select, textarea { border: 1px solid #d4dfd6; background: #fbfcfa; border-radius: 7px; padding: 8px 10px; width: 100%; min-width: 0; min-height: 39px; color: var(--ink); font-weight: 400; }
input::placeholder, textarea::placeholder { color: #67786d; }
select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%2352635a' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
textarea { resize: vertical; min-height: 61px; }
input[type=color] { padding: 4px; }
input[type=file] { padding: 6px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #689d54; outline-offset: 1px; }
.line-item { padding: 13px 0; border-top: 1px solid var(--line); }
.line-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; font-size: .875rem; }
.line-head strong { font-variant-numeric: tabular-nums; }
.line-head .icon-button { min-height: 27px; width: 31px; padding: 0; }
.line-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.span-2 { grid-column: span 2; }
.summary { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; margin-top: 15px; }
.summary strong { color: var(--ink); }
.editor-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 4px 0 9px; }
.sample { background: #eaf3e5; border: 1px solid #d4e6cf; border-radius: 8px; padding: 8px 12px; font-size: .875rem; margin-bottom: 12px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.preview { position: sticky; top: 14px; overflow: hidden; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.preview-label { display: flex; align-items: center; gap: 10px; }
.export-hint { padding: 8px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.preview-board { background: #e4ebe4; background-image: radial-gradient(#afc2b1 0.7px, transparent 0.7px); background-size: 13px 13px; padding: 19px; max-height: max(280px, calc(100vh - 358px)); min-height: 240px; overflow: auto; }
#invoice-canvas { display: block; width: min(100%, 595px); height: auto; margin: auto; background: white; box-shadow: 0 3px 12px #122c2342; }
#invoice-canvas:not([width]) { display: none; }
#native-preview { display: block; width: 100%; min-height: min(660px, 60vh); border: 0; background: white; }
.preview-message { text-align: center; color: var(--muted); padding: 30px 0; font-size: .875rem; }
.preview-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-top: 1px solid var(--line); }
.page-controls { display: flex; align-items: center; gap: 9px; font-size: .8125rem; color: var(--muted); }
.page-controls .icon-button { min-height: 29px; width: 29px; padding: 0; font-size: 1.15rem; line-height: 1; }
.app-footer { text-align: center; font-size: .8125rem; padding: 17px; color: var(--muted); }
.app-footer span { margin: 0 5px; }
.record { display: flex; justify-content: space-between; gap: 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.record h3 { font-size: .95rem; overflow-wrap: anywhere; }
.record .inline-actions { justify-content: flex-end; flex: 0 0 auto; }
.record .help { overflow-wrap: anywhere; }
.record-list { margin-top: 13px; }
.logo-controls { display: flex; align-items: end; margin: 0 0 13px; gap: 12px; flex-wrap: wrap; }
.logo-controls img { width: 45px; height: 45px; object-fit: contain; border-radius: 7px; border: 1px solid var(--line); }
.logo-controls label { flex: 1 1 190px; }
.logo-controls .button { min-height: 39px; }
.toast { position: fixed; right: 18px; bottom: 17px; max-width: min(28rem, calc(100% - 36px)); z-index: 5; color: #fff; background: #1f4030; border-radius: 8px; padding: 12px 15px; box-shadow: 0 6px 22px #1729233d; }
dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(480px, calc(100% - 28px)); }
dialog::backdrop { background: #14271e9c; }
dialog h2 { font-size: 1.2rem; margin-bottom: 8px; }
dialog p { line-height: 1.5; margin-bottom: 15px; color: var(--muted); }
dialog .inline-actions { justify-content: flex-end; }
dialog a.button { text-decoration: none; }
@media (max-width: 1100px) {
  .workspace, .top-inner { padding-left: 24px; padding-right: 24px; }
  .studio { gap: 15px; }
}
@media (max-width: 800px) {
  .studio { grid-template-columns: 1fr; }
  .button.mobile-preview { display: inline-flex; }
  .preview { position: static; }
  .preview-board { max-height: 72vh; }
  .top-inner { min-height: unset; padding-top: 13px; padding-bottom: 9px; flex-wrap: wrap; gap: 9px; }
  nav { overflow-x: auto; max-width: 100%; }
  nav a { padding: 9px 10px; }
}
@media (max-width: 470px) {
  .workspace, .top-inner { padding-left: 12px; padding-right: 12px; }
  .workspace { padding-top: 20px; }
  .workspace-head { flex-wrap: wrap; }
  .card, .preview-head { padding: 13px; }
  .preview-board { padding: 10px; }
  .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record { flex-wrap: wrap; }
}
