* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (min-width: 481px) {
  html {
    background: var(--tg-bg);
  }
  body {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
  }
}

:root {
  --tg-bg: var(--tg-theme-bg-color, #18222d);
  --tg-text: var(--tg-theme-text-color, #fff);
  --tg-hint: var(--tg-theme-hint-color, #8e8e93);
  --tg-link: var(--tg-theme-link-color, #2a8ad0);
  --tg-button: var(--tg-theme-button-color, #2a8ad0);
  --tg-button-text: var(--tg-theme-button-text-color, #fff);
  --tg-secondary: var(--tg-theme-secondary-bg-color, #1f2936);
  --tg-section: var(--tg-theme-section-bg-color, #1c2732);
  --tg-section-header: var(--tg-theme-section-header-text-color, #8e8e93);
  --tg-accent: var(--tg-theme-accent-text-color, #2a8ad0);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-btn: 0 2px 8px rgba(0,0,0,0.18);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.12);
  --glass-bg: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --red-del: #e56565;
  --glass-del-bg: rgba(229, 101, 101, 0.12);
  --glass-del-border: rgba(229, 101, 101, 0.35);
  --green-credit: #6bb87a;
  --green-credit-bg: rgba(107, 184, 122, 0.2);
  --red-debit: #d48383;
  --red-debit-bg: rgba(212, 131, 131, 0.2);
  --purple-btn-bg: #8b7aa8;
  --gradient-accent: linear-gradient(135deg, var(--tg-button) 0%, color-mix(in srgb, var(--tg-button) 80%, white) 100%);
  --glow-accent: 0 0 24px color-mix(in srgb, var(--tg-button) 30%, transparent);
  --dur: 0.12s;
  --dur-s: 0.08s;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-body: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --lh-tight: 1.25;
  --lh-normal: 1.4;
  --lh-relaxed: 1.5;
}

body {
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  background: var(--tg-bg);
  color: var(--tg-text);
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 60vh;
  background: radial-gradient(ellipse at top, color-mix(in srgb, var(--tg-button) 12%, transparent) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  border-radius: var(--radius-sm);
  font-family: inherit;
}

select {
  border-radius: var(--radius);
}

.header {
  flex-shrink: 0;
  padding: 24px 0 20px;
  text-align: center;
  position: relative;
}

.header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  border-radius: 2px;
  background: var(--tg-accent);
  opacity: 0.6;
}

.header h1 {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--tg-text);
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 20px;
  padding-bottom: 24px;
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.15s var(--ease-out) forwards;
}

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

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

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.hint {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-bottom: 16px;
  line-height: var(--lh-relaxed);
  text-align: center;
  padding: 0 8px;
}

.dashboard-top-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.dashboard-top-row > * {
  min-width: 0;
}

@media (max-width: 360px) {
  .dashboard-top-row { gap: 8px; }
}

.dashboard-hero {
  background: var(--gradient-accent);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-btn), var(--glow-accent);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

.dashboard-hero .dashboard-hero-value,
.dashboard-hero .dashboard-hero-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
}

.dashboard-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}

#stats.active .dashboard-hero {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#stats.active .dashboard-top-row .dashboard-stat:nth-child(2) { animation: dashIn var(--dur) var(--ease-out) 0.02s both; }
#stats.active .dashboard-top-row .dashboard-stat:nth-child(3) { animation: dashIn var(--dur) var(--ease-out) 0.04s both; }
#stats.active .dashboard-top-row .dashboard-stat:nth-child(4) { animation: dashIn var(--dur) var(--ease-out) 0.06s both; }

#stats.active .dashboard-activity {
  animation: dashIn var(--dur) var(--ease-out) 0.14s both;
}

#stats.active .dashboard-activity-item {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#stats.active .dashboard-activity-item:nth-child(1) { animation-delay: 0.16s; }
#stats.active .dashboard-activity-item:nth-child(2) { animation-delay: 0.18s; }
#stats.active .dashboard-activity-item:nth-child(3) { animation-delay: 0.2s; }
#stats.active .dashboard-activity-item:nth-child(4) { animation-delay: 0.22s; }
#stats.active .dashboard-activity-item:nth-child(5) { animation-delay: 0.24s; }

.dashboard-hero-value {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--tg-button-text);
  font-variant-numeric: tabular-nums;
}

.dashboard-hero-label {
  font-size: 10px;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
  line-height: 1.2;
}

.dashboard-stat {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-s) var(--ease), background var(--dur);
  min-width: 0;
  overflow: hidden;
}

.dashboard-stat:active {
  transform: scale(0.98);
  background: rgba(255,255,255,0.03);
}

.dashboard-stat .stat-num {
  display: block;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--tg-text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.dashboard-stat .stat-label {
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.dashboard-activity {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

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

.dashboard-activity-header span {
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--tg-text);
}

.dashboard-links {
  display: flex;
  gap: 12px;
}

.dashboard-link {
  background: none;
  border: none;
  color: var(--tg-link);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}

.dashboard-link {
  transition: opacity var(--dur-s), transform var(--dur-s) var(--ease);
}

.dashboard-link:active {
  opacity: 0.8;
  transform: scale(0.96);
}

.dashboard-activity-list {
  list-style: none;
}

.dashboard-activity-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: var(--fs-sm);
}

.dashboard-activity-item:last-child {
  border-bottom: none;
}

.dashboard-activity-item.clickable {
  cursor: pointer;
  transition: background var(--dur), transform var(--dur-s) var(--ease);
}

.dashboard-activity-item.clickable:active {
  background: rgba(255,255,255,0.04);
}

.activity-client {
  font-weight: 500;
  color: var(--tg-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-op {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.activity-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.activity-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.activity-desc {
  grid-column: 1;
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-date {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  justify-self: end;
  font-size: var(--fs-xs);
  color: var(--tg-hint);
}

/* Loading indicator with pulse (used across the app) */
.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
}
.loading-indicator__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tg-accent, var(--tg-button));
  animation: loading-pulse 1s ease-in-out infinite;
}
.loading-indicator__dot:nth-child(1) { animation-delay: 0s; }
.loading-indicator__dot:nth-child(2) { animation-delay: 0.15s; }
.loading-indicator__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes loading-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.loading-indicator__label {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-left: 2px;
}
.loading-item,
.loading-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  min-height: 48px;
}
.loading-wrap { padding: 24px 20px; }

.dashboard-activity-loading,
.dashboard-activity-empty,
.dashboard-activity-error {
  padding: 20px;
  text-align: center;
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}
.dashboard-activity-loading {
  display: flex;
  justify-content: center;
  align-items: center;
}

.bottom-nav {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, auto);
  background: color-mix(in srgb, var(--tg-secondary) 90%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 8px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  gap: 6px;
  margin: 0 -20px;
  border-top: 1px solid var(--glass-border);
  box-sizing: border-box;
}

.nav-item {
  position: relative;
  min-width: 0;
  padding: 12px 8px;
  touch-action: manipulation;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--tg-text);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:active {
  transform: scale(0.97);
}

.nav-item.active {
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  border-color: transparent;
  box-shadow: var(--glow-accent);
}

.nav-badge:empty {
  display: none;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  pointer-events: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.3);
}

.nav-item-twoline {
  line-height: 1.2;
  font-size: var(--fs-xs);
}

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

.stat-card {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-s) var(--ease), background var(--dur);
}

.stat-card:active {
  transform: scale(0.98);
  background: rgba(255,255,255,0.03);
}

.stat-card .label {
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.stat-card .value {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.list {
  list-style: none;
}

.list li {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-s) var(--ease), background var(--dur), border-color var(--dur);
}

.list li:active {
  background: rgba(255,255,255,0.03);
}

.list li .title {
  font-weight: 500;
  font-size: var(--fs-body);
}

.list li .sub {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-top: 4px;
}

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

.client-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.client-name {
  font-weight: 500;
  font-size: var(--fs-body);
  color: var(--tg-text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-debtor {
  border-left: 3px solid var(--red-del);
}

.client-debtor-badge {
  font-size: var(--fs-xs);
  color: var(--red-del);
  font-weight: 500;
}

.client-debtor .client-balance,
.client-debtor .client-balance.negative {
  color: var(--red-del);
  animation: balanceNegativeGlow 2s ease-in-out infinite;
}

.client-low-balance .client-balance.negative {
  color: #d4a017;
  animation: balanceNegativeGlow 2s ease-in-out infinite;
}

@keyframes balanceNegativeGlow {
  0%, 100% { text-shadow: 0 0 12px rgba(229, 101, 101, 0.9), 0 0 24px rgba(229, 101, 101, 0.5); }
  50% { text-shadow: 0 0 6px rgba(229, 101, 101, 0.4), 0 0 12px rgba(229, 101, 101, 0.2); }
}

.client-low-badge {
  font-size: var(--fs-xs);
  color: #d4a017;
  font-weight: 500;
}

.project-info-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.project-info-row .client-name {
  flex: 1;
  min-width: 0;
}
.project-info-row .project-status-badge {
  flex-shrink: 0;
  margin-left: 0;
}

.project-status-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
  vertical-align: middle;
}
.project-status-badge--active {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}
.project-status-badge--archived {
  background: rgba(255, 255, 255, 0.08);
  color: var(--tg-hint);
}

.client-balance {
  font-size: var(--fs-body);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--tg-text);
  flex-shrink: 0;
}

.client-balance.negative {
  color: var(--tg-hint);
}

.list li.clickable {
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), box-shadow var(--dur);
}

.list li.clickable:active {
  transform: scale(0.98);
}

.clients-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.clients-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  overflow: visible;
}

.clients-toolbar-row .clients-filter-wrap {
  flex: 1 1 0;
  min-width: 100px;
  overflow: visible;
}

.clients-toolbar-row .clients-filter-wrap .history-filter-select,
.clients-toolbar-row .clients-filter-wrap .custom-select-trigger {
  height: 40px;
  padding: 0 32px 0 14px;
}

.clients-toolbar-row .clients-filter-wrap .custom-select-wrap,
.projects-toolbar-row .projects-filter-wrap .custom-select-wrap {
  min-width: 0;
}
.clients-toolbar-row .custom-select-dropdown,
.projects-toolbar-row .custom-select-dropdown {
  z-index: 300;
}

.btn-add-icon-only {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 600;
}

.btn-add-icon-only.btn-add-top {
  margin-bottom: 0;
}

.tasks-toolbar .tasks-filter-searchable.searchable-select-wrap,
.tasks-toolbar .tasks-filter-searchable.history-filter-select-wrap {
  flex: 1 1 auto;
  min-width: 100px;
}

.tasks-toolbar .tasks-filter-searchable .history-filter-select {
  height: 40px;
  padding: 0 32px 0 14px;
  width: 100%;
  box-sizing: border-box;
}

#tasks #tasks-search {
  margin-bottom: 12px;
}

.export-label {
  display: block;
  margin-bottom: 8px;
}

.card-actions-export {
  flex-wrap: wrap;
  width: 100%;
}

.card-actions-export .btn-edit {
  flex: 1 1 0;
  min-width: 0;
}

.clients-search {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  box-sizing: border-box;
}

.clients-search::placeholder {
  color: var(--tg-hint);
}

.clients-search:focus {
  outline: none;
  border-color: var(--tg-button);
}

#clients.active #clients-list li {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#clients.active #clients-list li.client-debtor {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#clients.active #clients-list li:nth-child(1) { animation-delay: 0.02s; }
#clients.active #clients-list li:nth-child(2) { animation-delay: 0.04s; }
#clients.active #clients-list li:nth-child(3) { animation-delay: 0.06s; }
#clients.active #clients-list li:nth-child(4) { animation-delay: 0.08s; }
#clients.active #clients-list li:nth-child(5) { animation-delay: 0.1s; }
#clients.active #clients-list li:nth-child(n+6) { animation-delay: 0.12s; }

.form-save-hidden {
  display: none !important;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.card-actions-spaced {
  margin-top: 12px;
}

.client-card-block > .card-actions-spaced {
  margin-top: 0;
}

.card-actions-inline {
  margin-top: 0;
}

.card-actions button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.card-actions button:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.btn-confirm {
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  box-shadow: var(--shadow-btn), var(--glow-accent);
  font-weight: 600;
}

#settings .btn-confirm,
#settings-silent-clients .btn-confirm,
#settings-report-params .btn-confirm,
#analytics .btn-confirm {
  background: var(--tg-button);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
}

#settings-silent-clients .payments-header .btn-confirm,
#settings-report-params .payments-header .btn-confirm {
  padding: 12px 18px;
  min-height: 44px;
}

