:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --panel-surface: #f7fbfd;
  --soft: #f1f5f9;
  --input-surface: #ffffff;
  --text: #111827;
  --muted: #687789;
  --line: #e5e7eb;
  --panel-line: #d7e5ec;
  --brand: #0ea5a4;
  --brand-dark: #0f766e;
  --accent: #22c55e;
  --danger: #be123c;
  --warning: #9a4d00;
  --good: #047857;
  --glass-surface: rgba(255, 255, 255, 0.74);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(15, 23, 42, 0.08);
  --nav-surface: rgba(255, 255, 255, 0.82);
  --nav-shadow: 0 -18px 44px rgba(15, 23, 42, 0.12);
  --shadow: 0 16px 36px rgba(8, 16, 26, 0.08);
}

html[data-theme="dark"] {
  --bg: #050807;
  --surface: #070d0c;
  --panel-surface: #101817;
  --soft: #18211f;
  --input-surface: #111a18;
  --text: #f4fbfa;
  --muted: #b9c8c5;
  --line: #2c3b38;
  --panel-line: rgba(105, 231, 220, 0.2);
  --brand: #13aaa1;
  --brand-dark: #6ee7dc;
  --accent: #22c55e;
  --danger: #fb7185;
  --warning: #fbbf24;
  --good: #5eead4;
  --glass-surface: rgba(7, 11, 10, 0.78);
  --glass-strong: rgba(17, 25, 23, 0.92);
  --glass-line: rgba(110, 231, 220, 0.16);
  --nav-surface: rgba(13, 18, 17, 0.9);
  --nav-shadow: 0 -20px 52px rgba(0, 0, 0, 0.48);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

button:disabled {
  opacity: 0.56;
  cursor: default;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 1.75rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.app {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 18px 18px 96px;
  background: var(--surface);
  min-height: 100vh;
}

.app > main {
  padding-top: 12px;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.auth-view[hidden] {
  display: none;
}

.auth-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-message {
  color: var(--muted);
  line-height: 1.45;
}

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

.auth-method-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.auth-method-button {
  min-height: 40px;
  border-color: transparent;
  color: var(--brand-dark);
  background: transparent;
}

.auth-method-button.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.auth-step {
  display: grid;
  gap: 12px;
}

.auth-step[hidden] {
  display: none;
}

.otp-target,
.otp-timer {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.35;
}

.otp-target {
  color: var(--brand-dark);
}

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

.auth-message {
  min-height: 22px;
  margin: 12px 0 0;
  font-weight: 900;
}

.auth-message.bad {
  color: var(--danger);
}

.auth-message.ok {
  color: var(--good);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.header {
  position: sticky;
  top: 0;
  z-index: 9;
  display: grid;
  gap: 0;
  margin: -18px -18px 10px;
  border-bottom: 1px solid var(--glass-line);
  padding: calc(8px + env(safe-area-inset-top)) 18px 9px;
  background: var(--glass-surface);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
}

.eyebrow {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--glass-strong);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 0.95rem;
}

.summary-head {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.stats-period {
  display: grid;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stats-period label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.stats-period select {
  width: auto;
  min-width: 142px;
  min-height: 36px;
  border-color: var(--line);
  padding: 7px 34px 7px 10px;
  color: var(--brand-dark);
  background-color: rgba(255, 255, 255, 0.94);
  font-size: 0.86rem;
  font-weight: 900;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel,
.client-card,
.payment-card {
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  background: var(--panel-surface);
  box-shadow: 0 18px 40px rgba(8, 16, 26, 0.07);
}

.panel {
  padding: 14px;
}

.list-panel {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.summary-panel {
  margin-top: 10px;
}

.tools {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.search-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.search-field input {
  border: 0;
  border-radius: 10px;
  background-color: var(--soft);
  padding-left: 38px;
  background-image:
    radial-gradient(circle at 14px 20px, transparent 5px, #9ca3af 5px, #9ca3af 6px, transparent 7px),
    linear-gradient(45deg, transparent 0 60%, #9ca3af 60% 70%, transparent 70%);
  background-position: 0 0, 20px 25px;
  background-size: 32px 44px, 12px 12px;
  background-repeat: no-repeat;
}

.list-filter-menu-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.filter-button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  padding: 0;
  font-size: 1.1rem;
}

.filter-button.active {
  color: var(--brand-dark);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}

.filter-button.has-filter::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.grid,
.form,
.client-list,
.payment-list {
  display: grid;
  gap: 10px;
}

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

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.client-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 12px;
  background: var(--soft);
}

.client-switch-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  padding: 8px 10px;
}

.client-switch-button.active {
  color: var(--text);
  background: var(--glass-strong);
  box-shadow: 0 6px 16px rgba(8, 16, 26, 0.08);
}

.client-switch-button span {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  color: inherit;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.8rem;
  font-weight: 900;
}

.client-switch-button:not(.active) span {
  background: var(--line);
}

.list-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: min(320px, calc(100vw - 44px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  box-shadow: 0 18px 42px rgba(8, 16, 26, 0.16);
}

.list-options[hidden] {
  display: none;
}

.list-options select {
  width: 100%;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--input-surface);
  color: var(--text);
  font-weight: 900;
}

.toggle-line input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--brand);
}

.date-photo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 150px);
  gap: 10px;
  align-items: end;
}

.date-wheel-picker {
  --date-wheel-height: 116px;
  --date-wheel-item-height: 28px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, #f7fcff 0%, #ffffff 50%, #f7fcff 100%);
  padding: 6px 8px;
  overflow: hidden;
}

.date-wheel-picker::before {
  position: absolute;
  top: 50%;
  left: 8px;
  right: 8px;
  height: var(--date-wheel-item-height);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  content: "";
  pointer-events: none;
  transform: translateY(-50%);
}

.date-wheel {
  height: var(--date-wheel-height);
  min-width: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: ns-resize;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc((var(--date-wheel-height) - var(--date-wheel-item-height)) / 2) 0;
  scroll-snap-type: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: none;
  user-select: none;
}

.date-wheel::-webkit-scrollbar {
  display: none;
}

.date-wheel:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.wheel-option {
  display: grid;
  height: var(--date-wheel-item-height);
  place-items: center;
  overflow: hidden;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.1;
  opacity: 0.28;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: scale(0.92);
  transition: opacity 80ms ease, transform 80ms ease, color 80ms ease;
  will-change: opacity, transform;
}

.wheel-option.near {
  opacity: 0.55;
  transform: scale(0.98);
}

.wheel-option.selected {
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 900;
  opacity: 1;
  transform: scale(1);
}

.wheel-option.far {
  opacity: 0.22;
}

.photo-field {
  align-self: stretch;
}

.photo-upload-button {
  display: grid;
  min-height: 120px;
  align-content: center;
  justify-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
  color: var(--brand-dark);
  background: #f7fcff;
  box-shadow: none;
}

.photo-preview {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 12px;
  color: var(--brand-dark);
  background-color: #e0f2fe;
  background-position: center;
  background-size: cover;
  font-size: 1.6rem;
  font-weight: 900;
}

.photo-upload-button strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove-button {
  min-height: 34px;
  border-color: #fecdd3;
  border-radius: 9px;
  padding: 7px 9px;
  color: var(--danger);
  background: #fff1f2;
  font-size: 0.82rem;
}

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

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

.payment-card .row-actions {
  justify-content: flex-end;
}

.payment-card .row-actions button {
  flex: 0 1 280px;
}

.btn-light {
  color: var(--text);
  background: #eef7fb;
  border-color: var(--line);
}

.btn-warning {
  color: var(--warning);
  background: #fff7ed;
  border-color: #fed7aa;
}

.btn-danger {
  color: var(--danger);
  background: #fff1f2;
  border-color: #fecdd3;
}

.btn-pdf {
  color: var(--brand-dark);
  background: #e8f7ff;
  border-color: #91d5f6;
}

.client-card,
.payment-card {
  padding: 12px;
}

.payment-card.paid {
  border-color: var(--brand);
  background: rgba(20, 184, 166, 0.1);
}

.client-card.selected {
  border-color: #54bfe2;
  background: var(--soft);
}

.list-client-card {
  padding: 12px;
}

.list-client-card .card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 160px);
  align-items: center;
}

.client-open-button {
  min-height: 40px;
  padding: 8px 14px;
}

.client-section {
  display: grid;
  gap: 8px;
}

.client-section + .client-section {
  margin-top: 6px;
}

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

.section-head h3 {
  margin: 0;
}

.section-count {
  display: inline-grid;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  color: var(--brand-dark);
  background: #d9f1fb;
  font-size: 0.82rem;
  font-weight: 900;
}

.section-list {
  display: grid;
  gap: 8px;
  border-top: 0;
}

.client-chat-row {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 76px;
  border: 1px solid #d8e8ed;
  border-radius: 18px;
  padding: 10px 12px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(239, 249, 249, 0.96)),
    #f4fafb;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.055);
  text-align: left;
}

