:root {
  --blue: #6366F1;
  --blue-dark: #4f46e5;
  --gray-50: #18181b;
  --gray-100: #27272a;
  --gray-200: #3f3f46;
  --gray-400: #71717a;
  --gray-600: #a1a1aa;
  --gray-700: #d4d4d8;
  --gray-900: #f4f4f5;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: "Inter", sans-serif;
  background: #0a0a0b;
  color: var(--gray-900);
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 48px 16px;
}

.brand .logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue);
}

.brand .tagline {
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn-primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 12px 25px rgba(37, 99, 235, 0.2);
}

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

.btn-secondary {
  background: #27272a;
  color: #d4d4d8;
}

.btn-secondary:hover {
  background: #3f3f46;
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-ghost:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.app-shell {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  padding: 0 48px 48px;
}

.panel {
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.form-panel {
  overflow: hidden;
}

.preview-panel {
  position: sticky;
  top: 24px;
  height: fit-content;
}

.section {
  padding: 20px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.section h2 {
  font-size: 16px;
  color: var(--gray-700);
  font-weight: 600;
  margin-bottom: 14px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 12px;
}

input,
select,
textarea {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #27272a;
  color: #f4f4f5;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.line-items {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 2.2fr 0.7fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
}

.item-row input {
  margin-bottom: 0;
}

.item-row .remove-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.item-row .amount {
  font-weight: 600;
  color: var(--gray-700);
}

.totals-preview {
  background: var(--gray-50);
  border-radius: 14px;
  padding: 14px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 6px 0;
  color: var(--gray-700);
}

.total-row.grand {
  font-size: 16px;
  color: var(--gray-900);
  border-top: 1px solid var(--gray-200);
  margin-top: 6px;
  padding-top: 10px;
}

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

.badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--blue);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.invoice-paper {
  background: #1c1c1f;
  border: 1px solid #27272a;
  border-radius: 18px;
  padding: 28px;
  position: relative;
  min-height: 720px;
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.invoice-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.invoice-number {
  margin-top: 6px;
  color: var(--blue);
  font-weight: 600;
}

.invoice-meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--gray-600);
  display: grid;
  gap: 6px;
}

.sender-block {
  text-align: right;
  font-size: 13px;
  color: var(--gray-700);
}

.sender-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.invoice-billing {
  margin-top: 24px;
  padding: 16px;
  border-radius: 14px;
  background: #27272a;
  font-size: 13px;
  color: var(--gray-700);
}

.bill-to {
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gray-400);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.recipient-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 13px;
}

.items-table th {
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 8px;
}

.items-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.invoice-summary {
  margin-top: 20px;
  margin-left: auto;
  width: 55%;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  color: var(--gray-700);
}

.summary-row.total {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  border-top: 1px solid var(--gray-200);
  padding-top: 8px;
}

.invoice-notes {
  margin-top: 24px;
  display: grid;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-600);
}

.invoice-notes p {
  margin-top: 6px;
  color: var(--gray-700);
}

.invoice-watermark {
  position: absolute;
  right: 20px;
  bottom: 18px;
  font-size: 11px;
  color: var(--gray-400);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
  }

  .app-shell {
    padding: 0 24px 32px;
  }

  .grid-2,
  .grid-3,
  .item-row {
    grid-template-columns: 1fr;
  }

  .item-row {
    gap: 8px;
  }

  .invoice-summary {
    width: 100%;
  }
}