#settings .btn-confirm:active,
#settings-silent-clients .btn-confirm:active,
#settings-report-params .btn-confirm:active,
#analytics .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.btn-cancel {
  background: var(--glass-del-bg);
  color: var(--red-del);
  border: 1px solid var(--glass-del-border);
}

.btn-cancel:active,
.btn-cancel:hover {
  background: rgba(229, 101, 101, 0.18);
}

#pending #pending-search {
  margin-top: 12px;
}

#pending.active #pending-list li {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#pending.active #pending-list li:nth-child(1) { animation-delay: 0.02s; }
#pending.active #pending-list li:nth-child(2) { animation-delay: 0.04s; }
#pending.active #pending-list li:nth-child(3) { animation-delay: 0.06s; }
#pending.active #pending-list li:nth-child(n+4) { animation-delay: 0.08s; }

.pending-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pending-client {
  font-weight: 500;
  font-size: var(--fs-body);
  flex-shrink: 0;
}

.pending-op {
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pending-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.pending-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.pending-desc {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

.pending-card .btn-screenshot {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  background: var(--purple-btn-bg);
  color: white;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.pending-card .btn-screenshot:hover {
  opacity: 0.95;
}

.pending-card .btn-screenshot:active {
  opacity: 0.92;
  transform: scale(0.97);
}

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

.pending-actions button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.pending-actions button:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.pending-actions .btn-confirm {
  box-shadow: var(--shadow-btn), var(--glow-accent);
}

.pending-actions .btn-cancel {
  border: 1px solid var(--glass-del-border);
}

.task-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}

.task-card-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.task-card-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.task-card-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.task-client {
  font-weight: 500;
  font-size: var(--fs-body);
  color: var(--tg-text);
  overflow-wrap: break-word;
  word-break: break-word;
}

.task-title {
  font-size: var(--fs-sm);
  color: var(--tg-text);
  overflow-wrap: break-word;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-desc {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  overflow-wrap: break-word;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-project {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  display: block;
  margin-top: 2px;
}

.task-project-link {
  color: var(--tg-accent);
  text-decoration: none;
}

.task-project-link:hover {
  text-decoration: underline;
}

.task-status {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

.task-status-for-review {
  color: #d4a017;
  animation: taskStatusForReviewGlow 2s ease-in-out infinite;
}

.task-status-open {
  color: #5b9bd5;
  animation: taskStatusOpenGlow 2s ease-in-out infinite;
}

@keyframes taskStatusForReviewGlow {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(212, 160, 23, 0.5); }
  50% { opacity: 0.75; text-shadow: 0 0 4px rgba(212, 160, 23, 0.3); }
}

@keyframes taskStatusOpenGlow {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(91, 155, 213, 0.5); }
  50% { opacity: 0.75; text-shadow: 0 0 4px rgba(91, 155, 213, 0.3); }
}

.task-date {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.task-actions button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.tasks-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.tasks-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
}

.tasks-toolbar-row .btn-add-top {
  margin-bottom: 0;
}

.tasks-toolbar .btn-add {
  align-self: flex-start;
}

.task-form-modal {
  max-width: 420px;
  width: 100%;
}

.task-detail-desc {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.task-detail-title {
  overflow-wrap: break-word;
  word-break: break-word;
}

.task-detail-card .field-value {
  overflow-wrap: break-word;
  word-break: break-word;
}

.task-detail-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.task-detail-head-row .field-value:first-child {
  text-align: left;
}

.task-detail-head-row .field-value:last-child {
  text-align: right;
}

#task-detail .task-detail-head-row .task-status {
  font-size: var(--fs-body);
}

#task-detail .task-detail-head-row .field-value {
  font-size: var(--fs-body);
}

.task-detail-actions-wrap > .task-detail-actions {
  margin-bottom: 0;
}

.task-form-modal .client-detail-header {
  margin-bottom: 16px;
}

.task-form-heading {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--tg-text);
}

.task-form-modal .client-detail-header .btn-back {
  margin-left: auto;
}

.task-form-body {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.task-form-body .field {
  margin-bottom: 16px;
}

.task-form-body .field-label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.task-form-body .field-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
}

.task-form-body select.field-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border-radius: var(--radius);
}

