@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,700&display=swap');

/* ==========================================================================
   Tiyasha Enterprise Bill Generator
   Apple Mac Glassmorphism Design System & Print Precision
   ========================================================================== */

:root {
  /* Apple Palette */
  --apple-bg: #f5f5f7;
  --apple-card-bg: rgba(255, 255, 255, 0.82);
  --apple-glass-border: rgba(0, 0, 0, 0.09);
  --apple-glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --apple-text-primary: #1d1d1f;
  --apple-text-secondary: #86868b;
  --apple-text-muted: #a1a1a6;
  --apple-accent: #000000;
  --apple-accent-light: #f0f0f2;
  --apple-focus-ring: rgba(0, 0, 0, 0.2);
  --apple-danger: #ff3b30;
  --apple-danger-bg: rgba(255, 59, 48, 0.1);
  --apple-success: #34c759;
  
  /* Bill Document Specs (100% Matches Blueprint.png with tall condensed letterforms) */
  --bill-font: 'Roboto Condensed', 'Arial Narrow', 'Nimbus Sans L', sans-serif-condensed, sans-serif;
  --bill-line-color: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--bill-font);
  background-color: var(--apple-bg);
  color: var(--apple-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Apple Glassmorphic Top Navigation
   ========================================================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--apple-glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #000;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  background: #000;
  color: #fff;
  border-radius: 20px;
}

.nav-center {
  display: flex;
  align-items: center;
}

.save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--apple-text-secondary);
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 10px;
  border-radius: 20px;
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--apple-success);
  transition: background-color 0.3s;
}

.save-dot.saving {
  background-color: #ff9500;
  animation: pulse 1s infinite alternate;
}

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

/* Glass Buttons */
.glass-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--apple-glass-border);
  color: var(--apple-text-primary);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.glass-btn:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.glass-btn:active {
  transform: translateY(0);
  background: #ececec;
}

.glass-btn.icon-btn {
  padding: 8px;
  border-radius: 10px;
}

.primary-glass-btn {
  background: #000000;
  color: #ffffff;
  border: 1px solid #000000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.primary-glass-btn:hover {
  background: #2c2c2e;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.danger-glass-btn {
  background: var(--apple-danger-bg);
  color: var(--apple-danger);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.danger-glass-btn:hover {
  background: var(--apple-danger);
  color: #fff;
}

/* ==========================================================================
   Apple Mac Glass Sidebar Drawer
   ========================================================================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-right: 1px solid var(--apple-glass-border);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.12);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.sidebar-panel.active {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--apple-glass-border);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--apple-text-secondary);
}

.sidebar-action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--apple-glass-border);
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.sidebar-action-card:hover {
  border-color: #000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.sidebar-action-card.secondary {
  background: var(--apple-accent-light);
}

.sidebar-action-card.outline {
  background: transparent;
  border: 1.5px dashed var(--apple-glass-border);
}

.sidebar-action-card.outline:hover {
  background: #ffffff;
  border-color: #000;
  border-style: solid;
}

.templates-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #000;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-action-card.secondary .action-icon {
  background: #e2e2e5;
  color: #000;
}

.sidebar-action-card.outline .action-icon {
  background: rgba(0, 0, 0, 0.04);
  color: #555;
  border: 1px dashed rgba(0, 0, 0, 0.2);
}

.sidebar-action-card.outline:hover .action-icon {
  background: #000;
  color: #fff;
  border-style: solid;
  border-color: #000;
}

.action-details strong {
  display: block;
  font-size: 0.95rem;
  color: #000;
}

.action-details span {
  display: block;
  font-size: 0.78rem;
  color: var(--apple-text-secondary);
}

/* Stat Card */
.stat-card {
  background: #ffffff;
  border: 1px solid var(--apple-glass-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
}

.stat-badge {
  background: #000;
  color: #fff;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.stat-code {
  font-family: monospace;
  font-size: 0.85rem;
  background: #f0f0f2;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.stat-hint {
  font-size: 0.72rem;
  color: var(--apple-text-muted);
  line-height: 1.4;
}

/* Saved Bills */
.saved-bills-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.saved-bill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--apple-glass-border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.saved-bill-item:hover {
  background: #f8f8fa;
  border-color: #000;
}

.saved-bill-meta strong {
  display: block;
  font-size: 0.85rem;
}

.saved-bill-meta span {
  font-size: 0.75rem;
  color: var(--apple-text-secondary);
}

.saved-bill-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  font-size: 0.82rem;
  color: var(--apple-text-muted);
  text-align: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 10px;
}

/* Settings Form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-item span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--apple-text-secondary);
}

.glass-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--apple-glass-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.glass-input:focus {
  outline: none;
  border-color: #000;
  box-shadow: 0 0 0 2px var(--apple-focus-ring);
}

.w-100 {
  width: 100%;
}

/* ==========================================================================
   Main Viewport & Document Canvas
   ========================================================================== */
.main-viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 24px 16px 100px;
  background: var(--apple-bg);
  overflow-x: hidden;
}

