/* ============================================================
   InvoiceMaker – style.css
   Modern, responsive dark + light theme
   ============================================================ */

/* ── Custom Properties ── */
:root {
  --brand-h: 252;
  --brand-s: 80%;
  --brand-l: 62%;

  --brand: hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --brand-dark: hsl(var(--brand-h), var(--brand-s), 45%);
  --brand-light: hsl(var(--brand-h), var(--brand-s), 92%);
  --brand-glow: hsla(var(--brand-h), var(--brand-s), var(--brand-l), 0.35);

  --bg: #0f0f17;
  --bg-2: #16161f;
  --bg-3: #1e1e2d;
  --surface: #1e1e2d;
  --surface-hover: #252537;
  --border: rgba(255,255,255,0.07);
  --border-focus: hsl(var(--brand-h), var(--brand-s), 60%);

  --text-primary: #f0f0fa;
  --text-secondary: #9898b8;
  --text-muted: #5c5c7a;

  --danger: #ff5c5c;
  --success: #4ade80;
  --warning: #fbbf24;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-btn: 0 4px 16px var(--brand-glow);

  --transition: 0.2s ease;
  --transition-bounce: 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Invoice doc colors */
  --inv-accent: hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --inv-accent-dark: hsl(var(--brand-h), var(--brand-s), 38%);
  --inv-text: #1a1a2e;
  --inv-text-muted: #666680;
  --inv-border: #e8e8f0;
  --inv-bg: #fafbff;
  --inv-row-alt: #f5f5fc;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography ── */
h1, h2, h3 { font-family: 'Outfit', sans-serif; }

/* ── Links ── */
a { color: var(--brand); text-decoration: none; }

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  height: 64px;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--brand-glow);
}

.brand-icon svg { width: 18px; height: 18px; color: #fff; }

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff 0%, hsl(var(--brand-h), 60%, 80%) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--brand-glow);
  filter: brightness(1.1);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 9999;
  pointer-events: none;
  transition: transform 0.3s var(--transition-bounce), opacity 0.3s ease;
  opacity: 0;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ── Main Layout ── */
.app-main {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 480px 1fr;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* ── Form Panel ── */
.form-panel {
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.12); }

.card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.card-header-icon {
  width: 28px;
  height: 28px;
  background: var(--brand-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-header-icon svg { width: 14px; height: 14px; color: var(--brand-dark); stroke: var(--brand); }

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 1rem 1.1rem; }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  transition: all var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.5);
  cursor: pointer;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 14px;
  padding-right: 2rem;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-2);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ── Logo Upload ── */
.logo-upload-area {
  position: relative;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-placeholder {
  width: 96px;
  height: 72px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.logo-placeholder:hover {
  border-color: var(--brand);
  background: var(--brand-glow);
}

.logo-placeholder svg { width: 20px; height: 20px; color: var(--text-muted); }
.logo-placeholder span { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); }
.logo-placeholder small { font-size: 0.65rem; color: var(--text-muted); }

.logo-preview {
  width: 96px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  padding: 4px;
}

.logo-remove-btn {
  position: absolute;
  top: -8px;
  left: 82px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform var(--transition);
}
.logo-remove-btn:hover { transform: scale(1.1); }

/* ── Line Items ── */
.items-header {
  display: grid;
  grid-template-columns: 1fr 60px 90px 100px 28px;
  gap: 0.4rem;
  padding: 0 0 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.items-header span:nth-child(2),
.items-header span:nth-child(3),
.items-header span:nth-child(4) {
  text-align: right;
  padding-right: 4px;
}

.line-items-list { display: flex; flex-direction: column; gap: 0.4rem; }

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 60px 90px 100px 28px;
  gap: 0.4rem;
  align-items: center;
  animation: slideIn 0.2s var(--transition-bounce);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.line-item-row input {
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
}

.item-amount {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  padding: 0.45rem 0.1rem;
  min-width: 70px;
}

.remove-item-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.remove-item-btn:hover { background: rgba(255,92,92,0.12); border-color: var(--danger); color: var(--danger); }

.add-item-btn {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--brand);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition);
}
.add-item-btn svg { width: 14px; height: 14px; }
.add-item-btn:hover { background: rgba(var(--brand-h), var(--brand-s), var(--brand-l), 0.08); border-color: var(--brand); border-style: solid; }

