/* ============ Design tokens ============ */
/* Brand: Loov purple #A00CDA from the official logo, deepening to indigo in gradients */
:root {
  --brand: #a00cda;
  --brand-2: #5b3df5;
  --brand-soft: #f6e8fc;
  --grad: linear-gradient(120deg, #a00cda 0%, #7b2ff7 55%, #4f46e5 100%);
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --border: #e4e6ef;
  --text: #171a2c;
  --muted: #6b7088;
  --success: #12a150;
  --warning: #d97706;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(20, 22, 50, .04), 0 8px 24px rgba(20, 22, 50, .06);
  --radius: 14px;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #c95cf0; --brand-soft: #2d1838;
    --bg: #0d0f1a; --surface: #151827; --surface-2: #1c2033; --border: #2a2f45;
    --text: #eceefa; --muted: #9aa0bb;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #c95cf0; --brand-soft: #2d1838;
  --bg: #0d0f1a; --surface: #151827; --surface-2: #1c2033; --border: #2a2f45;
  --text: #eceefa; --muted: #9aa0bb;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
a[role="button"] { cursor: pointer; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* minmax(0, …) stops wide content (the 794px A4 invoice) from stretching the column on phones */
@media (max-width: 1100px) { .g21 { grid-template-columns: minmax(0, 1fr); } }
.g21 > * { min-width: 0; }
@media (max-width: 600px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; } .kpi .val { font-size: 19px; } .kpi .ic { display: none; }
}

/* ============ Controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn.grad { background: var(--grad); color: #fff; border: 0; background-size: 200% 200%; animation: gradmove 6s ease infinite; }
.btn.wa { background: #25d366; color: #06301a; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.icon-btn { padding: 8px; }
label.f { display: grid; gap: 6px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; width: 100%;
  outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
textarea { min-height: 72px; resize: vertical; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.paid { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.badge.overdue { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.sent, .badge.partial { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { transition: background .15s; }
table.t tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* ============ Landing ============ */
.landing { min-height: 100vh; overflow-x: hidden; }
.nav { display: flex; align-items: center; gap: 12px; padding: 18px clamp(16px, 5vw, 64px); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--bg) 75%, transparent); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); }
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo img { height: var(--h, 30px); width: auto; display: block; }
.brand-logo .on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo .on-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo .on-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo .on-light { display: none; }
:root[data-theme="dark"] .brand-logo .on-dark { display: block; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 800; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent); }
.hero { position: relative; padding: clamp(40px, 8vw, 96px) clamp(16px, 5vw, 64px) 40px; text-align: center; }
.hero h1 { font-size: clamp(34px, 6vw, 66px); font-weight: 800; letter-spacing: -.03em; max-width: 920px; margin: 18px auto 0; }
.hero p.lead { font-size: clamp(15px, 2vw, 19px); color: var(--muted); max-width: 640px; margin: 18px auto 28px; }
.rotator { display: inline-block; position: relative; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; min-width: 4ch; }
.rotator span { display: inline-block; animation: wordIn .55s cubic-bezier(.2, .8, .2, 1); }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; z-index: -1; animation: float 12s ease-in-out infinite; }
.blob.a { width: 380px; height: 380px; background: #a00cda; top: -60px; left: -80px; }
.blob.b { width: 320px; height: 320px; background: #4f46e5; top: 120px; right: -60px; animation-delay: -4s; }
.pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px; box-shadow: var(--shadow); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }
.typing { font-family: ui-monospace, Consolas, monospace; border-right: 2px solid var(--brand); padding-right: 3px; animation: caret 1s steps(1) infinite; }
.mock { max-width: 1000px; margin: 46px auto 0; border-radius: 18px; padding: 10px; background: var(--grad); box-shadow: 0 30px 80px color-mix(in srgb, var(--brand) 30%, transparent); transform: perspective(1400px) rotateX(8deg); transition: transform .6s; }
.mock:hover { transform: perspective(1400px) rotateX(0); }
.mock-inner { background: var(--surface); border-radius: 12px; padding: 18px; text-align: left; }
.mock .kpi .val { font-size: clamp(14px, 3.6vw, 26px); }
@media (max-width: 600px) { .mock-inner { padding: 10px; } .mock { transform: none; } }
.section { padding: 70px clamp(16px, 5vw, 64px); max-width: 1200px; margin: 0 auto; }
.section h2 { font-size: clamp(26px, 4vw, 40px); text-align: center; letter-spacing: -.02em; }
.section .sub { text-align: center; color: var(--muted); margin: 10px auto 36px; max-width: 600px; }
.feature { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: transform .25s, box-shadow .25s, border-color .25s; }
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.feature .ic svg.i { width: 22px; height: 22px; }
.feature h4 { font-size: 15.5px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 13.5px; }
.price-card { max-width: 420px; margin: 0 auto; text-align: center; padding: 32px; position: relative; overflow: hidden; }
.price-card .amt { font-size: 52px; font-weight: 800; letter-spacing: -.03em; }
.price-card ul { list-style: none; padding: 0; margin: 20px 0; text-align: left; display: grid; gap: 9px; }
.price-card li { display: flex; gap: 10px; align-items: center; }
.price-card li svg { color: var(--success); }
.ribbon { position: absolute; top: 18px; right: -38px; transform: rotate(45deg); background: var(--grad); color: #fff; padding: 4px 44px; font-size: 12px; font-weight: 700; }
.marquee { overflow: hidden; white-space: nowrap; border-block: 1px solid var(--border); padding: 14px 0; color: var(--muted); font-weight: 600; }
.marquee > div { display: inline-flex; gap: 42px; animation: marquee 30s linear infinite; padding-left: 42px; }
.footer { padding: 30px clamp(16px, 5vw, 64px); border-top: 1px solid var(--border); color: var(--muted); display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
/* Content is always visible at rest; scrolling into view only adds a gentle rise */
.reveal.in { animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: .35; transform: translateY(18px); } to { opacity: 1; transform: none; } }
/* Hosted demo: the frame cannot print or save files, so those actions are hidden */
html.embed .x-file { display: none !important; }

/* ============ Auth ============ */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
/* Deep navy, not purple: the logo's purple accents must stay visible on this panel */
.auth-art { background: radial-gradient(620px 420px at 85% 10%, rgba(160,12,218,.38), transparent 70%), radial-gradient(560px 420px at 10% 95%, rgba(79,70,229,.35), transparent 70%), linear-gradient(160deg, #150a26, #0b0716 60%, #0d0b22); background-size: 140% 140%; animation: gradmove 14s ease infinite; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h2 { font-size: 38px; letter-spacing: -.02em; max-width: 440px; }
.auth-art .logo { position: relative; z-index: 2; }
.auth-art .floaty { position: absolute; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(6px); border-radius: 14px; padding: 12px 16px; font-weight: 600; animation: float 7s ease-in-out infinite; display: flex; gap: 8px; align-items: center; }
.auth-form { display: grid; place-items: center; padding: 32px 16px; }
.auth-form .box { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 2px 0 12px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.gsi-btn { display: flex; justify-content: center; min-height: 44px; }
.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input { text-align: center; font-size: 20px; font-weight: 700; padding: 12px 0; }
/* Login: laptop + phone mockup with "breathing" feature chips */
.auth-art .devices { position: relative; height: 380px; max-width: 560px; width: 100%; margin: 10px auto; }
.auth-art .laptop { position: absolute; left: 4%; top: 30px; width: 80%; animation: floatdev 8s ease-in-out infinite; }
.auth-art .lscreen { background: #0d0b16; border: 9px solid #23202f; border-bottom-width: 12px; border-radius: 14px 14px 0 0; box-shadow: 0 30px 70px rgba(0,0,0,.55); overflow: hidden; aspect-ratio: 16 / 10; }
.auth-art .lscreen img, .auth-art .mphone img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.auth-art .lbase { height: 12px; margin: 0 -7%; background: linear-gradient(#cfd0da, #8d8fa1); border-radius: 0 0 14px 14px; box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.auth-art .mphone { position: absolute; right: 3%; top: 110px; width: 25%; aspect-ratio: 9 / 19; border: 6px solid #111018; border-radius: 22px; overflow: hidden; background: #fff; box-shadow: 0 30px 60px rgba(0,0,0,.6); animation: floatdev 7s ease-in-out infinite reverse; }
.auth-art .breathe { position: absolute; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 8px 13px; border-radius: 99px; font-size: 13px; font-weight: 700;
  background: rgba(21,10,38,.72); border: 1px solid rgba(213,139,255,.45); backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: breathe 3.3s ease-in-out infinite; }
.auth-art .breathe svg { width: 16px; height: 16px; color: #d58bff; }
.auth-art .breathe.c1 { left: -2%; top: 4px; } .auth-art .breathe.c2 { right: 2%; top: 46px; } .auth-art .breathe.c3 { left: -4%; top: 170px; }
.auth-art .breathe.c4 { right: -2%; bottom: 46px; } .auth-art .breathe.c5 { left: 8%; bottom: 0; } .auth-art .breathe.c6 { left: 42%; bottom: -14px; }
@keyframes breathe { 0%, 100% { transform: scale(1); box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 0 rgba(160,12,218,.0); } 50% { transform: scale(1.07); box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 22px 2px rgba(160,12,218,.45); } }
@keyframes floatdev { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.keep { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; margin-top: -4px; }
.keep input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.keep .muted { font-weight: 500; font-size: 12px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  /* Phones: a compact animated banner above the form instead of the full panel */
  .auth-art { padding: 18px 16px 8px; min-height: 0; }
  .auth-art .auth-copy, .auth-art .auth-by, .auth-art .logo { display: none; }
  .auth-art .devices { height: 210px; margin: 6px auto 0; max-width: 380px; }
  .auth-art .laptop { top: 14px; } .auth-art .mphone { top: 52px; border-width: 4px; border-radius: 14px; }
  .auth-art .lscreen { border-width: 5px; border-bottom-width: 7px; } .auth-art .lbase { height: 7px; }
  .auth-art .breathe { font-size: 10.5px; padding: 5px 9px; } .auth-art .breathe svg { width: 12px; height: 12px; }
  .auth-art .breathe.c5, .auth-art .breathe.c6 { display: none; }
  .auth-art .breathe.c3 { top: 96px; } .auth-art .breathe.c4 { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { .auth-art .breathe, .auth-art .laptop, .auth-art .mphone { animation: none; } }

/* ============ App shell ============ */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .logo { padding: 4px 8px 14px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; position: relative; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--brand-soft); color: var(--brand); }
.nav-item.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav-item .tag { margin-left: auto; font-size: 10px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.topbar .search { max-width: 360px; position: relative; flex: 1; }
.topbar .search input { padding-left: 36px; }
.topbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.page { padding: 24px; max-width: 1360px; animation: pageIn .35s ease; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; letter-spacing: -.02em; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.menu-btn { display: none; }
.trial-bar { background: var(--grad); color: #fff; border-radius: 12px; padding: 12px 14px; font-size: 12.5px; margin-top: auto; }
.trial-bar b { display: block; font-size: 13.5px; }
.powered { font-size: 11.5px; color: var(--muted); padding: 10px; text-align: center; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: 270px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .page { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .hide-sm { display: none !important; }
}
.bottom-nav { display: none; }
@media (max-width: 600px) {
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 20; justify-content: space-around; padding: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav a { display: grid; justify-items: center; font-size: 10.5px; color: var(--muted); font-weight: 600; gap: 2px; }
  .bottom-nav a.on { color: var(--brand); }
  .bottom-nav .fab { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; margin-top: -22px; box-shadow: var(--shadow); }
  .page { padding-bottom: 90px; }
}

/* ============ Dashboard ============ */
.kpi { position: relative; overflow: hidden; }
.kpi .lbl { color: var(--muted); font-weight: 600; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; font-weight: 700; margin-top: 4px; }
.kpi .delta.up { color: var(--success); } .kpi .delta.down { color: var(--danger); }
.kpi .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--brand-soft); opacity: .6; z-index: 0; }
.kpi > * { position: relative; z-index: 1; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.quick a { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 12.5px; text-align: center; transition: transform .2s, background .2s; }
.quick a:hover { transform: translateY(-3px); background: var(--brand-soft); color: var(--brand); }
.quick a .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--brand); box-shadow: var(--shadow); }
.chart-box { position: relative; height: 260px; }

/* ============ Doc editor ============ */
/* Form on the left gets most of the room; the live preview is a smaller, scaled-down page on the right */
.editor { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor > * { min-width: 0; }
.editor > .grid, .g21 > .grid { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1180px) { .editor { grid-template-columns: minmax(0, 1fr); } .preview-wrap { position: static; } }
/* Items table fits its card: no sideways scrolling. Below 640px each line becomes a stacked card. */
.items-table { width: 100%; table-layout: fixed; }
.items-table th:nth-child(2) { width: 10%; } .items-table th:nth-child(3) { width: 7%; } .items-table th:nth-child(4) { width: 12%; }
.items-table th:nth-child(5) { width: 7%; } .items-table th:nth-child(6) { width: 12%; } .items-table th:nth-child(7) { width: 17%; } .items-table th:nth-child(8) { width: 34px; }
.items-table th { padding: 8px 4px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items-table input, .items-table select { padding: 7px 5px; border-radius: 8px; min-width: 0; width: 100%; font-size: 13.5px; }
.items-table select { padding-right: 2px; }
.items-table input[type=number] { -moz-appearance: textfield; } .items-table input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.items-table td { padding: 6px 3px; vertical-align: top; }
.items-table td.num { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.items-wrap { overflow: visible !important; }
@media (max-width: 640px) {
  .items-table, .items-table tbody, .items-table tr, .items-table td { display: block; width: 100% !important; }
  .items-table thead { display: none; }
  .items-table tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .items-table td { padding: 0; }
  .items-table td:first-child { grid-column: 1 / -1; }
  .items-table td.num { grid-column: 1 / 3; padding-top: 8px; }
}
.paper-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.paper-pick select { width: auto; padding: 5px 8px; font-size: 12px; }
.totals { display: grid; gap: 6px; margin-left: auto; max-width: 320px; }
.totals .r { display: flex; justify-content: space-between; }
.totals .grand { font-size: 18px; font-weight: 800; padding-top: 8px; border-top: 1px dashed var(--border); }
.preview-wrap { position: sticky; top: 80px; }
.preview-scroll { background: var(--surface-2); border-radius: var(--radius); padding: 16px; overflow: auto; max-height: calc(100vh - 160px); }
.tpl-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-pick button { border: 2px solid var(--border); background: var(--surface); border-radius: 10px; padding: 6px 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text); }
.tpl-pick button.on { border-color: var(--brand); color: var(--brand); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }

/* ============ Invoice paper (always light) ============ */
.paper {
  --acc: #5b4cf5;
  background: #fff; color: #1d2033; width: var(--pw, 794px); min-height: var(--ph, 1121px); margin: 0 auto;
  padding: 36px 38px 22px; font-size: 12px; line-height: 1.5; border-radius: 4px; box-sizing: border-box;
  box-shadow: 0 6px 30px rgba(0,0,0,.12); font-family: "Plus Jakarta Sans", Arial, sans-serif;
  display: flex; flex-direction: column;   /* a full page: the signature and footer sit at the bottom */
}
.paper > .p-foot { margin-top: auto; padding-top: 22px; }
.paper .p-copy { align-self: flex-end; font-size: 9.5px; font-weight: 800; letter-spacing: .12em; color: #4b5068; border: 1px solid #c9ccda; background: #fff; padding: 2px 9px; border-radius: 4px; margin: -22px -14px 10px 0; position: relative; z-index: 1; }
.paper.thermal .p-copy { align-self: center; margin: 0 0 6px; }
.paper.t-corporate .p-copy, .paper.t-aurora .p-copy, .paper.t-royal .p-copy { margin: 8px 0 8px; }
.paper.t-executive .p-copy + .p-head { margin-top: 0; }
.copy-break { break-after: page; page-break-after: always; height: 0; }
.copies-render { position: fixed; left: -20000px; top: 0; }
.html2pdf__container .copies-render { position: static; left: auto; }   /* html2pdf renders a clone of the holder */
.copies-render .paper { box-shadow: none; border-radius: 0; }
.copy-pick { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-bottom: 12px; font-weight: 600; }
.copy-pick label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.copy-pick input { width: 18px; height: 18px; accent-color: var(--success, #12a150); margin: 0; }
.paper .p-sub { font-size: 10.5px; color: #6b7088; margin-top: 1px; }
.paper tr { break-inside: avoid; }

/* Thermal POS rolls (80 / 58 mm): one compact column */
.paper.thermal { padding: 14px 12px 10px; font-size: 10.5px; line-height: 1.4; border-radius: 0; }
.paper.thermal .p-head { flex-direction: column; align-items: center; text-align: center; gap: 6px; border-bottom: 1px dashed #9aa0b5; padding-bottom: 8px; }
.paper.thermal .p-head > div { width: 100%; }
.paper.thermal .p-logo { max-height: 40px; margin: 0 auto; display: block; }
.paper.thermal .p-logo-txt { margin: 0 auto; width: 36px; height: 36px; font-size: 14px; border-radius: 8px; background: #1d2033; }
.paper.thermal .p-title { text-align: center; font-size: 13px; color: #1d2033; letter-spacing: .12em; }
.paper.thermal .p-meta { text-align: center; margin-top: 2px; }
.paper.thermal .p-meta div { display: inline-block; margin: 0 4px; }
.paper.thermal .p-parties { grid-template-columns: 1fr; gap: 6px; margin: 8px 0; }
.paper.thermal th { background: none; color: #1d2033; border-bottom: 1px dashed #9aa0b5; padding: 4px 2px; font-size: 9.5px; }
.paper.thermal td { padding: 5px 2px; border-bottom: 1px dotted #d6d9e4; vertical-align: top; }
.paper.thermal .p-sum { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.paper.thermal .p-sum > div:first-child { order: 2; }
.paper.thermal .p-sum .grand { color: #1d2033; border-top: 1px dashed #1d2033; font-size: 13px; }
.paper.thermal .p-pay { flex-direction: column; text-align: center; gap: 6px; padding: 8px; }
.paper.thermal .p-foot { flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-top: 12px; }
.paper.thermal .p-sign { min-width: 120px; }
.paper[data-size="thermal58"] { font-size: 9.5px; padding: 10px 8px; }
.paper[data-size="thermal58"] .p-pay .qr { width: 80px; height: 80px; }

/* Payment receipt */
.paper .rc-hero { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; margin: 22px 0 18px; padding: 18px 20px; border-radius: 12px; background: color-mix(in srgb, var(--acc) 7%, #fff); border: 1px solid color-mix(in srgb, var(--acc) 22%, #fff); }
.paper .rc-amt { font-size: 30px; font-weight: 800; color: var(--acc); letter-spacing: -.02em; text-align: right; line-height: 1.1; }
.paper .rc-stamp { display: inline-block; margin-top: 8px; padding: 4px 12px; border: 2px solid #12a150; color: #12a150; border-radius: 6px; font-weight: 800; letter-spacing: .14em; font-size: 11px; transform: rotate(-4deg); }
.paper .rc-stamp.part { border-color: #d97706; color: #d97706; }
.paper.thermal .rc-hero { grid-template-columns: 1fr; text-align: center; margin: 10px 0; padding: 10px; }
.paper.thermal .rc-amt { text-align: center; font-size: 20px; }
.paper .p-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.paper .p-logo { max-height: 56px; max-width: 160px; object-fit: contain; }
.paper .p-logo-txt { width: 52px; height: 52px; border-radius: 12px; background: var(--acc); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.paper .p-title { font-size: 24px; font-weight: 800; color: var(--acc); letter-spacing: .02em; text-transform: uppercase; text-align: right; }
.paper .p-meta { text-align: right; margin-top: 6px; }
.paper .p-meta div span { color: #6b7088; }
.paper .p-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0 16px; }
.paper .p-lbl { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8a8fa8; margin-bottom: 4px; }
.paper table { width: 100%; border-collapse: collapse; }
.paper th { background: var(--acc); color: #fff; text-align: left; padding: 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.paper td { padding: 8px; border-bottom: 1px solid #eceef5; }
.paper .r { text-align: right; }
.paper .p-sum { display: grid; grid-template-columns: 1fr 260px; gap: 20px; margin-top: 14px; }
.paper .p-sum .line { display: flex; justify-content: space-between; padding: 3px 0; }
.paper .p-sum .grand { font-size: 15px; font-weight: 800; color: var(--acc); border-top: 2px solid var(--acc); margin-top: 6px; padding-top: 8px; }
.paper .p-pay { display: flex; gap: 16px; margin-top: 18px; padding: 12px; border-radius: 8px; background: #f6f7fb; align-items: center; }
.paper .p-pay .qr { width: 92px; height: 92px; background: #fff; padding: 4px; border-radius: 6px; flex: none; }
.paper .p-pay .qr img, .paper .p-pay .qr canvas { width: 84px !important; height: 84px !important; }
.paper .p-foot { margin-top: 18px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.paper .p-sign { text-align: center; min-width: 160px; border-top: 1px solid #c9ccda; padding-top: 6px; font-weight: 700; }
.paper .p-brand { margin-top: 18px; padding-top: 8px; border-top: 1px dashed #dfe2ec; text-align: center; font-size: 10px; color: #8a8fa8; }
.paper .p-brand a { color: #5b4cf5; font-weight: 700; }
/* Template: Corporate */
.paper.t-corporate { padding-top: 0; }
.paper.t-corporate .p-head { background: var(--acc); color: #fff; margin: 0 -38px; padding: 26px 38px; }
.paper.t-corporate .p-title, .paper.t-corporate .p-meta div span { color: #fff; opacity: .95; }
.paper.t-corporate .p-logo-txt { background: #fff; color: var(--acc); }
/* Template: Modern */
.paper.t-modern { border-left: 10px solid var(--acc); }
.paper.t-modern .p-title { font-size: 34px; text-transform: none; letter-spacing: -.02em; }
.paper.t-modern th { background: transparent; color: var(--acc); border-bottom: 2px solid var(--acc); }
/* Template: Minimal */
.paper.t-minimal th { background: transparent; color: #6b7088; border-bottom: 1px solid #1d2033; }
.paper.t-minimal .p-title { color: #1d2033; font-weight: 600; letter-spacing: .2em; font-size: 18px; }
.paper.t-minimal .p-sum .grand { color: #1d2033; border-color: #1d2033; }
/* Template: Elegant */
.paper.t-elegant { font-family: Georgia, "Times New Roman", serif; }
.paper.t-elegant .p-title { font-family: "Playfair Display", Georgia, serif; text-transform: none; font-size: 30px; }
.paper.t-elegant .p-head { border-bottom: 3px double var(--acc); padding-bottom: 14px; }
.paper.t-elegant th { background: #f7f3ea; color: #5a4a2a; }
/* Template: GST (government format, bordered) */
.paper.t-gst { border: 1.5px solid #1d2033; }
.paper.t-gst th { background: #eef0f6; color: #1d2033; border: 1px solid #c3c7d6; }
.paper.t-gst td { border: 1px solid #d6d9e4; }
.paper.t-gst .p-title { color: #1d2033; text-align: center; }

/* Template: Executive (tinted head, dark table, boxed total) */
.paper.t-executive { border-top: 6px solid var(--acc); }
.paper.t-executive .p-head { background: #f4f5fa; margin: -36px -38px 0; padding: 28px 38px 22px; }
.paper.t-executive th { background: #1d2033; }
.paper.t-executive .p-title { color: #1d2033; font-size: 28px; }
.paper.t-executive .p-sum > div:last-child { background: #f4f5fa; border-radius: 8px; padding: 12px 14px; }
.paper.t-executive .p-sum .grand { background: var(--acc); color: #fff; border: 0; border-radius: 6px; padding: 8px 10px; margin: 8px -6px 0; }
/* Template: Aurora (gradient header, curved edge) */
.paper.t-aurora { padding-top: 0; }
.paper.t-aurora .p-head { background: linear-gradient(120deg, var(--acc), #00b8a9); color: #fff; margin: 0 -38px; padding: 30px 38px 46px; border-radius: 0 0 50% 50% / 0 0 34px 34px; }
.paper.t-aurora .p-title { color: #fff; font-size: 30px; text-transform: none; letter-spacing: -.01em; }
.paper.t-aurora .p-meta div span { color: rgba(255,255,255,.8); }
.paper.t-aurora .p-logo-txt { background: rgba(255,255,255,.22); }
.paper.t-aurora th { background: #f6e8fc; color: #7a0aa6; }
.paper.t-aurora .p-sum .grand { border: 0; background: linear-gradient(120deg, var(--acc), #00b8a9); color: #fff; border-radius: 99px; padding: 8px 14px; }
/* Template: Royal (navy + gold, serif) */
.paper.t-royal { font-family: Georgia, "Times New Roman", serif; padding-top: 0; }
.paper.t-royal .p-head { background: #14213d; color: #f3ead2; margin: 0 -38px; padding: 28px 38px; border-bottom: 4px solid #c9a227; }
.paper.t-royal .p-title { font-family: "Playfair Display", Georgia, serif; color: #c9a227; text-transform: none; font-size: 32px; }
.paper.t-royal .p-meta div span { color: #c9b98f; }
.paper.t-royal .p-logo-txt { background: #c9a227; color: #14213d; }
.paper.t-royal .p-lbl { color: #a8892a; }
.paper.t-royal th { background: transparent; color: #14213d; border-top: 1px solid #c9a227; border-bottom: 1px solid #c9a227; }
.paper.t-royal .p-sum .grand { color: #14213d; border-top: 3px double #c9a227; }
/* Template: Bold (oversized type, black total block) */
.paper.t-bold .p-title { font-size: 46px; color: #111; letter-spacing: -.03em; line-height: 1; }
.paper.t-bold .p-head { border-bottom: 6px solid #111; padding-bottom: 18px; }
.paper.t-bold th { background: #111; }
.paper.t-bold td { border-bottom-color: #e2e2e2; }
.paper.t-bold .p-sum .grand { background: #111; color: #fff; border: 0; padding: 12px 14px; font-size: 18px; margin-top: 10px; }
.paper.t-bold .p-logo-txt { background: #111; }

/* Template gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tpl-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.tpl-thumb { background: var(--surface-2); height: 300px; overflow: hidden; display: flex; justify-content: center; padding-top: 14px; cursor: zoom-in; }
.tpl-thumb .paper { zoom: .34; pointer-events: none; }
.tpl-card .tpl-body { padding: 14px 16px 16px; display: grid; gap: 8px; }

/* ============ Modal & toast ============ */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 25, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .2s; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: pop .25s cubic-bezier(.2,.9,.3,1.2); }
.modal.wide { max-width: 860px; }
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: toastIn .3s ease; max-width: 340px; }
#offline-banner { background: var(--warning); color: #fff; text-align: center; padding: 6px; font-weight: 600; font-size: 13px; position: sticky; top: 0; z-index: 40; }

/* ============ Animations ============ */
@keyframes gradmove { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@keyframes wordIn { from { opacity: 0; transform: translateY(60%) rotateX(60deg); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes caret { 50% { border-color: transparent; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  body * { visibility: hidden; }
  html:not(.print-one) #print-area, html:not(.print-one) #print-area *,
  html.print-one .print-target.printing, html.print-one .print-target.printing * { visibility: visible; }
  html:not(.print-one) #print-area, html.print-one .print-target.printing { position: absolute; left: 0; top: 0; width: auto; }
  html.print-one .modal-bg, html.print-one .modal { position: static !important; display: block !important; max-height: none !important; overflow: visible !important; padding: 0 !important; background: none !important; box-shadow: none !important; animation: none !important; backdrop-filter: none !important; }
  .preview-scroll { background: none !important; padding: 0 !important; overflow: visible !important; max-height: none !important; }
  .paper { box-shadow: none !important; border-radius: 0 !important; margin: 0 !important; }
  #print-area .paper { zoom: 1 !important; }
}

/* ============ Launch extras: feedback, nudge, WhatsApp button, demo videos ============ */
.fb-btn { gap: 6px; padding: 8px 12px; font-weight: 700; color: var(--brand); }
.fb-btn .i { width: 18px; height: 18px; }
.rate { display: flex; gap: 8px; flex-wrap: wrap; }
.rate button { font-size: 26px; line-height: 1; width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; transition: transform .15s, border-color .15s; filter: grayscale(.6); }
.rate button:hover { transform: translateY(-2px); filter: none; }
.rate button.on { border-color: var(--brand); background: var(--brand-soft, #f4e6fb); filter: none; transform: scale(1.08); }
.rate.sm button { font-size: 20px; width: 40px; height: 40px; border-radius: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.nudge { position: fixed; right: 20px; top: 76px; z-index: 45; width: min(340px, calc(100vw - 32px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 16px 18px; box-shadow: 0 24px 60px rgba(20, 10, 40, .25); animation: nudgein .45s cubic-bezier(.2,.9,.3,1.2); }
.nudge b { display: flex; gap: 8px; align-items: center; font-size: 14.5px; }
.nudge b .i { color: var(--brand); }
.nudge p { margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
.nudge .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
@keyframes nudgein { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
.wa-float { position: fixed; left: 18px; bottom: 18px; z-index: 40; display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px 0 15px; border-radius: 99px; background: #25d366; color: #fff !important; font-weight: 700; text-decoration: none !important; box-shadow: 0 12px 30px rgba(37, 211, 102, .45); animation: wapulse 2.6s ease-in-out infinite; }
.wa-float .i { width: 26px; height: 26px; }
.wa-float span { max-width: 0; overflow: hidden; white-space: nowrap; transition: max-width .35s; }
.wa-float:hover span { max-width: 160px; }
@keyframes wapulse { 0%, 100% { box-shadow: 0 12px 30px rgba(37, 211, 102, .45), 0 0 0 0 rgba(37, 211, 102, .5); } 50% { box-shadow: 0 12px 30px rgba(37, 211, 102, .45), 0 0 0 12px rgba(37, 211, 102, 0); } }
@media (max-width: 900px) { .wa-float { bottom: 78px; left: 12px; height: 48px; padding: 0 12px; } .nudge { top: auto; bottom: 84px; right: 12px; } }
.vids { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.vid { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #0b0716; cursor: pointer; box-shadow: var(--shadow); }
.vid img, .vid iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.vid .vplay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.vid .vplay .i { width: 64px; height: 64px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
@media print { .wa-float, .nudge { display: none !important; } }
.credit { font-size: 12.5px; color: var(--muted); margin-top: -4px; }
.credit.over { color: var(--danger); font-weight: 700; display: flex; gap: 6px; align-items: center; }
