/* MakeItInvoice - Clean Minimal Styles */

/* Body padding reset */
body {
  padding-top: 0px;
}

/* Universal inline editable styles */
[contenteditable="true"] {
  cursor: text;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: inline-block;
}

[contenteditable="true"]:hover {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

[contenteditable="true"]:focus {
  outline: none;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* CSS Variables */
:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #0e1116;
  --muted: #6b7280;
  --accent: #3b82f6;
  --border: #e5e7eb;
  --error: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  
  /* Additional variables for CSV import */
  --text-secondary: #6b7280;
  --bg-secondary: #f9fafb;
  --bg-hover: #f3f4f6;
  --accent-hover: #2563eb;
  --success-bg: #ecfdf5;
  --success-border: #d1fae5;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;
}

:root[data-theme="dark"] {
  --bg: #0b0b0f;
  --panel: #13131a;
  --text: #eaeaf2;
  --muted: #9aa0a6;
  --accent: #3b82f6;
  --border: #1f2430;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
}

.brand .sub {
  color: var(--muted);
  font-size: 11px;
  font-weight: normal;
}

.logo-emoji {
  font-size: 18px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.actions > * {
  margin-left: 6px;
}

.actions button,
.file,
select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.2s ease;
}

.actions button:hover,
.file:hover,
select:hover {
  border-color: var(--accent);
}

.actions button:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Mobile Menu */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
}

.mobile-menu-toggle:hover {
  background: var(--bg);
}

/* Help Button */
.help-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
}

.help-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.help-icon {
  font-size: 15px;
}

/* Mobile Feedback Button */
.btn-feedback-mobile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
}

.btn-feedback-mobile:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.feedback-text {
  font-size: 12px;
  font-weight: 500;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-icon {
  font-size: 15px;
}

/* Container */
.container {
  max-width: 1029px;
  margin: 0 auto 20px auto;
  padding: 0 20px 20px 20px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Invoice Section */
.invoice-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.invoice-meta-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.invoice-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1;
  align-self: flex-start;
}

.invoice-meta-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invoice-meta {
  display: grid;
  gap: 2px;
  background: var(--bg);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 350px;
}

.meta-field {
  display: flex;
  justify-content: flex-start;
  gap: 5px;
  align-items: center;
}

.meta-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  cursor: text;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  width: 150px;
  display: inline-block;
  text-align: left;
}


.meta-input {
  width: 150px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
}

.meta-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Дополнительные стили для мета полей */
.meta-field input {
  width: 150px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.meta-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.meta-field input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* Стили для динамических полей */
#dynamic-fields .meta-field {
  margin-bottom: 2px;
  position: relative;
}

#dynamic-fields .meta-field input {
  width: 140px;
  margin-right: 5px;
}

#dynamic-fields .meta-label {
  min-width: 120px;
  font-size: 12px;
  color: var(--text);
  cursor: text;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

#dynamic-fields .meta-label:hover {
  background-color: var(--hover);
}

#dynamic-fields .meta-label:focus {
  background-color: var(--hover);
  outline: none;
}

/* Стили для колонок таблицы */
.qty-col {
  width: 100px;
  min-width: 100px;
  text-align: center;
}

.rate-col {
  width: 130px;
  min-width: 130px;
  text-align: center;
}

.amount-col {
  width: 160px;
  min-width: 130px;
  position: relative;
  text-align: center;
  overflow: visible;
}

.meta-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 350px;
}

.meta-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.meta-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.meta-btn:disabled {
  display: none;
}

.field-remove {
  background: none;
  color: var(--muted);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
  margin-left: 0px;
}

.meta-field:hover .field-remove,
.party-title:hover .field-remove,
.party-section:hover .field-remove {
  opacity: 1;
  visibility: visible;
}

.field-remove:hover {
  background: var(--error);
  color: white;
}

/* Party Sections */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 20px 0 20px;
}

.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.cols-3.ship-hidden {
  grid-template-columns: 1fr 1fr;
}

.party-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.party-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  gap: 5px;
}

.party-title span {
  flex: 1;
}

.party-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel);
  resize: vertical;
  font-family: inherit;
}

.party-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.party-textarea::placeholder {
  color: var(--muted);
}

/* Company Fields */
.company-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.company-field {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  font-family: inherit;
  transition: all 0.2s ease;
}

.company-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.company-field::placeholder {
  color: var(--muted);
}

/* Dynamic buttons container */
.dynamic-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.add-field-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
}

.add-field-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.add-field-btn:active {
  transform: translateY(1px);
}

