:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #172033;
  --muted: #637089;
  --line: #d9e1ec;
  --brand: #1073d6;
  --brand-strong: #0759aa;
  --teal: #0f8f83;
  --amber: #b77400;
  --red: #c64747;
  --green: #20845a;
  --shadow: 0 16px 42px rgba(24, 37, 56, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  color: #fff;
  background: #122640;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #27a7f2;
  font-weight: 800;
  font-size: 23px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-footer span {
  color: #aac0d7;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 26px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9e8f7;
  text-align: right;
}

.nav-item.active,
.nav-item:hover {
  background: #203b5d;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 40vw);
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  padding: 0 15px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.ghost-button {
  padding: 0 13px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

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

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.metric small {
  color: var(--green);
  font-weight: 700;
}

.dashboard-grid,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 16px;
}

.lead-flow-panel {
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header.compact {
  align-items: center;
}

.panel-header p {
  margin-bottom: 0;
  font-size: 14px;
}

.lead-chart {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  min-height: 260px;
  padding: 18px 18px 14px;
}

.chart-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.chart-day {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-height: 220px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.bar-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 184px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to top, rgba(217, 225, 236, 0.8) 1px, transparent 1px);
  background-size: 100% 46px;
}

.bar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: min(48px, 78%);
  min-height: 6px;
  border-radius: 8px 8px 0 0;
  background: #8dbcf0;
  color: #12365f;
  transition: height 180ms ease;
}

.bar.above-average {
  background: var(--brand);
  color: #fff;
}

.bar strong {
  position: absolute;
  top: -24px;
  font-size: 13px;
  color: var(--ink);
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  min-height: 38px;
  padding: 0 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.company-cell strong,
.account-card strong {
  display: block;
  margin-bottom: 3px;
}

.company-cell span,
.account-card span,
.detail-meta,
.task-card span,
.task-row span {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e8f2ff;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.health-good {
  background: #e4f6ee;
  color: var(--green);
}

.health-watch {
  background: #fff3d9;
  color: var(--amber);
}

.health-risk {
  background: #ffe8e8;
  color: var(--red);
}

.status-new {
  background: #e8f2ff;
  color: var(--brand-strong);
}

.status-unhandled {
  background: #fff3d9;
  color: var(--amber);
}

.status-active {
  background: #e4f6ee;
  color: var(--green);
}

.status-irrelevant {
  background: #edf0f4;
  color: #5b6473;
}

.task-stack,
.account-list,
.task-table {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.task-card,
.account-card,
.task-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.task-card,
.account-card {
  padding: 13px;
}

.account-card {
  width: 100%;
  text-align: right;
}

.account-card.active,
.account-card:hover {
  border-color: #8ac4ff;
  background: #f0f7ff;
}

.account-card-top,
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.split-layout {
  grid-template-columns: minmax(320px, 0.43fr) minmax(0, 0.57fr);
}

.detail-panel {
  padding: 18px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  max-width: 440px;
}

.detail-actions .ghost-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

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

.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.full-detail {
  grid-column: 1 / -1;
}

.close-reason-field {
  display: none;
}

.close-reason-field.visible {
  display: grid;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding: 12px;
  border-right: 3px solid var(--brand);
  background: var(--surface-soft);
  border-radius: 8px 0 0 8px;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.pipeline-column {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.pipeline-column header {
  display: flex;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.deal-card {
  margin: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.deal-card strong,
.deal-card span {
  display: block;
}

.deal-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.task-row {
  padding: 12px 14px;
}

.task-row.done {
  opacity: 0.62;
}

.task-row.done strong {
  text-decoration: line-through;
}

dialog {
  border: 0;
  padding: 0;
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(10, 20, 33, 0.3);
}

dialog::backdrop {
  background: rgba(18, 38, 64, 0.42);
}

.dialog-card {
  width: min(760px, calc(100vw - 28px));
  background: #fff;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin-bottom: 0;
}

.dialog-actions {
  justify-content: flex-start;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 400;
}

.icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.dashboard-icon,
.accounts-icon,
.pipeline-icon,
.tasks-icon,
.search-icon,
.plus-icon,
.export-icon,
.close-icon,
.edit-icon,
.phone-icon,
.meeting-icon {
  color: currentColor;
}

.dashboard-icon::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
  box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.16);
}

.accounts-icon::before,
.accounts-icon::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.accounts-icon::before {
  width: 6px;
  height: 6px;
  top: 1px;
  right: 5px;
}

.accounts-icon::after {
  width: 12px;
  height: 7px;
  right: 1px;
  bottom: 1px;
  border-radius: 8px 8px 4px 4px;
}

.pipeline-icon::before {
  content: "";
  position: absolute;
  inset: 3px 1px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  box-shadow: 0 5px 0 currentColor;
}

.tasks-icon::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.tasks-icon::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 5px;
  width: 8px;
  height: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(35deg);
}

.search-icon::before {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 50%;
  top: 1px;
  right: 1px;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
  left: 1px;
  bottom: 3px;
}

.plus-icon::before,
.plus-icon::after,
.close-icon::before,
.close-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 2px;
}

.plus-icon::before {
  width: 14px;
  height: 2px;
  top: 8px;
  right: 2px;
}

.plus-icon::after {
  width: 2px;
  height: 14px;
  top: 2px;
  right: 8px;
}

.close-icon::before,
.close-icon::after {
  width: 14px;
  height: 2px;
  top: 8px;
  right: 2px;
}

.close-icon::before {
  transform: rotate(45deg);
}

.close-icon::after {
  transform: rotate(-45deg);
}

.export-icon::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 10px;
  right: 3px;
  bottom: 2px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.export-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: 1px;
  right: 5px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(-45deg);
}

.edit-icon::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 4px;
  top: 7px;
  right: 2px;
  border: 2px solid currentColor;
  border-radius: 2px;
  transform: rotate(-35deg);
}

.edit-icon::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 2px;
  right: 2px;
  bottom: 3px;
  background: currentColor;
}

.phone-icon::before {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border: 2px solid currentColor;
  border-top-width: 4px;
  border-bottom-width: 4px;
  border-radius: 8px;
  transform: rotate(-28deg);
}

.meeting-icon::before {
  content: "";
  position: absolute;
  inset: 3px 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.meeting-icon::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 5px;
  width: 8px;
  height: 4px;
  border-right: 2px solid currentColor;
  border-left: 2px solid currentColor;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metrics-grid,
  .dashboard-grid,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .pipeline-board {
    grid-template-columns: repeat(4, 240px);
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .topbar-actions,
  .panel-header,
  .detail-header,
  .detail-actions,
  .account-card-top,
  .task-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-grid,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .lead-chart {
    grid-template-columns: 34px 1fr;
    overflow-x: auto;
    padding: 14px;
  }

  .chart-bars {
    grid-template-columns: repeat(7, 54px);
  }
}