.task-form-body .card-actions {
  margin-top: 20px;
}

.btn-edit {
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  box-shadow: var(--shadow-btn), var(--glow-accent);
  font-weight: 600;
}

.btn-del {
  background: var(--glass-del-bg);
  color: var(--red-del);
  border: 1px solid var(--glass-del-border);
}

.btn-del:active,
.btn-del:hover {
  background: rgba(229, 101, 101, 0.18);
}

.btn-back {
  padding: 12px 18px;
  margin-bottom: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.btn-back:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

.btn-add {
  width: 100%;
  padding: 16px 18px;
  margin-top: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease);
  box-shadow: var(--shadow-btn), var(--glow-accent);
}

.btn-add.btn-add-icon-only {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  flex: 0 0 40px !important;
  padding: 0;
  margin-top: 0;
}

.btn-add:active {
  transform: scale(0.97);
}

.btn-add-top {
  margin-top: 0;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--tg-text);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  display: block;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--tg-hint);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.payment-qr-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input[type="file"] {
  padding: 12px 16px;
  font-size: var(--fs-body);
  font-family: inherit;
  font-weight: 500;
  color: var(--tg-button-text);
  background: var(--gradient-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
}

input[type="file"]::-webkit-file-upload-button {
  padding: 0 10px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.payment-qr-group input[type="file"] {
  align-self: flex-start;
}

.payment-qr-preview-wrap {
  min-height: 80px;
}

.payment-qr-preview {
  max-width: 160px;
  max-height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.payment-qr-placeholder {
  padding: 20px;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}

.payment-qr-remove {
  align-self: flex-start;
  min-height: 44px;
  padding: 12px 20px;
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.form-card {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

#projects.active #projects-list li {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#projects.active #projects-list li:nth-child(1) { animation-delay: 0.02s; }
#projects.active #projects-list li:nth-child(2) { animation-delay: 0.04s; }
#projects.active #projects-list li:nth-child(3) { animation-delay: 0.06s; }
#projects.active #projects-list li:nth-child(4) { animation-delay: 0.08s; }
#projects.active #projects-list li:nth-child(5) { animation-delay: 0.1s; }
#projects.active #projects-list li:nth-child(n+6) { animation-delay: 0.12s; }

#projects .projects-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.projects-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  overflow: visible;
}

#projects .projects-toolbar-row .projects-filter-wrap {
  flex: 1 1 0;
  min-width: 100px;
  overflow: visible;
}

#projects .projects-toolbar-row .projects-filter-wrap .history-filter-select,
#projects .projects-toolbar-row .projects-filter-wrap .custom-select-trigger {
  height: 40px;
  padding: 0 32px 0 14px;
}

#projects #projects-search {
  margin-bottom: 12px;
}

#project-detail.active .client-detail-header {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#project-detail.active .client-card-block {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#project-detail.active .client-card-block:nth-child(1) { animation-delay: 0.04s; }
#project-detail.active .client-card-block:nth-child(2) { animation-delay: 0.08s; }
#project-detail.active .client-card-block:nth-child(3) { animation-delay: 0.12s; }
#project-detail.active .client-card-block:nth-child(4) { animation-delay: 0.16s; }
#project-detail.active .client-card-block:nth-child(5) { animation-delay: 0.2s; }
#project-detail.active .client-card-block:nth-child(n+6) { animation-delay: 0.24s; }

#project-tasks-search {
  margin-bottom: 12px;
}

