:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-soft: #eaf0f3;
  --ink: #0d1a1e;
  --muted: #3d5560;
  --line: #dde6e9;
  --accent: #630404;
  --accent-dark: #4a0303;
  --teal: #226673;
  --teal-dark: #1a4f5a;
  --teal-light: #7ea6ac;
  --navy: #0a1520;
  --navy-soft: #0f1e2a;
  --amber: #b7791f;
  --rose: #b34c60;
  --blue: #226673;
  --shadow: 0 8px 32px rgba(34, 102, 115, 0.14);
  --shadow-strong: 0 18px 48px rgba(10, 21, 32, 0.18);
  font-family: "Open Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(34, 102, 115, 0.08), rgba(244, 247, 248, 0) 320px),
    var(--bg);
  line-height: 1.55;
}

body.auth-pending .app-shell {
  display: none;
}

body.auth-ready .auth-screen {
  display: none;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card .brand-mark {
  color: #fff;
}

.auth-setup {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-setup p {
  margin-top: 6px;
  color: var(--muted);
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
h4,
h5 {
  font-family: "Oswald", sans-serif;
  letter-spacing: 0.02em;
  line-height: 1.18;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  background:
    linear-gradient(180deg, #0d2e38 0%, var(--teal) 58%, var(--navy) 100%);
  color: #ffffff;
  padding: 24px;
  box-shadow: 8px 0 32px rgba(10, 21, 32, 0.18);
  min-width: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(126, 166, 172, 0.42);
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 0 22px rgba(99, 4, 4, 0.24);
  font-family: "Oswald", sans-serif;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-head h3,
.section-head p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-family: "Oswald", sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand p {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.84rem;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.nav-tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  text-align: left;
  padding: 10px 12px;
}

.nav-subtab {
  min-height: 36px;
  margin-left: 18px;
  padding-left: 18px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.92rem;
  position: relative;
}

.nav-subtab::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 50%;
  width: 6px;
  height: 1px;
  background: rgba(126, 166, 172, 0.82);
}

.nav-tab.active,
.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 3px 0 0 var(--teal-light);
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar,
.section-head,
.panel-header,
.bulk-email,
.contact-main,
.activity-item,
.account-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: "Oswald", sans-serif;
}

.topbar h2 {
  font-family: "Oswald", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-actions,
.bulk-controls,
.filter-row,
.row-actions,
.contact-actions,
.activity-actions,
.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.chip-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(99, 4, 4, 0.2);
}

.primary-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: 0 8px 24px rgba(99, 4, 4, 0.32);
  transform: translateY(-1px);
}

.secondary-button,
.chip-button {
  color: var(--teal);
  background: var(--surface);
  border-color: rgba(34, 102, 115, 0.18);
}

.secondary-button:hover,
.chip-button:hover,
.icon-button:hover {
  background: rgba(34, 102, 115, 0.07);
  border-color: rgba(34, 102, 115, 0.34);
}

.lookup-cta-button {
  min-height: 42px;
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(34, 102, 115, 0.24);
}

.lookup-cta-button:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.lookup-cta-button:disabled {
  opacity: 0.68;
  box-shadow: none;
}

.danger-button {
  color: #8f1f1f;
  background: #fff7f6;
  border-color: #efc4bf;
}

.danger-button:hover {
  background: #fdecea;
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.danger-icon {
  color: #8f1f1f;
  background: #fff7f6;
  border-color: #efc4bf;
}

.bulk-email,
.panel,
.contact-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bulk-email {
  padding: 14px 16px;
  margin-bottom: 18px;
}

.bulk-email span {
  color: var(--muted);
  margin-left: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(34, 102, 115, 0.16);
  background: #fff;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.dashboard-grid,
.card-grid,
.account-workspace,
.bulk-import-workspace,
.bulk-email-workspace,
.calendar-list,
.contacts-workspace,
.pipeline-summary,
.pipeline-groups,
.pipeline-board {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 14px;
}

.metric {
  padding: 16px;
  min-height: 104px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
  font-family: "Oswald", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--teal);
  font-family: "Oswald", sans-serif;
  font-size: 2rem;
}

.dashboard-grid {
  grid-template-columns: 1.3fr 0.7fr;
}

.panel {
  padding: 16px;
}

.panel-header {
  margin-bottom: 12px;
}

.panel h3,
.section-head h3 {
  color: var(--ink);
  font-family: "Oswald", sans-serif;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.section-head {
  margin: 8px 0 14px;
}

.section-head p {
  color: var(--muted);
  margin-top: 4px;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.account-workspace {
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  align-items: start;
}

.contacts-workspace {
  grid-template-columns: minmax(300px, 0.78fr) minmax(380px, 1.22fr);
  align-items: start;
}

.bulk-email-workspace {
  grid-template-columns: minmax(340px, 0.86fr) minmax(360px, 1.14fr);
  align-items: start;
}

.bulk-import-workspace {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.account-list,
.account-detail,
.contacts-list,
.contact-detail-panel,
.bulk-import-panel,
.bulk-import-preview,
.bulk-compose,
.bulk-contact-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.bulk-compose,
.bulk-import-panel,
.bulk-import-preview,
.bulk-contact-picker {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.bulk-import-panel {
  grid-template-columns: minmax(260px, 0.9fr) auto minmax(180px, 1fr);
  align-items: end;
}

.bulk-compose h4,
.bulk-import-panel h4,
.bulk-import-preview h4,
.bulk-contact-picker h4 {
  margin: 0;
}

.bulk-import-panel h4 {
  grid-column: 1 / -1;
}

.bulk-compose-actions,
.bulk-import-actions,
.bulk-picker-head,
.bulk-picker-actions,
.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-picker-actions {
  justify-content: flex-end;
}

.bulk-import-actions {
  justify-content: flex-start;
}

.bulk-import-panel .lookup-status {
  align-self: center;
  margin: 0;
}

.import-account-cell {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.import-account-cell small {
  color: var(--muted);
  line-height: 1.25;
}

.bulk-email-workspace textarea {
  min-height: 220px;
}

.admin-panel {
  display: grid;
  gap: 16px;
  width: min(720px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-panel h4 {
  margin: 0;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.import-preview-wrap {
  overflow-x: auto;
}

.import-preview-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.import-preview-table th,
.import-preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

.import-preview-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.import-preview-table tr.potential-duplicate-row td {
  background: #fff0f3;
}

.duplicate-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #f3b8c3;
  border-radius: 999px;
  color: #9f2840;
  background: #ffe1e8;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.import-preview-table input,
.import-preview-table select,
.import-preview-table textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
}

.import-preview-table textarea {
  resize: vertical;
  min-width: 180px;
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.bulk-contact-list {
  display: grid;
  gap: 10px;
}

.bulk-contact-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.bulk-contact-item input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.bulk-contact-item strong,
.bulk-contact-item small {
  display: block;
}

.bulk-contact-item small {
  color: var(--muted);
  margin-top: 3px;
}

.account-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.contacts-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.account-letter-group,
.contact-letter-group {
  display: grid;
  gap: 0;
}

.account-letter-header,
.contact-letter-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--teal);
  background: var(--surface-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.account-list-item,
.contact-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.account-letter-group .account-list-item:last-child,
.contact-letter-group .contact-list-item:last-child {
  border-bottom: 0;
}

.account-list-item:hover,
.contact-list-item:hover {
  background: var(--surface-soft);
  box-shadow: inset 3px 0 0 var(--teal-light);
}

.account-list-item.active,
.contact-list-item.active {
  background: #d6e5e8;
  box-shadow: inset 5px 0 0 var(--teal), 0 1px 0 rgba(34, 102, 115, 0.12);
}

.account-list-item.active strong,
.contact-list-item.active strong {
  color: var(--teal-dark);
}

.account-list-item strong,
.account-list-item small,
.contact-list-item strong,
.contact-list-item small {
  display: block;
}

.contact-list-account {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.account-list-item small,
.contact-list-item small {
  color: var(--muted);
  margin-top: 4px;
}

.account-detail,
.contact-detail-panel {
  min-height: 420px;
  padding: 18px;
}

.account-detail-head,
.contact-detail-head,
.account-contact {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.account-detail-head,
.contact-detail-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.account-detail-head h4,
.contact-detail-head h4 {
  margin: 10px 0 4px;
  font-size: 1.35rem;
}

.account-detail-head p,
.contact-detail-head p,
.detail-section p,
.account-contact p {
  color: var(--muted);
  margin: 0;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h5 {
  margin: 0 0 10px;
  font-family: "Oswald", sans-serif;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--teal);
  letter-spacing: 0.12em;
}

.detail-section-head {
  margin-bottom: 10px;
}

.detail-section-head h5 {
  margin: 0;
}

.detail-section-head select {
  width: min(220px, 100%);
}

.account-note-list {
  display: grid;
  gap: 10px;
}

.account-note-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.note-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-note-item p {
  margin: 0;
  color: var(--muted);
}

.account-contact-list {
  display: grid;
  gap: 10px;
}

.account-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.contact-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.account-fact {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.account-fact span,
.account-fact strong {
  display: block;
}

.account-fact span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.account-fact strong {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

.select-contact {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.select-contact input {
  width: auto;
  min-height: auto;
}

.contact-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-contact {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.account-card,
.contact-card,
.stage-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.account-card,
.contact-card {
  padding: 16px;
}

.account-card p,
.contact-card p,
.activity-item p {
  color: var(--muted);
  margin: 6px 0 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--teal);
  background: rgba(126, 166, 172, 0.16);
  border: 1px solid rgba(126, 166, 172, 0.24);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.call {
  color: var(--teal);
  background: rgba(34, 102, 115, 0.1);
}

.pill.meeting {
  color: var(--accent);
  background: rgba(99, 4, 4, 0.08);
}

.pill.note {
  color: var(--teal-dark);
  background: rgba(126, 166, 172, 0.18);
}

.contact-table-wrap {
  overflow-x: auto;
}

.contact-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.contact-table th,
.contact-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

.contact-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.contact-name {
  font-weight: 800;
}

.contact-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.pipeline-summary {
  grid-template-columns: 1fr;
  align-items: start;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.funnel-total {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.funnel-total-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 180px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.funnel-total-button:hover,
.funnel-total-button.active {
  border-color: rgba(34, 102, 115, 0.42);
  background: var(--surface-soft);
}

.funnel-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.funnel-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: var(--funnel-width);
  min-height: 58px;
  padding: 0 46px;
  border: 0;
  color: #1e2724;
  background: var(--funnel-color);
  clip-path: polygon(4% 0, 96% 0, 90% 100%, 10% 100%);
  overflow: hidden;
}

.funnel-stage:hover,
.funnel-stage.active {
  outline: 3px solid rgba(126, 166, 172, 0.44);
  outline-offset: 2px;
}

.funnel-stage span,
.funnel-stage strong {
  position: relative;
  z-index: 1;
}

.funnel-stage span {
  font-weight: 800;
  text-align: center;
}

.funnel-stage strong {
  font-size: 1.35rem;
}

.pipeline-groups {
  grid-template-columns: 1fr;
}

.pipeline-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--stage-color) 18%, #fff);
  box-shadow: var(--shadow);
}

.pipeline-group .stage-header {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--stage-color);
}

.pipeline-group .stage-header .pill {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
}

.stage-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  min-height: 260px;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stage-header h4 {
  margin: 0;
}

.stage-list {
  display: grid;
  gap: 10px;
}

.pipeline-contact-list {
  display: grid;
  gap: 10px;
}

.pipeline-contact {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--stage-color) 52%, var(--line));
  border-left: 6px solid var(--stage-color);
  border-radius: 8px;
  background: #fff;
}

.pipeline-contact p {
  color: var(--muted);
  margin: 4px 0 0;
}

.pipeline-contact .contact-actions select {
  width: 150px;
}

.calendar-list {
  grid-template-columns: 1fr;
}

.calendar-day {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-day h4 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
}

.calendar-events {
  display: grid;
  gap: 10px;
}

.calendar-event {
  display: grid;
  grid-template-columns: 130px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.calendar-time {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.calendar-event-body strong {
  display: block;
}

.calendar-event-body p {
  color: var(--muted);
  margin: 4px 0 0;
}

.calendar-event-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-list.full {
  gap: 12px;
}

.activity-group {
  display: grid;
  gap: 10px;
}

.activity-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
}

.activity-group-header h4 {
  margin: 0;
  font-size: 1rem;
}

.activity-item {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.activity-body strong {
  display: block;
}

.stage-bars {
  display: grid;
  gap: 12px;
}

.stage-bar label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--teal-light));
}

dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}

dialog.wide-dialog {
  width: min(980px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(10, 21, 32, 0.55);
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Oswald", sans-serif;
  letter-spacing: 0.04em;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
}

.modal-form > .primary-button:last-child {
  position: sticky;
  bottom: -18px;
  margin: 4px -18px -18px;
  border-radius: 0;
  min-height: 48px;
  z-index: 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.location-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(80px, 0.55fr) minmax(100px, 0.7fr);
  gap: 12px;
}

.create-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.create-section {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.create-toggle,
.select-lookup-contact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.create-toggle {
  gap: 8px;
  color: var(--ink);
  font-size: 0.95rem;
}

.create-toggle input,
.select-lookup-contact input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.lookup-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lookup-actions span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.lookup-actions div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.lookup-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.lookup-status {
  color: var(--muted);
  margin: 0;
}

.lookup-suggestions {
  display: grid;
  gap: 8px;
}

.account-lookup-results .lookup-suggestions {
  max-height: min(360px, 45vh);
  overflow-y: auto;
  padding-right: 4px;
}

.account-lookup-results {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.account-lookup-results[hidden] {
  display: none;
}

.lookup-contact {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.lookup-contact.priority-contact {
  border-color: rgba(126, 166, 172, 0.7);
  background: rgba(126, 166, 172, 0.12);
}

.lookup-contact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lookup-contact-head .secondary-button {
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.lookup-contact-head .will-add-button {
  color: var(--teal);
  background: rgba(126, 166, 172, 0.18);
  border-color: rgba(126, 166, 172, 0.5);
}

.lookup-contact span {
  color: var(--muted);
  font-size: 0.84rem;
}

.lookup-contact small {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  margin-top: 3px;
}

.activity-date-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr);
  gap: 12px;
}

.empty {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav-tabs {
    display: flex;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
  }

  .nav-tab {
    flex: 0 0 auto;
  }

  .nav-subtab {
    margin-left: 0;
  }

  .metric-grid,
  .dashboard-grid,
  .account-workspace,
  .bulk-email-workspace,
  .contacts-workspace,
  .pipeline-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bulk-import-panel,
  .bulk-import-workspace {
    grid-template-columns: 1fr;
  }

  .pipeline-contact {
    grid-template-columns: 1fr;
  }

  .calendar-event {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

@media (max-width: 680px) {
  html,
  body {
    overflow-x: hidden;
  }

  .workspace {
    padding: 16px;
    width: 100%;
  }

  .topbar,
  .section-head,
  .bulk-email,
  .activity-item {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .bulk-controls,
  .filter-row {
    min-width: 0;
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    flex: 1 1 auto;
  }

  .metric-grid,
  .dashboard-grid,
  .account-workspace,
  .bulk-import-workspace,
  .bulk-email-workspace,
  .contacts-workspace,
  .pipeline-board,
  .create-modal-grid,
  .activity-date-grid,
  .lookup-row,
  .location-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .account-detail-head,
  .contact-detail-head,
  .account-contact,
  .detail-actions {
    flex-direction: column;
  }

  .account-facts,
  .contact-facts {
    grid-template-columns: 1fr;
  }
}
