:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef6f2;
  --ink: #17211f;
  --muted: #65736d;
  --line: #dbe6df;
  --teal: #0d8377;
  --teal-dark: #0b655d;
  --blue: #2f6fe4;
  --amber: #b87918;
  --rose: #c92b52;
  --shadow: 0 18px 45px rgba(23, 33, 31, 0.08);
  --shadow-soft: 0 8px 22px rgba(23, 33, 31, 0.06);
  --radius: 8px;
  --sidebar: 280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(13, 131, 119, 0.08), rgba(13, 131, 119, 0) 280px),
    radial-gradient(circle at top right, rgba(215, 242, 103, 0.16), transparent 360px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Aptos", "Trebuchet MS", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

body.auth-pending .sidebar,
body.auth-pending .app-shell,
body.auth-pending .toast,
body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 40px 24px;
  background:
    linear-gradient(135deg, rgba(244, 247, 245, 0.96), rgba(232, 237, 235, 0.92)),
    #eef2f0;
}

.login-bg-word {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(96px, 18vw, 240px);
  font-weight: 800;
  color: rgba(23, 33, 31, 0.06);
  line-height: 0.9;
  pointer-events: none;
  user-select: none;
}

.login-stage {
  width: min(1120px, 100%);
  min-height: 650px;
  position: relative;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(219, 230, 223, 0.84);
  box-shadow: 0 28px 80px rgba(23, 33, 31, 0.12);
  overflow: hidden;
}

.login-brand {
  position: absolute;
  top: 34px;
  left: 42px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  z-index: 2;
}

.login-brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #b6264f;
  border: 5px solid #f1c65f;
  font-size: 14px;
  font-weight: 900;
}

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

.login-brand strong {
  font-size: 14px;
}

.login-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.login-food {
  position: absolute;
  width: clamp(220px, 28vw, 380px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 16px 28px rgba(23, 33, 31, 0.14));
  pointer-events: none;
}

.login-food-left {
  left: -120px;
  bottom: 118px;
}

.login-food-right {
  right: -110px;
  top: 76px;
}

.login-card {
  width: min(330px, calc(100vw - 64px));
  position: relative;
  z-index: 2;
  padding: 48px 46px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(23, 33, 31, 0.08);
}

.login-heading {
  text-align: center;
  margin-bottom: 28px;
}

.login-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  line-height: 1.1;
}

.login-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.login-field {
  min-height: 44px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e7eeea;
  border-radius: 22px;
  background: #fbfcfb;
  padding: 0 12px;
}

.login-field svg {
  width: 16px;
  height: 16px;
  color: #9aa7a1;
  flex: 0 0 16px;
}

.login-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.password-toggle {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #7c8b84;
}

.password-toggle:hover {
  background: #eef6f2;
  color: var(--teal-dark);
}

.login-options {
  margin: 2px 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.login-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.login-options input {
  width: 13px;
  height: 13px;
  accent-color: #b6264f;
}

.login-options button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #7d5968;
  font-size: 11px;
}

.login-submit {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 22px;
  background: #d80a55;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(216, 10, 85, 0.22);
}

.login-submit:hover {
  background: #b90747;
}

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

button,
label.file-button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: linear-gradient(180deg, #0f1d19, #142821);
  color: #f7fbf8;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  box-shadow: 12px 0 35px rgba(15, 29, 25, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: #d7f267;
  color: #13201d;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: #b7c5bd;
  font-size: 13px;
}

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

.nav-links a {
  color: #ccd8d1;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  min-height: 46px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-links a.active,
.nav-links a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-links a:hover {
  transform: translateX(2px);
}

.nav-links svg,
button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 14px;
}

.sidebar-footer p {
  margin: 0 0 5px;
  color: #aab7b0;
  font-size: 13px;
}

.app-shell {
  margin-left: var(--sidebar);
  padding: 28px 30px 40px;
}

.page-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar,
.panel-heading,
.table-heading,
.topbar-actions,
.table-tools,
.field-row,
.payment-grid,
.chart-card,
.client-main,
.row-actions,
.reminder-item,
.ledger-item {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  text-transform: uppercase;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.topbar-actions,
.table-tools {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #108e80, var(--teal-dark));
  color: #ffffff;
  padding: 0 16px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(13, 131, 119, 0.2);
}

.primary-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.ghost-button,
.icon-button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.ghost-button {
  padding: 0 13px;
  font-weight: 750;
}

.ghost-button:hover,
.icon-button:hover,
.action-button:hover {
  border-color: rgba(13, 131, 119, 0.42);
  box-shadow: 0 10px 24px rgba(23, 33, 31, 0.08);
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
}

.subtle {
  background: var(--surface-soft);
}

.small {
  min-height: 36px;
  padding: 0 12px;
}

.full {
  width: 100%;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

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

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-height: 132px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: space-between;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
}

.metric p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.accent-teal {
  --accent: var(--teal);
}

.accent-blue {
  --accent: var(--blue);
}

.accent-amber {
  --accent: var(--amber);
}

.accent-rose {
  --accent: var(--rose);
}

.nutritionist-overview {
  margin-bottom: 16px;
}

.compact-select {
  min-width: 240px;
}

.overview-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.overview-mini-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.overview-mini-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.overview-mini-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
}

.nutritionist-actions {
  margin-top: 4px;
}

.nutritionist-client-list {
  display: grid;
  gap: 10px;
}