#project-tasks-pagination {
  border-top: none;
}

#project-tasks-pagination:empty {
  padding: 0;
  min-height: 0;
}

.project-clients-add-block {
  position: relative;
  z-index: 10;
}

.project-clients-add-block .project-clients-list {
  margin-bottom: 0;
}

.project-client-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-client-row .contact-link {
  flex: 1;
  min-width: 0;
}

.project-client-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--glass-del-border);
  border-radius: var(--radius-sm);
  background: var(--glass-del-bg);
  color: var(--red-del);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--dur), transform var(--dur-s) var(--ease);
}

.project-client-remove:active,
.project-client-remove:hover {
  background: rgba(229, 101, 101, 0.25);
  transform: scale(0.97);
}

.project-client-remove-icon {
  display: block;
  pointer-events: none;
}

.project-clients-add-block .project-add-client-inner {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.project-secrets-block {
  border-top: 1px solid var(--glass-border);
  margin-top: 8px;
  padding-top: 12px;
}

.project-secrets-block .field-label {
  display: block;
  margin-bottom: 6px;
}

.secrets-notes-wrap {
  margin-bottom: 16px;
}

.secrets-notes-textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  margin-bottom: 8px;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.secrets-notes-textarea::placeholder {
  color: var(--tg-hint);
}

.secrets-notes-textarea:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.secrets-credential-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.secrets-credential-fields .field-input {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.secrets-credential-fields .field-input::placeholder {
  color: var(--tg-hint);
}

.secrets-credential-fields .field-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.secrets-credentials-list {
  margin-bottom: 16px;
}

.secrets-credential-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  padding-right: 44px;
  margin-bottom: 12px;
}

.secrets-delete-icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--tg-hint);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color var(--dur), background var(--dur), transform var(--dur-s) var(--ease);
}

.secrets-delete-icon-btn:hover,
.secrets-delete-icon-btn:active {
  color: var(--red-del);
  background: var(--glass-del-bg);
  transform: scale(0.95);
}

.secrets-trash-icon {
  display: block;
  pointer-events: none;
}

.secrets-credential-fields-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: baseline;
  font-size: var(--fs-sm);
}

.secrets-credential-fields-row .field-label {
  margin-bottom: 0;
}

.secrets-monospace {
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

.secrets-copy-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.secrets-copy-wrap .secrets-monospace {
  min-width: 0;
}

.secrets-copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--tg-text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--dur), transform var(--dur-s) var(--ease);
}

.secrets-copy-btn:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.97);
}

.secrets-copy-icon {
  display: block;
  pointer-events: none;
}

.project-secrets-block .secrets-copy-btn {
  width: 28px;
  height: 28px;
  padding: 0;
}

.secrets-password-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.secrets-password-mask {
  font-family: ui-monospace, monospace;
}

.secrets-password-visible {
  word-break: break-all;
}

.secrets-credential-files {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
}

.secrets-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-width: 0;
}

.secrets-file-row .secrets-file-download,
.secrets-file-row .contact-link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secrets-file-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.secrets-file-input {
  max-width: 180px;
}

.secrets-credential-actions {
  margin-top: 10px;
}

.secrets-add-credential {
  margin-top: 12px;
}

.project-secrets-block button {
  -webkit-appearance: none;
  appearance: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur), background var(--dur);
}

.project-secrets-block .btn-confirm {
  padding: 12px 18px;
  border: none;
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  box-shadow: var(--shadow-btn), var(--glow-accent);
  font-weight: 600;
}

.project-secrets-block .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.project-secrets-block .btn-cancel {
  padding: 8px 14px;
  background: var(--glass-del-bg);
  color: var(--red-del);
  border: 1px solid var(--glass-del-border);
}

.project-secrets-block .btn-cancel:active,
.project-secrets-block .btn-cancel:hover {
  background: rgba(229, 101, 101, 0.18);
  transform: scale(0.97);
}

.project-secrets-block .btn-back {
  padding: 8px 14px;
  margin-bottom: 0;
  background: var(--glass-bg);
  color: var(--tg-text);
  border: 1px solid var(--glass-border);
}

.project-secrets-block .btn-back:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

.secrets-notes-wrap .btn-confirm {
  margin-top: 4px;
}

.secrets-file-row .btn-cancel {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: var(--fs-sm);
}

.secrets-password-wrap .secrets-password-reveal {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin-bottom: 0;
}

.secrets-eye-icon {
  display: block;
  pointer-events: none;
}


#project-form.active .client-detail-header {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#project-form.active .client-edit-form {
  animation: dashIn var(--dur) var(--ease-out) 0.06s both;
}

#client-detail.active .client-detail-header {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#client-detail.active .client-card-block {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#client-detail.active .client-card-block:nth-child(1) { animation-delay: 0.04s; }
#client-detail.active .client-card-block:nth-child(2) { animation-delay: 0.08s; }
#client-detail.active .client-card-block:nth-child(3) { animation-delay: 0.12s; }
#client-detail.active .client-card-block:nth-child(4) { animation-delay: 0.16s; }
#client-detail.active .client-card-block:nth-child(5) { animation-delay: 0.2s; }
#client-detail.active .client-card-block:nth-child(n+6) { animation-delay: 0.24s; }

#client-form.active .client-detail-header {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#client-form.active .client-edit-form {
  animation: dashIn var(--dur) var(--ease-out) 0.06s both;
}

.client-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.client-card-block {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.client-card .field {
  margin-bottom: 16px;
}

.client-card-block .field:last-child {
  margin-bottom: 0;
}

.client-name-balance-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.client-name-balance-row .field-part {
  flex: 1;
  min-width: 0;
}

.client-name-balance-row .field-part:last-child {
  flex: 0 1 auto;
  text-align: right;
}

.client-card .field-label {
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-bottom: 4px;
  font-weight: 500;
}

.client-card .field-value {
  font-size: var(--fs-body);
  font-weight: 500;
}

.balance-display.negative {
  color: var(--red-del);
  animation: balanceNegativeGlow 2s ease-in-out infinite;
}

.balance-display.balance-updated {
  animation: balancePulse 0.25s var(--ease-out);
}

@keyframes balancePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.92; transform: scale(1.02); }
}

.client-contacts .field-label {
  display: block;
  margin-bottom: 10px;
}

.contacts-list,
.projects-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-row {
  display: flex;
  align-items: center;
  font-size: var(--fs-body);
  font-weight: 500;
}

.contact-row .contact-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-link {
  color: var(--tg-link);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

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

.contact-add .btn-confirm {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur);
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--shadow-btn), var(--glow-accent);
}

.contact-add .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.client-detail-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.client-detail-header .btn-back {
  margin-bottom: 0;
}

