/* ═══════════════════════════════════════════════════════════════════════════
   ETALONIX INVOICE APP — Design System
   Dark premium theme with silver accents
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:         #080b12;
  --bg2:        #0d1017;
  --bg3:        #111520;
  --card:       #13172080;
  --card-solid: #131720;
  --border:     #1e2438;
  --border2:    #252c40;
  --sidebar-w:  230px;

  --silver:     #c4cad8;
  --silver-hi:  #e8edf8;
  --silver-dim: #7c8599;
  --gold:       #c9a84c;

  --text:       #dde3f0;
  --text2:      #9199b0;
  --text3:      #5a6278;
  --muted-c:    #4a5268;

  --green:       #22c55e;
  --green-dim:   #16a34a20;
  --brand-green: #10b981;
  --brand-green2:#059669;
  --brand-glow:  rgba(16,185,129,.07);
  --blue:       #3b82f6;
  --blue-dim:   #1d4ed820;
  --amber:      #f59e0b;
  --amber-dim:  #d9770620;
  --red:        #ef4444;
  --red-dim:    #dc262620;
  --purple:     #a855f7;
  --purple-dim: #7c3aed20;

  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  14px;

  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.3);

  --transition: 200ms ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 140px;
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(16,185,129,.05) 0%, transparent 100%);
}
.sidebar-logo-img {
  max-height: 120px;
  max-width: 200px;
  object-fit: contain;
  filter: brightness(1.15) drop-shadow(0 0 10px rgba(16,185,129,.25));
  transition: filter var(--transition);
}
.sidebar-logo-img:hover { filter: brightness(1.25) drop-shadow(0 0 12px rgba(16,185,129,.3)); }
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--silver-hi);
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  transition: background var(--transition), color var(--transition);
  font-size: 13.5px;
  font-weight: 500;
}
.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(16,185,129,.1), rgba(13,16,23,0));
  color: var(--silver-hi);
  border: 1px solid rgba(16,185,129,.2);
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--brand-green);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}
.nav-item.active .nav-icon svg { stroke: var(--silver-hi); }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: var(--red-dim);
  color: var(--red);
}

/* ── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
.content-area {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}

/* ── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--silver-hi);
  letter-spacing: -.02em;
}
.page-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--silver);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #c4cad8 0%, #8890a8 100%);
  color: #0d1017;
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #dde3f0 0%, #a0a8bc 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(196,202,216,.25);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border2);
}
.btn-success {
  background: var(--green);
  color: #fff;
  font-weight: 600;
}
.btn-success:hover { background: #16a34a; transform: translateY(-1px); }
.btn-danger {
  background: var(--red);
  color: #fff;
  font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }
.btn-danger-hover:hover {
  background: var(--red-dim);
  color: var(--red);
  border-color: #7f1d1d50;
}
.btn-convert {
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
  font-weight: 600;
  border: 1px solid #0d948850;
}
.btn-convert:hover {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(13,148,136,.3);
}
.btn-full { width: 100%; }

/* ── Icon Buttons ───────────────────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }
.icon-btn-danger:hover { background: var(--red-dim); border-color: #7f1d1d60; color: var(--red); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: .01em;
}
.req { color: var(--red); }
.form-input, .form-select, .form-textarea {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text3); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--silver-dim);
  box-shadow: 0 0 0 3px rgba(196,202,216,.08);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6278' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.field-note {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}
.danger-note { color: var(--red) !important; margin-top: 10px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead tr { background: var(--bg2); }
.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--bg2); }
.data-table tbody td { padding: 12px 14px; color: var(--text); }
.center { text-align: center; }
.amount-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--silver); }
.actions-cell { display: flex; gap: 4px; align-items: center; }
.empty-row { text-align: center; color: var(--text3); padding: 36px 14px !important; }
.tbl-link { color: var(--silver); font-weight: 500; }
.tbl-link:hover { color: var(--silver-hi); text-decoration: underline; }
.muted { color: var(--text3); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: capitalize;
}
.badge-draft   { background: rgba(100,116,139,.15); color: #94a3b8; border: 1px solid #334155; }
.badge-sent    { background: var(--blue-dim);        color: #60a5fa; border: 1px solid #1e3a5f; }
.badge-paid    { background: var(--green-dim);       color: #4ade80; border: 1px solid #14532d; }
.badge-overdue { background: var(--red-dim);         color: #f87171; border: 1px solid #7f1d1d; }

/* ── Type Tags ──────────────────────────────────────────────────────────── */
.type-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}
.type-inv { background: #1e2a40; color: #7eb3fa; }
.type-pro { background: #1e2d28; color: #6ee7b7; }

.currency-chip {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #1e2438;
  color: var(--silver);
  border: 1px solid var(--border2);
}

/* ── Search ─────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 16px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text3);
}
.search-input {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px 9px 36px;
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input::placeholder { color: var(--text3); }
.search-input:focus { border-color: var(--silver-dim); }

/* ── Filters ────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.filter-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-btn:hover { color: var(--text); background: var(--bg3); }
.filter-btn.active { background: var(--bg3); color: var(--silver-hi); border: 1px solid var(--border2); }

/* ── Content Section ────────────────────────────────────────────────────── */
.content-section { margin-top: 28px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--silver);
}
.section-link { font-size: 13px; color: var(--silver-dim); }
.section-link:hover { color: var(--silver); }

/* ── Stats Grid ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.stat-card-danger { border-color: #7f1d1d60; background: #1a0a0a; }
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-green  { background: var(--green-dim);  color: var(--green); }
.stat-blue   { background: var(--blue-dim);   color: var(--blue); }
.stat-amber  { background: var(--amber-dim);  color: var(--amber); }
.stat-red    { background: var(--red-dim);    color: var(--red); }
.stat-purple { background: var(--purple-dim); color: var(--purple); }
.stat-silver { background: rgba(196,202,216,.08); color: var(--silver); }
.stat-label { font-size: 11.5px; color: var(--text2); margin-bottom: 2px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--silver-hi); line-height: 1.2; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--card-solid);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 95vw;
  box-shadow: var(--shadow);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.95) translateY(8px); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--silver-hi); }
.modal-close-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 14px;
  transition: all var(--transition);
}
.modal-close-btn:hover { background: var(--bg3); color: var(--text); }
.modal-body {
  padding: 18px 20px;
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.6;
}
.modal-body strong { color: var(--text); }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── Convert Proforma Modal ─────────────────────────────────────────────── */
.convert-modal-body { display: flex; flex-direction: column; gap: 4px; }
.convert-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(13,148,136,.08);
  border: 1px solid rgba(13,148,136,.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.convert-icon {
  width: 48px; height: 48px;
  background: rgba(13,148,136,.15);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #2dd4bf;
  flex-shrink: 0;
}
.convert-info { display: flex; flex-direction: column; gap: 2px; }
.convert-label { font-size: 10.5px; font-weight: 600; color: #2dd4bf; letter-spacing: .08em; text-transform: uppercase; }
.convert-number { font-size: 15px; font-weight: 700; color: var(--silver-hi); }
.convert-client { font-size: 12.5px; color: var(--text2); }
.convert-amount { font-size: 13px; font-weight: 600; color: #4ade80; margin-top: 2px; }
.convert-desc { font-size: 13px; color: var(--text2); line-height: 1.6; }
.convert-desc strong { color: var(--text); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-solid);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(24px);
  transition: all .3s ease;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-success span { color: var(--green); font-weight: 700; }
.toast-error { border-left: 3px solid var(--red); }
.toast-error span { color: var(--red); font-weight: 700; }

/* ── Login Page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-glow {
  position: absolute;
  width: 800px; height: 800px;
  background: radial-gradient(ellipse, rgba(16,185,129,.06) 0%, rgba(196,202,216,.03) 35%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: pulseGlow 4s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { opacity: .8; transform: translate(-50%,-50%) scale(1); }
  50%       { opacity: 1;  transform: translate(-50%,-50%) scale(1.06); }
}
.login-card {
  background: var(--card-solid);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  animation: fadeUp .35s ease;
  position: relative;
  z-index: 1;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } }
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo {
  max-height: 88px;
  max-width: 240px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 16px rgba(16,185,129,.25));
}
.login-logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--silver-hi);
  margin-bottom: 6px;
}
.login-sub {
  font-size: 12.5px;
  color: var(--text3);
  letter-spacing: .04em;
  margin-top: 4px;
}
.login-error {
  background: var(--red-dim);
  border: 1px solid #7f1d1d60;
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 13px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.login-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 20px;
  letter-spacing: .02em;
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.content-section .table-wrap { margin-top: 0; }

/* ── Invoice Builder ────────────────────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 20px;
  align-items: start;
}
.builder-main { display: flex; flex-direction: column; gap: 0; }
.builder-main .card { margin-bottom: 16px; }
.builder-side { position: sticky; top: 24px; }

.summary-sticky {}
.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.sum-row:last-of-type { border-bottom: none; }
.sum-total { color: var(--silver-hi); font-weight: 700; font-size: 15px; }
.sum-divider { height: 1px; background: var(--border2); margin: 6px 0; }
.sum-currency { font-size: 11.5px; color: var(--text3); margin-top: 10px; text-align: right; }

/* Line items table */
.li-table { font-size: 13px; }
.li-table .form-input {
  padding: 7px 10px;
  font-size: 13px;
  background: var(--bg);
}
.li-amt {
  font-variant-numeric: tabular-nums;
  color: var(--silver);
  font-weight: 500;
  text-align: right;
}

/* ── Invoice Preview ────────────────────────────────────────────────────── */
.pv-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 20px 60px;
  background-color: #060810;
  background-image:
    radial-gradient(ellipse 800px 600px at 0% 50%,   rgba(16,185,129,.055) 0%, transparent 65%),
    radial-gradient(ellipse 700px 550px at 100% 50%,  rgba(16,185,129,.04)  0%, transparent 65%),
    radial-gradient(ellipse 500px 350px at 50% 0%,   rgba(196,202,216,.04) 0%, transparent 60%),
    radial-gradient(circle, rgba(196,202,216,.055) 1px, transparent 1px);
  background-size: auto, auto, auto, 22px 22px;
  border-radius: var(--radius-lg);
  margin-bottom: 0;
}
.pv-paper {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(16,185,129,.15);
  overflow: hidden;
  width: 100%;
  max-width: 800px;
  color: #1a1a2e;
  font-size: 12px;
  line-height: 1.65;
  position: relative;
}
/* Green accent bar at top of invoice */
.pv-paper::before {
  content: '';
  display: block;
  height: 5px;
  background: linear-gradient(90deg, #10b981 0%, #059669 40%, #c4cad8 100%);
}
.pv-paper-inner {
  padding: 40px 52px 48px;
}

.pv-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 72%;
  max-width: 520px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}
.pv-wm-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
  opacity: 0.055;
  filter: grayscale(100%) contrast(0.6);
  user-select: none;
  -webkit-user-drag: none;
}

.pv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 2.5px solid #10b981;
}
.pv-from { display: flex; flex-direction: column; gap: 10px; }
.pv-logo { max-height: 160px; max-width: 320px; object-fit: contain; }
.pv-logo-text { font-size: 20px; font-weight: 800; letter-spacing: .12em; color: #1a1a2e; }
.pv-from-details { display: flex; flex-direction: column; gap: 1px; color: #555; font-size: 11.5px; }
.pv-meta { text-align: right; }
.pv-type-label { font-size: 15px; font-weight: 800; letter-spacing: .12em; color: #1a1a2e; margin-bottom: 4px; }
.pv-number { font-size: 13px; font-weight: 600; color: #444; margin-bottom: 10px; }
.pv-dates { margin-bottom: 8px; }
.pv-dates div { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 2px; font-size: 11.5px; }
.pv-dates span { color: #888; }
.pv-dates strong { color: #1a1a2e; min-width: 85px; text-align: right; }
.pv-meta .badge { margin-top: 6px; font-size: 10px; }
.pv-meta .badge-draft   { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.pv-meta .badge-sent    { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pv-meta .badge-paid    { background: #dcfce7; color: #15803d; border-color: #86efac; }
.pv-meta .badge-overdue { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.pv-origin-note {
  margin-top: 6px;
  font-size: 10px;
  color: #999;
}
.pv-origin-link {
  color: #0d9488;
  font-weight: 600;
  text-decoration: underline;
}

.pv-parties {
  display: flex;
  gap: 36px;
  margin-bottom: 22px;
}
.pv-party { flex: 1; }
.pv-party-lbl {
  font-size: 9.5px;
  font-weight: 700;
  color: #999;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e5e7eb;
}
.pv-company { font-size: 14px; font-weight: 700; color: #1a1a2e; margin-bottom: 5px; }
.pv-pinfo { color: #555; font-size: 11.5px; }

.pv-table { width: 100%; border-collapse: collapse; margin-bottom: 0; }
.pv-table thead tr { background: #10b981; }
.pv-table thead th {
  padding: 9px 11px;
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
}
.pv-n { width: 4%; text-align: center !important; }
.pv-r { text-align: right !important; }
.pv-table thead th.pv-r { text-align: right; }
.pv-table tbody td { padding: 9px 11px; border-bottom: 1px solid #f0f0f0; color: #333; font-size: 11.5px; }
.pv-row-alt td { background: #f9fafb; }
.pv-table tbody td.pv-n { text-align: center; color: #aaa; }
.pv-table tbody td.pv-r { text-align: right; }

.pv-totals {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 20px;
}
.pv-totals-box { width: 260px; }
.pv-trow {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12px;
  color: #555;
  border-bottom: 1px solid #f0f0f0;
}
.pv-grand {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a2e;
  border-top: 2px solid #1a1a2e;
  border-bottom: none;
  padding-top: 9px;
  margin-top: 4px;
}

.pv-section { margin-bottom: 14px; }
.pv-sec-title {
  font-size: 9.5px;
  font-weight: 700;
  color: #999;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.pv-sec-text { color: #666; font-size: 10.5px; line-height: 1.65; }

.pv-footer {
  display: flex;
  gap: 24px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}
.pv-foot-block { flex: 1; }
.pv-foot-title {
  font-size: 9.5px; font-weight: 700; color: #999;
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 7px;
}
.pv-bank div {
  display: flex; gap: 8px; margin-bottom: 3px; font-size: 11px;
}
.pv-bank span { color: #999; width: 95px; flex-shrink: 0; }
.pv-bank strong { color: #333; }

.pv-sigs {
  display: flex;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 16px;
}
.pv-sig { text-align: center; width: 200px; }
.pv-sig-line { border-top: 1.5px solid #333; margin-bottom: 6px; }
.pv-sig-lbl { font-size: 10px; color: #777; }

/* ── Settings ───────────────────────────────────────────────────────────── */
.logo-upload-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.logo-preview-box {
  width: 140px; height: 80px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  flex-shrink: 0;
}
.logo-prev-img { max-height: 68px; max-width: 128px; object-fit: contain; }
.logo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text3); font-size: 12px; }
.logo-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Responsive tweaks ──────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-side { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 64px; }
  .nav-label { display: none; }
  .sidebar-logo-img { max-height: 32px; }
  .sidebar-logo-text { display: none; }
  .content-area { padding: 20px 14px; }
  .pv-paper { padding: 24px 20px; }
  .pv-parties { flex-direction: column; }
  .pv-header { flex-direction: column; gap: 16px; }
}
