:root {
  --ink: #111827;
  --muted: #7b8191;
  --line: #e5e8ef;
  --panel: #ffffff;
  --page: #e9edf4;
  --navy: #2f438f;
  --navy-deep: #253673;
  --blue: #2e63d6;
  --blue-soft: #eef4ff;
  --green: #39b879;
  --amber: #f4b943;
  --red: #cf4b45;
  --shadow: 0 22px 55px rgba(35, 47, 82, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.82) 0 18px, transparent 19px),
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.85) 0 28px, transparent 29px),
    radial-gradient(circle at 96% 80%, rgba(255, 255, 255, 0.68) 0 22px, transparent 23px),
    var(--page);
}

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

.shell {
  width: min(1540px, calc(100vw - 64px));
  min-height: calc(100vh - 72px);
  margin: 36px auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
}

.sidebar {
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  color: #fff;
  background: linear-gradient(180deg, var(--navy), var(--navy-deep));
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.brand,
.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.brand strong,
.profile strong {
  display: block;
  font-size: 17px;
}

.brand span,
.profile span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  cursor: pointer;
}

.nav-link.active,
.nav-link:hover {
  color: var(--navy-deep);
  background: #fff;
}

.profile {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 72px;
  padding: 12px 16px 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy), var(--navy-deep));
  border-radius: 9px;
  box-shadow: 0 16px 36px rgba(47, 67, 143, 0.22);
}

.breadcrumb,
.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .breadcrumb {
  color: rgba(255, 255, 255, 0.58);
}

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

h1 {
  margin-bottom: 0;
  font-size: 23px;
  font-weight: 750;
}

h2 {
  margin-bottom: 12px;
  font-size: 42px;
  line-height: 1.05;
}

h3 {
  margin-bottom: 0;
  font-size: 19px;
  font-weight: 750;
}

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

.mobile-control-panel summary {
  display: none;
}

button,
select,
input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
}

button {
  cursor: pointer;
}

select {
  min-width: 142px;
  appearance: none;
  padding-right: 42px;
  cursor: pointer;
  background:
    linear-gradient(45deg, transparent 50%, #617091 50%) calc(100% - 20px) 18px / 7px 7px no-repeat,
    linear-gradient(135deg, #617091 50%, transparent 50%) calc(100% - 15px) 18px / 7px 7px no-repeat,
    #fff;
  box-shadow: 0 10px 20px rgba(20, 32, 66, 0.07);
}

input {
  cursor: text;
}

.topbar select {
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  background:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.85) 50%) calc(100% - 20px) 18px / 7px 7px no-repeat,
    linear-gradient(135deg, rgba(255, 255, 255, 0.85) 50%, transparent 50%) calc(100% - 15px) 18px / 7px 7px no-repeat,
    rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.topbar select option {
  color: var(--ink);
}

#view-select {
  display: none;
}

.projection-line {
  color: var(--muted);
  font-size: 12px;
}

#sync-status {
  border-color: transparent;
  color: var(--navy-deep);
  font-weight: 750;
  background: #fff;
}

#all-time-toggle.active {
  border-color: transparent;
  color: #fff;
  background: var(--green);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  margin-top: 18px;
  min-height: 220px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 315px;
  gap: 22px;
  align-items: stretch;
  border-radius: 12px;
  padding: 30px;
  color: #fff;
  background:
    radial-gradient(circle at 66% 0%, rgba(255, 255, 255, 0.18), transparent 31%),
    linear-gradient(135deg, #4071df 0%, #263b8b 100%);
  box-shadow: var(--shadow);
}

.hero p {
  max-width: 640px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.55;
}

.hero .eyebrow {
  color: rgba(255, 255, 255, 0.7);
}

.hero-score {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
}

.hero-score span,
.hero-score small {
  color: rgba(255, 255, 255, 0.78);
}

.hero-score strong {
  display: block;
  color: #fff;
  font-size: 44px;
  line-height: 1;
}

.kpi-grid,
.finance-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.metric,
.panel {
  border: 1px solid rgba(223, 227, 235, 0.95);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(35, 47, 82, 0.08);
}