.client-detail-header .btn-edit {
  margin-left: auto;
  padding: 12px 18px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--tg-text);
  box-shadow: none;
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.client-detail-header .btn-edit:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

.client-detail-header .btn-icon-header {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--tg-text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: all var(--dur) var(--ease);
}

.client-detail-header .btn-icon-header:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

.client-detail-header .btn-icon-header + .btn-icon-header {
  margin-left: 6px;
}

.client-detail-header .btn-archive-header {
  color: var(--tg-hint);
}

.client-detail-header .btn-archive-header:active,
.client-detail-header .btn-archive-header:hover {
  color: var(--red-del);
  background: var(--glass-del-bg);
}

.header-btn-icon {
  display: block;
  pointer-events: none;
}

.client-edit-form {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.settings-loading {
  display: none;
  padding: 16px 0;
  justify-content: center;
  align-items: center;
}
.settings-loading .loading-indicator {
  padding: 0;
}
.settings-form.loading .settings-loading {
  display: flex;
}
.settings-form.loading .field,
.settings-form.loading .card-actions {
  pointer-events: none;
  opacity: 0.5;
}

.settings-form .field {
  margin-bottom: 16px;
}

.settings-form .field-group-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--tg-hint);
  margin: 20px 0 8px 0;
}

.settings-form .field-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.settings-form .field-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.settings-form .field-input::placeholder {
  color: var(--tg-hint);
}

.settings-form .field-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.settings-form .field-input[type="number"] {
  -moz-appearance: textfield;
}

.settings-form textarea.field-input {
  resize: vertical;
  min-height: 80px;
}

.settings-block {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 0;
}

.settings-form .card-actions {
  margin-top: 20px;
  margin-bottom: 20px;
}

.settings-block .card-actions:last-child {
  margin-bottom: 0;
}

.settings-sub-form .field,
.settings-sub-form .field-group-label {
  margin-bottom: 16px;
}

.settings-sub-form .field-group-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--tg-hint);
  margin: 20px 0 8px 0;
}

.settings-sub-form .field-group-label:first-child {
  margin-top: 0;
}

.settings-sub-form .field-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.settings-sub-form .field-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
}

.settings-sub-form textarea.field-input {
  resize: vertical;
  min-height: 80px;
}

.settings-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.settings-link-btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  transition: all var(--dur) var(--ease);
}

.settings-link-btn:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

.settings-export-block {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.settings-export-block .field-group-label {
  text-align: center;
}

.settings-export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.settings-export-btn {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  transition: all var(--dur) var(--ease);
}

.settings-export-btn:active {
  background: rgba(255,255,255,0.06);
  transform: scale(0.97);
}

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

.payments-header .btn-back,
.payments-header-add {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
}

.payments-header .btn-back {
  flex-shrink: 0;
}

.payments-header-add {
  flex: 1;
  min-width: 0;
  max-width: 320px;
  margin-top: 0;
  padding: 12px 18px;
  justify-content: center;
}

.client-edit-form .field {
  margin-bottom: 16px;
}

.client-edit-form .field-label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.client-edit-form .field-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
}

.client-edit-form .field-readonly {
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  color: var(--tg-hint);
}

.client-contacts-edit {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.client-contacts-edit .field-label {
  display: block;
  margin-bottom: 10px;
}

.contacts-edit-list {
  list-style: none;
  margin-bottom: 12px;
}

.contact-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.contact-edit-row .contact-type-select {
  min-width: 100px;
}

.contact-edit-row .contact-value-input,
.contact-edit-row .contact-label-input {
  flex: 1;
  min-width: 100px;
}

.contact-edit-row .btn-contact-del {
  padding: 8px 12px;
  min-width: 36px;
  background: var(--glass-del-bg);
  border: 1px solid var(--glass-del-border);
  color: var(--red-del);
  border-radius: var(--radius-sm);
  font-size: var(--fs-lg);
  cursor: pointer;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.contact-edit-row .btn-contact-del:hover {
  opacity: 0.9;
}

.btn-add-contact-row {
  padding: 10px 16px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--tg-hint);
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--dur), color var(--dur);
}

.btn-add-contact-row:hover {
  border-color: var(--tg-accent);
  color: var(--tg-accent);
}

.contact-type-select,
.contact-value-input,
.contact-label-input {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.contact-type-select:focus,
.contact-value-input:focus,
.contact-label-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.contact-type-select { width: 110px; }
.contact-value-input { flex: 1; min-width: 120px; }
.contact-label-input { width: 120px; }

.contact-label-input::placeholder,
.contact-value-input::placeholder {
  color: var(--tg-hint);
}

.client-balance-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.client-card-block > .client-balance-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.balance-inputs-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.balance-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.balance-input-row .balance-input-with-unit {
  flex: 1;
  min-width: 0;
  position: relative;
}

.balance-input-row .balance-input-with-unit .balance-input {
  width: 100%;
  padding-right: 26px;
  box-sizing: border-box;
}

.balance-input-row .balance-input-with-unit .balance-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tg-hint);
  font-size: var(--fs-body);
  pointer-events: none;
}

.client-card-block .balance-input-row select.field-input,
.client-card-block .balance-input-row .searchable-select-wrap {
  flex: 1;
  min-width: 0;
}

.client-card-block .balance-input-row select.field-input {
  padding: 12px 36px 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.client-card-block .balance-input-row select.field-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.client-card-block .balance-input-row .btn-confirm {
  flex: 0 0 auto;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-sm);
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.client-card-block .balance-input-row .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.client-card-block-add-client {
  position: relative;
  z-index: 10;
}

.searchable-select-wrap {
  position: relative;
}

.history-filter-searchable.searchable-select-wrap {
  flex: 1;
  min-width: 0;
}

.searchable-select-input {
  width: 100%;
  padding: 12px 36px 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.searchable-select-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.searchable-select-input::placeholder {
  color: var(--tg-hint);
}

.searchable-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  list-style: none;
  padding: 6px 0;
  border-radius: var(--radius);
  background: var(--tg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-card);
  z-index: 100;
  display: none;
}

.searchable-select-dropdown.open {
  display: block;
}

.searchable-select-dropdown li {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--tg-text);
  font-size: var(--fs-body);
}
.searchable-select-dropdown li:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.searchable-select-dropdown li:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.searchable-select-dropdown li:hover,
.searchable-select-dropdown li:focus {
  background: rgba(255, 255, 255, 0.08);
}

.searchable-select-dropdown li.searchable-select-empty {
  color: var(--tg-hint);
  cursor: default;
}

.client-card-block > .btn-cancel {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), background var(--dur);
}

