/* =========================================
   InvoiceFlow - Custom Animations & Styles
   ========================================= */

/* ---- Keyframe Animations ---- */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-20px) rotate(3deg); }
  66%       { transform: translateY(-10px) rotate(-2deg); }
}

@keyframes float-slow {
  0%, 100% { transform: translateY(0px) scale(1); }
  50%       { transform: translateY(-30px) scale(1.05); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(99,102,241,0.3); }
  50%       { box-shadow: 0 0 40px rgba(99,102,241,0.7), 0 0 80px rgba(99,102,241,0.2); }
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slide-out-right {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes fade-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes shimmer {
  0%   { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

@keyframes scale-in {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes bounce-in {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.05); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes slide-down {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ---- Orb Backgrounds (Login Page) ---- */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #4f46e5, #7c3aed);
  top: -100px; left: -100px;
  animation: float 8s ease-in-out infinite;
}
.orb-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #0ea5e9, #6366f1);
  bottom: 10%; right: -80px;
  animation: float-slow 10s ease-in-out infinite reverse;
}
.orb-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, #8b5cf6, #ec4899);
  bottom: 30%; left: 20%;
  animation: float 12s ease-in-out infinite 2s;
}

/* ---- Glassmorphism Card ---- */
.glass-card {
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ---- TOTP Input Boxes ---- */
.totp-input-box {
  width: 48px; height: 56px;
  font-size: 1.5rem; font-weight: 700;
  text-align: center;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  color: #fff;
  transition: all 0.2s;
  outline: none;
  caret-color: transparent;
}
.totp-input-box:focus {
  border-color: #6366f1;
  background: rgba(99,102,241,0.2);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.3);
  transform: scale(1.05);
}
.totp-input-box.filled {
  border-color: #10b981;
  background: rgba(16,185,129,0.15);
}

/* ---- Toggle Switch ---- */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.toggle-track {
  width: 52px; height: 28px;
  background: #e2e8f0;
  border-radius: 14px;
  transition: background 0.3s;
  position: relative;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked ~ .toggle-track {
  background: #6366f1;
}
.toggle-switch input:checked ~ .toggle-track::after {
  transform: translateX(24px);
}

/* ---- Document Type Toggle ---- */
.doc-type-btn {
  padding: 8px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.25s ease;
  cursor: pointer;
  border: 2px solid transparent;
}
.doc-type-btn.active-quotation {
  background: #f59e0b;
  color: white;
  box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}
.doc-type-btn.active-invoice {
  background: #4f46e5;
  color: white;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}
.doc-type-btn.active-proforma {
  background: #0d9488;
  color: white;
  box-shadow: 0 4px 12px rgba(13,148,136,0.4);
}
.doc-type-btn.inactive {
  background: #f1f5f9;
  color: #64748b;
}

/* ---- Client name autocomplete ---- */
.client-suggest {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 60;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.client-suggest-item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
}
.client-suggest-item:last-child { border-bottom: none; }
.client-suggest-item:hover { background: #eef2ff; color: #4f46e5; }
.client-suggest-item .cs-sub { font-size: 11px; color: #94a3b8; }
[data-theme="dark"] .client-suggest { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .client-suggest-item { color: #e2e8f0; border-color: #334155; }
[data-theme="dark"] .client-suggest-item:hover { background: #312e81; }

/* ---- Live Preview Frame ---- */
.doc-preview-wrapper {
  position: relative;
  background: #f8fafc;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
}
.doc-preview-wrapper iframe {
  width: 100%;
  border: none;
  display: block;
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

/* ---- Spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(79,70,229,0.2);
  border-top-color: #4f46e5;
}

/* ---- Toast Notifications ---- */
#toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 280px; max-width: 400px;
  padding: 14px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  pointer-events: auto;
  animation: slide-in-right 0.3s ease-out;
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: currentColor;
  opacity: 0.5;
}
.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error   { background: #fff1f2; color: #881337; border: 1px solid #fecdd3; }
.toast-warning { background: #fffbeb; color: #78350f; border: 1px solid #fde68a; }
.toast-info    { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.toast.fade-out { animation: slide-out-right 0.3s ease-in forwards; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fade-in 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: scale-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
  max-height: 90vh;
  overflow-y: auto;
  width: 90%;
  max-width: 600px;
}

/* ---- Settings Drawer ---- */
/* Settings is a full-page view (slides in from the right) with a Back button. */
.settings-drawer {
  position: fixed;
  top: 0; right: -100vw;
  width: 100vw; height: 100vh;
  background: white;
  z-index: 900;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  transition: right 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
  overflow-y: auto;
}
.settings-drawer.open { right: 0; }
.settings-page-inner { max-width: 1000px; margin: 0 auto; }
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 899;
  display: none;
  animation: fade-in 0.2s ease;
}
.drawer-overlay.visible { display: block; }

/* ---- Items Table ---- */
.items-table thead th {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  padding: 10px 8px;
  white-space: nowrap;
}
.items-table tbody tr {
  transition: background 0.15s;
}
.items-table tbody tr:hover {
  background: #f8fafc;
}
.items-table input, .items-table select, .items-table textarea {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  transition: all 0.15s;
  background: transparent;
}
.items-table input:focus, .items-table select:focus, .items-table textarea:focus {
  outline: none;
  border-color: #6366f1;
  background: white;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.1);
}

/* ---- Phase/Subheading Row ---- */
.phase-row td {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  font-weight: 700;
  font-size: 12px;
  color: #0369a1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 12px !important;
  border-top: 2px solid #bae6fd !important;
  border-bottom: 2px solid #bae6fd !important;
}

/* ---- Tab Navigation ---- */
.tab-nav {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  gap: 0;
}
.tab-btn {
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn:hover { color: #4f46e5; }
.tab-btn.active {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
}

/* ---- Sidebar Document List ---- */
.doc-list-item {
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.doc-list-item:hover {
  background: #f0f4ff;
  border-color: #c7d2fe;
}
.doc-list-item.active {
  background: #eef2ff;
  border-color: #a5b4fc;
}

/* ---- Color Picker ---- */
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
  display: inline-block;
}
.color-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.color-swatch.active {
  border-color: #1e293b;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #1e293b;
}

/* ---- Status Badge ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.status-draft    { background: #f1f5f9; color: #475569; }
.status-sent     { background: #eff6ff; color: #1d4ed8; }
.status-paid     { background: #ecfdf5; color: #065f46; }
.status-cancelled{ background: #fff1f2; color: #9f1239; }

/* ---- Form Inputs ---- */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
  background: white;
  color: #1e293b;
}
.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ---- Button Styles ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,0.4); }
.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}
.btn-danger {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  color: white;
  box-shadow: 0 4px 12px rgba(225,29,72,0.3);
}
.btn-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: white;
  box-shadow: 0 4px 12px rgba(217,119,6,0.3);
}
.btn-outline {
  background: white;
  color: #4f46e5;
  border: 2px solid #4f46e5;
}
.btn-outline:hover { background: #eef2ff; }
.btn-ghost {
  background: transparent;
  color: #64748b;
}
.btn-ghost:hover { background: #f1f5f9; color: #1e293b; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- Animations for App ---- */
.fade-up { animation: fade-up 0.4s ease both; }
.slide-in-right { animation: slide-in-right 0.3s ease both; }
.scale-in { animation: scale-in 0.3s cubic-bezier(0.34,1.56,0.64,1) both; }

/* ---- Section Cards ---- */
.section-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.section-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Logo Preview ---- */
.logo-preview-box {
  width: 140px; height: 80px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  background: #f8fafc;
}
.logo-preview-box:hover {
  border-color: #6366f1;
  background: #eef2ff;
}
.logo-preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---- Footer Design Options ---- */
.footer-option {
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: all 0.2s;
}
.footer-option:hover { border-color: #6366f1; color: #4f46e5; }
.footer-option.active {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 700;
}

/* ---- Number To Words Display ---- */
.amount-words {
  font-style: italic;
  color: #64748b;
  font-size: 12px;
  margin-top: 4px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .settings-drawer {
    width: 100vw;
    right: -100vw;
  }
  .totp-input-box {
    width: 40px; height: 48px;
    font-size: 1.25rem;
  }
  .modal-card {
    width: 95%;
    border-radius: 12px;
  }
}

/* ---- Print / PDF preview styles ---- */
@media print {
  body { background: white !important; }
  .no-print { display: none !important; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Dropdown styling: ONLY for .form-input selects (not items table) ---- */
select.form-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}
select.form-input:focus {
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    border-color: #6366f1;
    outline: none;
}
select.form-input:hover { border-color: #a5b4fc; }

/* Items table selects: keep native arrow, compact size */
.items-table select {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    background-image: none;
    padding-right: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    cursor: pointer;
}
.items-table select:focus {
    outline: 1px solid #6366f1;
    border-color: #6366f1;
}

/* Transition only on buttons and inputs (not all elements — prevents jank) */
button { transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, color 0.15s ease; }
input, textarea { transition: border-color 0.15s ease, box-shadow 0.15s ease; }

/* ---- Layout toggle buttons ---- */
.layout-btn { background: white; color: #64748b; border: 2px solid #e2e8f0; }
.layout-btn:hover { border-color: #6366f1; color: #4f46e5; }
.layout-btn.active { background: #4f46e5 !important; color: white !important; border-color: #4f46e5 !important; box-shadow: 0 4px 12px rgba(79,70,229,0.35); }

.template-card { background: white; cursor: pointer; border-radius: 0.5rem; border: 2px solid #e2e8f0; transition: all 0.15s; }
.template-card:hover { border-color: #a5b4fc; background: #f5f3ff; }
.template-card.active { border-color: #4f46e5 !important; background: #eef2ff !important; }

/* ---- Column toggle popover ---- */
.columns-popover {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    padding: 12px;
    min-width: 180px;
    animation: scale-in 0.15s ease;
}
.col-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    transition: background 0.1s;
}
.col-toggle-row:hover { background: #f8fafc; }
.col-toggle-row input[type=checkbox] { accent-color: #4f46e5; width: 15px; height: 15px; cursor: pointer; }

/* ---- Mobile history panel ---- */
#mobile-history-panel {
    flex-direction: column;
}

/* ---- Consistent form label & input styles ---- */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Items table: compact text for more columns (BUG 5) */
.items-table input,
.items-table select,
.items-table textarea {
    font-size: 12px !important;
}

/* ---- BUG 11: Mobile improvements (applies below Tailwind's lg breakpoint) ---- */
@media (max-width: 1023px) {
    /* Preview iframe scales to screen */
    #preview-iframe {
        transform: scale(0.45);
        transform-origin: top left;
        width: 794px !important;
    }

    /* Larger, more readable type on mobile (~20% up) */
    .form-input { font-size: 16px !important; }
    .form-label { font-size: 13px !important; }
    .section-title { font-size: 14px !important; }
    .btn { font-size: 15px; }
    .btn-sm { font-size: 13px; }
    .doc-type-btn { font-size: 15px; }
    .status-badge { font-size: 12px; }
    .doc-list-item { font-size: 15px; }
    .doc-preview-wrapper {
        overflow: hidden;
        height: 370px;
    }

    /* Line items become stacked, labelled cards instead of a wide table */
    #items-table,
    #items-table tbody,
    #items-table tr,
    #items-table td {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }
    #items-table thead { display: none; }
    .section-card.overflow-x-auto,
    #items-table {
        overflow-x: visible;
    }
    #items-table tbody tr {
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 10px 12px;
        margin-bottom: 12px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    #items-table tbody tr:hover { background: #fff; }
    #items-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 6px 0 !important;
        border: none !important;
        text-align: right;
    }
    #items-table td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: #64748b;
    }
    #items-table td[data-label=""]::before { display: none; }
    #items-table td input,
    #items-table td select,
    #items-table td textarea {
        flex: 1;
        text-align: left;
        font-size: 14px !important;
        padding: 8px !important;
    }
    /* Item number cell becomes a small card header badge */
    #items-table td[data-label="Item"] {
        font-weight: 700;
        color: #4f46e5;
        border-bottom: 1px dashed #e2e8f0 !important;
        padding-bottom: 8px !important;
        margin-bottom: 4px;
    }
    #items-table td[data-label="Item"]::before { color: #4f46e5; }
    /* Remove (✕) cell becomes a full-width delete button */
    #items-table td[data-label=""] { justify-content: flex-end; }
    #items-table td[data-label=""] .item-remove-btn {
        font-size: 13px !important;
        color: #e11d48;
        border: 1px solid #fecdd3;
        border-radius: 8px;
        padding: 6px 14px;
        line-height: 1;
    }
    #items-table td[data-label=""] .item-remove-btn::after { content: " Remove"; }
    /* Phase rows stay full-width banners */
    #items-table tr.phase-row {
        padding: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }
    #items-table tr.phase-row td {
        display: block;
        text-align: left;
        padding: 8px 12px !important;
    }
    #items-table tr.phase-row td::before { display: none; }

    /* The card list provides its own borders — drop the outer table frame on mobile */
    #items-table-wrap {
        border: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    /* Native date/number inputs must not overflow their container on mobile */
    input[type="date"].form-input,
    input[type="number"].form-input,
    input[type="tel"].form-input,
    input[type="email"].form-input {
        max-width: 100%;
        min-width: 0;
        -webkit-appearance: none;
        appearance: none;
    }

    /* Form panel full width on mobile */
    #form-panel {
        max-width: 100% !important;
    }

    /* Bottom fixed mobile tab bar */
    .mobile-tab {
        font-size: 11px;
        padding: 10px 4px;
    }

    /* Mobile uses the History tab, never the slide-in sidebar */
    #sidebar { display: none !important; }
    #sidebar-overlay { display: none !important; }
}

/* ---- Sidebar ---- */
#sidebar {
  transition: transform 0.3s ease, width 0.3s ease;
}
/* Collapsed: removed from the layout so the editor gets the full width */
#sidebar.collapsed { display: none !important; }

/* Documents-panel toggle is desktop-only (mobile uses the History tab) */
#btn-sidebar-toggle { display: none; }
@media (min-width: 1024px) {
  #btn-sidebar-toggle { display: inline-flex; }
}

/* ---- Mobile Tab Bar ---- */
.mobile-tab {
  color: #64748b;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.mobile-tab.active {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
  font-weight: 700;
}

/* ---- Active nav link ---- */
.nav-link-active {
  background: rgba(99,102,241,0.1);
  color: #4f46e5;
  font-weight: 600;
}

/* ---- Bank account card ---- */
.bank-card {
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.bank-card:hover { border-color: #a5b4fc; }
.bank-card.selected { border-color: #4f46e5; background: #eef2ff; }
.bank-card .radio-dot {
  position: absolute; top: 12px; right: 12px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  transition: all 0.2s;
}
.bank-card.selected .radio-dot {
  border-color: #4f46e5;
  background: #4f46e5;
  box-shadow: inset 0 0 0 3px white;
}

/* ---- Drag handle ---- */
.drag-handle {
  cursor: grab;
  color: #94a3b8;
  padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }

/* ---- Discount mode toggle ---- */
.discount-mode {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
}
.discount-mode button {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
  color: #64748b;
}
.discount-mode button.active {
  background: white;
  color: #4f46e5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* =========================================================
   APP THEMES — Light (default) / Dark / Glossy
   data-theme is set on <html>. The document preview lives in
   an iframe (srcdoc) so the printed invoice stays unaffected.
   ========================================================= */

/* ---------- DARK THEME ---------- */
[data-theme="dark"] body { background: #0f172a !important; color: #e2e8f0 !important; }

/* Broad utility overrides (the UI leans heavily on these classes) */
[data-theme="dark"] .bg-white { background: #1e293b !important; }
[data-theme="dark"] .bg-slate-50 { background: #0f172a !important; }
[data-theme="dark"] .bg-slate-100 { background: #334155 !important; }
[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-slate-100 { border-color: #334155 !important; }
[data-theme="dark"] .text-slate-800,
[data-theme="dark"] .text-slate-700,
[data-theme="dark"] .text-slate-600 { color: #e2e8f0 !important; }
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-400 { color: #94a3b8 !important; }

/* Structural surfaces */
[data-theme="dark"] header { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] #sidebar { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .section-card { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .section-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] .section-title { color: #94a3b8 !important; }
[data-theme="dark"] .form-label { color: #94a3b8 !important; }
[data-theme="dark"] .modal-card { background: #1e293b !important; color: #e2e8f0 !important; }
[data-theme="dark"] .settings-drawer { background: #1e293b !important; color: #e2e8f0 !important; }

/* Inputs */
[data-theme="dark"] .form-input,
[data-theme="dark"] .items-table input,
[data-theme="dark"] .items-table select,
[data-theme="dark"] .items-table textarea {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .form-input::placeholder { color: #64748b; }
[data-theme="dark"] select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Lists / cards */
[data-theme="dark"] .doc-list-item:hover { background: #273449; border-color: #475569; }
[data-theme="dark"] .doc-list-item.active { background: #312e81; border-color: #6366f1; }
[data-theme="dark"] #items-table tbody tr { background: #1e293b; border-color: #334155; }
[data-theme="dark"] #items-table tbody tr:hover { background: #1e293b; }
[data-theme="dark"] .bank-card { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .btn-ghost { color: #cbd5e1; }
[data-theme="dark"] .btn-ghost:hover { background: #334155; color: #fff; }
[data-theme="dark"] .discount-mode { background: #334155; }
[data-theme="dark"] .discount-mode button.active { background: #0f172a; color: #a5b4fc; }
[data-theme="dark"] .columns-popover { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* ---------- GLOSSY THEME ---------- */
[data-theme="glossy"] body {
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 45%, #fae8ff 100%) !important;
  background-attachment: fixed !important;
}
[data-theme="glossy"] header {
  background: rgba(255,255,255,0.6) !important;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-color: rgba(255,255,255,0.6) !important;
}
[data-theme="glossy"] #sidebar {
  background: rgba(255,255,255,0.55) !important;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-color: rgba(255,255,255,0.6) !important;
}
[data-theme="glossy"] .section-card {
  background: rgba(255,255,255,0.62) !important;
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.75) !important;
  box-shadow: 0 8px 26px rgba(79,70,229,0.13), inset 0 1px 0 rgba(255,255,255,0.6) !important;
}
[data-theme="glossy"] .form-input {
  background: rgba(255,255,255,0.72) !important;
  border-color: rgba(255,255,255,0.85) !important;
}
[data-theme="glossy"] #items-table tbody tr {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 4px 14px rgba(79,70,229,0.1);
}
[data-theme="glossy"] .btn-primary { box-shadow: 0 6px 18px rgba(79,70,229,0.45); }
[data-theme="glossy"] .btn-success { box-shadow: 0 6px 18px rgba(5,150,105,0.4); }
[data-theme="glossy"] .modal-card,
[data-theme="glossy"] .settings-drawer {
  background: rgba(255,255,255,0.85) !important;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}

/* ---------- DARK THEME: extra polish ---------- */
[data-theme="dark"] .items-table thead th { background: #0f172a; color: #94a3b8; }
[data-theme="dark"] .phase-row td { background: #1e3a5f; color: #93c5fd; border-color: #1e40af !important; }
[data-theme="dark"] .tab-nav { border-bottom-color: #334155; }
[data-theme="dark"] .tab-btn { color: #94a3b8; }
[data-theme="dark"] .tab-btn.active { color: #a5b4fc; border-bottom-color: #6366f1; }
[data-theme="dark"] .doc-type-btn.inactive { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .footer-option { border-color: #334155; color: #cbd5e1; }
[data-theme="dark"] .mobile-tab.active { color: #a5b4fc; border-bottom-color: #6366f1; }
[data-theme="dark"] .toggle-track { background: #475569; }

/* ---- Collapsible editor sections ---- */
.collapsible-title { cursor: pointer; user-select: none; }
.collapse-chevron { margin-left: auto; padding-left: 8px; color: #94a3b8; transition: transform 0.2s ease; font-size: 12px; }
.section-card.collapsed .collapse-chevron { transform: rotate(-90deg); }
.section-card.collapsed > *:not(.section-title) { display: none !important; }
.section-card.collapsed { padding-bottom: 14px; }
[data-theme="dark"] .collapse-chevron { color: #64748b; }