.viewport-wrapper {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* Helper Strip */
.helper-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid var(--apple-glass-border);
  border-radius: 12px;
  font-size: 0.82rem;
  color: var(--apple-text-secondary);
}

.helper-tip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #000;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.pill-btn:hover {
  background: #333;
  transform: translateY(-1px);
}

/* ==========================================================================
   The Bill Sheet (Pixel-Perfect to Blueprint.png)
   ========================================================================== */
.bill-page {
  width: 100%;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: 80px 45px 75px;
  position: relative;
  transition: box-shadow 0.3s;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
}

/* Bill Header */
.bill-header {
  text-align: center;
  margin-bottom: 14px;
}

.enterprise-title {
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
  font-size: 3.25rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.035em !important;
  color: #000000;
  line-height: 1.1;
  margin-bottom: 8px;
  outline: none;
  border-radius: 4px;
}

.enterprise-title:focus {
  background: rgba(0, 0, 0, 0.03);
}

.address-line {
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
  font-size: 1.22rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em !important;
  color: #000000;
  line-height: 1.38;
  outline: none;
}

.phone-line {
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
  font-size: 1.22rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em !important;
  color: #000000;
  line-height: 1.38;
  outline: none;
}

.header-divider {
  width: 100%;
  height: 2.8px;
  background: #000000;
  margin: 14px 0 16px;
}

/* Metadata Row: Ref No & Date */
.metadata-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  font-family: var(--bill-font);
  font-size: 0.96rem;
}

.meta-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.meta-label {
  font-weight: 700;
  color: #000000;
  white-space: nowrap;
}

.meta-value,
.underline-dash {
  font-weight: 600;
  color: #000000;
  outline: none;
  display: inline-block;
  min-width: 14px; /* Dynamic underline that matches exact length */
  padding: 0 2px 1.5px 2px;
  border-bottom: 1.8px solid #000000 !important;
  text-decoration: none !important;
  box-sizing: border-box;
}

.meta-value:empty::before,
.underline-dash:empty::before {
  content: attr(placeholder);
  color: #bbb;
}

/* Bill Title */
.bill-title-container {
  text-align: center;
  margin-bottom: 18px;
}

.bill-title {
  font-family: var(--bill-font);
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #000000;
  border-bottom: 2px solid #000000;
  padding-bottom: 1px;
}

/* ==========================================================================
   Invoice Table (Dynamic & Exact to Blueprint.png)
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-family: var(--bill-font);
  font-size: 0.95rem;
  color: #000000;
  border: 1.8px solid #000000;
}

/* Column Width Allocations */
.col-sl {
  width: 50px;
  text-align: center;
}

.col-desc {
  width: auto;
}

.col-qty-rate {
  width: 220px;
  text-align: center;
}

