:root {
  color-scheme: light;
  --white: #fff;
  --on-atmosphere: #f3faff;
  --atmosphere-text-shadow: 0 0 5px rgba(230, 246, 255, .22);
  --line: rgba(255,255,255,.65);
  --divider: rgba(12,47,73,.18);
  --ink: #071d30;
  --quiet: #30485b;
  --focus: #286384;
  --glass: #dcebf6;
  --glass-warm: #e6f1f8;
  --control: #d5e8f6;
  --accent: linear-gradient(155deg, rgba(255,255,255,.98), rgba(232,251,255,.76));
  --rim: inset 0 1px 0 rgba(255,255,255,.66);
  --depth: 0 2px 4px rgba(6,36,58,.10), 0 9px 24px rgba(6,36,58,.14);
  --accent-shadow: var(--rim), 0 3px 8px rgba(6,36,58,.18);
  --danger: #512014;
  --radius: 16px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
  --safe-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
  --ease: 180ms cubic-bezier(.2,.75,.25,1);
  --glass-ease: cubic-bezier(.22, 1, .36, 1);
  background: transparent;
  color: var(--ink);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  accent-color: #204e74;
}
* { box-sizing: border-box; }
body { margin: 0; isolation: isolate; }
.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(ellipse at 3% 8%, #177878, transparent 60%),
    radial-gradient(ellipse at 95% 90%, #146b9a, transparent 58%),
    linear-gradient(145deg, #105368 8%, #125f87 44%, #155973 78%, #15567a);
}
.atmosphere::after {
  content: "";
  position: absolute;
  width: clamp(330px, 82vw, 1180px);
  height: 94%;
  left: 24%;
  top: 2%;
  background: radial-gradient(ellipse at 54% 50%, #a44186 0%, rgba(165,60,139,.85) 15%, rgba(131,64,156,.55) 34%, transparent 62%);
  will-change: transform;
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-17%, -10%, 0) rotate(-15deg) scale(.94); }
  to { transform: translate3d(14%, 10%, 0) rotate(8deg) scale(1.1); }
}
.page-hidden .atmosphere::after { animation-play-state: paused; }
::selection { background: #bfe5ff; color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: 4px; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
.btn[data-action="inline-client"][aria-expanded="true"] { color: #9C458F; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
strong, b { font-weight: 500; }
h1 { font-size: clamp(32px, 8vw, 42px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 400; overflow-wrap: anywhere; }
h2 { font-size: 17px; font-weight: 500; line-height: 1.3; }
h3 { font-size: 15px; font-weight: 500; }
small, .muted { color: var(--quiet); font-size: 13px; font-weight: 400; }
.wrap { overflow-wrap: anywhere; }
.shell {
  height: 100vh;
  height: 100dvh;
  height: var(--tg-viewport-stable-height, 100dvh);
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  grid-template-columns: minmax(0,1fr);
}
.topbar {
  padding: calc(8px + var(--safe-top)) max(20px,var(--safe-right)) 8px max(20px,var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: transparent; color: var(--on-atmosphere);
}
.topline { max-width: 720px; min-height: 44px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-button {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #163F61;
  position: relative;
  isolation: isolate;
  transition: transform var(--ease);
}
.profile-button::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(150deg, rgba(255,255,255,.32), transparent 70%), rgba(232,246,255,.74);
  box-shadow: var(--rim), 0 3px 8px rgba(6,36,58,.16);
  transition: box-shadow var(--ease);
}
.profile-button svg { display: block; width: 19px; height: 19px; fill: currentColor; }
.profile-button:focus-visible { outline-color: var(--white); }
.profile-button:active::before { box-shadow: var(--rim); }
@media (prefers-reduced-motion: no-preference) {
  .profile-button:active { transform: scale(.94); }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .profile-button::before { background: var(--glass); }
}
.brand { display: inline-flex; gap: 8px; align-items: center; font-size: 21px; font-weight: 500; letter-spacing: -0.02em; }
.mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #163c5d;
}
.mark .mark-glyph {
  display: block;
  width: 20px;
  height: auto;
  aspect-ratio: 512 / 446;
  fill: #a4ddff;
}
#main { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior-y: contain; padding: 24px max(20px,var(--safe-right)) calc(94px + var(--safe-bottom)) max(20px,var(--safe-left)); scrollbar-color: #497c9e transparent; }
.content { max-width: 720px; margin: auto; }
.heading { margin-bottom: 24px; }
.tasks-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
}
.tasks-heading > .btn { min-width: 0; max-width: 100%; }
.tasks-heading > .btn:focus-visible { outline-color: #fff; }
.heading p { margin-top: 8px; }
.section + .section { margin-top: 24px; }
.section-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-head small { padding-right: 4px; }
.surface { color: var(--ink); background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255,255,255,.73), 0 8px 22px rgba(6,36,58,.08); }
.task-panel.overdue { background: var(--glass-warm); }
.task-panel { overflow: hidden; }
.task-row { display: grid; grid-template-columns: minmax(58px, max-content) minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; min-height: 72px; }
.task-row + .task-row { border-top: 1px solid var(--divider); }
.task-clock {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  color: var(--quiet);
  white-space: nowrap;
}
.task-clock > :first-child { color: var(--ink); font-size: 14px; font-weight: 500; }
.task-copy {
  display: block;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}
.task-copy strong { display: block; font-size: 15px; font-weight: 500; }
.task-copy small { display: block; margin-top: 4px; }
.row-controls { display: flex; flex-wrap: wrap; gap: 4px; justify-content: end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 12px; border: 1px solid transparent; padding: 8px 12px; background: transparent; text-decoration: none; font-size: 14px; font-weight: 500; line-height: 1.3; text-align: center; }
.btn.secondary, .filter, .btn[data-action="touch"] {
  border-color: rgba(255, 255, 255, .79);
  background: var(--control);
  color: var(--ink);
}
.btn.quiet { color: var(--quiet); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 44px; padding: 0; flex: none; }
.btn.primary:not([data-action="touch"]),
.filter[aria-pressed="true"],
.btn[data-action="choose-stage"][aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--accent-shadow);
}
svg { width: 18px; height: 18px; flex: none; }
#nav {
  position: absolute;
  z-index: 2;
  bottom: calc(var(--safe-bottom) + 12px);
  left: var(--safe-left);
  right: var(--safe-right);
  margin: auto;
  width: max-content;
  max-width: calc(100% - var(--safe-left) - var(--safe-right));
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: clamp(2px, 1vw, 8px);
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.46);
  border-radius: 18px;
  color: var(--ink);
  background: #d7e9ee;
  box-shadow: var(--rim), 0 2px 4px rgba(5,26,46,.20), 0 9px 24px rgba(5,26,46,.28);
}
.nav-inner .btn { position: relative; width: 46px; height: 44px; padding: 0; color: var(--ink); border: 1px solid transparent; background: transparent; box-shadow: none; }
.nav-inner .btn svg { width: 21px; height: 21px; }
.nav-inner .btn[aria-current="page"] { color: var(--ink); background: var(--accent); }
.empty { padding: 20px; display: grid; gap: 8px; justify-items: start; }
.empty p { max-width: 42ch; color: var(--quiet); font-size: 14px; }
.empty .btn { margin-top: 4px; }
.search { margin-bottom: 10px; position: relative; }
.search svg { position: absolute; left: 12px; top: 14px; color: var(--quiet); pointer-events: none; }
.search input { padding-left: 38px; }
.filters { display: flex; overflow: auto; gap: 6px; padding: 4px 3px 10px; scrollbar-width: thin; }
.filter { border: 1px solid var(--line); min-height: 44px; white-space: nowrap; border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.filter[aria-pressed=true] { font-weight: 500; }
.client-list { display: grid; gap: 8px; margin-top: 8px; }
.client-add-action { display: flex; justify-content: center; margin: 16px 0 12px; }
.client-add-action .btn { border-radius: 999px; }
.client-row { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 12px; text-align: left; cursor: pointer; transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.client-name { color: #913E87; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
@media (prefers-contrast: more) { .client-name { color: var(--ink); } }
.client-meta, .client-aside { display: grid; align-content: start; gap: 4px; min-width: 0; }
.client-aside { justify-items: end; }
.client-aside > small { color: var(--ink); font-size: 14px; font-weight: 400; text-align: end; }
.next-task { grid-column: 1/-1; padding-top: 8px; border-top: 1px solid var(--divider); display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.badge { display: inline-flex; gap: 6px; align-items: center; border-radius: 8px; padding: 4px 8px; white-space: nowrap; font-size: 12px; line-height: 1.3; font-weight: 400; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .65; }
.badge { color: #16364b; background: rgba(255,255,255,.64); }
.open::before { background: #427ca3; }
.working::before { background: #21659b; }
.closed::before { background: #344c62; }
.detail { padding: 16px; display: grid; gap: 12px; }
.detail-actions, .touch, .inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.touch { justify-content: space-between; border-top: 1px solid var(--divider); padding-top: 12px; }
.touch strong { display: block; font-size: 14px; }
.detail .stage-button { justify-self: start; }
.notes, .detail-tasks { overflow: hidden; }
.note-row, .detail-task { padding: 12px; }
.note-row + .note-row, .detail-task + .detail-task { border-top: 1px solid var(--divider); }
.note-row p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.detail-task { display: grid; gap: 16px; padding-bottom: 14px; overflow-wrap: anywhere; }
.detail-task .muted { display: block; }
.detail-task .task-detail-actions { justify-content: start; gap: 8px; }
.detail-task .task-detail-actions > .btn.icon { background: rgba(177, 224, 242, .48); border-color: rgba(255, 255, 255, .79); }
.detail-task .task-detail-actions > [data-action="delete-task"] { color: #7b2442; }
dialog {
  position: fixed;
  inset: auto;
  top: calc(var(--dialog-top, 0px) + (var(--dialog-height, var(--tg-viewport-stable-height, 100dvh)) + var(--safe-top) - var(--safe-bottom)) / 2);
  left: calc(var(--dialog-left, 0px) + (var(--dialog-width, 100%) + var(--safe-left) - var(--safe-right)) / 2);
  transform: translate(-50%, -50%);
  width: min(520px, calc(var(--dialog-width, 100%) - 24px - var(--safe-left) - var(--safe-right)));
  max-width: none;
  max-height: min(calc(var(--dialog-height, 100dvh) - 24px - var(--safe-top) - var(--safe-bottom)), calc(var(--tg-viewport-stable-height, 100dvh) - 24px - var(--safe-top) - var(--safe-bottom)));
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: #edf6ff;
  box-shadow: 0 14px 44px rgba(6,36,58,.20), inset 0 1px 0 white;
  overflow: auto;
  overscroll-behavior: contain;
}
dialog[open] { animation: enter 180ms ease-out; }
dialog::backdrop { background: rgba(9,30,49,.32); }
@keyframes enter { from { opacity: .5; } to { opacity: 1; } }
.sheet-inner { padding: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 8px; }
.sheet-head h2 { font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
.sheet-head .btn { flex-shrink: 0; }
form, .sheet-options { display: grid; gap: 12px; }
.sheet-options .btn { justify-content: start; }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 400; color: var(--quiet); min-width: 0; }
input, textarea, select { min-width: 0; width: 100%; min-height: 44px; border: 1px solid rgba(33,70,99,.21); border-radius: 12px; background: rgba(255,255,255,.78); padding: 8px 12px; caret-color: var(--focus); color: var(--ink); font-size: 16px; transition: border-color var(--ease), box-shadow var(--ease); }
input::placeholder, textarea::placeholder { color: var(--quiet); opacity: .86; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.task-card { display: grid; gap: 6px; padding: 12px 16px; }
.task-icon-actions { display: flex; gap: 6px; margin-top: 6px; }
.task-icon-actions .btn > svg { color: var(--ink); }
.task-icon-actions .btn[data-action="delete-task"] > svg { color: #7b2442; }
.task-text-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 6px; }
.task-text-actions > .btn { min-width: 0; padding-inline: 8px; }
.task-text-actions > .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.task-card-date, .task-meta, .task-card-date > span { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.task-card-date { justify-content: space-between; color: var(--quiet); font-size: 13px; }
.task-card-date svg { width: 16px; height: 16px; }
.task-status { border-radius: 8px; padding: 3px 7px; background: #edf6fd; color: #14314b; }
.task-meta { font-size: 13px; overflow-wrap: anywhere; }
.task-card .task-meta { gap: 6px; }
.inline-client { min-width: 0; margin: 2px 0 0; padding: 8px 12px 12px; border-radius: 12px; border: 1px solid var(--divider); display: grid; gap: 8px; }
.inline-client legend { padding-inline: 4px; font-size: 13px; color: var(--quiet); }
.money-fields { display: grid; grid-template-columns: minmax(0,1fr) minmax(112px,.65fr); gap: 8px; }
.money-fields > label:first-child { position: relative; }
.money-fields > label:first-child::after { content: "₽"; position: absolute; right: 10px; bottom: 10px; pointer-events: none; }
.money-fields[data-currency="USD"] > label:first-child::after { content: "$"; }
.money-fields[data-currency="EUR"] > label:first-child::after { content: "€"; }
.money-fields input { padding-right: 32px; }
.money-fields > label:has(> input:required:invalid)::after { content: none; }
.form-error { color: var(--danger); font-size: 13px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .btn[aria-pressed=true] { background: #e9f5ff; border-color: #4a779a; }
.task-due-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.task-due-presets .btn { min-width: 0; min-height: 44px; }
dialog:has(.task-due-presets) { overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
dialog:has(.task-due-presets) .sheet-inner, dialog:has(.task-due-presets) form { min-width: 0; }
.btn[data-action="choose-stage"][aria-pressed="true"] .badge { background: transparent; }
.topbar .brand, .topline > small, .heading > h1, .heading > p,
.section-head > h2, .section-head > small {
  color: var(--on-atmosphere);
  text-shadow: var(--atmosphere-text-shadow);
}
.surface, dialog { box-shadow: var(--rim), var(--depth); }
.btn, .filter, input, textarea, select { box-shadow: var(--rim); }
.btn.quiet, .btn.danger { background: var(--control); border-color: var(--line); }
.filter[aria-pressed="true"] { border-color: #50768d; box-shadow: var(--rim); }
.task-card[data-state="inactive"] { border-style: dashed; }
.btn[data-action="choose-stage"][aria-pressed="true"] .badge { color: var(--ink); }
@supports ((backdrop-filter: blur(24px)) or (-webkit-backdrop-filter: blur(24px))) {
  .surface, dialog, .nav-inner, .filter {
    -webkit-backdrop-filter: blur(24px) saturate(135%);
    backdrop-filter: blur(24px) saturate(135%);
  }
  .surface, .btn.secondary, .btn.quiet, .btn.danger, .filter:not([aria-pressed="true"]) {
    background: linear-gradient(130deg, rgba(255,255,255,.10), transparent 45%), rgba(250,253,255,.68);
  }
  dialog { background: linear-gradient(145deg, rgba(255,255,255,.42), transparent 78%), rgba(234,245,255,.86); }
  .task-panel.overdue, .task-card[data-state="done"] { background: rgba(250,253,255,.76); }
  .nav-inner { background: linear-gradient(150deg, rgba(255,255,255,.34), transparent 64%), rgba(255,255,255,.52); }
}
.client-row:active {
  transform: scale(.985);
  box-shadow: var(--rim);
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .surface, dialog, .btn:not(.nav-inner .btn), .filter, input, select, textarea {
    background: #eaf5fc; color: var(--ink); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .nav-inner { background: #e0f2f5; }
}
#toast { position: fixed; z-index: 2; bottom: calc(78px + var(--safe-bottom)); left: 50%; transform: translate(-50%, 6px); padding: 8px 14px; border-radius: 12px; background: var(--ink); color: var(--white); font-size: 14px; width: max-content; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity var(--ease), transform var(--ease); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { max-width: 720px; margin: auto; display: grid; gap: 12px; }
.loading div { background: #bed6e6; height: 68px; border-radius: 12px; }
.loading div:first-child { height: 38px; width: 42%; margin-bottom: 10px; }
@media (min-width: 640px) { #main { padding-top: 32px; } .client-row, .detail { padding: 16px; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .atmosphere::after { will-change: auto; } }

.nav-inner .btn:focus-visible { outline-color: var(--ink); }

.deadline { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 8px; }
.task-card:focus { outline: 2px solid white; outline-offset: 2px; }

.task-shortcuts { margin-bottom: 12px; }
.task-title-fields { display: grid; gap: 4px; min-width: 0; }
.task-title-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.template-picker { position: relative; width: max-content; }
.template-picker.is-open { z-index: 3; }
.template-toggle { white-space: nowrap; }
.template-toggle[aria-expanded="true"] { background: var(--accent); }
.template-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.template-menu {
  position: absolute;
  z-index: 3;
  top: calc(100% + 6px);
  left: var(--template-x, 0px);
  width: var(--template-width, 260px);
  max-height: var(--template-height, 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #6b8592 transparent;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 14px;
  background: #f4fbff;
  color: var(--ink);
  box-shadow: var(--rim), 0 12px 30px rgba(9,30,49,.26);
}
.template-menu.opens-up { top: auto; bottom: calc(100% + 6px); }
@supports ((backdrop-filter: blur(24px)) or (-webkit-backdrop-filter: blur(24px))) {
  .template-menu {
    background: rgba(246,252,255,.92);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    backdrop-filter: blur(24px) saturate(150%);
  }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .template-menu { background: #f4fbff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.template-option {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: start;
  font-size: 14px;
}
.template-option[aria-pressed="true"] { background: #cee8f6; font-weight: 500; }
.template-option:focus-visible { outline-offset: -2px; }

.client-row {
  position: relative;
}
.client-open {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: start;
}
.client-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}
.client-open:focus-visible {
  outline: 0;
}
.client-open:focus-visible::after {
  outline: 2px solid var(--ink);
  outline-offset: -3px;
}
.client-stage {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.34);
  box-shadow: var(--rim);
}
.client-stage .badge { background: transparent; padding-inline: 2px; }
.client-stage svg { width: 14px; height: 14px; }
.stage-popover {
  top: clamp(
    calc(var(--dialog-top, 0px) + var(--safe-top) + 10px),
    var(--stage-top, 20px),
    calc(var(--dialog-top, 0px) + var(--dialog-height, 100dvh) - var(--safe-bottom) - var(--stage-height, 0px) - 10px)
  );
  left: clamp(
    calc(var(--dialog-left, 0px) + var(--safe-left) + 10px),
    var(--stage-left, 20px),
    calc(var(--dialog-left, 0px) + var(--dialog-width, 100vw) - var(--safe-right) - var(--stage-width, 0px) - 10px)
  );
  transform: none;
  width: min(250px, calc(var(--dialog-width, 100%) - 24px - var(--safe-left) - var(--safe-right)));
}
.stage-popover::backdrop { background: rgba(9,30,49,.10); }
.stage-popover .sheet-options { gap: 4px; }
.stage-popover .sheet-options .btn { justify-content: space-between; }
.sheet-options.stage-options { --stage-gap: 12px; gap: var(--stage-gap); }
.stage-popover .sheet-options.stage-options { --stage-gap: 4px; }
.stage-option { position: relative; }
.stage-option > .btn { width: 100%; justify-content: space-between; }
.stage-option .badge::before { content: none; }
.stage-option::before, .stage-option::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 31px;
  width: 2px;
  background: rgba(72, 90, 111, .20);
  pointer-events: none;
}
.stage-option::before {
  top: calc(var(--stage-gap) / -2);
  bottom: calc(50% + 13px);
  border-radius: 0 0 2px 2px;
}
.stage-option::after {
  top: calc(50% + 13px);
  bottom: calc(var(--stage-gap) / -2);
  border-radius: 2px 2px 0 0;
}
.stage-option:first-child::before, .stage-option:nth-child(3)::after { content: none; }
.stage-mark, .stage-selected {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
}
.stage-mark { height: 16px; align-content: center; }
.stage-mark svg, .stage-selected {
  height: 22px;
  border-radius: 50%;
}
.stage-mark svg { width: 22px; padding: 4px; }
[data-id="open"] .stage-mark svg { color: #9c5e19; background: #ffe0a6; }
[data-id="working"] .stage-mark svg { color: #325f9c; background: #c4dafb; }
[data-id="closed"] .stage-mark svg { color: #347651; background: #c4e7ce; }
:is(.client-stage, .stage-button) .badge::before { content: none; }
.badge.open .stage-mark svg { color: #9c5e19; background: #ffe0a6; }
.badge.working .stage-mark svg { color: #325f9c; background: #c4dafb; }
.badge.closed .stage-mark svg { color: #347651; background: #c4e7ce; }
.stage-selected {
  color: #fff;
  background: linear-gradient(150deg, #135fea, #0841d4);
  box-shadow: 0 2px 6px rgba(19, 85, 214, .30);
}
.stage-selected svg { width: 15px; height: 15px; stroke-width: 2.6; }

.task-shortcuts .template-toggle { background: var(--control); }
.task-shortcuts .template-toggle[aria-expanded="true"] { background: var(--accent); }

.counter {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  min-height: 19px;
  padding-inline: 4px;
  border-radius: 999px;
  background: #dceef8;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.nav-inner .btn .counter { position: absolute; top: -2px; right: -3px; }
.repeat-label { width: fit-content; color: var(--ink); }
.client-fields, .task-client-picker, .paste-client[open] { display: grid; gap: 8px; min-width: 0; }
.paste-client {
  padding-inline: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.4);
}
.paste-client summary { min-height: 44px; padding-block: 10px; font-weight: 500; cursor: pointer; }
.paste-client[open] { padding-bottom: 10px; }
.paste-client[open] > :not(summary) { margin-top: 8px; }
.paste-feedback { display: block; }
.paste-feedback:empty { display: none; }
.task-client-search { position: relative; }
.client-choices {
  position: relative;
  max-height: min(176px, calc(var(--dialog-height, 100dvh) * .36));
  margin-top: 4px;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #f4fbff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--rim);
}
.client-choices strong, .client-choices small { display: block; overflow-wrap: anywhere; }
.client-choices p { padding: 8px; }
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  padding: 6px;
  border-radius: 14px;
  background: #eef7fc;
  box-shadow: var(--rim), 0 -3px 12px rgba(9,30,49,.12);
}
.confirm-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.client-delete-confirm:focus { outline: none; }
.client-delete-confirm .confirm-actions [data-action="close-sheet"]:focus { outline: none; }
.client-delete-confirm .confirm-actions [data-action="close-sheet"]:focus-visible {
  outline: 2px solid #7b2442;
  outline-offset: 2px;
}
.client-delete-confirm .confirm-actions .danger {
  color: #7b2442;
  border-color: #7b2442;
}
.client-delete-confirm .confirm-actions .danger:focus-visible {
  outline-color: #7b2442;
}
.clipboard-helper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
/* Put actions below the title before their fixed tap targets squeeze the text. */
@media (max-width: 460px) {
  #main { padding-inline: max(12px, var(--safe-left)) max(12px, var(--safe-right)); }
  .task-row { grid-template-columns: minmax(48px, max-content) minmax(0,1fr); gap: 4px 8px; }
  .task-row > .row-controls { grid-column: 2; justify-content: start; padding-left: 8px; }
  .client-row { grid-template-columns: minmax(0,1fr) minmax(96px, 40%); }
  .client-aside { overflow-wrap: anywhere; }
  .client-stage { max-width: 100%; }
  .client-stage .badge { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .detail-task { flex-wrap: wrap; }
  .detail-task > div:first-child { min-width: 0; }
  .detail-task > .row-controls { justify-content: start; }
  .sheet-inner, .task-card, .detail { padding-inline: 12px; }
  .task-title-head, .section-head { flex-wrap: wrap; }
  .money-fields { grid-template-columns: minmax(0,1fr) minmax(100px,.65fr); }
}

.task-row > .row-controls > .btn {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .42);
  box-shadow: none;
}
@media (max-width: 360px) {
  .inline-client .form-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-height: 500px) {
  #main { padding-top: 12px; }
  .heading { margin-bottom: 12px; }
  .topbar { padding-bottom: 4px; }
}

.quick-actions .btn {
  min-height: 48px;
  gap: 12px;
  text-align: start;
  font-weight: 500;
}
.quick-actions .btn > svg { color: #6792da; }
.finance {
  --finance-turn: 0deg;
  position: relative;
  margin: 0 0 16px;
  border-radius: var(--radius);
  perspective: 1600px;
}
.finance[data-flipped="true"] { --finance-turn: -180deg; }
.finance-toggle {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
}
.finance-toggle:focus-visible { outline-offset: -3px; }
.finance-rotor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  transition: transform 260ms var(--glass-ease);
}
.finance-face {
  grid-area: 1 / 1;
  min-width: 0;
  padding: 0 16px 16px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: perspective(1600px) rotateY(0deg);
  opacity: 1;
  transition: transform 220ms ease-out 220ms, opacity 0s linear 220ms;
}
.finance-back {
  transform: perspective(1600px) rotateY(90deg);
  opacity: 0;
  transition: transform 220ms ease-in, opacity 0s linear 220ms;
}
.finance[data-flipped="true"] .finance-face:not(.finance-back) {
  transform: perspective(1600px) rotateY(-90deg);
  opacity: 0;
  transition: transform 220ms ease-in, opacity 0s linear 220ms;
}
.finance[data-flipped="true"] .finance-back {
  transform: perspective(1600px) rotateY(0deg);
  opacity: 1;
  transition: transform 220ms ease-out 220ms, opacity 0s linear 220ms;
}
.finance-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 8px;
  font-size: inherit;
  font-weight: 500;
}
.finance-title svg { width: 16px; height: 16px; flex: none; color: var(--quiet); }
@media (hover: hover) and (pointer: fine) {
  .finance-toggle:hover + .finance-rotor .finance-face {
    border-color: rgba(255, 255, 255, .94);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .finance-toggle:active + .finance-rotor {
    transform: scale(.988);
  }
}
.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
}
.finance-grid dt, .payment-totals, .payment-list small {
  color: var(--quiet);
  font-size: 12px;
}
.finance-grid dd { margin: 0; overflow-wrap: anywhere; }
.finance-grid dd > span { display: block; }
.finance-metric dd {
  font-size: clamp(18px, 4.5vw, 28px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.finance-secondary {
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}
.finance-secondary dd { font-size: 14px; font-weight: 500; }
.stats-panel { padding: clamp(14px, 4vw, 28px); }
.stats-panel h2 { font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
.stats-panel > p { margin: 4px 0 18px; }
.stats-panel + .stats-panel { margin-top: 12px; }
.stats-overview { display: grid; gap: 18px; }
.stats-overview > * { min-width: 0; }
.stats-overview h2 + p { margin-top: 4px; }
.stats-axis { display: flex; justify-content: space-between; padding-inline: 2.5%; }
.stats-money + .stats-money { margin-top: 14px; }
.stats-money tbody td { font-size: 13px; line-height: 1.3; }
.stats-money tr > :last-child { width: 22%; }
.stats-panel > .stats-note { margin: 10px 0 0; }
.stats-work { margin-top: 12px; }
.stats-work h3 { margin-bottom: 10px; }
.stats-work p.muted { margin-bottom: 14px; }
.stats-rate { font-size: clamp(30px, 8vw, 42px); font-weight: 400; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.stats-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding-top: 18px; }
.stats-bar {
  appearance: none;
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 0;
  gap: 4px;
  padding: 1px;
  border: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1.3;
  touch-action: manipulation;
}
.stats-bar:focus { outline: none; }
.stats-bar:focus-visible small { text-decoration: underline; text-underline-offset: 2px; }
.stats-bar-track {
  display: flex;
  align-items: end;
  width: min(18px, 100%);
  height: 66px;
  overflow: hidden;
  border-radius: 9px;
  background-color: var(--divider);
  pointer-events: none;
  transition: background-color 260ms var(--glass-ease), transform 260ms var(--glass-ease);
}
.stats-bar-track span { width: 100%; border-radius: inherit; background: #658092; }
.stats-bar:has(.stats-bar-count) .stats-bar-track span { background: #246784; }
.stats-bar-count { position: absolute; inset: auto 0 calc(100% + 2px); text-align: center; font-size: 11px; }
.stats-bar:active .stats-bar-track { transform: scale(.97); }
.stats-bar[aria-pressed="true"] .stats-bar-track { background-color: rgba(255,255,255,.38); }
.stats-bar[aria-pressed="true"] small { color: var(--ink); font-weight: 600; }
.stats-timeline { list-style: none; margin: 0; padding: 0; }
.stats-timeline li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; position: relative; padding-bottom: 12px; overflow-wrap: anywhere; }
.stats-timeline li + li { padding-top: 2px; }
.stats-timeline li:last-child { padding-bottom: 0; }
.stats-timeline li:not(:last-child)::before { content: ""; position: absolute; left: 8px; top: 13px; bottom: -4px; width: 1px; background: var(--divider); }
.stats-step { position: relative; display: grid; place-items: center; border: 1px solid #658092; border-radius: 50%; width: 17px; height: 17px; margin-top: 2px; background: var(--glass); font-size: 11px; }
.stats-step.is-done { background: var(--focus); color: var(--white); border-color: var(--focus); }
.stats-timeline strong { font-weight: 500; font-size: 13px; }
.stats-timeline small { display: block; color: var(--quiet); font-size: 11px; }
.stats-controls, .stats-currencies { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.stats-controls strong { flex: 1; text-align: center; font-weight: 550; }
.stats-next svg { transform: rotate(180deg); }
.stats-currencies .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--focus); }
.stats-finance-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-block: 12px; }
.stats-finance-actions .stats-currencies { margin: 0; gap: 4px; }
.stats-currencies { flex-wrap: wrap; }
.stats-finance-actions .btn { padding-inline: 8px; }
.stats-panel > .stats-comparison { margin: 16px 0 4px; }
.stats-detail { border-top: 1px solid var(--divider); }
.stats-detail summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; padding: 8px 2px; cursor: pointer; list-style: none; font-size: 13px; }
.stats-detail summary::-webkit-details-marker { display: none; }
.stats-detail summary > span { flex: 1 1 75px; }
.stats-detail summary strong { font-variant-numeric: tabular-nums; }
.stats-detail summary svg { transition: transform var(--ease); width: 14px; }
.stats-detail[open] summary svg { transform: rotate(180deg); }
.stats-detail-body { display: grid; gap: 4px; padding: 0 2px 10px; }
.stats-detail[open] .stats-detail-body { animation: stats-reveal 180ms ease-out; }
@keyframes stats-reveal { from { opacity: 0; transform: translateY(-3px); } }
.stats-panel .stats-growth { color: #216043; text-shadow: 0 0 7px #a7edbd, 0 0 13px #c1f4ce; }
.btn.stats-task-link { justify-content: start; text-align: left; width: 100%; padding: 0 4px; overflow-wrap: anywhere; }
@media (min-width: 490px) {
  .stats-overview { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; }
}
.payment-totals { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.client-profile {
  padding-block: 14px;
}
.payment-history { gap: 8px; }
.client-profile-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 8px; }
.client-profile-actions { display: grid; gap: 9px; align-content: end; }
.client-profile-summary {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-width: 0;
}
.client-deal {
  align-self: center;
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--quiet);
}
.client-contact-actions { grid-row: 3; display: flex; gap: 8px; min-width: 0; }
.client-call-number { font-size: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.client-profile :is(.client-contact-actions, .client-profile-actions) > .btn.icon {
  width: 44px; height: 44px; background: rgba(177, 224, 242, .48);
}
.client-profile-actions > [data-action="delete-client"] { color: #7b2442; }
.client-sections, .client-section { display: grid; gap: 8px; min-width: 0; }
.client-sections { gap: 16px; }
.client-section .section-head { margin: 0; }
.payment-history .payment-totals { padding: 2px 0; }
.payment-history .operation-add { justify-self: start; }
.operation-empty { font-size: 13px; }
.payment-list .operation-out { color: #854067; }
.payment-list .operation-in { color: #146050; }

.segmented {
  --segments: 2;
  --selected: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--segments), minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
}
.segmented[data-segments="3"] { --segments: 3; }
.segmented[data-selected="1"] { --selected: 1; }
.segmented[data-selected="2"] { --selected: 2; }
.segmented::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / var(--segments));
  border-radius: 10px;
  background: var(--accent);
  box-shadow: var(--rim), 0 1px 3px rgba(6,36,58,.15);
  transform: translateX(calc(var(--selected) * 100%));
  transition: transform 280ms var(--glass-ease);
}
.segmented button {
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--quiet);
  font: inherit;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.segmented button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.segmented button:active { background: rgba(255,255,255,.36); }
.client-sections > .segmented {
  z-index: 1;
  margin: 12px 10px 0;
  background: linear-gradient(165deg, rgba(247,252,255,.97), rgba(214,233,246,.94));
  box-shadow: var(--rim), 0 5px 12px rgba(6,36,58,.17);
}
.client-sections > .segmented::before {
  box-shadow: var(--rim), 0 2px 6px rgba(6,36,58,.16);
}
.client-sections :is(.payment-history, .client-section > .empty) { padding-bottom: 24px; }
.client-sections .client-section > .notes { padding-bottom: 20px; }
.payment-totals strong { margin-inline-start: 3px; color: var(--ink); font-size: 14px; font-weight: 500; }
.payment-list { margin: 0; padding: 0; list-style: none; }
.payment-list li {
  border-top: 1px solid var(--divider);
  padding-block: 6px;
}
.btn.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  text-align: start;
  overflow-wrap: anywhere;
}
.payment-row > * { min-width: 0; }
.payment-row:focus-visible { outline-offset: -2px; }
.payment-list small { display: block; }
.payment-list strong { text-align: end; font-weight: 500; }

#next-step {
  position: fixed;
  z-index: 4;
  bottom: calc(82px + var(--safe-bottom));
  left: calc((100% + var(--safe-left) - var(--safe-right)) / 2);
  transform: translateX(-50%);
  width: min(390px, calc(100% - 24px - var(--safe-left) - var(--safe-right)));
  padding: 12px;
  background-color: rgba(241,249,255,.95);
  animation: step-lifetime 4s ease both;
}
#next-step small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#next-step > div { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
#next-step .btn { padding-inline: 8px; font-size: 13px; }
@keyframes step-lifetime { 0%,100% {opacity:0} 5%,94% {opacity:1} }

.task-copy, .client-open { min-height: 44px; }
.task-copy:focus-visible { outline-offset: -2px; }
.task-meta > *, .detail-actions > *, .payment-list > li > * { min-width: 0; overflow-wrap: anywhere; }
.next-task span { min-width: 0; }
form, .sheet-options { grid-template-columns: minmax(0, 1fr); }
.deadline input, .money-fields select { max-width: 100%; }
.template-option { overflow-wrap: anywhere; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 4px 0 8px;
}
.filter-grid .filter {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 52px;
  padding: 6px 4px;
  white-space: normal;
  line-height: 1.2;
}
.filter-grid .filter > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 400px) {
  .filter-grid .filter { flex-direction: column; font-size: 12px; }
}

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

.task-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.task-filters .filter:last-child { grid-column: 1 / -1; }
.task-filters .filter { flex-direction: row; flex-wrap: nowrap; white-space: nowrap; }
.task-filters .filter > :first-child { overflow-wrap: normal; }

/* Taps should not double-tap zoom; scrolling and pinch zoom stay native. */
button, a, summary, input, textarea, select { touch-action: manipulation; }
@media (max-width: 600px), (pointer: coarse) {
  :root { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

  /* Tint and rim carry the glass look when list items scroll over the animated backdrop. */
  .surface, .filter, .template-menu {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .surface { background-color: rgba(250,253,255,.78); }
  /* Keep the scrolling card on its own stable layer in mobile WebViews. */
  .stats-productivity {
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  .template-menu { background: #f4fbff; }
  dialog, .nav-inner {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  body:has(dialog[open]) .atmosphere::after { animation-play-state: paused; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  dialog, .nav-inner { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .surface { background-color: #eaf5fc; }
}

.paste-preview { display: grid; gap: 8px; margin: 0; }
.paste-preview > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px; }
.paste-preview dt { color: var(--quiet); font-size: 13px; }
.paste-preview dd { margin: 0; overflow-wrap: anywhere; font-size: 14px; }
.parsed-service-edit { display: grid; gap: 8px; }
.paste-consent { grid-template-columns: 44px 1fr; align-items: center; min-height: 44px; }
.paste-consent input { width: 20px; height: 20px; min-height: 0; margin: auto; padding: 0; }

:is(.btn, .filter, .client-stage, .template-option, .task-copy) {
  transition: transform 260ms var(--glass-ease);
}

@media (hover: hover) and (pointer: fine) {
  :is(.btn, .filter, .client-stage, .template-option, .task-copy) {
    position: relative;
    transition: transform 260ms var(--glass-ease), box-shadow 280ms var(--glass-ease),
      background-color 240ms ease, border-color 240ms ease;
  }

  :is(.btn, .filter, .client-stage, .template-option, .task-copy):not(:disabled, [aria-disabled="true"]):hover {
    background-color: rgba(255, 255, 255, .72);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .96), 0 3px 8px rgba(6, 36, 58, .12);
  }

  :is(.btn:not(.nav-inner .btn), .filter:not([aria-pressed="true"]), .client-stage):not(:disabled, [aria-disabled="true"]):hover {
    border-color: rgba(255, 255, 255, .94);
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  :is(.btn, .filter, .client-stage, .template-option, .task-copy):not(:disabled, [aria-disabled="true"]):hover {
    transform: translateY(-1.5px);
  }

  /* Keep the original bottom edge hittable as the button lifts. */
  :is(.btn, .filter, .client-stage, .template-option, .task-copy):not(:disabled, [aria-disabled="true"]):hover::after {
    content: "";
    position: absolute;
    inset: auto 0 -2px;
    height: 3px;
  }

}

@media (prefers-reduced-motion: no-preference) {
  :is(.btn, .filter, .client-stage, .template-option, .task-copy):not(:disabled, [aria-disabled="true"]):active {
    transform: translateY(.5px) scale(.985);
    transition-duration: 110ms;
  }
}
@media (prefers-reduced-motion: reduce) { .client-row:active { transform: none; } }

.surface.client-row {
  --client-rim: inset 0 1px 0 rgba(255,255,255,.84);
  background: linear-gradient(170deg, rgba(255,255,255,.39), transparent 58%), rgba(228,245,255,.81);
  box-shadow: var(--client-rim), var(--depth);
}
.surface.client-row:active { box-shadow: var(--client-rim); }
@media (hover: hover) and (pointer: fine) {
  .surface.client-row:hover {
    --client-rim: inset 0 1px 0 rgba(255,255,255,.97);
    border-color: rgba(255,255,255,.90);
  }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .surface.client-row { background: #eaf5fc; }
}

.client-stage:has(.badge.open) { --stage-glass: #e6f4ff; --stage-dot: #5186ac; }
.client-stage:has(.badge.working) { --stage-glass: #e2f5f6; --stage-dot: #397c88; }
.client-stage:has(.badge.closed) { --stage-glass: #eaf0fb; --stage-dot: #657693; }
.client-stage {
  background-image: linear-gradient(160deg, var(--stage-glass, transparent), transparent 88%);
}
.client-stage .badge::before {
  flex: none;
  background: var(--stage-dot, currentColor);
}

@media (hover: hover) and (pointer: fine) {
  .btn.payment-row:not(:disabled, [aria-disabled="true"]):hover {
    transform: none;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .96);
  }
  .btn.payment-row:hover::after { content: none; }
}
.btn.payment-row:not(:disabled, [aria-disabled="true"]):active {
  transform: none;
  background-color: rgba(255, 255, 255, .55);
}

.task-card :is(.task-icon-actions, .task-text-actions) > .btn {
  position: relative;
  isolation: isolate;
  border-width: 0;
  background: none;
  box-shadow: none;
}
.task-card :is(.task-icon-actions, .task-text-actions) > .btn::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px 0;
  border: 1px solid rgba(255, 255, 255, .46);
  border-radius: inherit;
  background: rgba(255, 255, 255, .24);
  pointer-events: none;
  transition: background-color var(--ease);
}
.task-card .task-icon-actions > .btn::before { background: rgba(177, 224, 242, .48); border-color: rgba(255, 255, 255, .79); }
.task-card .task-text-actions > .btn.primary::before {
  background: rgba(244, 253, 255, .40);
}
@media (hover: hover) and (pointer: fine) {
  .task-card :is(.task-icon-actions, .task-text-actions) > .btn:not(:disabled, [aria-disabled="true"]):hover {
    background: none;
    box-shadow: none;
  }
  .task-card :is(.task-icon-actions, .task-text-actions) > .btn:not(:disabled, [aria-disabled="true"]):hover::before {
    background: rgba(255, 255, 255, .48);
  }
}
.task-card :is(.task-icon-actions, .task-text-actions) > .btn:not(:disabled, [aria-disabled="true"]):active::before {
  background: rgba(255, 255, 255, .54);
}
@media (forced-colors: active) {
  .task-card :is(.task-icon-actions, .task-text-actions) > .btn::before { border-color: ButtonText; }
}

.profile-content, .profile-settings { display: grid; gap: 14px; }
.profile-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(255,255,255,.54), rgba(226,241,250,.40));
  box-shadow: var(--rim);
}
.profile-content > .profile-card:nth-of-type(even),
.profile-settings > .profile-card:nth-of-type(even) {
  background: linear-gradient(150deg, rgba(255,255,255,.58), rgba(239,230,245,.30));
}
.profile-card h3 { font-weight: 600; }
.leadly-guide { display: grid; gap: 18px; padding-bottom: 12px; }
.leadly-guide section { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--divider); }
.leadly-guide section:last-child { border-bottom: 0; }
.leadly-guide p { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.leadly-guide b { font-weight: 600; }
#sheet:has(.leadly-guide) { height: min(760px, calc(var(--dialog-height, 100dvh) - 24px - var(--safe-top) - var(--safe-bottom))); }
#sheet[open]:has(:is(.profile-content, .leadly-guide)) {
  display: flex;
  overflow: hidden;
}
#sheet:has(:is(.profile-content, .leadly-guide)) > .sheet-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
#sheet:has(:is(.profile-content, .leadly-guide)) .sheet-head { flex: none; }
#sheet:has(:is(.profile-content, .leadly-guide)) .sheet-head h2 {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(155deg, rgba(255,255,255,.68), rgba(196,230,248,.72));
  pointer-events: none;
}
#sheet :is(.profile-content, .leadly-guide) {
  min-height: 0;
  overflow: hidden auto;
  overscroll-behavior-y: contain;
}
.profile-account { grid-template-columns: auto minmax(0,1fr); align-items: center; }
.profile-account small { display: block; overflow-wrap: anywhere; }
.profile-account h3 { overflow-wrap: anywhere; }
.profile-avatar {
  position: relative;
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--accent);
  color: #163f61;
  font-weight: 600;
  overflow: hidden;
}
.profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 180ms ease; }
.profile-avatar img.is-loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .profile-avatar img { transition: none; } }
.profile-pair { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.profile-pair:has([name="timezone"]) { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.profile-card :is(input, select) { min-width: 0; max-width: 100%; }
.profile-switch { display: flex; align-items: center; justify-content: space-between; min-height: 34px; gap: 8px; }
.profile-switch input {
  appearance: none;
  flex: none;
  width: 44px;
  min-height: 0;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #bacddd;
  cursor: pointer;
}
.profile-switch input::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  transition: transform var(--ease);
}
.profile-switch input:checked { background: #397c91; }
.profile-switch input:checked::before { transform: translateX(18px); }
.profile-services { list-style: none; display: grid; gap: 4px; padding: 0; margin: 0; }
.profile-services:empty { display: none; }
.profile-services li { display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
.profile-services .btn { flex: none; }
.profile-service-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; }
.profile-service-form .form-error { grid-column: 1 / -1; }
#sheet:has(.profile-content) .sheet-head {
  padding: 4px 8px;
  margin: -4px -4px 8px;
}
#sheet:has(.profile-content) .sheet-head .btn { border-radius: 50%; }
#sheet:has(.profile-content) :focus-visible { outline: 2px solid #fff; outline-offset: 0; box-shadow: 0 0 0 3px rgba(7,29,48,.24); }