.remove-field-btn {
  padding: 2px 4px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 6px;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-field-btn:hover {
  background: #c82333;
  transform: scale(1.1);
}

.remove-field-btn:active {
  transform: scale(0.95);
}

/* Responsive company fields */
@media (max-width: 768px) {
  .field-row {
    flex-direction: column;
  }

  .company-field {
    min-width: unset;
    width: 100%;
  }
  
  .field-with-button {
    min-width: unset;
    width: 100%;
  }
}

/* Ship Toggle */
.ship-toggle-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: 12px;
}

.add-section-btn {
  padding: 6px 10px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-section-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Table */
.items-table-container {
  margin: 20px 20px 10px 20px;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: none;
  border-radius: 0;
  table-layout: fixed;
  overflow: visible;
  box-shadow: none;
  margin-bottom: 0;
  min-width: 600px;
}

thead th {
  background: var(--accent);
  color: white;
  text-align: left;
  padding-top: 5px;
  padding-right: 10px;
  padding-bottom: 5px;
  padding-left: 10px;
  font-weight: 600;
  font-size: 13px;
    border: none;
}

.editable-header {
  color: white;
}

tbody td {
  padding: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--panel);
  border-left: none;
  border-right: none;
}

tbody tr:hover {
  background: var(--bg);
}

tbody td {
  padding: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--panel);
  border-left: none;
  border-right: none;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Table Inputs */
.input-group {
  display: flex;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.input-group-prefix {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  border: none;
  border-right: 1px solid var(--border);
  font-weight: 400;
  width: 20px;
  justify-content: center;
  flex-shrink: 0;
}

.input-group .cell {
  border: none;
  border-radius: 0;
  padding: 4px 6px;
  background: var(--panel);
  font-size: 13px;
  width: 50px;
}

.input-group .cell.price {
    flex: 1;
    margin: 0;
    border: none;
    border-radius: 0;
    padding: 4px 6px;
    font-size: 13px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
    position: relative;
    line-height: 1;
    vertical-align: middle;
}

/* Gray color for currency symbol in price field */
.cell.price {
    position: relative;
}

.cell.price::before,
.input-group .cell.price::before {
    content: "$ " !important;
    position: absolute !important;
    left: 4px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--muted) !important;
    pointer-events: none !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    z-index: 10 !important;
}

.input-group .cell:focus {
  box-shadow: none;
}

/* Input group for dynamic totals */
.input-group.toggleable {
  display: flex !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 120px;
  height: 36px;
}

.input-group.toggleable:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.input-group.toggleable .input-group-prefix {
  display: flex;
  align-items: center;
  padding: 8px 6px 8px 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border-right: 1px solid var(--border);
}

.input-group .dynamic-total-input {
  border: none;
  border-radius: 0;
  padding: 4px 6px;
  font-size: 13px;
  background: var(--panel);
  width: 50px;
}

.input-group .dynamic-total-input:focus {
  outline: none;
  box-shadow: none;
}

.input-group.toggleable .dynamic-total-input {
  flex: none;
}

.input-group.toggleable .input-group-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  background: #e5e7eb;
  color: var(--text);
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  min-width: 32px;
  height: 100%;
  flex-shrink: 0;
}

.input-group.toggleable .input-group-toggle:hover {
  background: var(--accent);
  color: white;
  transform: rotate(180deg);
}

/* Fallback for toggle button */
.input-group-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  background: #e5e7eb !important;
  color: var(--text) !important;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  min-width: 26px;
  height: 100%;
  flex-shrink: 0;
  visibility: visible !important;
  opacity: 1 !important;
}

.input-group-toggle:hover {
  background: var(--accent) !important;
  color: white !important;
  transform: rotate(180deg);
}

/* Force visibility for toggle buttons */
.dynamic-total-row .input-group-toggle {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Input group for Amount Paid (same style as Rate field) */
.input-group:not(.toggleable) {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 80px;
}

.input-group:not(.toggleable):focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.input-group:not(.toggleable) .input-group-prefix {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  border: none;
  border-right: 1px solid var(--border);
  font-weight: 400;
  width: 20px;
  justify-content: center;
  flex-shrink: 0;
}

.input-group:not(.toggleable) .dynamic-total-input {
  flex: none;
}

.input-group:not(.toggleable) {
  border-radius: 6px;
}

.input-group:not(.toggleable) .input-group-prefix {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

/* Special styling for Amount Paid */
#amount-paid-row .input-group {
  border-radius: 6px;
}

#amount-paid-row .input-group .input-group-prefix {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

input.cell {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  font-family: inherit;
}

input.cell:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

input.cell::placeholder {
  color: var(--muted);
}

/* Hide number input spinners */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Column Widths */
.item-col {
  width: auto;
  min-width: 200px;
}

.qty-col {
  width: 100px;
  min-width: 100px;
}

.rate-col {
  width: 130px;
  min-width: 130px;
}

.rate-col .input-group {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}

.amount-col {
  width: 160px;
  min-width: 130px;
  position: relative;
  overflow: visible;
}

.amount-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.amount-value {
  flex: 1;
  text-align: right;
  padding-right: 20px;
}

/* Item Name Row */
.item-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Description */
.description-section {
  margin-top: 8px;
}

.description {
  width: 100%;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.3;
  resize: vertical;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}

.description:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.description::placeholder {
  color: var(--muted);
}

/* Item Actions */
.item-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 16px;
  height: 20px;
  justify-content: center;
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
}