.client-chat-row::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: rgba(14, 165, 164, 0.44);
  content: "";
}

.client-chat-row:hover {
  filter: none;
  border-color: rgba(14, 165, 164, 0.28);
  background:
    linear-gradient(135deg, #ffffff, rgba(228, 247, 246, 0.98)),
    #eefafa;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.1);
}

.client-chat-row.selected {
  border-color: rgba(14, 165, 164, 0.55);
  background:
    linear-gradient(135deg, rgba(232, 250, 247, 0.98), rgba(214, 246, 239, 0.98)),
    #e8f8f5;
  box-shadow: 0 14px 30px rgba(14, 165, 164, 0.16);
}

.client-chat-row.completed {
  border-color: #d6eadf;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(238, 250, 244, 0.98)),
    #f2fbf6;
}

.client-chat-row.completed::before {
  background: rgba(34, 197, 94, 0.4);
}

.client-chat-row.overdue {
  border-color: #f4d7dd;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 244, 246, 0.98)),
    #fff7f8;
}

.client-chat-row.overdue::before {
  background: rgba(190, 18, 60, 0.36);
}

.client-avatar {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #0ea5a4, #0f766e 58%, #111827);
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.18);
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: 0;
}

.client-avatar.completed {
  background: linear-gradient(135deg, #22c55e, #0f766e);
  box-shadow: 0 8px 16px rgba(34, 197, 94, 0.16);
}

.client-avatar.danger {
  background: linear-gradient(135deg, #f43f5e, #7f1d1d);
  box-shadow: 0 8px 16px rgba(190, 18, 60, 0.16);
}

.chat-main,
.chat-side {
  display: grid;
  min-width: 0;
}

.chat-title,
.chat-preview,
.chat-side-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title {
  font-size: 1rem;
  font-weight: 900;
}

.chat-preview {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.22;
}

.chat-preview.muted {
  color: #7b8794;
  font-size: 0.82rem;
}

.chat-side {
  justify-items: end;
  align-self: stretch;
  align-content: center;
  gap: 6px;
  max-width: 112px;
}

.chat-side-value {
  color: #4b5563;
  font-size: 0.82rem;
  font-weight: 800;
}

.chat-side-value.ok {
  color: var(--good);
}

.chat-side-value.bad {
  color: var(--danger);
}

.chat-badge {
  display: inline-grid;
  min-width: 26px;
  min-height: 22px;
  place-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--brand-dark);
  background: rgba(14, 165, 164, 0.1);
  font-size: 0.72rem;
  font-weight: 900;
}

.chat-badge.ok {
  color: var(--good);
  background: #dcfce7;
}

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

.section-empty {
  padding: 12px 8px;
}

.compact-card {
  padding: 10px;
  box-shadow: none;
}

.compact-card .name {
  font-size: 0.98rem;
}

.product-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.compact-products {
  margin-top: 8px;
}

.product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 0;
  width: 100%;
  border-color: var(--line);
  padding: 9px 10px;
  color: var(--text);
  background: #f7fcff;
  text-align: left;
}