.col-amount {
  width: 140px;
  text-align: center;
}

/* Table Headers */.invoice-table {
  width: 100%;
  border-collapse: collapse;
  border: 1.8px solid #000000;
  margin-bottom: 25px;
  background: #ffffff;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
}

.invoice-table thead th {
  border: 1.8px solid #000000;
  padding: 6px 4px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  background: transparent;
  color: #000000;
  vertical-align: middle;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
}

/* Table Cells - Default for standalone items (e.g. Sheet Gate, Steel Railing) */
.invoice-table td {
  border-left: 1.8px solid #000000;
  border-right: 1.8px solid #000000;
  padding: 5px 8px;
  vertical-align: middle;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
}

/* Standalone item rows */
.item-row.standalone-item td {
  padding: 6px 8px;
  vertical-align: middle;
}

/* Main Item Row Border */
.item-row.main-item-start td {
  border-top: 1.8px solid #000000;
}

/* Breathing space between subtitle lines (natural, balanced, matching Blueprint.png) */
.item-row.has-subtitles td {
  vertical-align: top !important;
  padding-top: 5px !important;
  padding-bottom: 2.5px !important;
  line-height: 1.32 !important;
}

.sub-item-row td {
  padding-top: 2.5px !important;
  padding-bottom: 2.5px !important;
  vertical-align: top !important;
  line-height: 1.32 !important;
}

.sub-item-row:last-child td {
  padding-bottom: 6px !important;
}

/* Alignment */
.cell-sl {
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: var(--bill-font);
}

.item-row.has-subtitles .cell-sl {
  vertical-align: top !important;
  padding-top: 2px !important;
}

.item-row.standalone-item .cell-sl {
  vertical-align: middle !important;
}

.cell-desc {
  text-align: left;
}

.cell-qty-rate {
  text-align: center;
  white-space: nowrap;
  font-family: var(--bill-font);
}

.item-row.has-subtitles .cell-qty-rate,
.sub-item-row .cell-qty-rate {
  vertical-align: top !important;
  line-height: 1.15 !important;
}

.item-row.standalone-item .cell-qty-rate {
  vertical-align: middle !important;
}

.cell-amount {
  text-align: center; /* Centered amount numbers as requested */
  white-space: nowrap;
  font-family: var(--bill-font);
}

.item-row.has-subtitles .cell-amount,
.sub-item-row .cell-amount {
  vertical-align: top !important;
  line-height: 1.15 !important;
}

.item-row.standalone-item .cell-amount {
  vertical-align: middle !important;
}

/* Description Typography */
.item-desc-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.32 !important;
  min-height: 20px;
}

