* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.topbar { background: #111827; color: #fff; padding: 20px 0; }
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 4px 0 0; color: #9ca3af; font-size: 14px; }

main { padding: 24px 0 60px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 16px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card-head h2 { margin: 0; }

label { display: block; font-size: 13px; color: #374151; margin-bottom: 12px; }
.req { color: #dc2626; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; font-size: 14px;
  border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit;
}
button {
  background: #111827; color: #fff; border: none; padding: 9px 16px;
  border-radius: 6px; font-size: 14px; cursor: pointer;
}
button:hover { background: #374151; }
.link { background: none; color: #2563eb; padding: 4px 0; }
.link:hover { background: none; text-decoration: underline; }
.btn-secondary {
  display: inline-block; background: #fff; color: #111827; border: 1px solid #d1d5db;
  padding: 9px 16px; border-radius: 6px; font-size: 14px; text-decoration: none;
}
.form-msg { font-size: 13px; min-height: 16px; margin: 8px 0 0; }
.form-msg.ok { color: #059669; }
.form-msg.err { color: #dc2626; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px; cursor: pointer;
}
.row:hover { border-color: #9ca3af; }
.row .who { font-weight: 600; }
.row .meta { font-size: 13px; color: #6b7280; margin-top: 2px; }
.row .right { text-align: right; }
.row .amount { font-weight: 600; }
.empty { color: #6b7280; font-size: 14px; padding: 16px 0; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.new { background: #e0f2fe; color: #0369a1; }
.badge.quoted { background: #fef3c7; color: #92400e; }
.badge.won { background: #dcfce7; color: #166534; }
.badge.lost { background: #fee2e2; color: #991b1b; }

.modal { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; width: 100%; max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.icon { background: none; color: #6b7280; font-size: 24px; line-height: 1; padding: 0 6px; }
.icon:hover { background: none; color: #111827; }
.quote-customer { font-size: 14px; color: #374151; margin: 8px 0 16px; }
.status-row { margin-bottom: 12px; }
.status-row label { max-width: 200px; }

table.items { width: 100%; border-collapse: collapse; font-size: 14px; }
table.items th { text-align: left; font-size: 12px; color: #6b7280; padding: 6px 4px; border-bottom: 1px solid #e5e7eb; }
table.items td { padding: 4px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
table.items .num, table.items th.num { text-align: right; }
table.items input { margin: 0; }
.cell-desc { min-width: 160px; }
.cell-qty input, .cell-price input { width: 90px; text-align: right; }
.line-total { white-space: nowrap; }
.remove { background: none; color: #dc2626; padding: 2px 6px; font-size: 16px; }
.remove:hover { background: none; }

.quote-foot { display: flex; justify-content: space-between; align-items: flex-end; margin: 16px 0; gap: 24px; }
.quote-foot label { max-width: 120px; margin: 0; }
.totals { text-align: right; font-size: 14px; }
.totals .grand { font-size: 18px; font-weight: 700; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 820px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