.product-row:hover {
  filter: none;
  border-color: #79cae8;
  background: #ebf8ff;
}

.product-row.selected {
  border-color: var(--line);
  background: #f7fcff;
}

.product-row.closed {
  border-color: var(--brand);
  background: rgba(20, 184, 166, 0.12);
}

.product-row.closed.selected {
  border-color: var(--brand);
  background: rgba(20, 184, 166, 0.12);
}

.product-row strong,
.product-row small,
.product-row em {
  display: block;
}

.product-row strong,
.product-row em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.product-row em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 900;
}

.product-row em.ok {
  color: var(--brand-dark);
}

.product-row em.bad {
  color: var(--danger);
}

.product-row.compact {
  padding: 7px 9px;
}

.product-row.compact small {
  display: none;
}

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

.product-row-static:hover {
  border-color: var(--brand);
  background: #e8f7ff;
}

.product-payments-section {
  gap: 9px;
}

.product-payments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.product-back-button {
  display: inline-grid;
  min-width: 58px;
  min-height: 40px;
  place-items: center;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--brand-dark);
  background: #eef7fb;
  box-shadow: none;
  font-size: 0.92rem;
  font-weight: 900;
}

.product-back-button:hover {
  border-color: var(--brand);
  background: #e8f7ff;
  filter: none;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.compact-row.bottom {
  margin-top: 6px;
}

.compact-open {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.card-head,
.next-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

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

.name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
}

.meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.meta.bad {
  color: var(--danger);
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  color: #334155;
  background: #e7edf5;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.pill.ok {
  color: #fff;
  background: var(--brand);
}

.pill.bad {
  color: var(--danger);
  background: #ffe4e6;
}

.money-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.money-box {
  min-width: 0;
  border-radius: 8px;
  background: #f3f9fc;
  padding: 9px;
}

.money-box span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.money-box strong {
  display: block;
  margin-top: 4px;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.detail-tabs::-webkit-scrollbar {
  display: none;
}

.detail-tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  color: #4b5563;
  background: #f3f4f6;
  box-shadow: none;
  font-size: 0.92rem;
  font-weight: 900;
  white-space: nowrap;
}

.detail-tab-button.active {
  color: #ffffff;
  background: var(--brand-dark);
  box-shadow: none;
}

.detail-section {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-section-head h3 {
  margin: 0;
}

.detail-section-head span {
  display: inline-grid;
  min-width: 28px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  color: var(--brand-dark);
  background: #e0f2fe;
  font-size: 0.8rem;
  font-weight: 900;
}

.product-group-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.product-group-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: #4b5563;
  background: #f3f4f6;
  box-shadow: none;
  font-size: 0.92rem;
  font-weight: 900;
  white-space: nowrap;
}

.product-group-tab.active {
  color: #ffffff;
  background: var(--brand-dark);
  box-shadow: none;
}

.product-group-tab span {
  display: inline-grid;
  min-width: 22px;
  min-height: 20px;
  place-items: center;
  border-radius: 999px;
  color: var(--brand-dark);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
  font-weight: 900;
}

.product-group-tab.active span {
  color: var(--brand-dark);
  background: rgba(255, 255, 255, 0.9);
}

.product-group-tabs + .product-list {
  margin-top: 0;
}

.product-empty {
  margin-top: 0;
}

.summary-lines {
  display: grid;
  gap: 8px;
}

.summary-lines div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.summary-lines span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.summary-lines strong {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-viewer {
  display: grid;
  gap: 8px;
}

.photo-viewer img {
  display: block;
  width: 100%;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: contain;
  background: #f7fcff;
}

.photo-viewer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.next-line {
  align-items: center;
  flex-wrap: wrap;
}

.empty {
  padding: 22px 10px;
  color: var(--muted);
  text-align: center;
}

.edit-banner {
  border: 1px solid #91d5f6;
  border-radius: 8px;
  background: #effbff;
  color: var(--brand-dark);
  padding: 10px;
  font-weight: 900;
}

.detail-title {
  margin: 14px 0 4px;
}

.back-button {
  display: inline-grid;
  width: 58px;
  min-width: 58px;
  min-height: 40px;
  place-items: center;
  border-radius: 10px;
  padding: 0;
  color: var(--brand-dark);
  background: #eef7fb;
  font-size: 1.35rem;
  line-height: 1;
}

.detail-heading {
  display: grid;
  align-items: start;
  gap: 10px;
}

.detail-heading .btn-light {
  min-height: 38px;
  padding: 8px 10px;
}

.detail-heading-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.detail-action-menu-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.detail-menu-button.active {
  color: var(--brand-dark);
  background: #e0f2fe;
}

.detail-action-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 32;
  display: grid;
  gap: 6px;
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(8, 16, 26, 0.16);
  padding: 8px;
}

.detail-action-menu[hidden] {
  display: none;
}

.detail-action-menu button {
  display: flex;
  justify-content: flex-start;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  font-size: 0.92rem;
  font-weight: 900;
  text-align: left;
}

.detail-action-menu button:hover {
  filter: none;
  background: #f3f4f6;
}

.detail-action-menu button.danger {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 16, 26, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(8, 16, 26, 0.24);
  padding: 16px;
}

.modal-panel h2 {
  margin-bottom: 12px;
}

.modal-text {
  margin-bottom: 8px;
  color: var(--muted);
}

.modal-text strong {
  color: var(--text);
}

.modal-warning,
.modal-note {
  border-radius: 8px;
  padding: 10px;
  font-weight: 900;
}

.modal-warning {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: var(--danger);
}

.modal-note {
  border: 1px solid #91d5f6;
  background: #e8f7ff;
  color: var(--brand-dark);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.settings-panel {
  width: min(100%, 440px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border-radius: 18px;
  padding: 18px;
}

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

.settings-head h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
}

.settings-close {
  display: inline-grid;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  place-items: center;
  border-color: var(--line);
  border-radius: 999px;
  padding: 0;
  color: var(--text);
  background: var(--soft);
  font-size: 1.35rem;
  line-height: 1;
}

.settings-summary {
  display: grid;
  gap: 8px;
}

.settings-info {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--panel-surface);
}

.settings-info span,
.settings-info strong {
  display: block;
}

.settings-info span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.settings-info strong {
  margin-top: 2px;
  font-size: 0.96rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

.settings-panel .btn-light {
  min-height: 43px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 0.92rem;
  font-weight: 900;
}

.settings-main-actions,
.settings-two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-main-actions #migrateButton {
  grid-column: 1 / -1;
}

.settings-single-action {
  grid-template-columns: 1fr;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 12px;
  padding: 12px;
  background: var(--panel-surface);
}

.theme-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.theme-section h3 {
  margin: 0 0 3px;
}

.theme-section p {
  margin: 0;
  text-align: left;
}

.theme-switch {
  position: relative;
  display: inline-grid;
  width: 58px;
  min-width: 58px;
  height: 34px;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-switch span {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  box-shadow: inset 0 1px 2px rgba(8, 16, 26, 0.08);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.theme-switch span::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(8, 16, 26, 0.18);
  transition: transform 180ms ease, background-color 180ms ease;
}

.theme-switch input:checked + span {
  border-color: rgba(19, 168, 159, 0.55);
  background: var(--brand);
}

.theme-switch input:checked + span::before {
  transform: translateX(24px);
  background: #eafffb;
}

.settings-section-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
}

.settings-section h3 {
  margin: 0;
  font-size: 1rem;
}

.settings-section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: right;
  overflow-wrap: anywhere;
}

