:root {
  color-scheme: light;
  --ink: #2d211b;
  --muted: #71645d;
  --paper: #fffdf9;
  --cream: #f4eee5;
  --line: #dfd4c8;
  --brown: #673b27;
  --brown-dark: #452417;
  --terracotta: #a94f32;
  --olive: #687343;
  --gold: #b7802f;
  --danger: #a3372d;
  --shadow: 0 22px 60px rgba(58, 35, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(183, 128, 47, 0.14), transparent 32rem),
    linear-gradient(145deg, #f8f3eb, #efe5d9);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.login-panel {
  width: min(470px, 100%);
  margin: 8vh auto 0;
  padding: 42px;
  border: 1px solid rgba(103, 59, 39, 0.16);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.96);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 28px;
  border-radius: 50%;
  color: #fff;
  background: var(--brown);
  font-family: Georgia, serif;
  font-size: 21px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--terracotta);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
}

.login-copy,
.header-copy {
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

label span,
.login-form label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  min-height: 45px;
  padding: 9px 12px;
}

textarea {
  min-height: 92px;
  padding: 11px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(169, 79, 50, 0.16);
  border-color: var(--terracotta);
}

.login-form button,
.primary-button {
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--brown);
  font-weight: 800;
}

.login-form button:hover,
.primary-button:hover {
  background: var(--brown-dark);
}

.form-message,
.dashboard-message {
  min-height: 1.4em;
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.header-copy {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-button,
.text-button,
.save-button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 750;
}

.secondary-button,
.save-button {
  border: 1px solid var(--brown);
  color: var(--brown);
  background: #fff;
}

.text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.summary-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.9);
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.summary-card strong {
  font-family: Georgia, serif;
  font-size: 2rem;
}

.summary-card.attention strong {
  color: var(--danger);
}

.summary-card.success strong {
  color: var(--olive);
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(210px, 0.35fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.9);
}

.controls label {
  display: grid;
  gap: 6px;
}

.dashboard-message {
  color: var(--muted);
  margin: 15px 2px;
}

.lead-list {
  display: grid;
  gap: 16px;
}

.lead-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 8px 28px rgba(58, 35, 23, 0.06);
}

.lead-card.priority-urgent {
  border-left: 5px solid var(--danger);
}

.lead-card.priority-high {
  border-left: 5px solid var(--gold);
}

.lead-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 14px;
}

.lead-name {
  margin-bottom: 5px;
  font-size: 1.45rem;
}

.lead-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.badge {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--brown);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge.urgent {
  color: #fff;
  background: var(--danger);
}

.badge.high {
  color: #fff;
  background: var(--gold);
}

.lead-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 24px 20px;
}

.detail {
  min-width: 0;
}

.detail.wide {
  grid-column: span 2;
}

.detail-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-value {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.detail-value a {
  color: var(--brown);
  font-weight: 700;
}

.next-action {
  margin: 0 24px 20px;
  padding: 13px 15px;
  border-radius: 11px;
  color: var(--brown-dark);
  background: var(--cream);
  font-weight: 750;
}

.lead-editor {
  display: grid;
  grid-template-columns: minmax(160px, 0.3fr) minmax(160px, 0.3fr) 1fr auto auto;
  align-items: end;
  gap: 12px;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--line);
  background: #fbf7f1;
}

.lead-editor label {
  display: grid;
  gap: 6px;
}

.lead-editor textarea {
  min-height: 45px;
  height: 45px;
}

.save-button {
  white-space: nowrap;
}

.proposal-button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--brown);
  border-radius: 10px;
  color: #fff;
  background: var(--brown);
  font-weight: 800;
  white-space: nowrap;
}

.proposal-button:hover {
  background: var(--brown-dark);
}

.proposal-dialog {
  width: min(940px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.proposal-dialog::backdrop {
  background: rgba(41, 27, 19, 0.64);
  backdrop-filter: blur(3px);
}

.proposal-modal {
  overflow: auto;
  max-height: calc(100vh - 28px);
}

.proposal-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbf7f1;
}

.proposal-modal-header h2 {
  margin-bottom: 6px;
  font-size: 2rem;
}

.proposal-client-line {
  margin: 0;
  color: var(--muted);
}

.dialog-close {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brown);
  background: #fff;
  font-size: 1.8rem;
  line-height: 1;
}

