:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1e2722;
  --muted: #66726b;
  --line: #dfe5de;
  --accent: #137c5a;
  --accent-dark: #0f5f47;
  --gold: #c18b2d;
  --danger-bg: #fff6df;
  --danger-line: #ebc873;
  --shadow: 0 16px 48px rgba(30, 39, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #18362b 0%, #176348 100%);
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 12px;
  font-size: 2rem;
  line-height: 1.1;
}

.auth-form {
  margin-top: 22px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.status-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.status-message.error {
  color: #8a261d;
}

.status-message.success {
  color: var(--accent-dark);
}

.link-action {
  display: inline-flex;
  margin-top: 14px;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
  border: 0;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.eyebrow.dark {
  color: var(--accent-dark);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.userbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.install-tip {
  margin: 0 0 12px auto;
  padding: 10px 12px;
  max-width: 420px;
  color: var(--accent-dark);
  background: #e6f3ed;
  border: 1px solid #c7e4d7;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  color: #ffffff;
  background: linear-gradient(135deg, #18362b 0%, #176348 100%);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.72);
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 8px;
}

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

.topbar .muted {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.72);
}

.small {
  font-size: 0.88rem;
}

.primary-action,
.secondary,
.ghost,
.tab,
.icon-button {
  border: 0;
  border-radius: 8px;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.full-button {
  width: 100%;
}

.topbar .primary-action {
  background: #ffffff;
  color: #143f30;
}

.top-actions {
  display: grid;
  gap: 10px;
}

.secondary {
  min-height: 40px;
  padding: 0 14px;
  color: var(--accent-dark);
  background: #e6f3ed;
  font-weight: 700;
}

.secondary:disabled {
  color: #8b9891;
  background: #edf1ee;
  cursor: not-allowed;
}

.ghost {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent-dark);
  background: transparent;
  border: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0;
  overflow-x: auto;
}

.tab {
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: #ffffff;
  background: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.summary-grid,
.content-grid,
.plans {
  display: grid;
  gap: 16px;
}

.summary-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.content-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.metric,
.panel,
.plan-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(30, 39, 34, 0.05);
}

.goal-panel {
  margin-bottom: 16px;
}

.goal-actions {
  display: flex;
  gap: 10px;
}

.goal-details > .muted {
  margin: 0 0 14px;
}

.show-more-button {
  width: 100%;
}

.goal-grid,
.finance-indicators {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.goal-stat,
.indicator-card {
  padding: 14px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.goal-stat span,
.indicator-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.goal-stat strong,
.indicator-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.goal-progress {
  height: 12px;
  margin-top: 14px;
  overflow: hidden;
  background: #e7ece8;
  border-radius: 999px;
}

.goal-progress div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.metric {
  padding: 18px;
}

.metric span,
.plan-status span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
}

.panel {
  padding: 20px;
}

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

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

.list-item,
.client-button {
  width: 100%;
  padding: 14px;
  text-align: left;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-item strong,
.client-button strong {
  display: block;
  margin-bottom: 4px;
}

.item-main {
  min-width: 0;
}

.item-actions,
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.danger {
  min-height: 36px;
  padding: 0 12px;
  color: #8a261d;
  background: #fff0ed;
  border: 1px solid #f1c7c0;
  border-radius: 8px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #e6f3ed;
  font-weight: 700;
  font-size: 0.82rem;
}

.client-limit {
  font-weight: 700;
  color: var(--accent-dark);
}

.limit-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 8px;
}

.duplicate-client-notice {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 14px;
  color: #604700;
  background: #fff7df;
  border: 1px solid #e9c96d;
  border-radius: 8px;
}

.duplicate-client-notice span {
  color: #735d1d;
}

.hidden {
  display: none !important;
}

.client-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.client-sidebar {
  display: grid;
  align-content: start;
  gap: 12px;
}

.client-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.client-match-list {
  display: grid;
  gap: 8px;
  margin: -4px 0 14px;
}

.client-match-button {
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.client-match-button strong {
  display: block;
}

.client-match-button span {
  color: var(--muted);
  font-size: 0.88rem;
}

.client-match-empty {
  padding: 10px 12px;
  color: var(--muted);
  background: #fbfcfb;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
}

.search-label {
  margin-bottom: 0;
}

.client-button.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.client-profile {
  min-height: 320px;
  padding: 18px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.client-profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.profile-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.relationship-action {
  display: inline-flex;
  margin-top: 12px;
}

.finance-table {
  display: grid;
  gap: 10px;
}

.finance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.expense-form {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 8px;
  margin-bottom: 14px;
}

.expense-form.expanded {
  grid-template-columns: 1fr 140px 150px 190px auto;
  align-items: end;
  margin-bottom: 0;
}

.expense-form.expanded label {
  margin-bottom: 0;
}

.commission-preview {
  margin: 2px 0 14px;
  padding: 12px 14px;
  color: var(--accent-dark);
  background: #e6f3ed;
  border: 1px solid #c7e4d7;
  border-radius: 8px;
  font-weight: 800;
}

.optional-text {
  color: var(--muted);
  font-weight: 600;
}

.profile-form {
  display: grid;
  grid-template-columns: 1fr 180px 220px auto;
  gap: 12px;
  align-items: end;
}

.profile-form label {
  margin-bottom: 0;
}

.privacy-panel {
  max-width: 860px;
}

.privacy-panel p {
  line-height: 1.6;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.admin-metric {
  padding: 16px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.admin-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.admin-alerts h3 {
  margin-bottom: 10px;
}

.day-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

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

textarea {
  resize: vertical;
}

.plan-status {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: center;
  padding: 18px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plan-status strong {
  display: block;
  margin-top: 4px;
  font-size: 1.7rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.progress-bar {
  height: 14px;
  overflow: hidden;
  background: #e7ece8;
  border-radius: 999px;
}

.progress-bar div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.plans {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
}

.plan-card {
  padding: 18px;
}

.plan-card.current {
  border-color: var(--accent);
}

.plan-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.plan-card ul {
  padding-left: 18px;
  color: var(--muted);
}

dialog {
  width: min(680px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(30, 39, 34, 0.48);
}

.modal {
  padding: 22px;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  background: #edf1ee;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 18px 0 0;
}

.confirmation-text {
  font-size: 1.2rem;
  line-height: 1.5;
}

.link-button {
  width: 100%;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .panel-header,
  .limit-notice,
  .userbar,
  .stacked-mobile {
    align-items: stretch;
    flex-direction: column;
  }

  .goal-actions {
    width: 100%;
  }

  .goal-actions button {
    flex: 1;
  }

  .summary-grid,
  .content-grid,
  .goal-grid,
  .finance-indicators,
  .admin-metrics,
  .client-layout,
  .plan-status,
  .plans,
  .two-cols,
  .profile-form,
  .expense-form.expanded,
  .expense-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 22px;
  }

  .install-tip {
    margin-right: 0;
    max-width: none;
  }

  h1 {
    font-size: 2.4rem;
  }

  .auth-actions {
    grid-template-columns: 1fr;
  }
}