.sync-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  border: 1px solid #91d5f6;
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--brand-dark);
  background: rgba(232, 247, 255, 0.96);
  box-shadow: 0 14px 30px rgba(8, 16, 26, 0.14);
  font-weight: 900;
}

.sync-toast[hidden] {
  display: none;
}

.sync-toast.bad {
  border-color: #fecdd3;
  color: var(--danger);
  background: rgba(255, 241, 242, 0.96);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(100%, 540px);
  margin: 0 auto;
  border: 1px solid var(--glass-line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 42%),
    var(--nav-surface);
  backdrop-filter: blur(24px) saturate(1.45);
  -webkit-backdrop-filter: blur(24px) saturate(1.45);
  box-shadow: var(--nav-shadow);
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
}

.bottom-nav::before {
  display: none;
}

.bottom-nav-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 55px;
  border: 0;
  border-radius: 18px;
  padding: 5px 2px 4px;
  color: #7b8794;
  background: transparent;
  font-size: 0.68rem;
  box-shadow: none;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.bottom-nav-button#settingsNavButton {
  order: 1;
}

.bottom-nav-button[data-view="overdue"] {
  order: 2;
}

.bottom-nav-button[data-view="form"] {
  order: 3;
}

.bottom-nav-button[data-view="list"] {
  order: 4;
}