.client-card-block > .btn-cancel:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.balance-input,
.balance-desc-input {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.balance-input:focus,
.balance-desc-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.balance-input { -moz-appearance: textfield; }
.balance-input::-webkit-outer-spin-button,
.balance-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.balance-inputs-wrap .balance-desc-input { width: 100%; min-width: 0; box-sizing: border-box; }
.balance-desc-input::placeholder {
  color: var(--tg-hint);
}

.client-history {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.client-card-block > .client-history {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.client-history .field-label {
  display: block;
  margin-bottom: 12px;
}

.history-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: var(--fs-body);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.history-item .history-op {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  font-size: var(--fs-sm);
}

.history-item .history-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.history-item .history-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.history-item .history-desc {
  color: var(--tg-hint);
  font-size: var(--fs-sm);
  line-height: 1.4;
  padding-left: 8px;
}

.history-item .history-date {
  flex-shrink: 0;
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}

.transaction-detail-modal {
  max-width: 320px;
}

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

.transaction-detail-op {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
  font-size: var(--fs-body);
}

.transaction-detail-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.transaction-detail-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.transaction-detail-date {
  font-size: var(--fs-body);
  color: var(--tg-hint);
}

.transaction-detail-id {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-bottom: 12px;
  word-break: break-all;
}

.transaction-detail-id:empty {
  display: none;
}

.transaction-detail-rate {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin-bottom: 12px;
}

.transaction-detail-rate:empty {
  display: none;
}

.transaction-detail-desc {
  font-size: var(--fs-body);
  color: var(--tg-text);
  margin-bottom: 16px;
  line-height: var(--lh-relaxed);
}

.transaction-detail-desc:empty {
  display: none;
}

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

.transaction-detail-actions .btn-confirm,
.transaction-detail-actions .btn-cancel {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.transaction-detail-actions .btn-confirm {
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  box-shadow: var(--shadow-btn), var(--glow-accent);
  font-weight: 600;
}

.transaction-detail-actions .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.transaction-detail-actions .btn-cancel {
  background: var(--glass-del-bg);
  color: var(--red-del);
  border: 1px solid var(--glass-del-border);
}

.transaction-detail-actions .btn-cancel:active {
  background: rgba(229, 101, 101, 0.18);
  transform: scale(0.97);
}

.history-item.clickable {
  cursor: pointer;
  transition: background var(--dur);
}

.history-item.clickable:active {
  background: rgba(255, 255, 255, 0.04);
}

.reversal-field-wrap {
  margin: 12px 0;
}

.reversal-modal .reversal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.reversal-modal .reversal-input::placeholder {
  color: var(--tg-hint);
}

.reversal-modal .reversal-input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.reversal-modal .reversal-input[type="number"] {
  -moz-appearance: textfield;
}

.reversal-actions {
  flex-direction: column;
  gap: 12px;
}

.reversal-return-row {
  display: flex;
  gap: 10px;
}

.reversal-return-row .btn-confirm {
  flex: 1;
}

.reversal-actions .btn-cancel {
  width: 100%;
}

.btn-export-excel {
  padding: 6px 12px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--tg-text);
}

.btn-export-excel:hover {
  border-color: var(--tg-button);
}

.history-toolbar {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.history-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin-bottom: 0;
}

.history-search {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
  box-sizing: border-box;
}

.history-search::placeholder {
  color: var(--tg-hint);
}

.history-filters-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-hint);
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
  box-sizing: border-box;
}

.history-filters-toggle:hover {
  color: var(--tg-text);
  background: rgba(255, 255, 255, 0.04);
}

.history-filters-toggle-icon {
  width: 12px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease);
}

.history-filters-toggle[aria-expanded="false"] .history-filters-toggle-icon {
  transform: rotate(-135deg);
}

.history-filters-wrap {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  transition: grid-template-rows 0.3s var(--ease);
  width: 100%;
}

.history-filters-wrap:not(.collapsed) {
  overflow: visible;
}

.history-filters-wrap.collapsed {
  grid-template-rows: 0fr;
}

.history-filters-inner {
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.history-filters-wrap:not(.collapsed) .history-filters-inner {
  overflow: visible;
}

.history-filters-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
}

.history-filters-row:last-child {
  margin-bottom: 0;
}

.history-filter {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.history-filter:focus,
.history-search:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.history-filter-select-wrap {
  flex: 1;
  min-width: 0;
}

.history-filter-select-wrap .history-filter-select {
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.history-filter-select-wrap .history-filter-select:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.custom-select-wrap {
  position: relative;
  width: 100%;
}
.custom-select-wrap select.history-filter-select {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.custom-select-trigger {
  display: block;
  width: 100%;
  padding: 10px 32px 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-sm);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.custom-select-trigger:hover,
.custom-select-trigger:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}
.custom-select-wrap.open .custom-select-trigger {
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}
.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  overflow: hidden;
  overflow-x: hidden;
  list-style: none;
  padding: 4px 0;
  margin: 0;
  border-radius: var(--radius);
  background: var(--tg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-card);
  z-index: 100;
  display: none;
}
.custom-select-wrap.open .custom-select-dropdown {
  display: block;
}
.custom-select-dropdown li {
  padding: 6px 12px;
  min-height: 36px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--tg-text);
  font-size: var(--fs-sm);
}
.custom-select-dropdown li:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.custom-select-dropdown li:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}
.custom-select-dropdown li:hover,
.custom-select-dropdown li:focus {
  background: rgba(255, 255, 255, 0.08);
}

