body {
  font-family: 'Public Sans', system-ui, -apple-system, sans-serif;
  background: #F4F5F7;
  margin: 0;
  color: #1F2933;
  line-height: 1.4;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

header {
  margin-bottom: 1rem;
}

.header-content h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  font-size: .85rem;
  color: #64748b;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-top: .75rem;
}

.tab {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  padding: .5rem 1rem;
  font-size: .9rem;
  font-weight: 500;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  transition: all .1s ease;
}

.tab.active {
  border-color: #2F6FED;
  color: #2F6FED;
  background: #fff;
}

.tab:hover:not(.active) {
  background: #f1f5f9;
}

.view {
  display: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1.25rem;
  margin-top: .25rem;
}

.view.active {
  display: block;
}

.estimate-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.markup-group {
  max-width: 140px;
}

.markup-input {
  display: flex;
  align-items: center;
}

.markup-input input {
  width: 80px !important;
}

.form-group label {
  font-size: .75rem;
  font-weight: 600;
  margin-bottom: 3px;
  color: #475569;
}

input, select {
  font-family: inherit;
  font-size: .95rem;
  border: 1px solid #cbd5e1;
  padding: .45rem .55rem;
  border-radius: 4px;
  box-sizing: border-box;
  background: #fff;
}

input:focus, select:focus {
  outline: none;
  border-color: #2F6FED;
}

.unit {
  margin-left: .4rem;
  font-size: .9rem;
  color: #475569;
}

.lines-section {
  margin-bottom: 1rem;
}

.lines-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}

h2, h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1F2933;
}

.lines-actions {
  display: flex;
  gap: .5rem;
}

.btn {
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  padding: .5rem .85rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: #2F6FED;
  color: #fff;
  transition: background .1s;
}

.btn:hover {
  background: #2563eb;
}

.btn.outline {
  background: #fff;
  color: #2F6FED;
  border: 1px solid #2F6FED;
}

.btn.outline:hover {
  background: #f0f4ff;
}

.btn.primary {
  background: #2F6FED;
}

.btn.small {
  font-size: .8rem;
  padding: .35rem .6rem;
}

.btn.ghost {
  background: transparent;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.empty {
  padding: 1rem;
  font-size: .85rem;
  color: #64748b;
  background: #f8fafc;
  border-radius: 4px;
  text-align: center;
  margin-top: .6rem;
}

.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.lines-table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  padding: .5rem .4rem;
  color: #475569;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.lines-table td {
  padding: .4rem .3rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.lines-table td input,
.lines-table td select {
  width: 100%;
  font-size: .85rem;
  padding: .35rem .4rem;
  border: 1px solid #cbd5e1;
}

.lines-table td input[type="number"] {
  width: 78px;
}

.lines-table .amount {
  font-weight: 600;
  text-align: right;
  padding-right: .75rem;
  font-family: ui-monospace, monospace;
}

.delete-btn {
  font-size: 1.35rem;
  line-height: 1;
  padding: .1rem .35rem;
  color: #ef4444;
  border: none;
  background: none;
  cursor: pointer;
}

.totals {
  background: #f8fafc;
  border-radius: 5px;
  padding: .6rem .85rem .3rem;
  margin: 1rem 0 0.5rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: .92rem;
  padding: .3rem 0;
}

.total-row.grand {
  font-weight: 700;
  font-size: 1.05rem;
  border-top: 1px solid #cbd5e1;
  padding-top: .55rem;
  margin-top: .3rem;
}

.actions {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  margin: 1rem 0 .4rem;
}

.note {
  margin: 0;
  font-size: .75rem;
  color: #64748b;
}

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

.estimates-table, .items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.estimates-table th, .items-table th,
.estimates-table td, .items-table td {
  padding: .55rem .5rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.estimates-table th,
.items-table th {
  font-size: .75rem;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
}

.action {
  padding: 2px 7px;
  font-size: .8rem;
}

.add-saved-form {
  background: #f8fafc;
  border-radius: 5px;
  padding: .75rem .9rem;
  margin-bottom: .85rem;
}

.add-saved-form h3 {
  font-size: .85rem;
  margin-bottom: .4rem;
  color: #475569;
}

.form-row {
  display: flex;
  gap: .45rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-row input {
  flex: 1;
  min-width: 140px;
}

.form-row select {
  width: auto;
  min-width: 94px;
}

.form-row #item-price {
  width: 96px;
}

/* Modal styles */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #fff;
  width: 95%;
  max-width: 580px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .4rem;
  color: #64748b;
}

.modal-body {
  padding: 1rem;
}

.pick-list {
  max-height: 295px;
  overflow-y: auto;
}

.pick-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .55rem .65rem;
  border-bottom: 1px solid #f1f5f9;
}

.pick-item:last-child {
  border-bottom: none;
}

.item-info strong {
  font-size: .9rem;
}

.item-info small {
  color: #64748b;
  font-size: .78rem;
}

.view-meta {
  display: flex;
  gap: 1rem;
  font-size: .85rem;
  color: #64748b;
  padding-bottom: .5rem;
}

.view-table {
  width: 100%;
  font-size: .9rem;
  margin: .6rem 0;
  border-collapse: collapse;
}

.view-table th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .78rem;
  padding: .35rem .4rem;
  text-align: left;
}

.view-table td {
  padding: .4rem .4rem;
  border-bottom: 1px solid #f1f5f9;
}

.view-totals {
  margin: .2rem 0 0;
  padding: .4rem 0;
}

.kind-badge {
  display: inline-block;
  font-size: .72rem;
  padding: 1px 6px;
  background: #e0e7ff;
  color: #374151;
  border-radius: 10px;
}

.modal-footer {
  padding: .65rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* Responsive + empty adjustments */
@media (max-width: 640px) {
  .estimate-header {
    flex-direction: column;
  }
  .markup-group {
    max-width: 100%;
  }
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .lines-table td input[type="number"] {
    width: 68px;
  }
}

/* Print-friendly */
@media print {
  body * {
    visibility: hidden;
  }
  #modal-view, #modal-view * {
    visibility: visible;
  }
  #modal-view {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
  }
  .modal-content {
    box-shadow: none;
    max-width: 100%;
    width: 100%;
  }
  .totals,
  .modal-footer #print-close-btn {
    display: none !important;
  }
}