.description-toggle-btn {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 1;
  visibility: visible;
  margin-left: 5px;
  background: none;
  border: none;
  padding: 0;
}

.fav-icon,
.move-up-btn,
.row-delete-btn {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  margin-left: 5px;
  background: none;
  border: none;
  padding: 0;
}

tbody tr:hover .fav-icon,
tbody tr:hover .move-up-btn,
tbody tr:hover .row-delete-btn {
  opacity: 1;
  visibility: visible;
}

.description-toggle-btn:hover,
.move-up-btn:hover {
  background: var(--accent);
  color: white;
}

.fav-icon:hover {
  color: #fbbf24;
  background: transparent;
}

.row-delete-btn:hover {
  background: var(--error);
  color: white;
}

/* Table Actions */
.table-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  margin: 0;
}

.add-line-btn {
  background: var(--panel);
  color: var(--success);
  border: 1px solid var(--success);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
  min-width: auto;
  white-space: nowrap;
}

.add-line-btn:hover {
  background: var(--success);
  color: white;
  border-color: var(--success);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

/* Totals and Notes Row */
.totals-notes-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 20px 20px 20px;
}

/* Notes and Terms (left side) */
.notes-terms-left {
  display: flex;
  flex-direction: column;
  width: calc(50% - 10px);
  gap: 16px;
}

.notes-section,
.terms-section {
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 5px;
}

.editable-section-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.section-remove-btn {
  background: none;
  color: var(--muted);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
  margin-left: 5px;
  flex-shrink: 0;
}

.section-header:hover .section-remove-btn,
.notes-section:hover .section-remove-btn,
.terms-section:hover .section-remove-btn {
  opacity: 1;
  visibility: visible;
}

.section-remove-btn:hover {
  background: var(--error);
  color: white;
}

.notes-textarea,
.terms-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel);
  resize: vertical;
  font-family: inherit;
}

.notes-textarea:focus,
.terms-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.notes-textarea::placeholder,
.terms-textarea::placeholder {
  color: var(--muted);
}

.section-buttons {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Totals (right side) */
.totals-section {
  display: flex;
  flex-direction: column;
  width: 405px;
  align-self: flex-start;
}

.totals-table {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  position: relative;
  left: -1px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
  min-height: 28px;
}

.total-row > span:last-child {
  text-align: right;
  min-width: 160px;
  width: 160px;
  flex-shrink: 0;
  padding-right: 20px;
}

.editable-total-label {
  width: 100px;
  display: inline-block;
}

.editable-total-label.main-total {
  width: 150px;
}


.total-row.grand {
  margin-top: 4px;
  padding-top: 8px;
  font-weight: bold;
  font-size: 13px;
  border-top: 1px solid var(--border);
}

#subtotal-row {
  font-weight: bold;
  font-size: 13px;
}

#amount-paid-row {
  margin-top: 0px;
  padding-top: 0px;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 28px;
}

#amount-paid-row .dynamic-total-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

#amount-paid-row .dynamic-total-input {
  flex: none;
  width: 110px;
}

#amount-paid-row .dynamic-total-remove {
  background: none;
  color: var(--muted);
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
  margin-left: 5px;
}

#amount-paid-row:hover .dynamic-total-remove {
  opacity: 1;
  visibility: visible;
}

#amount-paid-row .dynamic-total-remove:hover {
  background: var(--error);
  color: white;
}

#amount-paid-row .dynamic-total-amount {
  text-align: right;
  min-width: 100px;
  width: 100px;
  flex-shrink: 0;
  padding-right: 0px;
}

.dynamic-total-amount {
  text-align: right;
  min-width: 100px;
  width: 100px;
  flex-shrink: 0;
  padding-right: 0px;
}

#amount-due-row {
  margin-top: 2px;
}

/* Dynamic total input fields - same style as Rate field */
.dynamic-total-input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text);
  width: 110px;
}

/* Dynamic Totals */
.totals-buttons {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

/* All totals buttons container */
.totals-buttons-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 0 20px 0 0; /* Right padding to align with totals table */
}

.add-total-btn {
  padding: 6px 10px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-total-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.add-total-btn.hidden,
.add-section-btn.hidden {
  display: none;
}

.dynamic-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0 2px 5px;
  min-height: 28px;
}

.dynamic-total-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}


