:root {
  --bg: #f5f3ee;
  --surface: #fffdf8;
  --surface-2: #ebe7de;
  --ink: #20231f;
  --muted: #70766b;
  --line: #ded8cc;
  --accent: #5f7f62;
  --accent-2: #d7e3cd;
  --danger: #a84a3f;
  --shadow: 0 18px 55px rgba(41, 49, 36, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

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

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  padding: 24px 18px;
  background: #1f2820;
  color: #f9f7ef;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: #cbdcbd;
  color: #243024;
  font-weight: 800;
}

.brand strong { display: block; font-size: 18px; }
.brand small { color: #b8c3b3; }

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

.nav a {
  padding: 12px 14px;
  border-radius: 10px;
  color: #d9dfd2;
}

.nav a.active,
.nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #c9d2c2;
}

.link-button {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 19px; }

.primary-action,
.secondary-action,
button {
  border: 0;
  border-radius: 10px;
  padding: 11px 15px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.secondary-action {
  background: var(--surface-2);
  color: var(--ink);
}

button:hover,
.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 22px;
}

.metrics div {
  background: var(--surface);
  padding: 20px;
}

.metrics span,
.panel-head span,
small,
.muted {
  color: var(--muted);
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 29px;
}

.workspace {
  margin-bottom: 22px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.funnel,
.segment-list,
.source-list,
.transaction-list {
  display: grid;
  gap: 10px;
}

.funnel-row,
.segment-row,
.source-list div,
.transaction-list div,
.finance-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.finance-strip {
  align-items: stretch;
  border-bottom: 0;
}

.finance-strip div {
  flex: 1;
  padding-right: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 12px 8px;
  border-bottom: 1px solid #ebe6da;
  vertical-align: top;
}

.data-table a {
  color: #315b34;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #354d35;
  font-size: 12px;
  font-weight: 700;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px auto;
  gap: 12px;
  margin-bottom: 18px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95, 127, 98, .13);
}

.client-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 22px;
}

.details {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px 18px;
  margin: 0;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.stack-form label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.inline-form {
  display: grid;
  grid-template-columns: 90px 140px 170px auto;
  gap: 8px;
  min-width: 520px;
}

.notes {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.notes article,
.service-list article {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.notes span,
.service-list span {
  color: var(--muted);
  font-size: 13px;
}

.service-list {
  display: grid;
  gap: 16px;
}

.service-list article > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.service-list b {
  display: block;
  margin: 10px 0;
}

.service-list article.is-muted {
  opacity: .62;
}

.service-edit-form {
  display: grid;
  gap: 10px;
}

.service-edit-head,
.service-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.service-edit-grid {
  grid-template-columns: minmax(0, 1fr) 160px;
}

.service-edit-form label {
  color: var(--muted);
  font-size: 13px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toggle-label input {
  width: 18px;
  height: 18px;
}

.login-body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(120deg, rgba(31,40,32,.82), rgba(31,40,32,.44)),
    url("https://images.unsplash.com/photo-1498837167922-ddd27525d352?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-wrap {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  background: rgba(255,253,248,.95);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 22px 80px rgba(0,0,0,.24);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 30px;
}

.login-brand p,
.login-help {
  color: var(--muted);
  margin-bottom: 0;
}

.login-form {
  display: grid;
  gap: 12px;
}

.form-error {
  color: var(--danger);
  font-size: 14px;
}

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
  }
  .brand { margin-bottom: 0; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .sidebar-foot { margin-left: auto; margin-top: 0; border-top: 0; }
  .main { padding: 20px; }
  .metrics, .two-col, .client-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
  .topbar { align-items: stretch; flex-direction: column; }
}

@media (max-width: 620px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .details { grid-template-columns: 1fr; }
  .sidebar { padding: 16px; }
}