.item-title-text {
  font-family: var(--bill-font);
  font-stretch: condensed;
  font-weight: 700;
  font-size: 0.95rem;
  color: #000000;
  outline: none;
  display: inline;
  line-height: 1.32 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.item-title-text:empty::before {
  content: 'Title';
  color: #a1a1a6;
  font-weight: 600;
}

.sub-item-text {
  font-family: var(--bill-font);
  font-stretch: condensed;
  font-weight: 500;
  font-size: 0.92rem;
  color: #000000;
  outline: none;
  display: inline;
  line-height: 1.32 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.sub-item-text:empty::before {
  content: 'Subtitle';
  color: #a1a1a6;
  font-weight: 500;
}

.sub-item-prefix {
  display: inline-block;
  width: 16px;
  font-weight: 600;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.32 !important;
}

/* Sub-item Row Layout */
.sub-item-row .cell-desc {
  padding-left: 18px !important;
}

/* Total Row */
.total-row td {
  border-top: 1.8px solid #000000;
  border-bottom: 1.8px solid #000000;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 1.05rem;
  font-family: var(--bill-font);
}

.total-label {
  text-align: center;
  letter-spacing: 0.05em;
}

.total-val {
  text-align: center; /* Centered total amount as requested */
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  outline: none;
}

/* Footer & Proprietor */
.bill-footer {
  margin-top: 35px;
  display: flex;
  justify-content: flex-end;
}

.proprietor-block {
  text-align: center;
  min-width: 180px;
}

.proprietor-name {
  font-family: var(--bill-font);
  font-weight: 700;
  font-size: 1rem;
  color: #000000;
  margin-bottom: 2px;
  outline: none;
  padding: 2px 4px;
}

.proprietor-title {
  font-family: var(--bill-font);
  font-weight: 500;
  font-size: 0.92rem;
  color: #000000;
}

/* ==========================================================================
   Interactive UI Controls (Visible on screen, hidden on print)
   ========================================================================== */

/* Inline Action Controls */
.row-actions-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  height: 16px;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.item-row:hover .row-actions-wrap,
.sub-item-row:hover .row-actions-wrap {
  opacity: 1;
}

@media (hover: none) {
  .row-actions-wrap {
    opacity: 0.8;
  }
}

.row-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #333;
  padding: 0px 4px;
  height: 16px;
  border-radius: 3px;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.row-action-btn:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}

.row-action-btn.delete-btn {
  color: var(--apple-danger);
  border-color: rgba(255, 59, 48, 0.2);
  background: rgba(255, 59, 48, 0.05);
}

.row-action-btn.delete-btn:hover {
  background: var(--apple-danger);
  color: #fff;
  border-color: var(--apple-danger);
}

/* ==========================================================================
   Natural Single Space Qty / Rate & Centered Amount
   ========================================================================== */
.qty-rate-text {
  outline: none;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
  font-size: 0.95rem;
  font-weight: 600;
  color: #000000;
  display: inline-block;
  text-align: center;
  padding: 0 4px;
  margin: 0;
  line-height: 1.32;
  word-spacing: normal !important; /* STRICTLY NATURAL SINGLE SPACEBAR */
  letter-spacing: normal !important;
  white-space: nowrap;
  border-bottom: 1px dashed transparent;
  cursor: text;
  min-width: 20px;
  transition: background 0.15s, border-color 0.15s;
}

.qty-rate-text:hover,
.qty-rate-text:focus {
  border-bottom: 1px dashed rgba(0, 0, 0, 0.4);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 2px;
}

.qty-rate-text:empty::before {
  content: '—';
  color: #000000;
  font-weight: 700;
}

.amount-text {
  outline: none;
  font-family: var(--bill-font) !important;
  font-stretch: condensed !important;
  font-size: 0.95rem;
  font-weight: 600;
  color: #000000;
  display: inline-block;
  text-align: center;
  padding: 0 4px;
  margin: 0;
  line-height: 1.32;
  border-bottom: 1px dashed transparent;
  cursor: text;
  min-width: 32px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, border-color 0.15s;
}

.amount-text:hover,
.amount-text:focus {
  border-bottom: 1px dashed rgba(0, 0, 0, 0.4);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 2px;
}

.amount-text:empty::before {
  content: '0.00';
  color: #a1a1a6;
}

/* Bottom Add Buttons */
.table-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.glass-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--apple-glass-border);
  color: #000;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-pill-btn:hover {
  background: #000;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Apple Mac Floating Bottom Dock
   ========================================================================== */
.bottom-dock {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  box-sizing: border-box;
  pointer-events: none;
}

.dock-wrapper {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 8px 14px;
  border-radius: 40px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
  max-width: min(100%, 480px);
  box-sizing: border-box;
}

.dock-label-short {
  display: none;
}

.dock-label-full {
  display: inline;
}

