* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: #111827;
  background: #fff;
}

.layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 200px;
  border-right: 1px solid #e5e7eb;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  font-size: 13px;
  font-weight: 700;
  color: #c0392b;
  letter-spacing: 1px;
  margin-bottom: 18px;
  padding-left: 8px;
}
.nav-item {
  display: block;
  padding: 9px 8px;
  border-radius: 6px;
  color: #4b5563;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.nav-item.active {
  background: #fdecea;
  color: #c0392b;
  font-weight: 600;
}
.nav-item:hover {
  background: #f9fafb;
}
.spacer {
  flex: 1;
}
.content {
  flex: 1;
  padding: 28px;
  max-width: 900px;
}

.alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

h2 {
  font-size: 18px;
  margin: 0 0 16px;
}

.field {
  margin-bottom: 10px;
}
.field label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}
.input,
input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: #c0392b;
  color: #fff;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-outline {
  background: #fff;
  color: #4b5563;
  border: 1px solid #d1d5db;
}
.btn-link {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.row {
  display: flex;
  gap: 20px;
}
.muted {
  color: #9ca3af;
  font-size: 13.5px;
}

/* auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 320px;
  padding: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.auth-card h2 {
  margin-bottom: 4px;
}
.auth-sub {
  font-size: 12.5px;
  color: #9ca3af;
  margin-bottom: 18px;
}

/* dashboard cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.doc-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px;
}
.doc-card .label {
  font-size: 12px;
  color: #c0392b;
  font-weight: 700;
  margin-bottom: 6px;
}
.doc-card .count {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}
.doc-card .desc {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 14px;
  min-height: 32px;
}

/* lists */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}
.list-row .title {
  font-weight: 600;
  font-size: 14px;
}
.list-row .sub {
  font-size: 12.5px;
  color: #6b7280;
}

/* client form panel */
.panel {
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
}

/* items table */
.items-table {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.items-head,
.items-row {
  display: grid;
  grid-template-columns: 2fr 1.6fr 0.7fr 0.8fr 0.9fr 30px;
  gap: 8px;
  padding: 8px 10px;
  align-items: center;
}
.items-head {
  background: #f9fafb;
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
}
.items-row {
  border-top: 1px solid #f0f0f0;
}

/* invoice preview */
.preview-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.divider {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
}
.invoice-sheet {
  max-width: 700px;
  margin: 0 auto;
  background: #fff;
  padding: 40px;
  border: 1px solid #eee;
}
.invoice-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}
.bill-to-label {
  color: #c0392b;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}
.doc-title {
  color: #c0392b;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: right;
}
.doc-number {
  font-size: 12.5px;
  color: #9ca3af;
  text-align: right;
}
.meta-box {
  display: flex;
  border: 1px solid #f0d4d1;
  border-radius: 4px;
  margin-bottom: 24px;
}
.meta-box .col {
  flex: 1;
  padding: 14px 16px;
}
.meta-box .col:first-child {
  border-right: 1px solid #f0d4d1;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.meta-row .k {
  color: #c0392b;
}
.meta-row .v {
  color: #6b7280;
}
table.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 20px;
}
table.items thead tr {
  border-bottom: 1px solid #eee;
  color: #c0392b;
  text-align: left;
}
table.items th,
table.items td {
  padding: 8px 4px;
}
table.items tbody tr {
  border-bottom: 1px solid #f4f4f4;
}
.text-right {
  text-align: right;
}
.summary-wrap {
  display: flex;
  justify-content: space-between;
  background: #f9fafb;
  padding: 20px;
  margin: 0 -40px -40px;
}
.summary {
  width: 220px;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: #c0392b;
}
.sum-row.bold {
  color: #111827;
  font-weight: 700;
}
.balance-due {
  background: #c0392b;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  margin-top: 8px;
  font-weight: 700;
  font-size: 14px;
}

/* GST document layout */
.gst-sheet {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  padding: 30px;
  border: 1px solid #333;
  font-size: 12.5px;
}
.gst-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.gst-title {
  color: #c0392b;
  font-weight: 700;
  font-size: 15px;
}
.gst-company-name {
  color: #e07b1a;
  font-weight: 700;
  font-size: 20px;
  text-align: center;
  flex: 1;
}
.gst-company-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
  margin-bottom: 0;
}
.gst-logo-block {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.gst-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
}
.gst-address {
  font-size: 12px;
  line-height: 1.5;
}
.gst-contact {
  text-align: right;
  font-size: 12px;
  line-height: 1.6;
  color: #e07b1a;
}
.gst-contact strong {
  color: #111827;
}

.gst-meta-box {
  display: flex;
  border: 1px solid #333;
  border-top: none;
}
.gst-bill-to,
.gst-doc-info {
  flex: 1;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
}
.gst-bill-to {
  border-right: 1px solid #333;
}
.gst-doc-info {
  text-align: right;
}

.gst-note {
  border: 1px solid #333;
  border-top: none;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
}

.gst-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: -1px;
}
.gst-table th,
.gst-table td {
  border: 1px solid #333;
  padding: 6px;
  text-align: center;
}
.gst-table thead th {
  background: #fdecea;
  color: #c0392b;
}
.gst-table td.left {
  text-align: left;
}
.gst-total-row {
  font-weight: 700;
}

.gst-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: -1px;
}
.gst-summary-table td {
  border: 1px solid #333;
  padding: 5px 10px;
}
.gst-summary-table .right {
  text-align: right;
}
.gst-summary-table .bold {
  font-weight: 700;
}
.gst-summary-table tr.bold td:last-child {
  background: #fdecea;
}

.gst-words {
  border: 1px solid #333;
  border-top: none;
  text-align: right;
  font-weight: 700;
  font-size: 12px;
  padding: 6px;
}

.gst-terms {
  border: 1px solid #333;
  border-top: none;
  padding: 8px 12px;
  font-size: 11.5px;
}
.gst-terms ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.gst-bank {
  display: flex;
  border: 1px solid #333;
  border-top: none;
  font-size: 11.5px;
}
.gst-bank-label {
  flex: 0 0 90px;
  font-weight: 700;
  padding: 8px;
  border-right: 1px solid #333;
}
.gst-bank-info {
  padding: 8px 12px;
  line-height: 1.6;
}

.gst-signoff {
  display: flex;
  justify-content: space-between;
  border: 1px solid #333;
  border-top: none;
  padding: 20px 12px;
  font-size: 11.5px;
}
.gst-date-box {
  color: #9ca3af;
}

.gst-seal {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.gst-signatory {
  text-align: center;
  flex: 1;
}

.gst-thanks {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
}

@media print {
  .sidebar,
  .preview-actions,
  .alert {
    display: none !important;
  }
  .content {
    padding: 12mm;
    max-width: 100%;
  }
  .invoice-sheet,
  .gst-sheet {
    border: none;
  }
}

/* quick-add modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 1000;
  overflow-y: auto;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal-box h3 {
  margin: 0 0 14px;
  font-size: 16px;
}
.modal-errors {
  color: #b91c1c;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.modal-errors:empty {
  display: none;
}
