.tool-hero {
  background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
  padding: 5rem 1.5rem 3rem;
  margin-top: 68px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.tool-hero::before {
  content: ''; position: absolute;
  width: 400px; height: 400px; border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -150px; right: -100px;
}

.tool-hero::after {
  content: ''; position: absolute;
  width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
  bottom: -100px; left: -50px;
}

.tool-hero-content { position: relative; z-index: 1; }

.tool-hero-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1.25rem;
  border: 1px solid rgba(255,255,255,0.2);
}

.tool-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800; color: white; letter-spacing: -1px; margin-bottom: 0.75rem;
}

.tool-hero p {
  font-size: 1rem; color: rgba(255,255,255,0.75);
  max-width: 480px; margin: 0 auto;
}

.tool-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* Layout */
.invoice-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

/* Form side */
.invoice-form-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.form-panel-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg);
}

.form-panel-icon {
  width: 30px; height: 30px; border-radius: 7px;
  background: rgba(5,150,105,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
}

.form-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.form-panel-body { padding: 1.5rem; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  padding: 0.65rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  background: white;
  width: 100%;
}

.form-control:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5,150,105,0.08);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* Logo upload */
.logo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.logo-upload-area:hover {
  border-color: #059669;
  background: rgba(5,150,105,0.02);
}

.logo-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

.logo-upload-icon { font-size: 1.75rem; margin-bottom: 0.5rem; }

.logo-upload-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.logo-upload-text strong { color: #059669; }

.logo-preview {
  max-height: 60px;
  max-width: 180px;
  object-fit: contain;
  display: none;
}

.logo-preview.show { display: block; margin: 0 auto; }

/* Items table */
.items-table-wrap {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.items-table-header {
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.items-table-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}

.items-table td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.items-table tr:last-child td { border-bottom: none; }

.items-table input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1.5px solid transparent;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  background: transparent;
}

.items-table input:focus {
  border-color: #059669;
  background: white;
  box-shadow: 0 0 0 2px rgba(5,150,105,0.08);
}

.items-table .amount-cell {
  font-weight: 600;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.delete-row-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

.delete-row-btn:hover { color: var(--danger); background: rgba(239,68,68,0.06); }

.items-add-row {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* Totals */
.totals-panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.totals-rows {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.totals-row.discount-row { color: var(--success); }
.totals-row.tax-row { color: var(--text-muted); }

.totals-row-label { font-weight: 500; color: var(--text-muted); }
.totals-row-value { font-weight: 600; color: var(--text); }

.totals-total {
  padding: 1.25rem 1.5rem;
  border-top: 2px solid var(--border);
  background: var(--gradient-soft, linear-gradient(135deg, #ede9fe, #ddd6fe));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.totals-total-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.totals-total-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.totals-inputs {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.totals-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.totals-input-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.totals-input-field {
  width: 100px;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  text-align: right;
  outline: none;
  transition: var(--transition);
}

.totals-input-field:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5,150,105,0.08);
}

/* Preview side */
.invoice-preview-section {
  position: sticky;
  top: 88px;
}

.preview-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.preview-toolbar-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
}

.preview-dots {
  display: flex;
  gap: 5px;
}

.preview-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

.preview-dot:nth-child(1) { background: #ff5f57; }
.preview-dot:nth-child(2) { background: #febc2e; }
.preview-dot:nth-child(3) { background: #28c840; }

/* The invoice document */
.invoice-doc {
  padding: 2rem;
  font-size: 0.875rem;
  min-height: 500px;
}

.invoice-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.invoice-doc-logo {
  max-height: 50px;
  max-width: 140px;
  object-fit: contain;
}

.invoice-doc-logo-placeholder {
  width: 100px; height: 40px;
  background: var(--gradient-primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 0.75rem; font-weight: 700;
}

.invoice-title-block { text-align: right; }

.invoice-doc-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.invoice-doc-number {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.invoice-doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.invoice-doc-party-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.invoice-doc-party-name {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.invoice-doc-party-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.invoice-doc-meta {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.invoice-meta-item { display: flex; flex-direction: column; gap: 2px; }

.invoice-meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-light);
}

.invoice-meta-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.invoice-doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.invoice-doc-table th {
  padding: 0.625rem 0.875rem;
  background: #0f0f23;
  color: rgba(255,255,255,0.85);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

.invoice-doc-table th:last-child { text-align: right; }

.invoice-doc-table td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-size: 0.83rem;
}

.invoice-doc-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.invoice-doc-totals {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 240px;
  margin-left: auto;
  margin-bottom: 1.5rem;
}

.doc-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
}

.doc-total-row.grand-total {
  font-weight: 800;
  font-size: 1rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--text);
}

.invoice-doc-notes {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.invoice-doc-notes strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.preview-actions {
  padding: 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 1024px) {
  .invoice-layout { grid-template-columns: 1fr; }
  .invoice-preview-section { position: static; }
  .form-row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .invoice-doc-parties { grid-template-columns: 1fr; }
  .invoice-doc-header { flex-direction: column; gap: 1rem; }
  .invoice-title-block { text-align: left; }
}