.dock-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--apple-text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.dock-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.dock-btn.primary-dock-btn {
  background: #000;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.dock-btn.primary-dock-btn:hover {
  background: #2c2c2e;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.dock-separator {
  width: 1px;
  height: 22px;
  background: rgba(0, 0, 0, 0.12);
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Mobile & Responsive Layouts
   ========================================================================== */
@media screen and (max-width: 768px) {
  .top-nav {
    padding: 8px 12px;
  }

  .brand-title {
    font-size: 0.92rem;
  }

  .brand-badge {
    display: none;
  }

  .nav-center {
    display: none;
  }

  .glass-btn .btn-label {
    display: none;
  }

  .glass-btn {
    padding: 8px;
  }

  .main-viewport {
    padding: 12px 6px 120px;
  }

  .bill-page {
    padding: 24px 16px 36px;
    border-radius: 0;
    box-shadow: none;
  }

  .enterprise-title {
    font-size: 1.6rem;
  }

  .address-line, .phone-line {
    font-size: 0.82rem;
  }

  .metadata-row {
    font-size: 0.85rem;
  }

  .meta-value,
  .underline-dash {
    min-width: 14px;
  }

  /* Table on mobile: ensure tight fit and readability */
  .invoice-table {
    font-size: 0.8rem;
  }

  .col-sl {
    width: 34px;
  }

  .col-qty-rate {
    width: 140px;
  }

  .col-amount {
    width: 90px;
  }

  .invoice-table thead th {
    padding: 6px 2px;
    font-size: 0.8rem;
  }

  .invoice-table td {
    padding: 4px 6px;
  }

  .qty-rate-text,
  .amount-text {
    font-size: 0.82rem;
  }

  /* Helper Strip in 1 neat line on mobile */
  .helper-strip {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .helper-tip {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.77rem;
    line-height: 1.22;
  }

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

  .strip-controls {
    flex-shrink: 0;
  }

  .helper-strip .pill-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }

  .helper-strip .pill-btn .btn-text {
    display: none;
  }

  .helper-strip .pill-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Bottom Dock on Mobile - Ultra-compact, safe-area edge detection, zero clipping */
  .bottom-dock {
    left: 0;
    right: 0;
    width: 100%;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding: 0 8px;
    box-sizing: border-box;
    transform: none;
    display: flex;
    justify-content: center;
  }

  .dock-wrapper {
    padding: 4px 6px;
    gap: 3px;
    border-radius: 28px;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
  }

  .dock-label-full {
    display: none;
  }

  .dock-label-short {
    display: inline;
  }

  .dock-btn {
    padding: 6px 9px;
    font-size: 0.77rem;
    gap: 3.5px;
    border-radius: 16px;
  }

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

  .dock-btn.primary-dock-btn {
    padding: 6px 12px;
    font-weight: 700;
  }

  .dock-separator {
    height: 16px;
    margin: 0 1px;
    opacity: 0.7;
  }
}

@media screen and (max-width: 360px) {
  .helper-tip {
    font-size: 0.71rem;
    line-height: 1.18;
  }

  .dock-wrapper {
    padding: 3px 4px;
    gap: 2px;
    max-width: calc(100vw - 10px);
  }

  .dock-btn {
    padding: 5px 7px;
    font-size: 0.72rem;
    gap: 2.5px;
  }

  .dock-btn.primary-dock-btn {
    padding: 5px 9px;
  }

  .dock-separator {
    display: none;
  }
}

/* ==========================================================================
   Templates Gallery Modal & Sidebar Header Styling
   ========================================================================== */
.clickable-header {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.clickable-header:hover {
  background: rgba(0, 0, 0, 0.05);
}

.header-left-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.open-gallery-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--apple-text-secondary);
  transition: color 0.15s;
}

.clickable-header:hover .open-gallery-tag {
  color: #000000;
}

/* Modal Overlay Backdrop */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-container {
  background: #ffffff;
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(12px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #111111;
}

.modal-subtitle {
  margin: 4px 0 0 0;
  font-size: 0.85rem;
  color: var(--apple-text-secondary);
}

.modal-close-btn {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: all 0.15s;
}

.modal-close-btn:hover {
  background: #000;
  color: #fff;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.templates-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.template-gallery-card {
  background: #fafafa;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.template-gallery-card:hover {
  border-color: #000000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
  transform: translateY(-2px);
  background: #ffffff;
}

.template-gallery-card.featured {
  border-color: rgba(0, 0, 0, 0.2);
  background: #ffffff;
}

.card-badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
}

