:root {
  color-scheme: light;
  --bg: #f6faf8;
  --panel: #ffffff;
  --panel-soft: #f0fdfa;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0fb37a;
  --brand-dark: #047857;
  --blue: #1e88ff;
  --orange: #ff7a00;
  --danger: #b91c1c;
  --shadow: 0 10px 24px rgba(2, 6, 23, 0.08);
  --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.05);
  font-family: Inter, "Noto Sans Hebrew", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--brand), var(--blue));
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover,
a.buttonlike:hover {
  box-shadow: 0 10px 20px rgba(30, 136, 255, 0.14);
  transform: translateY(-1px);
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--brand);
}

button.secondary.active {
  background: var(--panel-soft);
  color: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(15, 179, 122, 0.12);
}

button.danger {
  background: linear-gradient(145deg, #ef4444, #b91c1c);
}

button.icon {
  width: 40px;
  padding: 0;
}

a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

a.buttonlike {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--brand), var(--blue));
  color: #fff;
  text-decoration: none;
}

a.buttonlike.secondary {
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--blue);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 179, 122, 0.14);
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
  min-width: 0;
}

.sidebar {
  background: rgba(255, 255, 255, 0.82);
  border-inline-end: 1px solid var(--line);
  color: var(--ink);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(14px);
}

.brand {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  grid-row: span 2;
}