.metric {
  min-height: 118px;
  padding: 18px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.metric span,
.metric small,
.detail-grid span,
.plain-text,
.import-row span,
.gocardless-card span,
td,
th {
  color: var(--muted);
}

.metric strong {
  color: var(--ink);
  font-size: 27px;
  line-height: 1.1;
}

.metric.primary {
  border-color: rgba(47, 67, 143, 0.16);
  background: linear-gradient(180deg, #fff, var(--blue-soft));
}

.main-grid,
.page-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.panel {
  padding: 24px;
}

.panel-head,
.split-stats,
.next-imports,
.calls-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.chart-panel {
  min-height: 350px;
}

.bars,
.section-bars {
  height: 240px;
  display: grid;
  grid-template-columns: repeat(var(--bar-count, 12), minmax(28px, 1fr));
  align-items: end;
  gap: 14px;
  padding: 24px 4px 12px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.section-bars {
  height: 190px;
  margin-top: 20px;
}

.chart-filter-row {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.bar-wrap {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  justify-items: center;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.bar-value {
  min-height: 18px;
  display: block;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
  text-align: center;
  line-height: 1.15;
}

.bar {
  width: 34px;
  min-height: 12px;
  border-radius: 12px 12px 4px 4px;
  background: #e8ecf4;
  display: block;
  flex: 0 0 auto;
}

.combo-stack {
  width: 100%;
  min-height: 132px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
}

.bar-column {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.bar-wrap.combo {
  align-content: end;
}

.bar-wrap:not(.combo) .bar {
  background: linear-gradient(180deg, #2f438f, #263b8b);
}

.bar.outbound {
  background: linear-gradient(180deg, #2f438f, #5b6fd8);
}

.bar.booked {
  background: linear-gradient(180deg, #39b879, #a8e6bf);
}

.bar.projection {
  background: linear-gradient(180deg, #9ee7bd, #c9f3d8);
  opacity: 1;
  border: 1px dashed rgba(17, 24, 39, 0.34);
}

.bar.active,
.bar-wrap:not(.combo) .bar.active {
  background: linear-gradient(180deg, #57cf96, #a8e6bf);
}

.target-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.line-legend,
.category-manager,
.icon-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 0 11px;
  color: var(--muted);
  background: #f6f8fb;
}

.legend-chip span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-chip.active {
  color: var(--navy-deep);
  border-color: rgba(47, 67, 143, 0.28);
  background: var(--blue-soft);
}

.line-chart {
  width: 100%;
  height: 300px;
  margin-top: 18px;
  overflow: visible;
}

.grid-lines line {
  stroke: #e8ecf4;
  stroke-width: 1;
}

.axis-labels text {
  fill: var(--muted);
  font-size: 12px;
}

.kpi-line {
  cursor: pointer;
  opacity: 0.25;
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.kpi-line.active {
  opacity: 1;
}

.target-chip,
.badge,
.status-pill,
.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.target-chip {
  color: var(--navy-deep);
  background: var(--blue-soft);
}

.badge {
  color: var(--navy-deep);
  background: var(--blue-soft);
}

.badge.good {
  color: #08733a;
  background: #e8f8ee;
}

.detail-grid,
.import-list,
.steps,
.gocardless-card {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

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

.detail-grid div,
.gocardless-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-grid strong,
.gocardless-card strong {
  font-size: 18px;
}

.import-row {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.import-row.ready {
  border-color: rgba(57, 184, 121, 0.36);
}

.import-row.pending {
  border-color: rgba(244, 185, 67, 0.48);
}

.file-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 15px;
  background: #fff;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.finom-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.finom-summary div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f9fc;
}

.finom-summary strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 22px;
}

.calls-toolbar {
  margin-top: 18px;
  padding: 22px 24px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(35, 47, 82, 0.08);
}

.calls-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.calls-kpis .metric {
  min-height: 132px;
}

.calls-kpis .metric strong {
  font-size: 23px;
}

.search-input {
  width: min(360px, 100%);
}

.table-wrap {
  margin-top: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.monthly-table {
  min-width: 980px;
}

.monthly-table th:first-child,
.monthly-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  color: var(--ink);
  background: #fff;
}

.monthly-table tbody th {
  color: var(--ink);
  background: #fff;
  text-transform: none;
  font-size: 14px;
}

.calls-table {
  min-width: 880px;
}

.load-more {
  margin-top: 16px;
  color: var(--navy-deep);
  font-weight: 750;
  background: var(--blue-soft);
}

.calls-table td {
  vertical-align: top;
}

.calls-table input,
.calls-table select,
.expense-table input {
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.calls-table .amount-input {
  color: var(--ink);
  font-weight: 400;
}

.calls-table .amount-input:disabled {
  color: #8e95a3;
  background: #f0f2f5;
  cursor: not-allowed;
}

.prospect-cell strong,
.prospect-cell span,
.contact-cell span {
  display: block;
}

.prospect-cell span,
.contact-cell span {
  color: var(--muted);
  font-size: 13px;
}

.dirty-row {
  background: #fffaf0;
}

.expense-table input {
  max-width: 160px;
  text-align: right;
}

.expense-table select {
  min-width: 210px;
}

.category-manager input {
  min-width: 190px;
}

.icon-actions {
  justify-content: flex-end;
}

.icon-actions button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--navy-deep);
  background: var(--blue-soft);
}

.icon-actions button[data-expense-action="delete"] {
  color: #9b1c1a;
  background: #fff0ed;
}

.status-pill.pending {
  color: #8a5a00;
  background: #fff3d4;
}

.status-pill.manual {
  color: var(--navy-deep);
  background: var(--blue-soft);
}

.meta-row.ads td:last-child {
  color: #b42318;
}

.meta-row.subscription td:last-child {
  color: #7a5600;
}

.category-pill.ads {
  color: #b42318;
  background: #fff0ed;
}

.category-pill.subscription {
  color: #7a5600;
  background: #fff4d8;
}

.steps {
  padding-left: 20px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 3;
  transform: translateY(24px);
  opacity: 0;
  transition: 180ms ease;
  padding: 13px 18px;
  border-radius: 8px;
  color: #fff;
  background: var(--navy-deep);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 17, 40, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  backdrop-filter: blur(10px);
}

.sync-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.sync-dialog {
  width: min(420px, 100%);
  border: 1px solid rgba(29, 53, 122, 0.12);
  border-radius: 14px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(19, 35, 75, 0.26);
}

.sync-dialog h2 {
  margin: 6px 0 10px;
  font-size: 24px;
  letter-spacing: 0;
}

.sync-dialog p {
  margin: 0;
  color: var(--muted);
}

.sync-dialog small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.sync-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e8edf8;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.sync-progress {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2fb;
}

.sync-progress span {
  display: block;
  width: 24%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 240ms ease;
}

.download-snapshot {
  width: 100%;
  min-height: 44px;
  margin-top: 18px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  background: var(--navy);
  cursor: pointer;
}

.download-snapshot[hidden] {
  display: none;
}

.sync-close {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 1px solid #d9e1f2;
  border-radius: 10px;
  color: var(--navy-deep);
  font-weight: 800;
  background: #fff;
  cursor: pointer;
}

.sync-close[hidden] {
  display: none;
}

.sync-overlay.error .sync-spinner {
  border-color: #fde2e2;
  border-top-color: #d93025;
}

.is-syncing [data-action="sync-sheets"] {
  opacity: 0.72;
  cursor: wait;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .shell {
    width: min(100vw - 24px, 980px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  #view-select {
    display: block;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .kpi-grid,
  .finance-kpis,
  .calls-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    display: block;
  }

  .workspace {
    padding: 112px 14px 14px;
  }

  .topbar,
  .top-actions,
  .panel-head,
  .import-row,
  .calls-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    margin: 0;
    border-radius: 0;
    min-height: 0;
    padding: 10px 14px;
  }

  .topbar h1,
  .topbar .breadcrumb {
    display: none;
  }

  .mobile-control-panel summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 0 14px;
    color: var(--navy-deep);
    font-weight: 750;
    background: #fff;
    cursor: pointer;
  }

  .mobile-control-panel {
    width: 100%;
  }

  .mobile-control-panel:not([open]) .top-actions {
    display: none;
  }

  .mobile-control-panel[open] .top-actions {
    margin-top: 10px;
  }

  .import-row {
    display: flex;
  }

  .detail-grid,
  .finom-summary,
  .kpi-grid,
  .finance-kpis,
  .calls-kpis {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 34px;
  }

  .hero,
  .panel {
    padding: 20px;
  }

  .bars {
    gap: 8px;
  }
}