.dynamic-total-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Toggle button for discount/tax fields in new structure */
div[style*="position: relative"] .input-group-toggle {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  width: 10px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: all 0.2s ease;
}

div[style*="position: relative"] .input-group-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.dynamic-total-remove {
  background: none;
  color: var(--muted);
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
  margin-left: 5px;
}

.dynamic-total-row:hover .dynamic-total-remove {
  opacity: 1;
  visibility: visible;
}

.dynamic-total-remove:hover {
  background: var(--error);
  color: white;
}

/* Export Controls */
.export-controls {
  margin: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.export-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.export-btn {
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 140px;
  text-align: center;
}

.export-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.export-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.export-btn.primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* File Input */
.file {
  position: relative;
  cursor: pointer;
}

.file input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Ad Sidebar */
.ad-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.ad-panel.show {
  transform: translateX(0);
}

.ad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.ad-header h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.ad-toggle {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

/* Ad Footer */
.ad-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
}

.ad-footer.show {
  transform: translateY(0);
}

.ad-footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.ad-footer-text {
  font-size: 13px;
  color: var(--muted);
}

.ad-footer-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

/* Modal Styles */
dialog {
  border: none;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  max-width: 800px;
  width: 90vw;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 1000;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

/* Feedback Modal - Higher z-index */
#feedback-modal {
  z-index: 1100;
}

#feedback-modal::backdrop {
  z-index: 1099;
}

dialog h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

dialog menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding: 0;
  list-style: none;
}

dialog menu button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

dialog menu button:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

dialog menu button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Modal Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px 12px 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: 300;
}

.modal-close-btn:hover {
  background: var(--panel);
  color: var(--text);
  transform: scale(1.1);
}

/* Feedback Modal Specific Styles */
#feedback-modal {
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
}

#feedback-modal .modal-content {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Favorites Modal */
#fav-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow: auto;
  margin: 16px 0;
}

.fav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s ease;
}

.fav-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fav-content {
  flex: 1;
  min-width: 0;
}

.fav-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 4px;
}

.fav-price {
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 4px;
}

.fav-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

.fav-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--panel);
  color: var(--text);
}