.card-badge.blueprint-badge {
  background: #f0f0f5;
  color: #444455;
}

.card-badge.fab-badge {
  background: #000000;
  color: #ffffff;
}

.card-header-info {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.card-header-info h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #000;
}

.card-ref-tag {
  font-family: var(--bill-font);
  font-size: 0.85rem;
  font-weight: 700;
  color: #666;
}

.card-total-preview {
  font-family: var(--bill-font);
  font-size: 1.35rem;
  font-weight: 800;
  color: #000;
}

.card-summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--apple-text-secondary);
  line-height: 1.35;
}

.card-items-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.03);
  padding: 10px 12px;
  border-radius: 8px;
}

.item-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: #333;
}

.gallery-apply-btn {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #000000;
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gallery-apply-btn:hover {
  background: #333333;
  transform: translateY(-1px);
}

.modal-custom-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 16px;
}

.modal-subheading {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

/* ==========================================================================
   CLEAN EXPORT STATE (For 100% Crisp, Pixel-Perfect Single-Page PDF & PNG)
   ========================================================================== */
body.exporting-clean .no-print,
body.exporting-clean .row-actions-wrap,
body.exporting-clean .row-action-btn,
body.exporting-clean .add-sub-btn,
body.exporting-clean .delete-btn,
body.exporting-clean .delete-item-btn,
body.exporting-clean .delete-sub-btn,
body.exporting-clean .item-desc-wrap button,
body.exporting-clean .top-nav,
body.exporting-clean .floating-dock,
body.exporting-clean .sidebar-panel,
body.exporting-clean .sidebar-overlay,
body.exporting-clean .modal-overlay,
body.exporting-clean .toast-container,
body.exporting-clean .item-add-quick-btn {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.exporting-clean [contenteditable]:not(.meta-value):not(.underline-dash):not(#bill-ref-no):not(#bill-date) {
  outline: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.exporting-clean .meta-value,
body.exporting-clean .underline-dash,
body.exporting-clean #bill-ref-no,
body.exporting-clean #bill-date {
  border-bottom: 1.8px solid #000000 !important;
  display: inline-block !important;
  padding: 0 2px 1.5px 2px !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
}

body.exporting-clean .bill-card {
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 auto !important;
  width: 210mm !important;
  max-width: 210mm !important;
  min-height: auto !important;
  box-sizing: border-box !important;
  padding: 10mm 12mm !important;
}

/* ==========================================================================
   PRINT SPECIFICATION - 100% MATCH WITH BLUEPRINT.PNG
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 10mm 12mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    font-family: var(--bill-font) !important;
  }

  .no-print,
  .top-nav,
  .sidebar-overlay,
  .sidebar-panel,
  .helper-strip,
  .table-actions,
  .bottom-dock,
  .row-actions-wrap,
  .toast-container,
  .empty-draft-row {
    display: none !important;
  }

  .main-viewport {
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    display: block !important;
  }

  .viewport-wrapper {
    max-width: 100% !important;
    width: 100% !important;
  }

  .bill-page {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    font-family: var(--bill-font) !important;
  }

  .enterprise-title {
    font-family: var(--bill-font) !important;
    font-stretch: condensed !important;
    font-size: 3.25rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.035em !important;
    line-height: 1.1 !important;
    margin-bottom: 8px !important;
  }

  .address-line,
  .phone-line {
    font-family: var(--bill-font) !important;
    font-stretch: condensed !important;
    font-size: 1.22rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em !important;
    line-height: 1.38 !important;
  }

  .header-divider {
    height: 2.8px !important;
    background: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .meta-value,
  .underline-dash,
  #bill-ref-no,
  #bill-date {
    border-bottom: 1.8px solid #000 !important;
    display: inline-block !important;
    padding: 0 2px 1.5px 2px !important;
    text-decoration: none !important;
  }

  .bill-title {
    font-family: var(--bill-font) !important;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    border-bottom: 2px solid #000 !important;
  }

  .invoice-table {
    border: 1.8px solid #000 !important;
    width: 100% !important;
    page-break-inside: auto;
    font-family: var(--bill-font) !important;
  }

  .invoice-table thead th {
    border: 1.8px solid #000 !important;
    color: #000 !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    padding: 6px 4px !important;
    font-family: var(--bill-font) !important;
  }

  .invoice-table td {
    border-left: 1.8px solid #000 !important;
    border-right: 1.8px solid #000 !important;
    padding: 5px 8px !important;
    font-family: var(--bill-font) !important;
  }

  .item-row.main-item-start td {
    border-top: 1.8px solid #000 !important;
  }

  /* Natural breathing subtitle spacing in print & PDF */
  .item-row.has-subtitles td {
    padding-top: 5px !important;
    padding-bottom: 2.5px !important;
    line-height: 1.32 !important;
  }

  .sub-item-row td {
    padding-top: 2.5px !important;
    padding-bottom: 2.5px !important;
    line-height: 1.32 !important;
  }

  .sub-item-row:last-child td {
    padding-bottom: 6px !important;
  }

  .total-row td {
    border-top: 1.8px solid #000 !important;
    border-bottom: 1.8px solid #000 !important;
    font-weight: 800 !important;
    font-family: var(--bill-font) !important;
  }

  .qty-rate-text,
  .amount-text {
    border-bottom: none !important;
    background: transparent !important;
    word-spacing: normal !important;
  }
}

/* ==========================================================================
   Site Lazy Loader / Preloader Overlay
   Dead-center, auto-sized, blinking rounded portrait
   ========================================================================== */
#site-preloader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  background: rgba(245, 245, 247, 0.94);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s ease;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

#site-preloader.preloader-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.preloader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  max-width: 90vw;
}

