:root {
  color-scheme: light;
  --ink: #26343a;
  --muted: #68777c;
  --line: #dce3e3;
  --paper: #f4f6f5;
  --white: #ffffff;
  --teal: #246d69;
  --teal-dark: #174f4d;
  --sand: #f3eee5;
  --danger: #a44235;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 0%, rgba(204, 221, 216, 0.48), transparent 32rem),
    var(--paper);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.login-view {
  width: min(440px, 100%);
  margin: min(15vh, 150px) auto 60px;
  padding: 42px;
  border: 1px solid rgba(220, 227, 227, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 80px rgba(31, 55, 57, 0.08);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 4vw, 2.65rem); letter-spacing: -0.045em; line-height: 1.08; }
h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.025em; }
.muted { color: var(--muted); line-height: 1.55; }

.login-form { display: grid; gap: 10px; margin-top: 28px; }
.login-form label, .edit-grid label {
  display: grid;
  gap: 7px;
  color: #435257;
  font-size: 0.82rem;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cfd9d8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(36, 109, 105, 0.23);
  outline-offset: 2px;
  border-color: var(--teal);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover { transform: translateY(-1px); }
.button--primary { background: var(--teal); color: white; }
.button--primary:hover { background: var(--teal-dark); }
.button--light { border-color: var(--line); background: white; color: var(--ink); }
.button--light:hover, .button--quiet:hover { border-color: #a9b9b7; background: #f7faf9; }
.button--quiet { background: transparent; color: var(--muted); }
.login-form .button { width: 100%; margin-top: 8px; }
.login-note { margin: 24px 0 0; color: var(--muted); font-size: 0.77rem; line-height: 1.55; }

.message { margin: 0; color: var(--danger); font-size: 0.82rem; line-height: 1.5; }
.page-message { margin: 18px 24px 0; }

.topbar {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.88rem; letter-spacing: 0.1em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.text-link { color: var(--teal-dark); font-size: 0.82rem; font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 42px 0 26px;
}

.page-heading .muted { margin: 0; }
.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid #ccddd6;
  border-radius: 30px;
  background: #f1f8f4;
  color: #366b58;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.local-badge span { width: 7px; height: 7px; border-radius: 50%; background: #4c946d; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card {
  display: grid;
  gap: 10px;
  min-height: 100px;
  align-content: center;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.88);
}
.summary-card span { color: var(--muted); font-size: 0.76rem; }
.summary-card strong { font-size: 1.65rem; letter-spacing: -0.04em; }

.lead-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 12px 34px rgba(31, 55, 57, 0.035);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.panel-heading .eyebrow { margin-bottom: 6px; }
.filters { display: flex; align-items: center; gap: 9px; }
.filters input, .filters select { min-height: 40px; }
.search-label { width: min(280px, 32vw); }
.status-label { width: 205px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #f8faf9; }
th {
  padding: 12px 16px;
  color: #657579;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 15px 16px; border-top: 1px solid #edf0ef; vertical-align: middle; font-size: 0.8rem; }
tbody tr:hover { background: #fbfcfc; }
.contact-name { display: block; color: var(--ink); font-weight: 750; }
.contact-sub, .cell-muted { display: block; margin-top: 4px; color: var(--muted); font-size: 0.72rem; line-height: 1.4; overflow-wrap: anywhere; }
.cell-main { display: block; max-width: 230px; font-weight: 650; line-height: 1.45; }
.status-chip, .priority-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 5px 9px;
  background: #edf3f1;
  color: #41625d;
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}
.status-chip--new { background: #fff4df; color: #865b0d; }
.status-chip--closed { background: #e8f3eb; color: #346b49; }
.priority-chip--high { background: #fae9e6; color: #923b31; }
.row-action {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}
.row-action:hover { border-color: #8eaeaa; background: #f4f8f7; }
.empty-row { padding: 42px 16px; color: var(--muted); text-align: center; }
.list-footnote { margin: 0; padding: 12px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; }
.app-footer { display: flex; justify-content: space-between; gap: 16px; padding: 17px 2px 32px; color: var(--muted); font-size: 0.7rem; }

.users-panel { margin: 22px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 12px 34px rgba(31, 55, 57, 0.035); }
.users-heading { justify-content: start; }
.users-heading .muted { max-width: 620px; margin: 8px 0 0; font-size: 0.82rem; }
.invite-form, .invite-result { display: grid; gap: 10px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.invite-form > label, .invite-result > label { color: #435257; font-size: 0.82rem; font-weight: 700; }
.invite-form .muted, .invite-result .muted { margin: 0; font-size: 0.75rem; }
.invite-controls { display: flex; align-items: center; gap: 9px; }
.invite-controls input { min-width: 0; flex: 1; }
.user-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 22px 24px; }
.user-lists h3 { margin: 0 0 12px; font-size: 0.87rem; }
.user-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.user-list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 10px 12px; border: 1px solid #edf0ef; border-radius: 8px; }
.user-list strong { display: block; overflow-wrap: anywhere; font-size: 0.78rem; }
.user-list small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.68rem; }
.user-list .button { min-height: 34px; padding: 6px 9px; font-size: 0.7rem; }
.user-empty { color: var(--muted); font-size: 0.75rem; }

.lead-dialog {
  width: min(760px, calc(100% - 24px));
  max-width: 760px;
  max-height: min(92vh, 920px);
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: white;
  color: var(--ink);
  box-shadow: 0 25px 90px rgba(14, 37, 39, 0.26);
}
.lead-dialog::backdrop { background: rgba(23, 42, 44, 0.48); backdrop-filter: blur(3px); }
.dialog-layout { padding: 26px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-header h2 { font-size: 1.55rem; }
.dialog-header .muted { margin: 6px 0 0; font-size: 0.85rem; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); cursor: pointer; font-size: 1.35rem; line-height: 1; }
.contact-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 22px 0; padding: 17px; border-radius: 10px; background: #f7f9f8; }
.contact-facts > div { min-width: 0; }
.contact-facts span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.67rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.contact-facts strong, .contact-facts p { margin: 0; font-size: 0.78rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.fact-wide { grid-column: 1 / -1; }
.duplicate-warning { padding: 10px; border: 1px solid #ecd29b; border-radius: 7px; background: #fff9ea; color: #76560e; font-size: 0.8rem; }
.inline-button { display: block; margin-top: 6px; padding: 0; border: 0; background: transparent; color: #6b4a00; cursor: pointer; font-weight: 750; text-decoration: underline; }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; align-items: center; justify-content: end; gap: 9px; margin-top: 21px; padding-top: 17px; border-top: 1px solid var(--line); }
.dialog-actions .message { margin-right: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 24px, 1180px); }
  .topbar { align-items: start; padding: 16px 0; }
  .topbar-actions { justify-content: end; flex-wrap: wrap; }
  .topbar-actions .text-link { display: none; }
  .page-heading { align-items: start; flex-direction: column; padding: 32px 0 20px; }
  .user-lists { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-heading { align-items: start; flex-direction: column; padding: 18px; }
  .filters { width: 100%; flex-direction: column; align-items: stretch; }
  .search-label, .status-label { width: 100%; }
  th, td { padding-right: 12px; padding-left: 12px; }
  .app-footer { flex-direction: column; }
}

@media (max-width: 480px) {
  .login-view { margin-top: 8vh; padding: 28px 22px; }
  .brand-mark { width: 33px; height: 33px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 36px; padding: 7px 9px; font-size: 0.72rem; }
  .invite-controls { align-items: stretch; flex-direction: column; }
  .invite-controls .button { width: 100%; }
  .user-list > li { align-items: start; }
  .summary-card { min-height: 88px; padding: 14px; }
  .summary-card span { font-size: 0.69rem; }
  .dialog-layout { padding: 20px 16px; }
  .contact-facts, .edit-grid { grid-template-columns: 1fr; }
  .fact-wide, .field-wide { grid-column: auto; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .message { flex-basis: 100%; }
}