.proposal-form {
  padding: 0 30px 30px;
}

.proposal-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.proposal-section h3 {
  margin: 0 0 16px;
  color: var(--brown-dark);
  font-family: Georgia, serif;
  font-size: 1.25rem;
}

.proposal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.proposal-grid label {
  display: grid;
  gap: 6px;
}

.proposal-grid .span-2 {
  grid-column: span 2;
}

.pricing-guidance,
.staffing-note {
  margin: 13px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  color: var(--brown-dark);
  background: var(--cream);
  font-size: 0.88rem;
  line-height: 1.5;
}

.proposal-calculation-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.calculated-field {
  min-height: 70px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbf7f1;
}

.calculated-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.calculated-field strong {
  font-family: Georgia, serif;
  font-size: 1.35rem;
}

.grand-total-field {
  color: #fff;
  border-color: var(--brown);
  background: var(--brown);
}

.grand-total-field span {
  color: rgba(255, 255, 255, 0.78);
}

.proposal-message {
  min-height: 1.4em;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.proposal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 18px;
}

.proposal-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.proposal-actions div {
  display: flex;
  gap: 10px;
}

.proposal-actions .primary-button,
.proposal-actions .secondary-button {
  min-width: 140px;
  padding: 9px 15px;
}

.proposal-print-view {
  display: none;
}

.empty-state {
  padding: 48px 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 253, 249, 0.72);
  text-align: center;
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lead-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lead-editor {
    grid-template-columns: 1fr 1fr;
  }

  .proposal-calculation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 22px;
  }

  .login-panel {
    padding: 28px 22px;
  }

  .dashboard-header,
  .lead-topline {
    flex-direction: column;
  }

  .header-actions,
  .controls,
  .lead-details,
  .lead-editor,
  .proposal-grid,
  .proposal-calculation-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .badges {
    justify-content: flex-start;
  }

  .detail.wide {
    grid-column: span 1;
  }

  .proposal-grid .span-2 {
    grid-column: span 1;
  }

  .proposal-modal-header,
  .proposal-form {
    padding-left: 20px;
    padding-right: 20px;
  }

  .proposal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .proposal-actions div {
    flex-direction: column;
  }
}

@media print {
  @page {
    margin: 0.55in;
  }

  body {
    color: #261b16;
    background: #fff;
  }

  body > *:not(.proposal-print-view) {
    display: none !important;
  }

  .proposal-print-view {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
  }

  .print-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 2px solid #673b27;
  }

  .print-header .brand-mark {
    flex: 0 0 auto;
    margin: 0;
  }

  .print-header h1 {
    margin: 0 0 4px;
    font-size: 2.1rem;
  }

  .print-header p {
    margin-bottom: 0;
  }

  .print-title-block {
    padding: 28px 0 22px;
  }

  .print-title-block h2 {
    margin: 8px 0;
    font-size: 1.8rem;
  }

  .print-event-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 24px;
    padding: 18px;
    border: 1px solid #d8cabd;
    border-radius: 10px;
  }

  .print-event-grid span {
    display: block;
    margin-bottom: 3px;
    color: #71645d;
    font-family: Arial, sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .print-section {
    padding-top: 24px;
  }

  .print-section h3 {
    margin: 0 0 10px;
    color: #673b27;
    font-size: 1.2rem;
  }

  .preserve-lines {
    white-space: pre-line;
    line-height: 1.55;
  }

  .print-totals {
    width: 100%;
    border-collapse: collapse;
  }

  .print-totals td {
    padding: 9px 5px;
    border-bottom: 1px solid #e2d8ce;
  }

  .print-totals td:last-child {
    text-align: right;
  }

  .print-totals tr[hidden] {
    display: none;
  }

  .print-grand-total td {
    padding-top: 14px;
    border-bottom: 0;
    color: #452417;
    font-size: 1.25rem;
    font-weight: 800;
  }

  .print-footer {
    margin-top: 34px;
    padding-top: 14px;
    border-top: 1px solid #d8cabd;
    color: #71645d;
    font-family: Arial, sans-serif;
    font-size: 0.76rem;
    line-height: 1.5;
  }
}