.brand b {
  color: var(--brand-dark);
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.brand span,
.userline {
  color: var(--muted);
  font-size: 12px;
}

.userline {
  margin-top: auto;
}

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

.nav button {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  justify-content: flex-start;
  text-align: right;
  box-shadow: none;
}

.nav button.active,
.nav button:hover {
  background: #ecfeff;
  border-color: #a5f3fc;
  box-shadow: none;
  color: #164e63;
  transform: none;
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.main:has(.clients-view) {
  width: 100%;
  max-width: none;
}

.topbar,
.toolbar,
.panel,
.card,
.login {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar,
.toolbar {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar b {
  color: var(--ink);
  font-size: 21px;
}

.topbar p {
  margin-top: 3px;
}

.panel {
  padding: 14px;
}

.panel-soft {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.card {
  min-height: 132px;
  padding: 15px;
  display: grid;
  gap: 8px;
  text-align: start;
  color: inherit;
}

button.card {
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow);
  font-weight: inherit;
}

button.card:hover,
.row:hover {
  border-color: var(--brand);
  box-shadow: 0 12px 26px rgba(15, 179, 122, 0.12);
}

.card h3,
.panel h2 {
  margin: 0;
}

.card p,
.muted {
  color: var(--muted);
  margin: 0;
}

.section-title {
  margin: 2px 0 0;
  font-size: 17px;
}

.priority-leads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.priority-lead-card {
  min-height: 126px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  text-decoration: none;
}

.priority-lead-card.urgent {
  border-color: #fdba74;
  background: #fff7ed;
}

.priority-lead-card b,
.priority-lead-card small {
  overflow-wrap: anywhere;
}

.priority-lead-card small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.role-guide,
.login-credentials {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.role-guide > div,
.login-credentials > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.login-credentials {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.login-credentials span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-credentials b {
  overflow-wrap: anywhere;
}

.status-row,
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters {
  align-items: center;
}

.filters input {
  min-width: min(240px, 100%);
  flex: 1 1 180px;
}

.filters select {
  flex: 0 1 170px;
}

#leadSearch {
  flex-basis: 100%;
}

#sourceFilter {
  flex: 1 1 160px;
}

.filters label.chip {
  min-width: 142px;
}

.chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  white-space: nowrap;
  width: auto;
}

button.chip {
  box-shadow: none;
}

.chip:hover {
  transform: none;
  box-shadow: none;
}

.chip.active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: 0 7px 16px rgba(4, 120, 87, 0.22);
  outline: 2px solid rgba(15, 179, 122, 0.22);
}

.chip input {
  width: auto;
}

.tooltip {
  width: 20px;
  height: 20px;
  border: 1px solid #bae6fd;
  border-radius: 50%;
  background: #ecfeff;
  color: #0369a1;
  display: inline-grid;
  place-items: center;
  position: relative;
  cursor: help;
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

.tooltip::after {
  content: attr(data-tooltip);
  width: min(280px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
  padding: 9px 10px;
  position: absolute;
  inset-block-end: calc(100% + 8px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
  z-index: 20;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: start;
}

.tooltip:hover::after,
.tooltip:focus::after {
  opacity: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr);
  gap: 14px;
  align-items: start;
}

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

#leadList {
  grid-template-columns: 1fr;
  gap: 8px;
}

.row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 7px;
  cursor: pointer;
  color: inherit;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

a.row {
  text-decoration: none;
}

.row.active {
  border-color: var(--brand);
  background: var(--panel-soft);
  outline: 2px solid rgba(15, 179, 122, 0.18);
}

.row.urgent {
  border-color: #fdba74;
  background: #fff7ed;
}

.row-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.row-main b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.avatar.small {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar.large {
  width: 74px;
  height: 74px;
  font-size: 24px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  border: 1px solid #dbe3ef;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.type-nutrition,
.badge.status-REL,
.badge.status-CLNT,
.badge.status-CL,
.badge.status-CLIENT {
  background: #ecfeff;
  color: #164e63;
  border-color: #a5f3fc;
}

.badge.type-recruitment,
.badge.status-MESSAGES,
.badge.status-VIDEO,
.badge.status-SCHED_CALL,
.badge.status-CALL,
.badge.status-DIST,
.badge.status-SUP,
.badge.status-LE {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.badge.type-cosmetics,
.badge.status-MEET_WANTS_ONLINE,
.badge.status-MEET_WANTS_PHYS,
.badge.status-MEETING_DONE,
.badge.status-NEW {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.badge.status-NO_ANSWER,
.badge.status-MEETING_NO_SHOW,
.badge.status-NO_INT,
.badge.status-BAD,
.badge.status-IRR,
.badge.status-NA,
.badge.status-NINT,
.badge.status-CL_LEFT {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 10px;
}

.search-field {
  display: grid;
  gap: 6px;
}

.search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-field input {
  min-height: 42px;
}

.compact-form,
.invoice-form {
  display: grid;
  gap: 10px;
}

.clients-workspace {
  grid-template-columns: 1fr;
  align-items: start;
}

.clients-list-panel {
  width: 100%;
}

.clients-list-panel #newClientForm {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.clients-list-panel #newClientForm .form-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.clients-list-panel #newClientForm button {
  min-width: 170px;
  height: 42px;
}

.clients-list-panel .search-field {
  max-width: 560px;
}

.client-detail {
  align-content: start;
}

.client-list {
  max-height: none;
  overflow: visible;
  padding-inline-end: 0;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.client-list .row {
  min-height: 132px;
  align-content: space-between;
}

.client-list .row-main {
  align-items: start;
}

.client-list .row-main b {
  font-size: 19px;
  line-height: 1.2;
}

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

.metrics.compact-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.metrics b {
  color: var(--brand-dark);
  font-size: 22px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  color: var(--brand-dark);
  padding: 8px;
}

.chart.empty {
  display: grid;
  place-items: center;
  min-height: 180px;
}

.tanita-story {
  display: grid;
  gap: 12px;
}

.tanita-hero-insight {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.tanita-hero-insight h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.tanita-hero-insight p {
  margin: 0;
  color: #334155;
  font-weight: 700;
  line-height: 1.55;
}

.tanita-scoreboard {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tanita-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tanita-insight-card,
.trend-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 12px;
  display: grid;
  gap: 7px;
}

.tanita-insight-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tanita-insight-card b {
  color: var(--brand-dark);
  line-height: 1.25;
}

.tanita-insight-card p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.trend-card .chart {
  height: 190px;
}

.chart-grid-line {
  stroke: #e2e8f0;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chart-legend span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
}

.chart-legend b,
.chart-legend em {
  font: inherit;
}

.chart-legend em {
  color: var(--muted);
}

.chart-note {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.measurement-date {
  max-width: 260px;
}

.measurement-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.measurement-history h3 {
  margin: 0;
  font-size: 18px;
}

.measurement-history-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-inline-end: 2px;
}

.measurement-history-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.measurement-history-row b {
  color: var(--brand-dark);
}

.questionnaire-extra {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.questionnaire-extra[hidden] {
  display: none;
}

.submodal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.submodal[hidden] {
  display: none;
}

.submodal-panel {
  width: min(900px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  max-height: min(760px, calc(100dvh - 36px));
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.submodal-panel > .row-main:first-child {
  position: sticky;
  top: -16px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  margin: -16px -16px 0;
  padding: 14px 16px;
  backdrop-filter: blur(12px);
}

.tanita-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 10px;
}

.tanita-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  min-height: 168px;
  padding: 12px;
  display: grid;
  gap: 8px;
  justify-items: center;
  align-content: start;
}

.tanita-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #020617;
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0;
}

.tanita-label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  text-align: center;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.25;
}

.tanita-input {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.tanita-input input {
  text-align: center;
  font-weight: 900;
}

.tanita-input em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.referral-row {
  cursor: default;
}

.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 42px;
  gap: 8px;
  align-items: center;
}

.order-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
  max-height: min(520px, 58vh);
  overflow: auto;
  padding: 2px 2px 6px;
  align-items: stretch;
}

.order-product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: row-reverse;
  min-height: 204px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.order-product-card.selected {
  border-color: var(--brand);
  background: var(--panel-soft);
  outline: 2px solid rgba(15, 179, 122, 0.18);
}

.order-product-image {
  flex: 0 0 120px;
  min-height: 204px;
  background: #f8fafc;
  border-inline-end: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  color: #0369a1;
  font-size: 22px;
  font-weight: 900;
}

.order-product-image img {
  width: 100%;
  height: 170px;
  max-width: 92px;
  max-height: 170px;
  object-fit: contain;
  display: block;
}

.order-product-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px;
  display: grid;
  grid-template-rows: minmax(52px, auto) auto auto;
  gap: 8px;
  align-content: start;
}

.order-product-prices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.order-product-prices span {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 7px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.order-product-prices b {
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.order-product-prices em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.order-discount-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.discount-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.order-profit-summary {
  margin-top: 4px;
}

.inventory-page {
  gap: 10px;
}

.inventory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inventory-actions button {
  min-width: 142px;
}

.inventory-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-top: 2px;
}

.inventory-section-head h2 {
  margin: 0;
  font-size: 18px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
}

.inventory-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.inventory-card.is-busy {
  opacity: 0.68;
}

.inventory-card.highlighted,
.row.highlighted {
  border-color: var(--blue);
  outline: 3px solid rgba(30, 136, 255, 0.18);
}

.product-image {
  background: #fff;
  color: #0369a1;
  display: grid;
  place-items: center;
  height: 180px;
  overflow: hidden;
  padding: 0;
  border-bottom: 1px solid var(--line);
  font-size: 24px;
  font-weight: 900;
}

.product-image.small {
  height: 128px;
}

.product-image img {
  max-width: 100%;
  max-height: 100%;
  height: 180px;
  object-fit: fill;
  display: block;
}

.product-body {
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.product-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.product-title b {
  line-height: 1.18;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.product-title span,
.profit-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-details {
  display: grid;
  gap: 8px;
}

.product-details summary {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  list-style: none;
  padding: 8px 10px;
  text-align: center;
}

.product-details summary::-webkit-details-marker {
  display: none;
}

.product-details[open] summary {
  background: var(--panel-soft);
  border-color: var(--brand);
}

.product-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.product-facts span {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 7px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.product-facts b {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
}

.product-facts em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.product-edit-btn {
  width: 100%;
}

.product-admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 12px;
  align-items: start;
}

.product-admin-list,
.product-admin-form {
  min-width: 0;
}

.product-admin-results {
  max-height: min(560px, 58vh);
  overflow: auto;
  padding-inline-end: 2px;
}

.product-admin-row {
  cursor: default;
}

.global-edit-warning {
  display: grid;
  gap: 4px;
  background: #fff7ed;
  border-color: #fdba74;
}

.global-edit-warning b {
  color: #9a3412;
}

.global-edit-warning span {
  color: #7c2d12;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.product-image-upload-field {
  align-content: start;
}

.product-image-preview {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.product-image-preview img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.tier-price-editor {
  display: grid;
  gap: 10px;
}

.tier-price-editor > div:first-child {
  display: grid;
  gap: 3px;
}

.tier-price-editor b {
  color: var(--brand-dark);
}

.tier-price-editor span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.tier-price-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.qty-control {
  display: grid;
  grid-template-columns: 44px minmax(44px, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.qty-control input {
  min-height: 40px;
  padding: 0 8px;
  text-align: center;
  font-weight: 900;
}

.qty-control button {
  min-height: 40px;
}

.tier-table {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 4px 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 6px;
  font-size: 11px;
}

.tier-table span {
  color: var(--muted);
  font-weight: 900;
}

.tier-table b,
.tier-table em {
  font-style: normal;
  font-weight: 800;
}

.tier-table em {
  color: var(--brand-dark);
}

.low-stock {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.modal {
  width: min(720px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.modal.detail-modal {
  width: min(1120px, calc(100vw - 72px));
  height: auto;
  max-width: calc(100vw - 72px);
  max-height: calc(100vh - 72px);
  margin: 36px auto;
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(3px);
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-panel > .row-main:first-child,
.detail-modal #leadForm > .row-main:first-child {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  margin: -16px -16px 0;
  padding: 14px 16px;
  backdrop-filter: blur(12px);
}

.detail-modal .client-detail > .panel:first-child {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.detail-modal .modal-panel {
  max-height: calc(100vh - 72px);
  overflow: auto;
}

.detail-modal .client-detail {
  grid-template-columns: 1fr;
  align-items: start;
}

.detail-modal .client-detail > .panel:first-child {
  grid-column: auto;
}

@media (min-width: 1100px) {
  .modal.detail-modal {
    width: min(1500px, calc(100vw - 72px));
    max-width: calc(100vw - 72px);
  }

  .detail-modal .modal-panel {
    padding: 20px;
  }

  .modal-panel > .row-main:first-child,
  .detail-modal #leadForm > .row-main:first-child {
    margin: -20px -20px 0;
    padding: 16px 20px;
  }

  .detail-modal .order-product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-height: min(560px, calc(100vh - 360px));
    overflow-x: hidden;
  }

  .detail-modal .order-product-card {
    min-height: 190px;
  }

  .detail-modal .order-product-image {
    flex-basis: 116px;
    min-height: 190px;
    padding: 12px;
  }

  .detail-modal .order-product-image img {
    width: 100%;
    height: 166px;
    max-width: 92px;
    max-height: 166px;
    object-fit: contain;
  }

  .detail-modal .order-product-body {
    padding: 12px;
    gap: 10px;
  }
}

.detail-modal #leadDetail {
  grid-template-columns: 1fr;
  align-items: start;
}

.detail-modal #leadForm {
  position: static;
  align-self: start;
}

.modal-panel h2 {
  margin: 0;
}

.modal-panel > .row-main {
  align-items: start;
}

.invoice-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #f8fafc;
}

.invoice-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  font-weight: 800;
}

.public-page {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.public-header {
  min-height: 120px;
  border-radius: 8px;
  padding: 20px;
  background: linear-gradient(145deg, var(--brand-dark), var(--blue));
  color: #fff;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.public-header b {
  font-size: 28px;
}

.public-header p {
  margin: 4px 0 0;
}

.public-chart {
  height: 260px;
}

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

.profile-head h2 {
  margin: 0;
}

.autosave-msg {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  font-size: 13px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login {
  width: min(420px, 100%);
  padding: 24px;
  display: grid;
  gap: 14px;
}

.login-logo {
  width: 108px;
  height: 108px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

.empty,
.error {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

@media (max-width: 980px) {
  body {
    overflow-x: hidden;
  }

  .shell,
  .split,
  .grid.cols-2,
  .grid.cols-3,
  .form-row,
  .metrics {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    height: auto;
    padding: 12px;
    min-width: 0;
    overflow: hidden;
  }

  .brand {
    grid-template-columns: 28px minmax(0, 1fr);
    padding: 8px 10px;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }

  .nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav button {
    flex: 0 0 auto;
  }

  .userline {
    display: none;
  }

  #logoutBtn {
    align-self: stretch;
  }

  .main {
    padding: 12px;
    min-width: 0;
    overflow: hidden;
  }

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

  .tanita-scoreboard,
  .tanita-insight-grid,
  .product-admin-layout,
  .tier-price-grid,
  .role-guide,
  .login-credentials {
    grid-template-columns: 1fr;
  }

  .measurement-history-list {
    max-height: none;
    overflow: visible;
  }

  .submodal {
    padding: 0;
    align-items: stretch;
  }

  .submodal-panel {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  }

  .submodal-panel > .row-main:first-child {
    top: calc(-12px - env(safe-area-inset-top));
    margin: calc(-12px - env(safe-area-inset-top)) -12px 0;
    padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  }

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

  .client-list {
    max-height: none;
    grid-template-columns: 1fr;
  }

  .clients-list-panel #newClientForm {
    grid-template-columns: 1fr;
  }

  .order-item,
  .invoice-line {
    grid-template-columns: 1fr;
  }

  .order-product-grid {
    grid-template-columns: 1fr;
    max-height: min(560px, 62vh);
  }

  .order-product-card {
    flex-direction: row-reverse;
    min-height: 196px;
  }

  .order-product-image {
    flex-basis: 104px;
    min-height: 196px;
    padding: 8px;
  }

  .order-product-image img {
    height: 158px;
    max-width: 82px;
    max-height: 158px;
  }

  .product-title b {
    font-size: 16px;
  }

  .qty-control {
    grid-template-columns: 42px minmax(42px, 1fr) 42px;
    gap: 8px;
  }

  .product-image {
    min-height: 180px;
  }

  .inventory-section-head {
    display: grid;
    align-items: start;
  }

  .inventory-actions button {
    flex: 1 1 150px;
  }

  .modal {
    width: 100vw;
    width: 100dvw;
    max-width: 100vw;
    max-width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
  }

  .modal.detail-modal {
    width: 100vw;
    width: 100dvw;
    max-width: 100vw;
    max-width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    inset: 0;
  }

  .modal-panel {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  }

  .detail-modal [data-close-lead-dialog],
  .detail-modal [data-close-client-dialog] {
    position: sticky;
    top: calc(8px + env(safe-area-inset-top));
    z-index: 20;
    justify-self: end;
  }

  .detail-modal .row-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    max-width: 100%;
    min-width: 0;
  }

  .detail-modal .row-main > *,
  .detail-modal .actions {
    min-width: 0;
  }

  .detail-modal .actions {
    justify-content: end;
  }

  .detail-modal .muted,
  .detail-modal #shareMsg {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .detail-modal #leadDetail,
  .detail-modal .client-detail {
    grid-template-columns: 1fr;
    max-width: 100%;
    overflow-x: hidden;
  }

  .detail-modal #leadForm {
    position: static;
  }

  .detail-modal .panel,
  .detail-modal form,
  .detail-modal .list,
  .detail-modal .row,
  .detail-modal .metrics,
  .detail-modal .order-product-grid {
    max-width: 100%;
    min-width: 0;
  }

  .detail-modal .order-product-card {
    flex-direction: column;
    min-height: 318px;
    height: auto;
  }

  .detail-modal .order-product-image {
    flex-basis: auto;
    min-height: 132px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-modal .order-product-image img {
    width: auto;
    height: 118px;
    max-width: 150px;
    max-height: 118px;
  }

  .public-page {
    padding: 12px;
  }
}