.preloader-image-frame {
  position: relative;
  width: clamp(140px, 18vw, 195px);
  aspect-ratio: 1155 / 1362;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  border: 3px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preloader-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 21px;
  animation: preloaderBlink 1.3s ease-in-out infinite;
  background: transparent;
}

@keyframes preloaderBlink {
  0%, 100% {
    opacity: 0.28;
    transform: scale(0.96);
    filter: brightness(0.92) contrast(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
    filter: brightness(1.04) contrast(1.02);
  }
}

.preloader-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preloader-title {
  font-family: var(--bill-font);
  font-weight: 800;
  font-size: 1.18rem;
  letter-spacing: 2px;
  color: #1d1d1f;
  text-transform: uppercase;
  animation: preloaderTitlePulse 1.3s ease-in-out infinite;
}

@keyframes preloaderTitlePulse {
  0%, 100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.preloader-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.preloader-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #000000;
  opacity: 0.25;
  animation: preloaderDotBounce 1.3s infinite ease-in-out both;
}

.preloader-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.preloader-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes preloaderDotBounce {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.25;
  }
  40% {
    transform: scale(1.2);
    opacity: 0.85;
  }
}

/* Responsive adjustment for Mobile */
@media (max-width: 640px) {
  .preloader-image-frame {
    width: clamp(120px, 38vw, 160px);
    border-radius: 20px;
  }
  .preloader-img {
    border-radius: 17px;
  }
  .preloader-title {
    font-size: 1.02rem;
    letter-spacing: 1.5px;
  }
}

/* Ensure preloader never shows in print or export */
@media print {
  #site-preloader {
    display: none !important;
  }
}

body.exporting-clean #site-preloader {
  display: none !important;
}
