:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --panel: rgba(255, 255, 255, 0.82);
  --canvas: #f8fafc;
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --accent-soft: #eef2ff;
  --rose-soft: #fdf2f8;
  --danger: #dc2626;
  --shadow: 0 22px 60px rgba(79, 70, 229, 0.14);
  --shadow-soft: 0 16px 42px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #e0e7ff, transparent 34%),
    linear-gradient(135deg, #f8fafc, #eef2ff 48%, #fdf2f8);
}

body.locked .app-shell {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1380px, calc(100% - 56px));
  margin: 18px auto 0;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.site-nav div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  color: #334155;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.site-nav .brand-link {
  color: var(--ink);
  font-size: 1rem;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(500px, 1fr) minmax(390px, 430px);
  gap: 28px;
  width: min(1380px, 100%);
  min-height: calc(100vh - 74px);
  margin: 0 auto;
  padding: 28px;
}

.editor,
.preview-wrap {
  min-width: 0;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(248, 250, 252, 0.86);
  backdrop-filter: blur(10px);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
  padding: 30px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.auth-copy,
.hero-copy,
.section-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.auth-tabs button {
  min-height: 42px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
  font-weight: 800;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form .primary {
  width: 100%;
}

.site-page .site-nav {
  margin-bottom: 26px;
}

.page-shell {
  width: min(980px, calc(100% - 56px));
  margin: 0 auto 56px;
}

.page-card {
  padding: 34px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.page-card h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.page-card h2 {
  margin-bottom: 10px;
}

.page-card section {
  margin-top: 24px;
}

.page-card p,
.page-card li {
  color: #334155;
  line-height: 1.65;
}

.page-card a {
  color: var(--accent-dark);
  font-weight: 900;
}

.legal-copy section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 28px;
  margin-bottom: 26px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  margin: 0 0 10px;
  padding: 6px 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #dbeafe;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  color: #020617;
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.actions,
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-badge {
  max-width: 240px;
  overflow: hidden;
  padding: 8px 12px;
  color: #334155;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.panel {
  padding: 24px;
  margin-bottom: 22px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.plan-panel {
  border-color: rgba(199, 210, 254, 0.86);
}

.tier-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tier-card {
  display: grid;
  align-items: center;
  min-height: 72px;
  padding: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.tier-card.selected {
  background: var(--accent-soft);
  border-color: #c7d2fe;
}

.tier-card span {
  display: grid;
  gap: 3px;
}

.tier-card small {
  color: var(--muted);
  font-weight: 700;
}

.tier-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 72px 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 0.86rem;
}

.tier-grid span {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.tier-grid span:nth-child(3n + 2),
.tier-grid span:nth-child(3n + 3) {
  text-align: center;
}

.tier-grid span:nth-child(-n + 3) {
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.tier-grid span:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.notice {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.upgrade-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

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

.history-item {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(120px, 1.2fr) minmax(88px, 0.7fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 0.88rem;
}

.history-item span,
.empty-state {
  color: var(--muted);
}

.empty-state {
  margin: 0;
  font-size: 0.92rem;
}

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

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

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

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

label {
  display: grid;
  gap: 8px;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  background: #fff;
  border-color: #818cf8;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.file-field input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-field span {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 12px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
}

.primary,
.secondary,
.text-button,
.icon-button {
  min-height: 42px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-weight: 900;
}

.primary {
  padding: 0 18px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.18);
}

.primary:hover {
  background: #1e293b;
}

.secondary {
  padding: 0 16px;
  color: #334155;
  background: rgba(255, 255, 255, 0.82);
  border-color: #e2e8f0;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.text-button {
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.2);
}

.icon-button {
  inline-size: 42px;
  color: var(--danger);
  background: #fff7f7;
  border-color: #fecaca;
  font-size: 1.35rem;
  line-height: 1;
}

.line-items {
  display: grid;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.line-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 82px 112px 116px 48px;
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
}

.line-item:first-child::before {
  content: "Description";
  grid-column: 1;
}

.line-item:first-child label:nth-of-type(2)::before {
  content: "Qty";
}

.line-item:first-child label:nth-of-type(3)::before {
  content: "Rate";
}

.line-item:first-child::before,
.line-item:first-child label:nth-of-type(2)::before,
.line-item:first-child label:nth-of-type(3)::before {
  position: absolute;
  opacity: 0;
}

.line-item:last-child {
  border-bottom: 0;
}

.line-item label {
  text-transform: none;
}

.line-item input {
  min-height: 42px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 16px;
  box-shadow: none;
}

.line-item output {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 42px;
  padding: 0 10px;
  color: #1e293b;
  font-weight: 900;
}

.preview-wrap {
  position: sticky;
  top: 28px;
  align-self: start;
}

.invoice-preview {
  overflow: hidden;
  min-height: calc(100vh - 56px);
  background: #fff;
  border-radius: 30px;
  box-shadow: 0 26px 70px rgba(79, 70, 229, 0.2);
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  color: #fff;
  background: var(--ink);
}

.preview-logo {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
  padding: 8px;
  background: #fff;
  border-radius: 20px;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 950;
}

.invoice-title {
  text-align: right;
}

.invoice-title h2 {
  margin-bottom: 4px;
  font-size: 2rem;
  text-transform: none;
}

.payment-badge {
  display: inline-flex;
  justify-content: center;
  min-width: 86px;
  margin-top: 8px;
  padding: 5px 9px;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.22);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
}

.preview-body {
  display: grid;
  gap: 22px;
  padding: 24px;
}

.preview-meta,
.preview-parties,
.preview-item,
.preview-notes {
  display: grid;
  gap: 12px;
}

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

.preview-block,
.preview-parties {
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 22px;
}

.preview-block:nth-child(2) {
  background: var(--accent-soft);
}

.preview-block h3,
.preview-parties h3,
.preview-notes h3 {
  margin: 0 0 6px;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.preview-block p,
.preview-parties p,
.preview-notes p {
  margin: 0;
  color: #475569;
  white-space: pre-line;
}

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

.preview-item {
  grid-template-columns: 1fr auto;
  padding: 14px;
  background: #f8fafc;
  border-radius: 18px;
}

.preview-item strong {
  color: #1e293b;
}

.preview-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-totals {
  display: grid;
  gap: 12px;
  padding: 20px;
  color: #fff;
  background: var(--ink);
  border-radius: 24px;
}

.preview-total-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #cbd5e1;
}

.preview-total-row.grand {
  margin-top: 4px;
  padding-top: 16px;
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1.55rem;
  font-weight: 950;
}

body[data-template="modern"] .invoice-preview {
  border-top: 8px solid var(--accent);
}

body[data-template="compact"] .preview-body {
  gap: 14px;
  padding: 18px;
}

.content-section {
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto 48px;
}

.guide-article {
  padding: 30px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.guide-article h2 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(1.9rem, 3vw, 2.5rem);
}

.guide-article h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.guide-article p {
  color: #334155;
  line-height: 1.65;
}

.article-meta {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.article-grid section,
.faq-list details {
  padding: 18px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.article-grid p,
.faq-list p {
  margin-bottom: 0;
}

.faq-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.faq-list summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.faq-list details[open] summary {
  margin-bottom: 10px;
}

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

  .preview-wrap {
    position: static;
  }
}

@media (max-width: 760px) {
  .site-nav {
    position: static;
    align-items: stretch;
    flex-direction: column;
    width: calc(100% - 28px);
    margin-top: 14px;
  }

  .site-nav div {
    justify-content: flex-start;
  }

  .app-shell {
    padding: 14px;
  }

  .topbar,
  .actions,
  .section-heading,
  .upgrade-row,
  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .grid.four,
  .line-item,
  .tier-options,
  .article-grid,
  .history-item,
  .preview-meta,
  .preview-item {
    grid-template-columns: 1fr;
  }

  .content-section {
    width: calc(100% - 28px);
  }

  .page-shell {
    width: calc(100% - 28px);
  }

  .line-item output {
    justify-content: flex-start;
  }

  .invoice-title {
    text-align: left;
  }

  .panel,
  .topbar,
  .invoice-preview,
  .guide-article,
  .page-card {
    border-radius: 24px;
  }
}