/* ── Totals Section ── */
.totals-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tax-row, .discount-row { align-items: center; }

.tax-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tax-input-wrap input {
  width: 70px;
  text-align: right;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
}

.tax-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.total-row {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Preview Panel ── */
.preview-panel {
  display: flex;
  flex-direction: column;
  background: #13131d;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.preview-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preview-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.preview-zoom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.zoom-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  transition: all var(--transition);
}
.zoom-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

#zoomLabel {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
}

.preview-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.preview-wrapper {
  transform-origin: top center;
  /* transform is set via JS */
  display: flex;
  justify-content: center;
  width: min-content;
}

/* ── Invoice Document ── */
.invoice-doc {
  width: 794px; /* A4 at 96dpi */
  max-width: calc(100vw - 4rem);
  min-height: 1122px;
  background: var(--inv-bg);
  border-radius: 4px;
  box-shadow: 0 8px 60px rgba(0,0,0,0.5);
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  transition: transform 0.2s ease;
}

/* Invoice Header */
.inv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2.5rem 2.5rem 1.5rem;
  background: white;
}

.inv-sender { display: flex; align-items: flex-start; gap: 1rem; }

.inv-logo {
  width: 80px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
}

.inv-company {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--inv-text);
  margin-bottom: 0.3rem;
}

.inv-meta-line {
  font-size: 0.78rem;
  color: var(--inv-text-muted);
  line-height: 1.6;
  white-space: pre-line;
}

.inv-title-block { text-align: right; flex-shrink: 0; }

.inv-title-word {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--inv-accent);
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.3rem 1rem;
  text-align: left;
}

.inv-meta-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--inv-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inv-meta-val {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--inv-text);
}

/* Color Bar */
.inv-color-bar {
  height: 5px;
  background: linear-gradient(90deg, var(--inv-accent), var(--inv-accent-dark));
}

/* Invoice Body */
.inv-body { padding: 2rem 2.5rem; }

.inv-bill-section { margin-bottom: 1.5rem; }
.inv-bill-to { max-width: 280px; }

.inv-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--inv-accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.inv-client-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--inv-text);
  margin-bottom: 0.25rem;
}

.inv-client-detail {
  font-size: 0.78rem;
  color: var(--inv-text-muted);
  line-height: 1.55;
  white-space: pre-line;
}

/* Items Table */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.inv-table thead tr {
  background: var(--inv-accent);
}

.inv-table thead th {
  padding: 0.65rem 0.9rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.inv-table thead th.text-right {
  text-align: right;
}

.inv-table thead th:first-child { border-radius: 4px 0 0 0; }
.inv-table thead th:last-child { border-radius: 0 4px 0 0; }

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

.inv-table tbody tr:nth-child(even) { background: var(--inv-row-alt); }

.inv-table tbody tr td {
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  color: var(--inv-text);
  border-bottom: 1px solid var(--inv-border);
}
/* ── Auth & Modals ── */
.hidden { display: none !important; }

.user-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255,255,255,0.03);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.user-email {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-2);
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.3s var(--transition-bounce);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-tabs {
  display: flex;
  background: var(--bg-3);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
  gap: 0.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-submit {
  width: 100%;
  padding: 0.75rem !important;
  font-size: 0.95rem !important;
  margin-top: 0.5rem;
}

@media (max-width: 480px) {
  .modal-card {
    max-width: 90%;
    padding: 1.5rem;
  }
  .user-email { display: none; }
}

.inv-table tbody tr td.text-right { font-weight: 600; }

.inv-empty-row td {
  text-align: center;
  color: var(--inv-text-muted) !important;
  font-style: italic;
  padding: 2rem !important;
}

/* Invoice Totals */
.inv-totals { display: flex; justify-content: flex-end; margin-bottom: 2rem; }

.inv-totals-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.5rem 2rem;
  min-width: 240px;
}

.inv-totals-grid span {
  font-size: 0.82rem;
  color: var(--inv-text-muted);
}

.inv-totals-grid span:nth-child(even) {
  text-align: right;
  font-weight: 600;
  color: var(--inv-text);
}

.inv-total-label {
  font-size: 0.9rem !important;
  font-weight: 700 !important;
  color: var(--inv-text) !important;
  padding-top: 0.5rem;
  border-top: 2px solid var(--inv-border);
  margin-top: 0.25rem;
}