.fav-btn.insert {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.fav-btn.insert:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.fav-btn.delete {
  background: var(--error);
  color: white;
  border-color: var(--error);
  min-width: 24px;
  padding: 6px 8px;
}

.fav-btn.delete:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* History Modal */
.history-controls {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.danger-btn {
  background: var(--error);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.danger-btn:hover {
  background: #dc2626;
}

.history-list {
  max-height: 400px;
  overflow: auto;
  margin: 16px 0;
}

/* History Item Styles */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.history-info {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex: 1;
  align-items: center;
}

.history-info strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  min-width: 120px;
}

.history-info span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-small {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-small.btn-danger {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

.btn-small.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state h4 {
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 8px;
}

.empty-state small {
  font-size: 12px;
  opacity: 0.8;
}

/* History table */
.history-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.history-table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 80px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.history-table-body {
  background: var(--panel);
}

.history-table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 80px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.history-table-row:hover {
  background: var(--bg);
}

.history-table-row:last-child {
  border-bottom: none;
}

.history-col {
  padding: 12px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
}

.history-col:last-child {
  border-right: none;
}

.history-col.customer {
  font-weight: 500;
  color: var(--text);
}

.history-col.reference {
  color: var(--accent);
  font-weight: 500;
}

.history-col.date {
  color: var(--muted);
}

.history-col.total {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.history-col.actions {
  justify-content: center;
  gap: 4px;
}

.history-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.history-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.history-btn.open:hover {
  background: var(--accent);
  color: white;
}

.history-btn.delete:hover {
  background: var(--error);
  color: white;
}

/* PDF Export Interstitial */
.interstitial-content {
  text-align: center;
}

.interstitial-ad {
  margin: 20px 0;
  padding: 20px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.interstitial-timer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* Help Modal */
.help-content {
  max-width: 600px;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.help-section h4 {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.help-section h5 {
  margin: 16px 0 8px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.help-section p {
  margin-bottom: 8px;
  line-height: 1.5;
  color: var(--text);
}

.help-section ul,
.help-section ol {
  margin: 8px 0 8px 20px;
  color: var(--text);
}

.help-section li {
  margin-bottom: 4px;
  line-height: 1.4;
}

.help-section strong {
  color: var(--accent);
}

.primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background: var(--accent);
}

/* Export Success Modal */
.success-content {
  max-width: 500px;
  width: 100%;
}

.success-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.success-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.success-message {
  margin-bottom: 24px;
}

.success-message p {
  margin-bottom: 12px;
  line-height: 1.5;
  color: var(--text);
}

/* Export Success Modal */
#export-success-modal {
  max-width: 500px;
  width: 90vw;
  max-height: 70vh;
}

#export-success-modal .modal-content {
  padding: 20px;
  max-height: none;
  overflow: visible;
}

.success-message {
  text-align: center;
  margin-bottom: 24px;
}

.success-header-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.success-icon {
  font-size: 24px;
  animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
  60% {
    transform: translateY(-2px);
  }
}

.success-message h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.success-message p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.success-recommendation {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 16px;
}

.success-recommendation small {
  color: var(--muted);
  font-style: italic;
}

.success-actions {
  text-align: center;
}

.success-actions h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}

.success-btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
}

.success-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.success-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.success-btn.primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.success-btn {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.success-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
}

.success-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.success-btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.success-btn.secondary {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.success-btn.secondary:hover {
  background: #059669;
  border-color: #059669;
}

/* Scroll Indicator */
.items-table-container::after {
  content: "← Swipe to see more →";
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Mobile Touch Targets */
@media (max-width: 920px) {
  /* Ensure minimum touch target size of 44px */
  button, .btn, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Larger touch targets for interactive elements */
  .editable-label, .editable-header, [contenteditable="true"] {
    min-height: 44px;
    padding: 12px 8px;
  }
  
  /* Mobile-friendly input fields */
  input, textarea, select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s ease;
  }
  
  input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
  }
  
  /* Mobile-friendly table cells */
  .cell, input.cell {
    min-height: 44px;
    padding: 12px 8px;
    font-size: 16px;
  }
}

/* Mobile Responsive */
@media (max-width: 920px) {
  .cols {
    grid-template-columns: 1fr;
  }
  
  .cols-3 {
    grid-template-columns: 1fr;
  }
  
  .cols-3.ship-hidden {
    grid-template-columns: 1fr;
  }
  
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .actions {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    flex-direction: column;
    gap: 8px;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .actions.open {
    transform: translateY(0);
  }
  
  /* Mobile modal improvements */
  dialog {
    width: 95vw;
    max-width: 95vw;
    max-height: 90vh;
    margin: 5vh auto;
    padding: 20px;
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile modal backdrop */
  dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
  }
  
  /* Mobile modal content */
  dialog h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
  }
  
  dialog .modal-content {
    padding: 0;
  }
  
  /* Mobile modal buttons */
  dialog .modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
  }
  
  dialog .modal-actions button {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  /* Mobile form improvements */
  .form-group {
    margin-bottom: 20px;
  }
  
  .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
  }
  
  /* Mobile button improvements */
  .btn {
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  /* Mobile spacing improvements */
  .section {
    margin-bottom: 24px;
    padding: 16px;
  }
  
  .actions .btn,
  .actions select {
    width: 100%;
    justify-content: center;
  }
  
  .theme-toggle {
    align-self: center;
  }
  
  .invoice-meta-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .invoice-meta {
    min-width: auto;
  }
  
  .items-table-container {
    margin: 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  table {
    min-width: 500px;
    font-size: 13px;
  }
  
  thead th {
    padding: 10px 8px;
    font-size: 13px;
  }
  
  tbody td {
    padding: 10px 8px;
    font-size: 13px;
  }
  
  input.cell {
    font-size: 13px;
    padding: 6px;
  }
  
  .item-col {
    min-width: 150px;
  }
  
  .qty-col {
    min-width: 60px;
  }
  
  .rate-col {
    min-width: 80px;
  }
  
  .amount-col {
    min-width: 80px;
  }
  
  .item-actions {
    width: 14px;
    height: 18px;
    gap: 1px;
  }
  
  .description-toggle-btn,
  .fav-icon,
  .move-up-btn,
  .row-delete-btn {
    font-size: 11px;
    width: 12px;
    height: 12px;
  }
  
  .item-name-row {
    gap: 6px;
  }
  
  .add-line-btn {
    padding: 12px 16px;
    font-size: 15px;
    min-width: 120px;
    min-height: 48px;
  }
  
  .table-actions {
    margin: 16px;
    padding: 0 8px;
  }
  
  .dropdown-trigger {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .description-toggle-btn,
  .fav-icon,
  .move-up-btn,
  .row-delete-btn {
    min-width: 24px;
    min-height: 24px;
    touch-action: manipulation;
  }
  
  .totals-notes-row {
    flex-direction: column;
    gap: 16px;
  }
  
  .notes-terms-left,
  .totals-section {
    width: 100%;
  }
  
  .export-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .export-btn {
    justify-content: center;
  }
  
  .ad-panel {
    display: none;
  }
  
  .items-table-container::after {
    opacity: 1;
    animation: fadeInOut 3s ease-in-out infinite;
  }
  
  /* Mobile Modal Styles */
  dialog {
    width: 95vw;
    max-width: none;
    max-height: 90vh;
    margin: 0;
    padding: 16px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  dialog h3 {
    font-size: 18px;
    margin-bottom: 12px;
  }
  
  dialog menu {
    flex-direction: column;
    gap: 8px;
  }
  
  dialog menu button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  /* Horizontal scroll for tables on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
  }
  
  table {
    min-width: 500px; /* Increased for better mobile display */
    font-size: 14px; /* Slightly larger for mobile readability */
    width: 100%;
  }
  
  thead th {
    padding: 12px 8px;
    font-size: 12px;
  }
  
  tbody td {
    padding: 12px 8px;
    font-size: 14px;
  }
  
  input.cell {
    font-size: 14px;
    padding: 8px;
    min-height: 44px;
  }
  
  .item-col {
    min-width: 150px;
  }
  
  .qty-col {
    width: 80px;
    min-width: 80px;
  }
  
  .rate-col {
    min-width: 100px;
  }
  
  .amount-col {
    min-width: 100px;
  }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
  .container {
    padding: 8px;
  }
  
  .section {
    padding: 12px;
    margin-bottom: 16px;
  }
  
  dialog {
    width: 98vw;
    max-width: 98vw;
    padding: 16px;
    margin: 1vh auto;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  input, textarea, select {
    padding: 10px 6px;
    font-size: 14px;
  }
  
  table {
    min-width: 450px;
    font-size: 12px;
  }
  
  .item-col {
    min-width: 130px;
  }
  
  .qty-col {
    width: 70px;
    min-width: 70px;
  }
  
  .rate-col {
    min-width: 90px;
  }
  
  .amount-col {
    min-width: 90px;
  }
}

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

/* Top Navigation - Fixed and unified for all pages */
.top-nav {
  background: white;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Add top padding to body to account for fixed nav */
body {
  padding-top: 70px;
}

/* Privacy badge in top nav */
.top-nav .privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(59, 130, 246, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  margin-left: 1rem;
}


.top-nav .nav-container {
  max-width: 1029px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.top-nav .logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.top-nav .logo h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--accent);
}

.top-nav .nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.top-nav .nav-links a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.3s ease;
  padding: 0.5rem 0;
}

.top-nav .nav-links a:hover {
  color: var(--accent);
}

.top-nav .nav-links a.create-invoice {
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.top-nav .nav-links a.create-invoice:hover {
  background: var(--accent);
  color: white;
}

/* Hide old header when using top-nav */
body .topbar {
  display: none;
}

/* Show topbar only when no top-nav is present */
body:not(:has(.top-nav)) .topbar {
  display: block;
}
.nav-links a.create-invoice {
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
}

.nav-links a.create-invoice:hover {
  background: var(--accent);
  color: white;
}

/* Dynamic fields input styles */
#dynamic-fields .meta-field input {
  width: 150px;
  margin-right: 5px;
}

/* Meta field textarea styles */
.meta-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
}

.meta-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.feedback-content {
  padding: 20px;
}

.feedback-content p {
  margin-bottom: 20px;
  color: var(--muted);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.primary-btn:hover {
  background: var(--accent);
}

.secondary-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: var(--border);
}

/* Theme Toggle Styles */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --text: #ffffff;
  --muted: #b3b3b3;
  --border: #404040;
  --accent: #4a9eff;
}

[data-theme="dark"] .privacy-badge {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

[data-theme="dark"] .benefit-card {
  background: var(--surface);
  border: 1px solid var(--border);
}

[data-theme="dark"] .guide-step {
  background: var(--surface);
  border: 1px solid var(--border);
}

[data-theme="dark"] .feedback-section form {
  background: var(--surface);
  border: 1px solid var(--border);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Tab Navigation Styles */
.tab-navigation {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  min-height: 44px; /* Touch target */
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg);
}

.tab-content {
  display: none;
  min-height: 300px;
}

.tab-content.active {
  display: block;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Preview and History Tab Styles */
.preview-content {
  padding: 20px;
  background: var(--bg);
  border-radius: 8px;
  margin: 20px 0;
}

.history-content {
  padding: 0;
  background: var(--bg);
  border-radius: 8px;
  margin: 20px 0;
  width: 100%;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 20px 20px 15px 20px;
  border-bottom: 2px solid var(--border);
}

.history-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
}

.history-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.history-search {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  min-width: 200px;
}

.history-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.preview-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  min-height: 400px;
}

.history-list {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  min-height: 400px;
  overflow: visible;
}

/* Mobile styles for tabs */
@media (max-width: 920px) {
  .tab-btn {
    padding: 16px 12px;
    font-size: 16px;
  }
  
  .tab-content {
    min-height: 250px;
  }
  
  .preview-header, .history-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }
  
  .history-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .history-search {
    min-width: 150px;
  }
}

/* CSV Import Styles */
.csv-import-content {
  padding: 1.5rem;
  max-width: 100%;
}

.csv-info-section {
  margin-bottom: 2rem;
  text-align: center;
}

.csv-info-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
}

.csv-info-section p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 500px;
  margin: 0 auto;
}

.csv-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.file-upload-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.file-upload-btn input[type="file"] {
  display: none;
}

.csv-preview-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.csv-preview-section h4 {
  margin: 0 0 1.5rem 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.csv-preview-table th,
.csv-preview-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.csv-preview-table th {
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.csv-preview-table td {
  color: var(--text-secondary);
  background: white;
}

.csv-preview-table tbody tr:hover {
  background: var(--bg-hover);
}

.csv-preview-table tbody tr:last-child td {
  border-bottom: none;
}

.csv-summary {
  padding: 1rem;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 8px;
  margin-top: 1.5rem;
  text-align: center;
}

.csv-summary p {
  margin: 0;
  color: var(--success-text);
  font-size: 0.95rem;
  font-weight: 500;
}

.csv-preview-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.csv-error-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--error-bg);
  border-radius: 12px;
  border: 1px solid var(--error-border);
  text-align: center;
}

.csv-error-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--error-text);
  font-size: 1.1rem;
  font-weight: 600;
}