.history-list-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pagination,
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.pagination-btn,
.history-pagination-btn {
  padding: 8px 16px;
  font-size: var(--fs-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

.pagination-btn:hover:not(:disabled),
.history-pagination-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.pagination-btn:disabled,
.history-pagination-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination-info,
.history-pagination-info {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.history-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  font-size: var(--fs-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background var(--dur);
}

.history-row-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.history-row.clickable {
  cursor: pointer;
}

.history-row.clickable:active {
  background: rgba(255, 255, 255, 0.04);
}

#history.active .history-row {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#history.active .history-row:nth-child(1) { animation-delay: 0.02s; }
#history.active .history-row:nth-child(2) { animation-delay: 0.04s; }
#history.active .history-row:nth-child(3) { animation-delay: 0.06s; }
#history.active .history-row:nth-child(4) { animation-delay: 0.08s; }
#history.active .history-row:nth-child(5) { animation-delay: 0.1s; }
#history.active .history-row:nth-child(n+6) { animation-delay: 0.12s; }

.history-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-cell.history-client {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.history-cell.history-op {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.history-cell.history-desc {
  flex: 1;
  min-width: 0;
  white-space: normal;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  color: var(--tg-hint);
}

.history-cell.history-date {
  flex-shrink: 0;
  color: var(--tg-hint);
  font-size: var(--fs-xs);
}

.history-cell.history-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.history-cell.history-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.history-empty,
.history-error {
  padding: 20px;
  text-align: center;
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}


.history-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: var(--fs-body);
}

.history-card .history-client {
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card .history-op {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  font-size: var(--fs-sm);
}

.history-card .history-op.credit {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}

.history-card .history-op.debit {
  background: var(--red-debit-bg);
  color: var(--red-debit);
}

.history-card .history-desc {
  width: 100%;
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}

.history-card .history-date {
  color: var(--tg-hint);
  font-size: var(--fs-sm);
}

.settings-rate-block {
  margin-bottom: 24px;
}

.rate-box {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.rate-display {
  transition: opacity var(--dur);
}

.rate-display.rate-loading .rate-value,
.rate-display.rate-loading .rate-earnings,
.rate-display.rate-loading .rate-earnings-alt,
.rate-display.rate-loading .rate-exchanges {
  animation: rate-pulse 0.6s ease-in-out infinite;
}

@keyframes rate-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.rate-value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--tg-text);
  font-variant-numeric: tabular-nums;
}

.rate-label {
  color: var(--tg-hint);
  margin-bottom: 6px;
  font-size: var(--fs-sm);
}

.rate-earnings {
  color: var(--tg-link);
  font-size: var(--fs-body);
  font-weight: 500;
  margin-bottom: 12px;
  min-height: 1.5em;
}

.rate-earnings-alt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

.rate-earnings-row {
  display: block;
}

.rate-exchanges {
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-bottom: 24px;
}

.rate-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.rate-actions input {
  width: 140px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  -moz-appearance: textfield;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.rate-actions input:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

.rate-actions input::-webkit-outer-spin-button,
.rate-actions input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rate-actions input::placeholder {
  color: var(--tg-hint);
}

.rate-actions button {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  font-size: var(--fs-body);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease);
  box-shadow: var(--shadow-btn), var(--glow-accent);
}

.rate-actions button:active {
  transform: scale(0.97);
}

.analytics-placeholder-text,
.analytics-message .analytics-placeholder-text {
  color: var(--tg-hint);
  font-size: var(--fs-body);
}

.analytics-message {
  padding: 24px 16px;
  text-align: center;
}

#analytics-access-denied[aria-hidden="true"],
#analytics-ga4-not-configured[aria-hidden="true"] {
  display: none;
}

.analytics-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.analytics-tab {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.analytics-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}

.analytics-tab.active {
  background: var(--tg-button);
  color: var(--tg-button-text);
  border-color: var(--tg-button);
}

.analytics-tab:active {
  transform: scale(0.97);
}

.ga4-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ga4-history-item {
  text-align: left;
}

.analytics-home {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analytics-home[aria-hidden="true"] {
  display: none;
}

.analytics-panel {
  display: block;
}

.analytics-panel[aria-hidden="true"] {
  display: none;
}

#analytics .analytics-row {
  display: flex;
  gap: 12px;
}

#analytics .analytics-row > .field {
  flex: 1;
  margin-bottom: 16px;
}

#analytics .history-filter-select-wrap {
  width: 100%;
}

#analytics .history-filter-select-wrap .history-filter-select {
  width: 100%;
  padding: 12px 32px 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background-color: var(--tg-secondary);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

#analytics .history-filter-select-wrap .history-filter-select:focus {
  outline: none;
  border-color: var(--tg-button);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tg-button) 25%, transparent);
}

#analytics .analytics-output-box {
  word-break: break-all;
  font-size: var(--fs-sm);
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--tg-secondary);
  color: var(--tg-link-color, var(--tg-link));
  min-height: 2.5rem;
  font-family: inherit;
}

#analytics .analytics-hint {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  margin: -8px 0 12px;
}

.analytics-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.analytics-loading[aria-hidden="true"] {
  display: none;
}

#analytics .analytics-loading .loading-indicator {
  padding: 0;
}

/* Shortlinks panel */
#analytics .shortlinks-filters-row {
  margin-bottom: 0;
}
#analytics .shortlinks-filters-row .field {
  margin-bottom: 16px;
}
#shortlinks-list-wrap .analytics-loading {
  min-height: 80px;
}
.shortlink-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shortlink-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shortlink-card-date {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}
.shortlink-card-status {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
}
.shortlink-status-active {
  background: var(--green-credit-bg);
  color: var(--green-credit);
}
.shortlink-status-pending {
  background: rgba(255, 193, 7, 0.2);
  color: #d4a017;
}
.shortlink-status-failed {
  background: var(--glass-del-bg);
  color: var(--red-del);
}
.shortlink-card-url {
  font-weight: 500;
  color: var(--tg-link);
  text-decoration: none;
  word-break: break-all;
}
.shortlink-card-url:hover {
  text-decoration: underline;
}
.shortlink-card-origin {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shortlink-card-spend {
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  font-variant-numeric: tabular-nums;
}
.shortlink-card-clicks {
  font-size: var(--fs-xs);
  color: var(--tg-link);
  font-variant-numeric: tabular-nums;
}
.shortlinks-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.shortlinks-pagination .btn-confirm {
  padding: 8px 14px;
  font-size: var(--fs-sm);
}
.shortlinks-pagination-info {
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

/* Shortlink detail panel */
.shortlink-detail-url-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shortlink-detail-url-wrap .shortlink-copy-btn {
  align-self: flex-start;
  padding: 8px 14px;
  font-size: var(--fs-sm);
}
.shortlink-detail-url {
  word-break: break-all;
  font-size: var(--fs-sm);
}
.shortlink-detail-short {
  word-break: break-all;
}
.shortlink-detail-status {
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}
.shortlink-detail-spend-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.shortlink-detail-spend-row .field-input {
  flex: 1;
  min-width: 80px;
}
.shortlink-detail-spend-row .btn-confirm {
  flex-shrink: 0;
}
.shortlink-save-spend-btn {
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.shortlink-save-spend-btn .shortlink-save-icon {
  flex-shrink: 0;
}

.analytics-report-result {
  margin-top: 16px;
}

.ga4-report-header {
  margin-bottom: 12px;
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}
.ga4-report-header .ga4-report-period {
  margin-bottom: 4px;
}
.ga4-report-header .ga4-report-export-date {
  font-size: var(--fs-xs);
}

.ga4-export-actions {
  margin-bottom: 14px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
}

.ga4-export-actions .ga4-export-btn {
  flex: 1;
  padding: 10px 14px;
  font-size: var(--fs-sm);
}

.ga4-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.ga4-preset-btn {
  padding: 6px 12px;
  font-size: var(--fs-sm);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--tg-section) 90%, white);
  color: var(--tg-text);
  cursor: pointer;
}
.ga4-preset-btn:hover {
  background: color-mix(in srgb, var(--tg-section) 80%, white);
}

#ga4-report-form-card {
  transition: max-height 0.35s ease-out, opacity 0.25s ease-out, padding 0.35s ease-out, margin 0.35s ease-out;
  overflow: hidden;
  max-height: 420px;
}
#ga4-report-form-card.ga4-form-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border: none;
}