.nutritionist-client-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
}

.nutritionist-client-card strong {
  display: block;
  margin-bottom: 6px;
}

.nutritionist-client-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.nutritionist-client-card p + p {
  margin-top: 7px;
}

.clients-layout {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel h3 {
  margin-top: 3px;
  font-size: 20px;
}

.client-form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #33413d;
  font-size: 13px;
  font-weight: 750;
}

.field-row {
  gap: 12px;
}

.field-row label {
  flex: 1 1 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  color: var(--ink);
  padding: 10px 12px;
  outline: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
  background: #ffffff;
}

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

.client-buckets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.client-bucket {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.bucket-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
}

.bucket-heading h4 {
  margin: 2px 0 0;
  font-size: 16px;
}

.client-bucket-item {
  align-items: flex-start;
}

.bucket-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.bucket-actions .small {
  min-height: 30px;
  padding: 0 9px;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}

.bucket-actions .small svg {
  width: 14px;
  height: 14px;
}

.reminder-item {
  gap: 12px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.reminder-item strong,
.ledger-item strong {
  display: block;
}

.reminder-item p,
.ledger-item p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
  background: var(--surface-soft);
  color: #35413d;
}

.badge.danger {
  background: #ffe4e6;
  color: var(--rose);
}

.badge.warning {
  background: #fef3c7;
  color: #92400e;
}

.badge.success {
  background: #dcfce7;
  color: #166534;
}

.data-panel,
.payment-panel,
.history-panel,
.sync-panel {
  margin-bottom: 16px;
}

.sync-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.table-heading {
  justify-content: space-between;
  align-items: flex-end;
}

.search-box {
  min-width: min(320px, 100%);
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding-left: 12px;
}

.search-box input {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding-left: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f7faf8;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #f8fbf9;
}

.row-highlight {
  background: #ecfdf5;
  box-shadow: inset 4px 0 0 var(--teal);
}

.client-main {
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e6f6f3;
  color: var(--teal-dark);
  font-weight: 900;
}

.client-main p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  gap: 6px;
}

.action-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.action-button svg {
  width: 16px;
  height: 16px;
}

.payment-grid {
  align-items: stretch;
  gap: 16px;
}

.chart-card,
.ledger {
  flex: 1 1 0;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fbfcfa;
}

.chart-card {
  gap: 18px;
}

.donut {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--percent) * 1%), #e4ebe3 0);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  position: relative;
}

.donut::before {
  content: "";
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #fbfcfa;
  position: absolute;
}

.donut span {
  position: relative;
  z-index: 1;
  font-size: 24px;
  font-weight: 900;
}

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

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

.ledger-item {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ledger-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.form-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-status {
  margin: 6px 0 0;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.save-proof {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(13, 131, 119, 0.28);
  border-radius: var(--radius);
  background: #ecfdf5;
  color: #114d44;
  padding: 11px 12px;
  font-size: 13px;
}

.save-proof[hidden] {
  display: none;
}

.save-proof strong {
  font-size: 14px;
}

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

.summary-tile,
.sub-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.summary-tile {
  padding: 14px;
}

.summary-tile p {
  color: var(--muted);
  font-size: 12px;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(430px, 1.1fr) minmax(360px, 0.9fr);
  gap: 16px;
}

.sub-panel {
  padding: 15px;
}

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

.sub-heading h4 {
  margin: 0;
  font-size: 16px;
}

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

.timeline-list.compact {
  margin-top: 14px;
}

.timeline-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.timeline-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.timeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.timeline-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.empty-state {
  border: 1px dashed #b9c6bd;
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: #fbfcfa;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  background: #13201d;
  color: #ffffff;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  z-index: 20;
}

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

@media (max-width: 1180px) {
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clients-layout,
  .client-buckets,
  .overview-mini-grid,
  .payment-grid,
  .history-grid,
  .sync-row {
    grid-template-columns: 1fr;
    display: grid;
  }

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

@media (max-width: 820px) {
  :root {
    --sidebar: 0px;
  }

  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .nav-links {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-links a {
    justify-content: center;
    min-height: 48px;
  }

  .nav-links span,
  .sidebar-footer {
    display: none;
  }

  .app-shell {
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .table-heading,
  .field-row,
  .reminder-item,
  .ledger-item,
  .chart-card,
  .nutritionist-client-card,
  .timeline-top {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .table-tools {
    justify-content: flex-start;
    width: 100%;
  }

  .topbar-actions > *,
  .table-tools > * {
    flex: 1 1 auto;
  }

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

  .detail-summary {
    grid-template-columns: 1fr;
  }

  .bucket-actions {
    justify-content: flex-start;
  }

  .compact-select {
    min-width: 0;
    width: 100%;
  }

  .login-screen {
    padding: 18px;
  }

  .login-stage {
    min-height: 620px;
  }

  .login-brand {
    top: 22px;
    left: 22px;
  }

  .login-food-left {
    left: -150px;
    bottom: 80px;
  }

  .login-food-right {
    right: -150px;
    top: 90px;
  }

  .login-card {
    width: min(330px, calc(100vw - 48px));
    padding: 40px 28px;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .form-panel,
  .table-tools,
  .row-actions,
  .toast {
    display: none !important;
  }

  .app-shell {
    margin: 0;
    padding: 0;
  }

  .panel,
  .metric {
    box-shadow: none;
  }
}