.csv-error-section p {
  margin: 0;
  color: var(--error-text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Mobile styles for CSV Import */
@media (max-width: 920px) {
  .csv-import-content {
    padding: 1rem;
  }
  
  .csv-info-section {
    margin-bottom: 1.5rem;
  }
  
  .csv-info-section h4 {
    font-size: 1.1rem;
  }
  
  .csv-info-section p {
    font-size: 0.9rem;
  }
  
  .csv-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .file-upload-btn {
    padding: 14px 20px;
    font-size: 1rem;
  }
  
  .csv-preview-section {
    padding: 1rem;
    margin-top: 1.5rem;
  }
  
  .csv-preview-table {
    font-size: 0.8rem;
  }
  
  .csv-preview-table th,
  .csv-preview-table td {
    padding: 8px 10px;
  }
  
  .csv-preview-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .csv-error-section {
    padding: 1rem;
    margin-top: 1.5rem;
  }
}

/* Cookie Banner Styles */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 20px;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  display: none;
}

.cookie-banner.show {
  display: block;
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.cookie-text h4 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 16px;
}

.cookie-text p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.cookie-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.cookie-btn.primary {
  background: var(--accent);
  color: white;
}

.cookie-btn.primary:hover {
  background: var(--accent);
}

.cookie-btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.cookie-btn.secondary:hover {
  background: var(--border);
}

.cookie-btn.link {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

.cookie-btn.link:hover {
  color: var(--accent);
}

/* Print Styles */
@media print {
  .container {
    background: white;
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: none;
  }
  
  .topbar,
  .table-actions,
  .export-controls,
  .ad-panel,
  .ad-footer {
    display: none;
  }
  
  .totals-notes-row {
    display: flex;
    gap: 20mm;
    margin-bottom: 0;
  }
  
  .notes-terms-left,
  .totals-section {
    width: calc(50% - 10mm);
  }
  
  .totals-table {
    background: white;
    border: 1px solid #ccc;
    padding: 5mm;
  }
  
  .notes-section textarea,
  .terms-textarea {
    background: white;
    border: 1px solid #ccc;
    padding: 5mm;
  }
  
  table {
    background: white;
  }
  
  thead th {
    background: var(--accent) !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* PWA Install Notification */
.install-notification {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

.install-content {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 12px;
}

.install-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.install-text {
  flex: 1;
}

.install-text strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.install-text small {
  color: var(--muted);
  font-size: 12px;
}

.install-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.install-btn:hover {
  background: var(--accent);
}

.install-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.install-close:hover {
  background: var(--bg);
  color: var(--text);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}



/* Language selector */
.language-selector {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.language-selector:hover {
  border-color: var(--accent);
}

.language-selector:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}


/* Seller margin fix */
.party-section:first-child {
  margin-left: 5px;
}

/* Success content */
.success-content {
  max-width: 600px;
  width: 100%;
}

/* Bank details section - gap between rows */
#bank-details-section .field-row {
  margin-bottom: 8px;
}

#bank-details-section .field-row:last-child {
  margin-bottom: 0;
}

/* Preview Modal Styles */
#preview-modal {
  max-width: 900px;
  width: 95vw;
  max-height: 80vh;
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  background: var(--panel);
}

#preview-modal .modal-header {
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px 12px 0 0;
}

#preview-modal .modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.draft-actions button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.draft-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.draft-actions .load-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.draft-actions .load-btn:hover {
  background: var(--accent-hover);
}