.inv-total-amount {
  font-size: 1.2rem !important;
  font-weight: 800 !important;
  color: var(--inv-accent) !important;
  text-align: right;
  padding-top: 0.5rem;
  border-top: 2px solid var(--inv-border);
}

.hidden-row { display: none !important; }

/* Invoice Notes */
.inv-notes { margin-bottom: 2rem; }
.inv-notes-text {
  font-size: 0.78rem;
  color: var(--inv-text-muted);
  line-height: 1.6;
  white-space: pre-line;
}
.hidden { display: none; }

/* Invoice Footer */
.inv-footer { padding-top: 1rem; }
.inv-footer-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--inv-accent), transparent);
  border-radius: 99px;
  margin-bottom: 0.75rem;
}
.inv-footer-text {
  font-size: 0.78rem;
  color: var(--inv-text-muted);
  text-align: center;
  font-style: italic;
}

/* ── New App Layout ── */
:root {
  --sidebar-width: 260px;
  --header-height: 72px;
}

body {
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  padding: 0 1.5rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
}

.app-sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.nav-item.active svg {
  color: var(--accent);
  opacity: 1;
}

.app-main {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  flex: 1;
  min-height: calc(100vh - var(--header-height));
  display: block;
  overflow: visible;
}

.view {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.view-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-2);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
}

/* Invoice List Table */
.invoice-list-container {
  overflow-x: auto;
}

.invoice-list {
  width: 100%;
}

.invoice-item {
  display: grid;
  grid-template-columns: 100px 1fr 120px 120px 100px 40px;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
  cursor: pointer;
}

.invoice-item:hover {
  background: rgba(255,255,255,0.02);
}

.invoice-item span {
  font-size: 0.9rem;
}

.inv-id { font-weight: 600; color: var(--text-primary); }
.inv-client { color: var(--text-secondary); }
.inv-amount { font-weight: 700; color: var(--text-primary); text-align: right; }
.inv-date { color: var(--text-muted); font-size: 0.8rem !important; }

.status-badge {
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-paid { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.status-draft { background: rgba(107, 114, 128, 0.1); color: #9ca3af; }

/* Editor Layout */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: calc(100vh - var(--header-height) - 4rem);
}

.editor-layout > div {
  height: 100%;
  overflow: hidden;
}

/* Pricing Grid */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.pricing-card {
  background: var(--bg-2);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.pricing-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
}

.pricing-card.featured {
  background: linear-gradient(135deg, var(--bg-2), rgba(124, 92, 252, 0.05));
  border: 2px solid var(--accent);
}

.plan-badge {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.plan-name { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.plan-price { font-size: 3rem; font-weight: 800; font-family: 'Outfit', sans-serif; }
.plan-period { font-size: 1rem; color: var(--text-muted); font-weight: 400; }

.plan-features {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  flex: 1;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.plan-features li.disabled {
  opacity: 0.4;
  text-decoration: line-through;
}

.check-icon { width: 18px; height: 18px; color: #10b981; }
.x-icon { width: 18px; height: 18px; color: #ef4444; }

.full-width { width: 100%; }

/* Mobile FAB */
.fab {
  position: fixed;
  right: 1.5rem;
  bottom: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 10px 25px rgba(124, 92, 252, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}

/* ── Mobile Overrides ── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 80px; }
  .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 1rem; }
  .editor-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .editor-layout > div { height: auto; overflow: visible; }
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-sidebar.active {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
    padding: 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
  .view-title { font-size: 1.5rem; }
  .mobile-nav-toggle { display: block; }
  .fab { display: flex; bottom: calc(2rem + env(safe-area-inset-bottom)); right: calc(1.5rem + env(safe-area-inset-right)); }
  .hide-mobile { display: none !important; }
  .invoice-doc {
    max-width: calc(100vw - 2rem);
  }
  .preview-toolbar {
    padding-left: calc(1.25rem + env(safe-area-inset-left));
    padding-right: calc(1.25rem + env(safe-area-inset-right));
  }
}

@media print {
  .app-sidebar, .app-header, .fab, .mobile-nav-toggle { display: none !important; }
  .app-main { margin: 0; padding: 0; }
}
