/* Clients Dashboard — Vercel-inspired (Geist + shadow-as-border) */

:root {
  --bg: #ffffff;
  --text: #171717;
  --muted: #4d4d4d;
  --muted-2: #666666;
  --placeholder: #808080;
  --surface: #fafafa;
  --border-soft: #ebebeb;
  --link: #0072f5;
  --focus: hsla(212, 100%, 48%, 1);
  --shadow-border: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  --shadow-light: rgb(235, 235, 235) 0px 0px 0px 1px;
  --shadow-card: rgba(0,0,0,0.08) 0px 0px 0px 1px, rgba(0,0,0,0.04) 0px 2px 2px, #fafafa 0px 0px 0px 1px;
  --shadow-card-hover: rgba(0,0,0,0.10) 0px 0px 0px 1px, rgba(0,0,0,0.06) 0px 4px 8px, #fafafa 0px 0px 0px 1px;
  --red: #ff5b4f;
  --red-soft: #fff1f0;
  --pink: #de1d8d;
  --blue: #0a72ef;
  --green: #0a6e2e;
  --green-soft: #e6f7ed;
  --amber: #b85c00;
  --amber-soft: #fff4e5;
  --badge-bg: #ebf5ff;
  --badge-text: #0068d6;
  --purple-soft: #fdf4ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: Geist, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  font-feature-settings: "liga";
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono, .num { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; }
.num { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.96px;
  line-height: 1.25;
  color: var(--text);
}
h1 { font-size: 2rem; letter-spacing: -1.28px; }
h2 { font-size: 1.25rem; letter-spacing: -0.6px; }
h3 { font-size: 1rem; letter-spacing: -0.32px; }

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

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  border: none;
  box-shadow: var(--shadow-border);
  outline: none;
  width: 100%;
  font-feature-settings: "liga";
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
textarea { resize: vertical; min-height: 72px; }

.hidden { display: none !important; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface);
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-card);
}
.login-card h1 { margin-bottom: 8px; }
.login-card > p { margin-bottom: 28px; }
.login-card label { display: block; margin-bottom: 18px; }
.login-card label span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.login-card input { padding: 14px 16px; font-size: 16px; }

/* Buttons */
.btn-primary {
  background: var(--text);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s;
  letter-spacing: -0.16px;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; padding: 14px 16px; font-size: 15px; margin-top: 8px; }

.btn-ghost {
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-light);
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--surface); }

/* Solid red destructive CTA (used in type-to-confirm dialogs) */
.btn-danger-solid {
  background: var(--red);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-danger-solid:hover:not(:disabled) { opacity: 0.9; }
.btn-danger-solid:disabled {
  background: var(--surface);
  color: var(--placeholder);
  box-shadow: var(--shadow-light);
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-light);
  transition: background 0.15s;
}
.btn-sm:hover { background: var(--surface); }
.btn-sm.danger { color: var(--red); }
.btn-sm.danger:hover { background: var(--red-soft); }

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: rgba(0,0,0,0.08) 0px 1px 0px 0px;
}
.logo {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.32px;
  white-space: nowrap;
}
.tabs { display: flex; gap: 2px; }
#logout { margin-left: auto; }
.tab {
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab:hover { background: var(--surface); color: var(--text); }
.tab.active { color: var(--text); background: var(--surface); }

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

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

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Filter pills */
.filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
button.filter-pill {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: #fff;
  border: none;
  border-radius: 9999px;
  box-shadow: var(--shadow-light);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
button.filter-pill:hover { color: var(--text); }
button.filter-pill.active {
  background: var(--text);
  color: #fff;
  box-shadow: none;
}
.filter-count {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--surface);
  color: var(--muted-2);
}
button.filter-pill.active .filter-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Card */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.card.no-pad { padding: 0; overflow: hidden; }
.card-header { margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; letter-spacing: -0.4px; }

/* KPI grid */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.kpi-label {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -1.12px;
  font-variant-numeric: tabular-nums;
}
.kpi-value.danger { color: var(--red); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Two col */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.two-col > .card { margin-bottom: 0; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  font-size: 14px;
  transition: background 0.12s;
}
.card.no-pad .list-row + .list-row {
  box-shadow: rgba(0,0,0,0.06) 0px -1px 0px 0px;
}
.card:not(.no-pad) .list-row {
  padding: 12px 0;
}
.card:not(.no-pad) .list-row + .list-row {
  box-shadow: rgba(0,0,0,0.06) 0px -1px 0px 0px;
}
.list-row:hover { background: var(--surface); }
.list-row .primary { font-weight: 500; }
.list-row .sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.list-row .amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}
.list-row .actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.list-row.danger .amount { color: var(--red); }
.list-row .date {
  color: var(--muted);
  font-size: 12.5px;
  font-family: "Geist Mono", ui-monospace, monospace;
  white-space: nowrap;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--badge-bg);
  color: var(--badge-text);
  white-space: nowrap;
}
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--red-soft); color: var(--red); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.muted { background: var(--surface); color: var(--muted); box-shadow: var(--shadow-light); }
.badge.plan-monthly { background: var(--badge-bg); color: var(--badge-text); }
.badge.plan-quarterly { background: var(--purple-soft); color: var(--pink); }
.badge.plan-one-off { background: var(--amber-soft); color: var(--amber); }