.ga4-report-header-row {
  flex-wrap: wrap;
}
.ga4-report-header-row .ga4-report-bar[aria-hidden="true"] {
  display: none;
}
.ga4-report-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  margin-left: 8px;
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}
.ga4-report-bar-period {
  flex: 1;
  min-width: 0;
  color: var(--tg-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ga4-report-bar-edit {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--tg-section) 90%, white);
  color: var(--tg-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ga4-report-bar-edit:hover {
  background: color-mix(in srgb, var(--tg-section) 80%, white);
}
.ga4-report-bar-edit .ga4-icon-pencil {
  display: block;
}

#ga4-report-form-card .ga4-report-actions {
  align-items: stretch;
}
#ga4-report-form-card .ga4-report-actions .ga4-report-request-main {
  flex: 1;
}
#ga4-report-form-card .ga4-report-collapse-btn {
  flex-shrink: 0;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--tg-section) 90%, white);
  color: var(--tg-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#ga4-report-form-card .ga4-report-collapse-btn:hover {
  background: color-mix(in srgb, var(--tg-section) 80%, white);
}
#ga4-report-form-card .ga4-report-collapse-btn[aria-hidden="true"] {
  display: none;
}
#ga4-report-form-card .ga4-report-collapse-btn .ga4-icon-chevron-up {
  display: block;
}

.analytics-report-result .summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.analytics-report-result .summary-card-full {
  grid-column: 1 / -1;
}

.analytics-report-result .summary-card {
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 12px 10px;
  min-width: 0;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.analytics-report-result .summary-card strong {
  display: block;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--tg-text);
  font-variant-numeric: tabular-nums;
}

.analytics-report-result .summary-card span {
  display: block;
  font-size: var(--fs-xs);
  color: var(--tg-hint);
  margin-top: 4px;
}

.ga4-heatmap-wrap {
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ga4-heatmap {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: min(100%, 24 * 14px);
  font-size: var(--fs-xs);
  color: var(--tg-hint);
}

.ga4-heatmap-hour-labels {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 2px;
}

.ga4-heatmap-day-label {
  width: 28px;
  flex-shrink: 0;
  font-weight: 500;
  color: var(--tg-text);
}

.ga4-heatmap-hour-label {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.ga4-heatmap-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ga4-heatmap-cells {
  display: flex;
  gap: 2px;
}

.ga4-heatmap-cell {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 2px;
  min-width: 0;
}

.analytics-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  max-width: 100%;
  touch-action: pan-x pan-y;
}

.analytics-report-result table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0;
}

.analytics-report-result th,
.analytics-report-result td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--tg-hint);
}

.analytics-report-result th {
  font-weight: 600;
}

.analytics-report-result tr.good {
  background: rgba(76, 175, 80, 0.15);
}

.analytics-report-result tr.ok {
  background: rgba(255, 193, 7, 0.15);
}

.analytics-report-result tr.low {
  background: rgba(244, 67, 54, 0.1);
}

.analytics-report-result .chart-wrap {
  max-width: 100%;
  height: 320px;
  min-height: 200px;
  margin: 16px 0;
  padding: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

.client-card .field textarea {
  width: 100%;
  padding: 12px 16px;
  margin-top: 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--tg-bg);
  color: var(--tg-text);
  font-size: var(--fs-body);
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

#settings.active .settings-form {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#settings.active .settings-links {
  animation: dashIn var(--dur) var(--ease-out) 0.06s both;
}

#payments.active .payments-header {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#payments.active .btn-add {
  animation: dashIn var(--dur) var(--ease-out) 0.04s both;
}

#payments.active #payments-list li {
  animation: dashIn var(--dur) var(--ease-out) both;
}

#payments.active #payments-list li:nth-child(1) { animation-delay: 0.08s; }
#payments.active #payments-list li:nth-child(2) { animation-delay: 0.1s; }
#payments.active #payments-list li:nth-child(3) { animation-delay: 0.12s; }
#payments.active #payments-list li:nth-child(n+4) { animation-delay: 0.14s; }

#payments #payments-search {
  margin-bottom: 12px;
}

.payment-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.payment-row .info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.payment-row .info .title {
  display: block;
}

.payment-row .info .sub {
  display: block;
  word-break: break-all;
  white-space: pre-wrap;
}

.payment-row .card-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 4px;
}

.payment-row .card-actions button {
  flex: 1;
  padding: 10px 16px;
  white-space: nowrap;
}

.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-overlay.visible {
  display: flex;
}

.confirm-modal {
  max-width: 360px;
  width: 100%;
  background: color-mix(in srgb, var(--tg-section) 95%, white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  animation: popIn var(--dur) var(--ease-out) both;
}

.confirm-message {
  font-size: var(--fs-body);
  color: var(--tg-text);
  line-height: var(--lh-relaxed);
  margin-bottom: 16px;
}

.confirm-message .confirm-highlight {
  color: var(--tg-accent);
  font-weight: 600;
}

.confirm-message .confirm-message-desc {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--tg-hint);
}

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

.confirm-actions .btn-confirm,
.confirm-actions .btn-cancel {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease), opacity var(--dur), box-shadow var(--dur);
}

.confirm-actions .btn-confirm {
  background: var(--gradient-accent);
  color: var(--tg-button-text);
  box-shadow: var(--shadow-btn), var(--glow-accent);
  font-weight: 600;
}

.confirm-actions .btn-confirm:active {
  opacity: 0.92;
  transform: scale(0.97);
}

.confirm-actions .btn-cancel {
  background: var(--glass-del-bg);
  color: var(--red-del);
  border: 1px solid var(--glass-del-border);
}

.confirm-actions .btn-cancel:active {
  background: rgba(229, 101, 101, 0.18);
  transform: scale(0.97);
}

.alert-modal .confirm-actions {
  justify-content: stretch;
}

.alert-modal .confirm-actions .btn-confirm {
  flex: 1;
}

.screenshot-viewer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.screenshot-viewer-overlay.visible {
  display: flex;
}

.screenshot-viewer-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 85vh;
  max-height: 85vh;
  background: var(--tg-section);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.screenshot-viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur), transform var(--dur-s);
}

.screenshot-viewer-close::before {
  content: "\00d7";
}

.screenshot-viewer-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.screenshot-viewer-close:active {
  transform: scale(0.95);
}

.screenshot-viewer-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
}

.screenshot-viewer-inner {
  display: inline-block;
  min-width: 100%;
}

.screenshot-viewer-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  vertical-align: top;
}