.bottom-nav-button[data-view="summary"] {
  order: 5;
}

.bottom-nav-button:hover {
  filter: none;
  background: rgba(15, 23, 42, 0.035);
}

.bottom-nav-button:active {
  transform: translateY(1px);
}

.bottom-nav-button.active {
  color: var(--brand-dark);
  background: color-mix(in srgb, var(--brand) 11%, transparent);
  box-shadow: none;
}

.bottom-nav-button.active .nav-icon {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent);
}

.bottom-nav-button .nav-icon {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 999px;
  color: inherit;
  line-height: 1;
}

.bottom-nav-button .nav-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.bottom-nav-button span:not(.nav-icon) {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .client-card,
html[data-theme="dark"] .payment-card,
html[data-theme="dark"] .modal-panel {
  background: var(--panel-surface);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .panel {
  border-color: rgba(110, 231, 220, 0.18);
}

html[data-theme="dark"] .list-panel {
  background: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .search-field input {
  background-color: rgba(255, 255, 255, 0.08);
  background-image:
    radial-gradient(circle at 14px 20px, transparent 5px, #7a8583 5px, #7a8583 6px, transparent 7px),
    linear-gradient(45deg, transparent 0 60%, #7a8583 60% 70%, transparent 70%);
}

html[data-theme="dark"] .client-chat-row {
  border-color: rgba(110, 231, 220, 0.18);
  background:
    linear-gradient(135deg, rgba(20, 33, 31, 0.98), rgba(12, 20, 19, 0.98)),
    #101817;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] .client-chat-row:hover,
html[data-theme="dark"] .client-chat-row.selected {
  border-color: rgba(110, 231, 220, 0.36);
  background:
    linear-gradient(135deg, rgba(20, 45, 41, 0.76), rgba(13, 29, 27, 0.96)),
    #13211f;
  box-shadow: none;
}

html[data-theme="dark"] .client-chat-row.completed {
  border-color: rgba(94, 234, 212, 0.22);
  background:
    linear-gradient(135deg, rgba(16, 35, 30, 0.96), rgba(11, 25, 22, 0.98)),
    #0f1b18;
}

html[data-theme="dark"] .client-chat-row.overdue {
  border-color: rgba(251, 113, 133, 0.28);
  background:
    linear-gradient(135deg, rgba(42, 17, 23, 0.96), rgba(25, 12, 15, 0.98)),
    #1a1012;
}

html[data-theme="dark"] .chat-side-value,
html[data-theme="dark"] .chat-preview.muted,
html[data-theme="dark"] .detail-tab-button,
html[data-theme="dark"] .product-group-tab,
html[data-theme="dark"] .bottom-nav-button {
  color: var(--muted);
}

html[data-theme="dark"] .chat-title,
html[data-theme="dark"] .name,
html[data-theme="dark"] .product-row strong {
  color: var(--text);
}

html[data-theme="dark"] .chat-preview,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .product-row small,
html[data-theme="dark"] .product-row em {
  color: var(--muted);
}

html[data-theme="dark"] .chat-badge,
html[data-theme="dark"] .section-count,
html[data-theme="dark"] .detail-section-head span {
  color: var(--brand-dark);
  background: rgba(19, 170, 161, 0.18);
}

html[data-theme="dark"] .chat-badge.ok {
  background: rgba(34, 197, 94, 0.15);
}

html[data-theme="dark"] .chat-badge.bad,
html[data-theme="dark"] .pill.bad {
  background: rgba(251, 113, 133, 0.14);
}

html[data-theme="dark"] .product-row,
html[data-theme="dark"] .product-row.selected,
html[data-theme="dark"] .summary-lines div,
html[data-theme="dark"] .money-box,
html[data-theme="dark"] .photo-viewer img {
  border-color: rgba(110, 231, 220, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .product-row:hover,
html[data-theme="dark"] .product-row-static:hover,
html[data-theme="dark"] .product-back-button:hover,
html[data-theme="dark"] .back-button:hover {
  background: rgba(19, 168, 159, 0.12);
}

html[data-theme="dark"] .product-row.closed,
html[data-theme="dark"] .product-row.closed.selected,
html[data-theme="dark"] .payment-card.paid {
  border-color: rgba(19, 170, 161, 0.54);
  background: rgba(19, 170, 161, 0.18);
}

html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .settings-panel .btn-light,
html[data-theme="dark"] .product-back-button,
html[data-theme="dark"] .back-button,
html[data-theme="dark"] .detail-tab-button,
html[data-theme="dark"] .product-group-tab {
  border-color: rgba(110, 231, 220, 0.16);
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  text-shadow: none;
}

html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .settings-panel .btn-light:hover,
html[data-theme="dark"] .product-back-button:hover,
html[data-theme="dark"] .back-button:hover {
  color: var(--text);
  background: rgba(19, 170, 161, 0.16);
}

html[data-theme="dark"] .btn-light:disabled,
html[data-theme="dark"] .settings-panel .btn-light:disabled {
  color: rgba(244, 251, 250, 0.58);
  background: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .detail-tab-button.active,
html[data-theme="dark"] .product-group-tab.active {
  color: #f8fffd;
  background: var(--brand);
}

html[data-theme="dark"] .product-group-tab span {
  color: inherit;
  background: rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] .product-group-tab.active span {
  color: var(--brand);
  background: rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .detail-action-menu,
html[data-theme="dark"] .list-options {
  background: var(--glass-strong);
}

html[data-theme="dark"] .detail-menu-button.active,
html[data-theme="dark"] .filter-button.active {
  background: rgba(19, 168, 159, 0.16);
}

html[data-theme="dark"] .pill {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .pill.ok {
  color: #052321;
  background: var(--brand);
}

html[data-theme="dark"] .payment-card {
  border-color: rgba(110, 231, 220, 0.14);
  background: rgba(255, 255, 255, 0.052);
}

html[data-theme="dark"] .payment-card .btn-light {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .date-wheel-picker {
  background: linear-gradient(180deg, #111817 0%, #0b0f0e 50%, #111817 100%);
}

html[data-theme="dark"] .sync-toast {
  background: rgba(16, 24, 23, 0.92);
}

html[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.58);
}

html[data-theme="dark"] .bottom-nav {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 46%),
    var(--nav-surface);
}

html[data-theme="dark"] .bottom-nav-button:hover {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .bottom-nav-button.active {
  color: var(--brand-dark);
  background: rgba(19, 170, 161, 0.15);
}

html[data-theme="dark"] .bottom-nav-button.active .nav-icon {
  color: var(--brand-dark);
  background: rgba(19, 170, 161, 0.2);
  box-shadow: inset 0 0 0 1px rgba(110, 231, 220, 0.28);
}

@media (min-width: 720px) {
  .app {
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(8, 16, 26, 0.12);
    min-height: calc(100vh - 40px);
  }

  .header {
    padding-top: 4px;
  }

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

  .list-options {
    grid-template-columns: minmax(0, 1fr) minmax(190px, auto);
    align-items: end;
  }

  .list-filter-menu-wrap .list-options {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    transform: translateX(50%);
  }

  .detail-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }

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

@media (max-width: 520px) {
  .app {
    overflow-x: hidden;
  }

  .header {
    padding-top: calc(5px + env(safe-area-inset-top));
    padding-bottom: 8px;
  }

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

  .stat:last-child {
    grid-column: 1 / -1;
  }

  .stats-period select {
    min-width: 132px;
  }

  .date-photo-grid {
    grid-template-columns: minmax(0, 1fr) minmax(104px, 118px);
    gap: 7px;
  }

  .date-wheel-picker {
    --date-wheel-height: 104px;
    --date-wheel-item-height: 26px;
    gap: 2px;
    padding: 5px 6px;
  }

  .date-wheel-picker::before {
    left: 6px;
    right: 6px;
  }

  .wheel-option {
    font-size: 0.78rem;
  }

  .wheel-option.selected {
    font-size: 1rem;
  }

  .photo-upload-button {
    min-height: 108px;
    padding: 6px;
  }

  .photo-preview {
    width: 48px;
    height: 48px;
  }

  .photo-upload-button strong,
  .photo-remove-button {
    font-size: 0.76rem;
  }

  .client-chat-row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 9px;
  }

  .client-avatar {
    width: 44px;
    height: 44px;
  }

  .chat-side {
    max-width: 92px;
  }

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