/* Empty state */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  animation: fade 0.15s ease;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  z-index: 110;
  box-shadow: rgba(0,0,0,0.16) 0px 24px 48px, var(--shadow-border);
  animation: scale-in 0.18s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.modal h2 { margin-bottom: 18px; font-size: 1.25rem; letter-spacing: -0.6px; }
.modal label { display: block; margin-bottom: 14px; }
.modal label > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}
.modal label > .hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 5px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row label { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal-actions .spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: rgba(0,0,0,0.2) 0px 8px 24px;
  animation: slide-up 0.2s ease;
}
.toast.error { background: var(--red); }

/* Segmented control */
.seg-control {
  display: inline-flex;
  background: var(--surface);
  border-radius: 7px;
  padding: 3px;
  box-shadow: var(--shadow-light);
}
.seg-control button {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
}
.seg-control button:hover { color: var(--text); }
.seg-control button.active {
  background: #fff;
  color: var(--text);
  box-shadow: rgba(0,0,0,0.08) 0px 1px 2px;
}

/* Bar chart */
.bar-chart {
  display: flex;
  gap: 6px;
  height: 220px;
}
.bar-col {
  flex: 1;
  display: grid;
  grid-template-rows: 20px 1fr 22px;
  text-align: center;
  min-width: 0;
}
.bar-value {
  font-size: 10.5px;
  color: var(--muted);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  align-self: end;
  padding-bottom: 2px;
}
.bar {
  width: 100%;
  background: var(--text);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  align-self: end;
  transition: background 0.15s;
}
.bar:hover { background: var(--blue); }
.bar-label {
  font-size: 10.5px;
  color: var(--muted);
  font-family: "Geist Mono", ui-monospace, monospace;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: start;
  padding-top: 6px;
}
.bar-spacer { /* empty middle cell for zero-value months */
  background: transparent;
}

/* Errors */
.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}

/* Banner */
.banner {
  background: var(--amber-soft);
  color: var(--amber);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  box-shadow: var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.banner.danger { background: var(--red-soft); color: var(--red); }
.banner strong { font-weight: 600; }
.banner .banner-hint {
  font-size: 12px;
  opacity: 0.75;
  font-family: "Geist Mono", ui-monospace, monospace;
}

/* Reminder buttons */
.btn-sm.wa {
  background: #fff;
  color: #075e54;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: var(--shadow-light);
}
.btn-sm.wa:hover { background: #e7f7ef; color: #075e54; }

.btn-sm.email {
  background: #fff;
  color: var(--badge-text);
  box-shadow: var(--shadow-light);
}
.btn-sm.email:hover { background: var(--badge-bg); color: var(--badge-text); }

/* Services multi-select form */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-light);
}
.service-group { display: flex; flex-direction: column; gap: 4px; }
.service-group-name {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  margin-bottom: 4px;
}
.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  padding: 4px 0;
  margin-bottom: 0 !important;
}
.check span {
  display: inline;
  font-size: 13px !important;
  font-weight: 400 !important;
  margin-bottom: 0 !important;
  color: var(--text) !important;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--text);
}