.draft-actions .delete-btn {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

.draft-actions .delete-btn:hover {
  background: var(--error);
  color: white;
}

.empty-drafts {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-drafts .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-drafts h4 {
  margin: 0 0 8px 0;
  color: var(--text);
}

.empty-drafts p {
  margin: 0;
  font-size: 14px;
}

/* Preview Modal Styles */
#preview-modal {
  max-width: 90vw;
  width: 90vw;
  max-height: 90vh;
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  background: var(--panel);
}

#preview-modal .modal-header {
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#preview-modal .modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.preview-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preview-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.preview-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.preview-content {
  padding: 24px;
  max-height: calc(90vh - 200px);
  overflow-y: auto;
}

.history-content {
  padding: 24px;
  max-height: calc(90vh - 200px);
  overflow-y: auto;
}

.preview-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 40px;
  margin: 0 auto;
  max-width: 800px;
}

.preview-container .invoice-section {
  margin-bottom: 0;
}

.preview-container .invoice-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  text-align: center;
}

.preview-container .invoice-meta-section {
  margin-bottom: 32px;
}

.preview-container .cols-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.preview-container .party-section {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview-container .party-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-container .company-field {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 0;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
}

.preview-container .items-table-container {
  margin-bottom: 32px;
}

.preview-container table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.preview-container th,
.preview-container td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.preview-container th {
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
}

.preview-container .amount-col,
.preview-container .rate-col,
.preview-container .qty-col {
  text-align: right;
}

.preview-container .totals-section {
  margin-left: auto;
  max-width: 300px;
}

.preview-container .totals-table {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview-container .total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.preview-container .total-row.grand {
  font-weight: 700;
  font-size: 18px;
  padding-top: 12px;
  border-top: 2px solid var(--accent);
  margin-top: 12px;
}

.preview-container .notes-section,
.preview-container .terms-section {
  margin-top: 32px;
  padding: 20px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview-container .section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.preview-container .notes-textarea,
.preview-container .terms-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: white;
  resize: vertical;
}

/* Responsive preview */
@media (max-width: 768px) {
  #preview-modal {
    width: 95vw;
    max-width: 95vw;
  }
  
  .preview-container {
    padding: 20px;
  }
  
  .preview-container .cols-3 {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .preview-container .invoice-title {
    font-size: 24px;
  }
}

/* Invoice header left section */
.invoice-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-right: 30px;
}

/* Logo styles */
.logo-container {
  margin: 10px 0;
  display: flex;
  justify-content: flex-start;
}

.logo-placeholder {
  width: 200px;
  height: 100px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #f9f9f9;
}

.logo-placeholder:hover {
  border-color: #007bff;
  background-color: #f0f8ff;
}

.logo-placeholder-text {
  color: #666;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
}

.logo-wrapper {
  position: relative;
  display: inline-block;
}

.logo-image {
  max-width: 200px;
  max-height: 100px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}

.logo-controls {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.logo-wrapper:hover .logo-controls {
  opacity: 1;
}

.logo-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.3s ease;
}

.change-btn {
  background-color: #007bff;
  color: white;
}

.change-btn:hover {
  background-color: #0056b3;
  transform: scale(1.1);
}

.remove-btn {
  background-color: #dc3545;
  color: white;
}

.remove-btn:hover {
  background-color: #c82333;
  transform: scale(1.1);
}

.logo-placeholder.dragover {
  border-color: #007bff;
  background-color: #e3f2fd;
  transform: scale(1.02);
}

/* Main Tabs Styles */
.main-tabs {
  background: var(--bg);
  padding: 10px 0 0px 20px;
  margin: 20px auto 0px auto;
  max-width: 1200px;
}

.tabs-container {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  max-width: 1200px;
  margin: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 6px;
  position: relative;
  width: 100px;
  justify-content: center;
}

.tab-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-bg);
}

.tab-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.tab-btn.disabled:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.tab-icon {
  font-size: 14px;
}

.tab-text {
  font-weight: 500;
}

/* Responsive tabs */
@media (max-width: 768px) {
  .main-tabs {
    padding: 8px 10px;
  }
  
  .tabs-container {
    gap: 6px;
  }
  
  .tab-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .tab-text {
    display: none;
  }
  
  .tab-icon {
    font-size: 16px;
  }
}

/* History Item Styles */
.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  margin: 15px 20px;
  background: white;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.history-item-header h4 {
  margin: 0;
  color: var(--text);
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

.status-badge.pending {
  background: #fff3cd;
  color: #856404;
}

.status-badge.paid {
  background: #d4edda;
  color: #155724;
}

.status-badge.overdue {
  background: #f8d7da;
  color: #721c24;
}

.history-item-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.detail {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-item-actions {
  display: flex;
  gap: 10px;
}

.btn-secondary, .btn-danger, .btn-primary {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 10px;
  color: var(--text);
}