/* Form section divider (for grouping related fields in a modal) */
.form-section {
  margin-top: 8px;
  padding-top: 18px;
  box-shadow: rgba(0,0,0,0.06) 0px -1px 0px 0px;
}
.form-section-title {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  margin-bottom: 12px;
}

/* Services chips on client rows */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.service-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--badge-bg);
  color: var(--badge-text);
  white-space: nowrap;
}

/* Fade in */
@media (prefers-reduced-motion: no-preference) {
  .kpi-card, .card, .login-card {
    animation: fade-in-up 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
  }
  .kpi-row .kpi-card:nth-child(1) { animation-delay: 0s; }
  .kpi-row .kpi-card:nth-child(2) { animation-delay: 0.06s; }
  .kpi-row .kpi-card:nth-child(3) { animation-delay: 0.12s; }
  .kpi-row .kpi-card:nth-child(4) { animation-delay: 0.18s; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Mobile */
@media (max-width: 720px) {
  .header {
    padding: 10px 14px 0;
    flex-wrap: wrap;
    gap: 0;
    align-items: center;
  }
  .logo { font-size: 15px; flex: 1; }
  #logout {
    margin-left: 0;
    padding: 6px 10px;
    font-size: 12.5px;
    flex-shrink: 0;
  }
  .tabs {
    order: 99;
    flex-basis: 100%;
    width: 100%;
    margin-top: 10px;
    gap: 0;
    padding-bottom: 4px;
  }
  .tab {
    flex: 1;
    padding: 8px 6px;
    font-size: 12.5px;
    text-align: center;
    border-radius: 6px 6px 0 0;
  }
  .tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: rgba(0,0,0,0.06) 0px 2px 0px 0px;
  }
  .main { padding: 18px 14px 60px; }
  .card { padding: 16px; }
  .card.no-pad { padding: 0; }
  .kpi-row { gap: 10px; grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 14px 14px; }
  .kpi-label { font-size: 10px; }
  .kpi-value { font-size: 20px; letter-spacing: -0.7px; }
  .kpi-sub { font-size: 11px; }
  /* Stack list rows: info on top, actions on bottom (right-aligned) */
  .list-row {
    grid-template-columns: 1fr;
    padding: 12px 14px;
    gap: 8px;
  }
  .card:not(.no-pad) .list-row { padding: 12px 0; }
  .list-row > .actions {
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
  }
  .list-row .amount {
    margin-right: auto;
    font-size: 14px;
  }
  .list-row .sub { font-size: 12px; gap: 6px; }
  .btn-sm { padding: 5px 9px; font-size: 12px; }
  h2 { font-size: 1.05rem; }
  /* Segmented control: full-width with equal buttons */
  .seg-control { width: 100%; box-sizing: border-box; }
  .seg-control button { padding: 6px 8px; font-size: 12px; flex: 1; }
  .row-between { gap: 10px; }
  .row-between h2 { font-size: 1.05rem; }
  /* Bar chart — compact at mobile */
  .bar-chart { gap: 3px; height: 200px; }
  .bar-col { grid-template-rows: 18px 1fr 20px; }
  .bar-label { font-size: 9px; padding-top: 4px; }
  .bar-value { font-size: 9px; }
  /* Forms: stack form-row on mobile */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-row label { margin-bottom: 14px; }
  .modal { padding: 20px; max-width: calc(100% - 24px); }
}
@media (max-width: 340px) {
  .kpi-row { grid-template-columns: 1fr; }
}
