/* Tony design system 2026 ---------------------------------------------------
   Final visual layer, loaded after app.css. app.css keeps layout and feature
   structure; this file owns tokens, typography, surfaces and interaction. */

/* Onest, self-hosted (SIL OFL 1.1, see ../fonts/OFL-Onest.txt). Variable weight 100–900. */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/onest-cyrillic-ext.woff2") format("woff2-variations"), url("../fonts/onest-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/onest-cyrillic.woff2") format("woff2-variations"), url("../fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/onest-latin-ext.woff2") format("woff2-variations"), url("../fonts/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/onest-latin.woff2") format("woff2-variations"), url("../fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root,
body,
html body:not(.is-telegram-mini-app) {
  --font-sans: Onest, "Segoe UI Variable Text", "Segoe UI Variable", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --font-display: Onest, "Segoe UI Variable Display", "Segoe UI Variable", -apple-system, BlinkMacSystemFont, "SF Pro Display", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --ink: #111318;
  --ink-soft: #5b616e;
  --ink-faint: #8a909b;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --surface-muted: #f1f2f5;
  --surface-hover: #f3f4f7;
  --line: #e8eaef;
  --line-strong: #d9dce3;

  --accent: #10a571;
  --accent-strong: #0a7f56;
  --accent-soft: #e9f7f0;
  --accent-ring: rgb(16 165 113 / 20%);

  --brand-950: #0d0f13;
  --brand-900: #15181d;
  --brand-800: #262a32;
  --brand-700: #0a7f56;
  --brand-600: #0a7f56;
  --brand-500: #10a571;
  --brand-300: #9edcc2;
  --brand-100: #e9f7f0;

  --warm-100: #fdf3e4;
  --warm-600: #a35f1c;
  --blue-100: #e8f0fb;
  --blue-600: #3a68b0;
  --purple-100: #f1ecfb;
  --purple-600: #6a4fb0;
  --danger-100: #fdecec;
  --danger-600: #c2413b;
  --success-100: #e9f7f0;
  --success-700: #0a7f56;

  --shadow-xs: 0 1px 2px rgb(16 19 26 / 5%);
  --shadow-sm: 0 1px 2px rgb(16 19 26 / 4%), 0 2px 8px rgb(16 19 26 / 4%);
  --shadow-md: 0 4px 12px rgb(16 19 26 / 6%), 0 1px 3px rgb(16 19 26 / 5%);
  --shadow-lg: 0 24px 48px -12px rgb(16 19 26 / 18%), 0 4px 12px rgb(16 19 26 / 6%);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --sidebar-width: 252px;
  /* Content fills the column next to the sidebar; the cap only matters on
     ultra-wide monitors, where endless lines would hurt readability. */
  --page-width: 1840px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 140ms var(--ease);
  --t: 200ms var(--ease);
}

:root { font-family: var(--font-sans); background: var(--canvas); }

html body,
html body:not(.is-telegram-mini-app) {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--canvas);
  background-attachment: initial;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.003em;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); letter-spacing: -.02em; }
h1 { font-weight: 650; }
h2, h3 { font-weight: 620; }
strong, b { font-weight: 600; }
::selection { background: rgb(16 165 113 / 18%); }

/* Every interactive element shows the hand cursor across its whole hit area,
   including nested icons and text. */
a[href], button:not(:disabled), summary, select, label[for],
[role="button"], [role="tab"], [data-dialog-open], [data-tab],
input[type="checkbox"], input[type="radio"], input[type="color"], input[type="file"] { cursor: pointer; }
a[href] *, button:not(:disabled) *, summary *, [role="button"] *, [role="tab"] * { cursor: inherit; }
button:disabled, .button[disabled] { cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: #cfd3da transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: #cfd3da padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #b5bac4; }
*::-webkit-scrollbar-track { background: transparent; }

.eyebrow,
html body .eyebrow {
  color: var(--ink-faint);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
}

/* Buttons --------------------------------------------------------------- */
html body .button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 560;
  letter-spacing: -.005em;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
html body .button:hover { transform: none; }
html body .button:active { transform: scale(.98); }
html body .button svg { width: 16px; height: 16px; }
html body .button--primary,
html body:not(.is-telegram-mini-app) .button--primary {
  border-color: transparent;
  background: var(--brand-900);
  color: #fff;
  box-shadow: 0 1px 2px rgb(16 19 26 / 18%), inset 0 1px 0 rgb(255 255 255 / 10%);
}
html body .button--primary:hover,
html body:not(.is-telegram-mini-app) .button--primary:hover { background: #2a2e36; box-shadow: 0 4px 12px rgb(16 19 26 / 18%); }
html body .button--quiet,
html body:not(.is-telegram-mini-app) .button--quiet,
html body:not(.is-telegram-mini-app) .icon-button--surface {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
}
html body .button--quiet:hover,
html body:not(.is-telegram-mini-app) .button--quiet:hover,
html body:not(.is-telegram-mini-app) .icon-button--surface:hover { border-color: #c8ccd4; background: var(--surface-hover); }
html body .button--ghost { color: var(--ink-soft); }
html body .button--ghost:hover { background: var(--surface-hover); color: var(--ink); }
html body .icon-button { border-radius: 10px; transition: background-color var(--t-fast), color var(--t-fast); }
html body .icon-button:hover { background-color: var(--surface-hover); }

/* Green call-to-action variants from older layers become the calm primary. */
html body:not(.is-telegram-mini-app) [data-life-open="workspace-editor"] {
  border-color: transparent;
  background: var(--brand-900);
  color: #fff;
  box-shadow: 0 1px 2px rgb(16 19 26 / 18%);
}

/* Form controls ------------------------------------------------------------ */
html body .field { gap: 6px; }
html body .field > span,
html body .field > label { color: var(--ink); font-size: .8125rem; font-weight: 560; }
html body .field input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
html body .field select,
html body .field textarea,
html body .app-dialog .field input:not([type="checkbox"]):not([type="radio"]),
html body .app-dialog .field select,
html body .app-dialog .field textarea {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background-color: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
html body .field input:hover:not(:focus):not([type="checkbox"]):not([type="radio"]),
html body .field select:hover:not(:focus),
html body .field textarea:hover:not(:focus) { border-color: #c5c9d1; }
html body .field input:focus,
html body .field select:focus,
html body .field textarea:focus,
html body .app-dialog .field input:focus,
html body .app-dialog .field select:focus,
html body .app-dialog .field textarea:focus,
html body .inline-add input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
html body input::placeholder,
html body textarea::placeholder { color: #a3a8b2; }
html body .field-hint { color: var(--ink-faint); font-size: .75rem; }
html body input[type="checkbox"],
html body input[type="radio"],
html body input[type="range"],
html body progress { accent-color: var(--accent); }

/* Native selects get a clean chevron instead of the OS arrow. */
html body select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a909b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 11px center !important;
  background-size: 16px !important;
}
html body select[aria-expanded="true"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2310a571' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m18 15-6-6-6 6'/%3E%3C/svg%3E") !important;
}

/* Colour fields: a rounded swatch instead of the grey OS bar. */
html body input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 40px;
  padding: 5px !important;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
html body input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
html body input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; box-shadow: inset 0 0 0 1px rgb(16 19 26 / 10%); }
html body input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }
html body select:not(.field select):not([multiple]) {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background-color: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  box-shadow: var(--shadow-xs);
}

/* Native date and time inputs: keep the typed value, hide the dated OS picker
   button; datepicker.js opens Tony's own calendar instead. */
html body input[type="date"],
html body input[type="datetime-local"],
html body input[type="month"] {
  position: relative;
  padding-right: 38px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a909b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='17' rx='3'/%3E%3Cpath d='M3 9.5h18M8 2.5v4M16 2.5v4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 16px !important;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
html body input[type="date"]::-webkit-calendar-picker-indicator,
html body input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html body input[type="month"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0 0 0 auto;
  width: 38px;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
html body svg + input[type="date"],
html body svg + input[type="datetime-local"] { padding-right: 6px !important; background-image: none !important; }
html body input[type="time"]::-webkit-calendar-picker-indicator { opacity: .45; cursor: pointer; }
html body input[type="date"]::-webkit-datetime-edit-fields-wrapper,
html body input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
html body input[type="date"]::-webkit-datetime-edit-text,
html body input[type="datetime-local"]::-webkit-datetime-edit-text { color: var(--ink-faint); padding: 0 1px; }
html body input::-webkit-datetime-edit-day-field:focus,
html body input::-webkit-datetime-edit-month-field:focus,
html body input::-webkit-datetime-edit-year-field:focus,
html body input::-webkit-datetime-edit-hour-field:focus,
html body input::-webkit-datetime-edit-minute-field:focus { border-radius: 4px; background: var(--accent-soft); color: var(--accent-strong); }

/* Surfaces ----------------------------------------------------------------- */
html body .panel,
html body .metric-card,
html body .finance-panel,
html body .finance-summary-card,
html body .finance-account-card,
html body .vault-card,
html body .fx-strip,
html body .analytics-card,
html body .work-card,
html body .watch-card,
html body .auth-card,
html body:not(.is-telegram-mini-app) .panel,
html body:not(.is-telegram-mini-app) .metric-card,
html body:not(.is-telegram-mini-app) .fx-strip,
html body:not(.is-telegram-mini-app) .finance-panel,
html body:not(.is-telegram-mini-app) .finance-summary-card,
html body:not(.is-telegram-mini-app) .finance-account-card,
html body:not(.is-telegram-mini-app) .vault-card {
  border: 1px solid var(--line);
  background-color: var(--surface);
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
}
html body:not(.is-telegram-mini-app) .panel,
html body:not(.is-telegram-mini-app) .finance-panel,
html body:not(.is-telegram-mini-app) .vault-card,
html body .panel,
html body .finance-panel { border-radius: var(--radius-lg); }
html body .panel__header h3,
html body .finance-panel__header h3 { font-size: .9375rem; font-weight: 620; }

html body .metric-card,
html body:not(.is-telegram-mini-app) .metric-card {
  min-height: 132px;
  border-radius: var(--radius-lg);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
html body .metric-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
html body .metric-card > strong { font-family: var(--font-display); font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
html body .metric-card.metric-card--balance,
html body:not(.is-telegram-mini-app) .metric-card.metric-card--balance,
html body:not(.is-telegram-mini-app) .finance-summary-card.finance-summary-card--featured,
html body .finance-summary-card.finance-summary-card--featured {
  border-color: transparent;
  background:
    radial-gradient(120% 120% at 100% 0%, rgb(16 165 113 / 28%), transparent 55%),
    var(--brand-900);
  color: #fff;
}
html body .metric-card--balance:hover { border-color: transparent; }
html body .finance-summary-card::after { display: none; }
html body .finance-summary-card { border-radius: var(--radius-lg); }
html body .finance-period-bar { border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs); }
html body .finance-refresh { border-radius: 8px; transition: background-color var(--t-fast), color var(--t-fast); }
html body .finance-refresh:hover { background: var(--surface-hover); color: var(--ink); }
html body .analytics-kpi { border-radius: var(--radius-lg); transition: border-color var(--t), box-shadow var(--t); }
html body .analytics-kpi:hover { box-shadow: var(--shadow-md); }
html body .analytics-kpi--brand {
  border-color: transparent;
  background: radial-gradient(120% 120% at 100% 0%, rgb(16 165 113 / 28%), transparent 55%), var(--brand-900);
}
html body .analytics-kpi--danger { background: var(--surface); }

/* Section heroes read as page headers, not banners. */
html body .analytics-hero,
html body:not(.is-telegram-mini-app) .analytics-hero {
  min-height: 0;
  padding: 20px 0 8px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
html body .analytics-hero h1,
html body .finance-hero h1,
html body .vault-hero h1,
html body .life-hero h1,
html body .calendar-page__header h1 {
  font-size: clamp(1.75rem, 2.3vw, 2.25rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -.025em;
}
html body .metric-icon { border-radius: 10px; }

/* Tony assistant card stays light and quiet. */
html body:not(.is-telegram-mini-app) .tony-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
html body:not(.is-telegram-mini-app) .tony-card::after { display: none; }
html body:not(.is-telegram-mini-app) .tony-composer {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
html body:not(.is-telegram-mini-app) .tony-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
html body .tony-composer textarea:focus-visible { outline: 0; }
html body .tony-composer textarea { scrollbar-width: none; }
html body .tony-composer textarea::-webkit-scrollbar { display: none; }
html body .composer-button { border-radius: 9px; transition: background-color var(--t-fast), color var(--t-fast); }
html body .composer-button--send { background: var(--brand-900); color: #fff; }
html body .composer-button--send:hover { background: #2a2e36; color: #fff; }
html body:not(.is-telegram-mini-app) .prompt-chips button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .8125rem;
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
html body:not(.is-telegram-mini-app) .prompt-chips button:hover { border-color: var(--line-strong); background: var(--surface-hover); color: var(--ink); }

/* Segmented tabs: one look everywhere --------------------------------------- */
html body .analytics-tabs,
html body .analytics-periods,
html body .finance-tabs,
html body .finance-periods,
html body .finance-record-switch,
html body .work-tabs,
html body .life-tabs,
html body:not(.is-telegram-mini-app) .life-tabs,
html body .life-view-switch,
html body .task-view-tabs,
html body .calendar-view-switch,
html body .segmented-control {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
  box-shadow: none;
  backdrop-filter: none;
}
html body .analytics-tabs button,
html body .analytics-periods button,
html body .finance-tabs button,
html body .finance-periods button,
html body .finance-record-switch button,
html body .work-tabs button,
html body .life-tabs button,
html body .life-view-switch button,
html body .calendar-view-switch button,
html body .segmented-control span {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: .8125rem;
  font-weight: 560;
  box-shadow: none;
  transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
html body .analytics-tabs button:hover,
html body .analytics-periods button:hover,
html body .finance-tabs button:hover,
html body .finance-periods button:hover,
html body .finance-record-switch button:hover,
html body .work-tabs button:hover,
html body .life-tabs button:hover,
html body .life-view-switch button:hover,
html body .calendar-view-switch button:hover,
html body .task-view-tabs button:hover { background: rgb(255 255 255 / 60%); color: var(--ink); }
html body .analytics-tabs button.is-active,
html body .analytics-tabs button[aria-selected="true"],
html body .analytics-periods button.is-active,
html body .analytics-periods button[aria-pressed="true"],
html body .finance-tabs button.is-active,
html body .finance-periods button.is-active,
html body .finance-record-switch button.is-active,
html body .work-tabs button.is-active,
html body .life-tabs button.is-active,
html body:not(.is-telegram-mini-app) .life-tabs button.is-active,
html body .life-view-switch button.is-active,
html body .task-view-tabs button.is-active,
html body .calendar-view-switch button.is-active,
html body .segmented-control input:checked + span {
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%);
}
html body .task-scope__tabs button { border-radius: 9px; transition: background-color var(--t-fast), color var(--t-fast); }
html body .task-scope__tabs button.is-active { color: var(--ink); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px var(--line); }
html body .task-scope__tabs button.is-active > strong,
html body .subscription-filter.is-active,
html body .finance-currency-switch button.is-active { background: var(--accent-soft); color: var(--accent-strong); }
html body .finance-currency-switch button.is-active { border-color: rgb(16 165 113 / 35%); }
html body .life-filter-chip { border-radius: 8px; transition: background-color var(--t-fast), color var(--t-fast); }
html body .life-filter-chip:hover { background: var(--surface-hover); color: var(--ink); }

/* Dialogs and toasts --------------------------------------------------------- */
html body .app-dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
html body .app-dialog[open] { animation: tony-pop .22s var(--ease); }
html body .app-dialog::backdrop { background: rgb(13 15 19 / 38%); backdrop-filter: blur(6px); }
html body .dialog-header h2 { font-size: 1.125rem; font-weight: 620; }
html body .dialog-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-faint);
  transition: background-color var(--t-fast), color var(--t-fast);
}
html body .dialog-close:hover { background: var(--surface-hover); color: var(--ink); }
html body .dialog-actions { border-top-color: var(--line); background: var(--surface-soft); border-radius: 0 0 18px 18px; }
html body .toast { border-radius: 12px; box-shadow: var(--shadow-lg); animation: tony-slide .24s var(--ease); }

@keyframes tony-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes tony-slide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Tables --------------------------------------------------------------------- */
html body table th { color: var(--ink-faint); font-size: .75rem; font-weight: 560; letter-spacing: .01em; }
html body table td { font-variant-numeric: tabular-nums; }
html body table tbody tr { transition: background-color var(--t-fast); }
html body table tbody tr:hover { background: var(--surface-soft); }

/* Shell: desktop ------------------------------------------------------------- */
@media (min-width: 1020px) {
  html body:not(.is-telegram-mini-app) .app-shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

  html body:not(.is-telegram-mini-app) .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    max-height: none;
    padding: 18px 12px 14px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;
    transform: none;
  }
  html body:not(.is-telegram-mini-app) .sidebar__brand {
    display: flex;
    gap: 10px;
    padding: 4px 10px 22px;
    color: var(--ink);
  }
  html body:not(.is-telegram-mini-app) .sidebar__brand img { width: 32px; height: 32px; border-radius: 9px; box-shadow: none; }
  html body:not(.is-telegram-mini-app) .sidebar__brand strong { font-family: var(--font-display); font-size: 1rem; font-weight: 650; letter-spacing: -.02em; }
  html body:not(.is-telegram-mini-app) .sidebar__brand span { color: var(--ink-faint); font-size: .75rem; letter-spacing: 0; text-transform: none; }
  html body:not(.is-telegram-mini-app) .sidebar__nav { gap: 2px; }
  html body:not(.is-telegram-mini-app) .sidebar__footer { gap: 6px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
  html body:not(.is-telegram-mini-app) .assistant-health,
  html body:not(.is-telegram-mini-app) .sidebar__profile {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
  }
  html body:not(.is-telegram-mini-app) .assistant-health strong,
  html body:not(.is-telegram-mini-app) .sidebar__profile strong { font-size: .8125rem; font-weight: 600; }
  html body:not(.is-telegram-mini-app) .assistant-health span:not(.status-dot),
  html body:not(.is-telegram-mini-app) .sidebar__profile span:not(.avatar) { color: var(--ink-faint); font-size: .75rem; }
  html body:not(.is-telegram-mini-app) .sidebar__profile .avatar { width: 30px; height: 30px; }
  html body:not(.is-telegram-mini-app) .logout-form button {
    width: 100%;
    height: auto;
    min-height: 36px;
    justify-content: flex-start;
    gap: 12px;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-soft);
    font-size: .875rem;
    font-weight: 500;
    transition: background-color var(--t-fast), color var(--t-fast);
  }
  html body:not(.is-telegram-mini-app) .logout-form button span { display: inline; }
  html body:not(.is-telegram-mini-app) .logout-form button:hover { background: var(--danger-100); color: var(--danger-600); }

  html body:not(.is-telegram-mini-app) .desktop-topbar {
    position: sticky;
    top: 0;
    z-index: 58;
    width: 100%;
    min-height: 64px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 12px 40px;
    border-bottom: 1px solid transparent;
    background: rgb(246 247 249 / 82%);
    backdrop-filter: saturate(1.4) blur(14px);
  }
  html body:not(.is-telegram-mini-app) .desktop-topbar__brand { display: none; }
  html body:not(.is-telegram-mini-app) .desktop-command {
    grid-column: 1;
    justify-self: stretch;
    width: 100%;
    min-height: 40px;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-faint);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
  }
  html body:not(.is-telegram-mini-app) .desktop-command:hover { border-color: #c5c9d1; box-shadow: var(--shadow-sm); }
  html body:not(.is-telegram-mini-app) .desktop-command svg { width: 16px; height: 16px; color: var(--ink-faint); }
  html body:not(.is-telegram-mini-app) .desktop-command span { font-size: .875rem; }
  html body:not(.is-telegram-mini-app) .desktop-command kbd {
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--ink-faint);
    box-shadow: none;
    font: 500 .6875rem var(--font-sans);
  }
  html body:not(.is-telegram-mini-app) .desktop-topbar__actions { grid-column: 2; justify-self: end; gap: 8px; }
  @media (max-width: 1400px) {
    html body:not(.is-telegram-mini-app) .desktop-topbar { padding-inline: 28px; }
  }
  @media (max-width: 1180px) {
    html body:not(.is-telegram-mini-app) .desktop-workspace { width: 38px; justify-content: center; padding: 0; }
    html body:not(.is-telegram-mini-app) .desktop-workspace span { display: none; }
  }
  html body:not(.is-telegram-mini-app) .desktop-workspace,
  html body:not(.is-telegram-mini-app) .desktop-icon-action {
    min-height: 38px;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
    transition: background-color var(--t-fast), border-color var(--t-fast);
  }
  html body:not(.is-telegram-mini-app) .desktop-workspace:hover,
  html body:not(.is-telegram-mini-app) .desktop-icon-action:hover { border-color: #c5c9d1; background: var(--surface-hover); }
  html body:not(.is-telegram-mini-app) .desktop-workspace svg,
  html body:not(.is-telegram-mini-app) .desktop-icon-action svg { width: 17px; height: 17px; color: var(--ink-soft); }
  html body:not(.is-telegram-mini-app) .desktop-workspace span { font-size: .8125rem; font-weight: 560; }
  html body:not(.is-telegram-mini-app) .desktop-icon-action { width: 38px; padding: 0; border-radius: 10px; }
  html body:not(.is-telegram-mini-app) .desktop-profile .avatar { width: 38px; height: 38px; border: 0; box-shadow: none; }
  html body:not(.is-telegram-mini-app) .desktop-profile i { right: -1px; bottom: -1px; width: 11px; height: 11px; background: var(--accent); }

  html body:not(.is-telegram-mini-app) .main-content { width: 100%; padding: 12px 40px 64px; }
  html body:not(.is-telegram-mini-app) .main-content > * { width: min(100%, var(--page-width)); }

  /* Page headers are typography, not decorated cards. */
  html body:not(.is-telegram-mini-app) .page-hero {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 24px;
    padding: 20px 0 24px;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  html body:not(.is-telegram-mini-app) .page-hero h1 { max-width: 720px; font-size: clamp(1.75rem, 2.3vw, 2.25rem); line-height: 1.15; }
  html body:not(.is-telegram-mini-app) .page-hero__summary { max-width: 620px; margin-top: 6px; line-height: 1.55; }
  html body:not(.is-telegram-mini-app) .page-hero__actions { position: static; align-self: end; }
  html body:not(.is-telegram-mini-app) .home-living-mark { display: none; }
}

html body .sidebar__brand img { border-radius: 9px; box-shadow: none; }
html body .sidebar__brand strong { font-family: var(--font-display); font-weight: 650; letter-spacing: -.02em; }
html body .sidebar__brand span { font-size: .75rem; letter-spacing: 0; text-transform: none; }

/* Navigation item: the whole row is the target ------------------------------- */
html body .nav-link {
  min-height: 38px;
  gap: 12px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  transition: background-color var(--t-fast), color var(--t-fast);
}
html body .nav-link svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: 1; transition: transform var(--t-fast), color var(--t-fast); }
html body .nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html body .nav-link:active svg { transform: scale(.92); }

@media (min-width: 1020px) {
  html body:not(.is-telegram-mini-app) .nav-link {
    min-height: 38px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: .875rem;
    font-weight: 500;
    text-align: left;
  }
  html body:not(.is-telegram-mini-app) .nav-link svg { width: 18px; height: 18px; color: var(--ink-faint); }
  html body:not(.is-telegram-mini-app) .nav-link:hover { border: 0; background: var(--surface-hover); color: var(--ink); }
  html body:not(.is-telegram-mini-app) .nav-link:hover svg { color: var(--ink); }
  html body:not(.is-telegram-mini-app) .nav-link.is-active {
    border: 0;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
    box-shadow: none;
  }
  html body:not(.is-telegram-mini-app) .nav-link.is-active svg { color: var(--accent); }
  html body:not(.is-telegram-mini-app) .nav-link.is-active::before { display: none; }
}

/* Shell: tablet and phone ------------------------------------------------------ */
@media (max-width: 1019px) {
  html body .sidebar {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
  }
  html body .sidebar__brand span,
  html body .assistant-health span:not(.status-dot),
  html body .sidebar__profile span:not(.avatar) { color: var(--ink-faint); }
  html body .nav-link { color: var(--ink-soft); }
  html body .nav-link svg { color: var(--ink-faint); }
  html body .nav-link:hover { background: var(--surface-hover); color: var(--ink); }
  html body .nav-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
  html body .nav-link.is-active svg { color: var(--accent); }
  html body .nav-link.is-active::before { display: none; }
  html body .assistant-health,
  html body .sidebar__profile { border-color: var(--line); background: var(--surface-soft); }
  html body .logout-form button { border-color: var(--line); color: var(--ink-soft); }
  html body .logout-form button:hover { background: var(--danger-100); color: var(--danger-600); }
  html body .sidebar-scrim { background: rgb(13 15 19 / 36%); backdrop-filter: blur(3px); }
  html body .mobile-header {
    border-bottom: 1px solid var(--line);
    background: rgb(246 247 249 / 85%);
    backdrop-filter: saturate(1.4) blur(14px);
  }
  html body .mobile-header__brand strong { font-family: var(--font-display); font-weight: 650; letter-spacing: -.02em; }
}

html body .bottom-nav {
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 -8px 24px rgb(16 19 26 / 5%);
  backdrop-filter: saturate(1.4) blur(16px);
}
html body .bottom-nav a { color: var(--ink-faint); font-size: .6875rem; font-weight: 560; transition: color var(--t-fast); }
html body .bottom-nav a:hover { color: var(--ink); }
html body .bottom-nav a.is-active { color: var(--accent-strong); }
html body .bottom-nav a.is-active svg { color: var(--accent); }

/* Quiet pages: titles only, no marketing copy ------------------------------------ */
html body .eyebrow,
html body .section-intro,
html body .page-hero__summary,
html body .analytics-hero p,
html body .finance-hero__copy p,
html body .vault-hero p,
html body .life-hero p,
html body .calendar-page__header p,
html body .calendar-backlog small,
html body .finance-section-heading p,
html body .finance-subsection-heading p,
html body .life-section-heading p,
html body .life-panel-heading p,
html body .tony-card__header p,
html body .task-scope__label,
html body .task-scope__note { display: none !important; }
html body .auth-heading p { display: block !important; }
html body.is-telegram-mini-app .eyebrow { display: block !important; }
/* The standalone notes page already carries the "Заметки" title. */
html body .life-os--notes .life-section-heading > div:first-child { display: none; }
html body .life-os--notes .life-section-heading { justify-content: flex-end; }

/* Line icons drawn with strokes (fill stays off despite the global svg rule). */
html body svg.icon-line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Nothing jumps under the cursor: hover never moves content. */
html body .task-card:hover,
html body .project-card:hover,
html body .life-note:hover,
html body .vault-card:hover,
html body .life-recipient-option:hover,
html body .life-message-mode button:hover,
html body .telegram-dialog-card:hover,
html body .button:hover,
html body .metric-card:hover { transform: none; }
html body .task-complete-button:hover span { transform: none; }

/* "Мой план" scopes: one font, line icons, calm active state. */
html body .task-scope { padding: 10px; }
@media (min-width: 1020px) {
  html body .task-center { grid-template-columns: 216px minmax(0, 1fr); }
}
html body .task-scope__tabs { gap: 2px; }
html body .task-scope__tabs button {
  min-height: 38px;
  gap: 10px;
  padding: 7px 10px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 500;
}
html body .task-scope__tabs button:hover { background: var(--surface-hover); color: var(--ink); }
html body .task-scope__tabs button.is-active { background: var(--surface); color: var(--ink); font-weight: 600; }
html body .task-scope__icon { width: 20px; height: 20px; border-radius: 0; color: var(--ink-faint); }
html body .task-scope__icon svg { width: 18px; height: 18px; }
html body .task-scope__tabs button.is-active .task-scope__icon { color: var(--accent); }
html body .task-scope__tabs button > strong { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--surface-muted); color: var(--ink-faint); font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Sign-in and invite pages ------------------------------------------------------ */
html body.auth-page { background: radial-gradient(60rem 30rem at 50% -10%, rgb(16 165 113 / 7%), transparent 70%), var(--canvas); }
html body .auth-card { border-radius: 20px; box-shadow: var(--shadow-md); }
html body .auth-brand img { box-shadow: none; border-radius: 12px; }
html body .auth-brand strong { font-family: var(--font-display); font-weight: 650; letter-spacing: -.02em; }
html body .auth-brand span { color: var(--ink-faint); font-size: .8125rem; letter-spacing: 0; text-transform: none; }
html body .auth-heading h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -.025em; }
html body .auth-heading p { color: var(--ink-soft); font-size: .9375rem; }
html body .auth-submit { min-height: 44px; font-size: .9375rem; }
html body .password-toggle { border-radius: 8px; color: var(--ink-soft); transition: background-color var(--t-fast), color var(--t-fast); }
html body .password-toggle:hover { background: var(--surface-hover); color: var(--ink); }
html body .auth-invite-help { border-radius: 12px; background: var(--surface-soft); }
html body .auth-security { color: var(--ink-faint); }
html body .auth-footer { color: var(--ink-faint); }

/* Tasks / calendar switcher ---------------------------------------------------- */
html body .task-suite-nav,
html body:not(.is-telegram-mini-app) .task-suite-nav.panel {
  width: min(100%, var(--page-width));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 8px;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  box-shadow: none;
}
html body .task-suite-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9px;
  transition: background-color var(--t-fast), box-shadow var(--t-fast);
}
html body .task-suite-nav a > span { width: 18px; height: 18px; display: grid; place-items: center; background: transparent; color: var(--ink-faint); }
html body .task-suite-nav a > span svg { width: 18px; height: 18px; }
html body .task-suite-nav small { display: none; }
html body .task-suite-nav strong { font-size: .875rem; font-weight: 600; }
html body .task-suite-nav a:hover { background: rgb(255 255 255 / 60%); }
html body .task-suite-nav a.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%); }
html body .task-suite-nav a.is-active > span { background: transparent; color: var(--accent); }
html body .task-suite-nav a.is-active strong { color: var(--ink); }
html body .task-suite-nav a.is-active small { color: var(--ink-faint); }

/* Calendar page polish --------------------------------------------------------- */
html body .calendar-toolbar { border-radius: 14px; }
html body .calendar-toolbar__navigation strong { font-family: var(--font-display); font-size: 1rem; font-weight: 620; letter-spacing: -.01em; }
html body .calendar-timeline__header { background: rgb(255 255 255 / 94%); backdrop-filter: blur(8px); }
html body .calendar-timeline__header button { transition: background-color var(--t-fast); }
html body .calendar-timeline__header button:hover { background: var(--surface-soft); }
html body .calendar-timeline__header button.is-today strong,
html body .calendar-month__day.is-today .calendar-month__number { background: var(--accent); color: #fff; }
html body .calendar-timeline__day.is-today { background-color: rgb(16 165 113 / 4%); }
html body .calendar-month__day { background: var(--surface); transition: background-color var(--t-fast); }
html body .calendar-month__day:hover { background: var(--surface-soft); }
html body .calendar-month__day.is-outside { background: var(--surface-soft); color: #b0b4bc; }
html body .calendar-month__day.is-today { background: rgb(16 165 113 / 5%); }
html body .calendar-month__weekday { color: var(--ink-faint); font-size: .75rem; font-weight: 560; letter-spacing: .04em; }
html body .calendar-task-block { border-radius: 8px; box-shadow: 0 1px 3px rgb(16 19 26 / 8%); color: var(--ink); transition: box-shadow var(--t-fast); }
html body .calendar-task-block:hover { box-shadow: 0 4px 12px rgb(16 19 26 / 12%); }
html body .calendar-chip { border-radius: 6px; transition: filter var(--t-fast); }
html body .calendar-chip:hover { filter: brightness(.97); }
html body .calendar-backlog-item { background: var(--surface); transition: box-shadow var(--t-fast); }
html body .calendar-backlog-item:hover { box-shadow: var(--shadow-sm); }
html body .calendar-backlog-item.is-selected { outline: 2px solid var(--accent-ring); background: var(--accent-soft); }

html body .telegram-folder-filter button { transition: background-color var(--t-fast), border-color var(--t-fast); }
html body .telegram-folder-filter button:hover { border-color: var(--line-strong); background: var(--surface-hover); }
html body .telegram-folder-filter button.is-active { border-color: var(--brand-900); background: var(--brand-900); color: #fff; }
html body .telegram-dialog-card { background: var(--surface); }
html body .telegram-dialog-card:hover { border-color: var(--line-strong); transform: none; box-shadow: var(--shadow-sm); }
html body .telegram-dialog-card.is-selected { border-color: var(--accent); background: var(--accent-soft); }
html body .telegram-dialog-card__avatar { background: var(--brand-800); }
html body .telegram-account-state { background: var(--surface-soft); }
html body .tony-capabilities-summary { background: var(--surface-soft); }
html body .tony-capability-section li::before { color: var(--accent); }
html body .field-heading button { border-color: rgb(16 165 113 / 25%); background: var(--accent-soft); color: var(--accent-strong); }
html body .field-heading button:hover { border-color: var(--accent); background: #dcf3e8; }
html body .subscription-usage-fields { background: var(--surface-soft); }

/* Tony date picker --------------------------------------------------------------- */
.tdp {
  position: fixed;
  z-index: 1000;
  inset: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  width: 296px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: .875rem;
  user-select: none;
  animation: tony-pop .18s var(--ease);
}
.tdp[hidden] { display: none; }
.tdp__head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; padding: 0 2px; }
.tdp__title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 620 .9375rem var(--font-display);
  letter-spacing: -.01em;
  text-transform: capitalize;
}
.tdp__title:hover { background: var(--surface-hover); }
.tdp__title svg { width: 14px; height: 14px; color: var(--ink-faint); }
.tdp__nav { display: flex; gap: 2px; }
.tdp__icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.tdp__icon:hover { background: var(--surface-hover); color: var(--ink); }
.tdp__icon svg { width: 16px; height: 16px; }
.tdp__week,
.tdp__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.tdp__week span { padding: 4px 0 6px; color: var(--ink-faint); font-size: .6875rem; font-weight: 560; text-align: center; text-transform: capitalize; }
.tdp__week span:nth-child(n+6) { color: #c08a8a; }
.tdp__day {
  position: relative;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 500 .8125rem var(--font-sans);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.tdp__day:hover { background: var(--surface-hover); }
.tdp__day.is-outside { color: #b9bdc6; }
.tdp__day.is-today { color: var(--accent-strong); font-weight: 650; }
.tdp__day.is-today::after { position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); content: ""; }
.tdp__day.is-selected,
.tdp__day.is-selected:hover { background: var(--brand-900); color: #fff; font-weight: 600; }
.tdp__day.is-selected::after { background: #fff; }
.tdp__day:disabled { color: #d3d6dc; cursor: not-allowed; background: transparent; }
.tdp__months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tdp__months button {
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 500 .8125rem var(--font-sans);
  text-transform: capitalize;
  transition: background-color var(--t-fast);
}
.tdp__months button:hover { background: var(--surface-hover); }
.tdp__months button.is-selected { background: var(--brand-900); color: #fff; }
.tdp__months button.is-today:not(.is-selected) { color: var(--accent-strong); font-weight: 650; }
.tdp__time { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tdp__time label { color: var(--ink-soft); font-size: .8125rem; font-weight: 560; margin-right: auto; }
.tdp__time select {
  min-height: 34px !important;
  width: 76px;
  padding: 4px 24px 4px 10px !important;
  background-position: right 6px center !important;
  font-variant-numeric: tabular-nums;
}
.tdp__time b { color: var(--ink-faint); }
.tdp__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tdp__link {
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: 560 .8125rem var(--font-sans);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.tdp__link:hover { background: var(--surface-hover); color: var(--ink); }
.tdp__link--accent { color: var(--accent-strong); }
.tdp__link--primary { background: var(--brand-900); color: #fff; }
.tdp__link--primary:hover { background: #2a2e36; color: #fff; }
@media (max-width: 520px) {
  .tdp { left: 12px !important; right: 12px; width: auto; }
  .tdp__day { height: 40px; }
}

/* The hidden attribute always wins over component display rules. Older layers
   gave some blocks display:grid/flex, which kept "hidden" loaders on screen. */
[hidden]:not(dialog) { display: none !important; }

/* Private vault ------------------------------------------------------------------- */
.sv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.sv > *, .sv-toolbar > * { min-width: 0; }
.sv-tabs { max-width: 100%; }
.sv-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 4px; }
.sv-head h1 { margin: 0; font-size: clamp(1.75rem, 2.3vw, 2.25rem); line-height: 1.15; }
.sv-head__actions { display: flex; align-items: center; gap: 8px; }
.sv-status { display: inline-flex; align-items: center; gap: 7px; margin-right: 4px; color: var(--ink-soft); font-size: .8125rem; font-weight: 500; }
.sv-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.sv-head .button svg { width: 16px; height: 16px; }

.sv-loading { display: grid; gap: 10px; padding: 8px 0; }
.sv-loading span, .sv-detail__loading span {
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface-muted) 0%, #f8f9fb 50%, var(--surface-muted) 100%);
  background-size: 200% 100%;
  animation: sv-shimmer 1.2s ease-in-out infinite;
}
.sv-loading span:nth-child(2) { width: 85%; }
.sv-loading span:nth-child(3) { width: 70%; }
@keyframes sv-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Setup and unlock gate */
.sv-gate { display: grid; place-items: center; min-height: min(68vh, 620px); padding: 12px 0 40px; }
.sv-gate__card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.sv-gate__icon {
  width: 56px; height: 56px; display: grid; place-items: center; justify-self: center;
  border-radius: 16px; background: var(--accent-soft); color: var(--accent-strong);
}
.sv-gate__icon svg { width: 28px; height: 28px; }
.sv-gate__card h2 { margin: 2px 0 0; font-size: 1.375rem; font-weight: 650; }
.sv-gate__card > p { margin: -4px 0 4px; color: var(--ink-soft); font-size: .9375rem; line-height: 1.5; }
.sv-gate__card .sv-field { text-align: left; }
.sv-gate__submit { min-height: 44px; font-size: .9375rem; }
.sv-gate__hint { margin: 0; color: var(--ink-faint); font-size: .8125rem; line-height: 1.5; }
.sv-check { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: .875rem; text-align: left; cursor: pointer; }
.sv-check input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.sv-strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: -6px; }
.sv-strength i { height: 4px; border-radius: 999px; background: var(--surface-muted); transition: background-color var(--t); }
.sv-strength small { grid-column: 1 / -1; color: var(--ink-faint); font-size: .75rem; text-align: left; }
.sv-strength[data-level="1"] i:nth-child(-n+1) { background: #e5484d; }
.sv-strength[data-level="2"] i:nth-child(-n+2) { background: #f5a524; }
.sv-strength[data-level="3"] i:nth-child(-n+3) { background: #4cc38a; }
.sv-strength[data-level="4"] i { background: var(--accent); }

/* Fields */
.sv-field { display: grid; gap: 6px; min-width: 0; }
.sv-field > span:first-child:not(.sv-secret-input) { color: var(--ink); font-size: .8125rem; font-weight: 560; }
.sv-field input:not([type="checkbox"]), .sv-field textarea, .sv-field select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background-color: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .9375rem;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.sv-field textarea { resize: vertical; line-height: 1.5; }
.sv-field input:focus, .sv-field textarea:focus, .sv-field select:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
.sv-secret-input { position: relative; display: flex; align-items: center; }
.sv-secret-input input { padding-right: 44px !important; }
.sv-secret-input input:has(~ .sv-generate) { padding-right: 80px !important; }
.sv-secret-input [data-vault-toggle], .sv-generate {
  position: absolute; right: 5px; width: 32px; height: 32px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-faint);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.sv-secret-input .sv-generate { right: 5px; }
.sv-secret-input .sv-generate ~ [data-vault-toggle], .sv-secret-input [data-vault-toggle]:has(+ .sv-generate) { right: 39px; }
.sv-secret-input [data-vault-toggle]:hover, .sv-generate:hover { background: var(--surface-hover); color: var(--ink); }
.sv-secret-input [data-vault-toggle]::before {
  content: ""; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12S6 5 12 5s9.5 7 9.5 7-3.5 7-9.5 7-9.5-7-9.5-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 12S6 5 12 5s9.5 7 9.5 7-3.5 7-9.5 7-9.5-7-9.5-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sv-secret-input [data-vault-toggle].is-on { color: var(--accent-strong); }
.sv-generate svg { width: 17px; height: 17px; }
.sv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sv-grid--3 { grid-template-columns: 1.2fr 1fr 1fr; }

/* App layout */
.sv-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sv-tabs { display: flex; gap: 2px; padding: 3px; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); scrollbar-width: none; }
.sv-tabs::-webkit-scrollbar { display: none; }
.sv-tabs button {
  min-height: 32px; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 5px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft);
  font-size: .8125rem; font-weight: 560; transition: background-color var(--t-fast), color var(--t-fast);
}
.sv-tabs button:hover { background: rgb(255 255 255 / 60%); color: var(--ink); }
.sv-tabs button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%); }
.sv-tabs b { min-width: 20px; padding: 0 6px; border-radius: 999px; background: rgb(16 19 26 / 6%); color: var(--ink-faint); font-size: .6875rem; font-weight: 600; line-height: 18px; text-align: center; }
.sv-tabs button.is-active b { background: var(--accent-soft); color: var(--accent-strong); }
.sv-search { position: relative; flex: 0 1 300px; min-width: 200px; }
.sv-search svg { position: absolute; top: 50%; left: 12px; width: 16px; height: 16px; color: var(--ink-faint); transform: translateY(-50%); pointer-events: none; }
.sv-search input {
  width: 100%; min-height: 38px; padding: 8px 12px 8px 36px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem; box-shadow: var(--shadow-xs);
}
.sv-search input:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }

.sv-body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.sv-list { display: flex; flex-direction: column; gap: 2px; max-height: 72vh; overflow-y: auto; padding: 8px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.sv-list__empty { display: grid; gap: 4px; padding: 40px 16px; color: var(--ink-faint); font-size: .8125rem; text-align: center; }
.sv-list__empty strong { color: var(--ink); font-size: .9375rem; font-weight: 600; }
.sv-item {
  width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) 16px; align-items: center; gap: 12px;
  padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); text-align: left;
  transition: background-color var(--t-fast);
}
.sv-item:hover { background: var(--surface-hover); }
.sv-item.is-selected { background: var(--surface); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px var(--line); }
.sv-item.is-archived { opacity: .6; }
.sv-item__text { display: grid; min-width: 0; }
.sv-item__text strong, .sv-item__text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-item__text strong { font-size: .875rem; font-weight: 600; }
.sv-item__text small { color: var(--ink-faint); font-size: .8125rem; }
.sv-item__chevron { width: 16px; height: 16px; color: #c3c7cf; transition: transform var(--t-fast), color var(--t-fast); }
.sv-item__chevron svg { width: 16px; height: 16px; }
.sv-item:hover .sv-item__chevron, .sv-item.is-selected .sv-item__chevron { color: var(--ink-faint); }

/* Avatars */
.sv-avatar { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; font-weight: 650; font-size: 1rem; }
.sv-avatar svg { width: 20px; height: 20px; }
.sv-avatar--lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.25rem; }
.sv-avatar--lg svg { width: 24px; height: 24px; }
.sv-avatar--hue0 { background: #e8f0fe; color: #2f5fd0; }
.sv-avatar--hue1 { background: #e9f7f0; color: #0a7f56; }
.sv-avatar--hue2 { background: #fdf0e3; color: #b25e09; }
.sv-avatar--hue3 { background: #f3ecfd; color: #6a4fb0; }
.sv-avatar--hue4 { background: #fdecef; color: #c2364f; }
.sv-avatar--hue5 { background: #e6f6fa; color: #127a93; }
.sv-avatar--note { background: #fff6dc; color: #9a6b00; }
.sv-avatar--card { position: relative; align-items: end; justify-items: end; padding: 0 5px 4px 0; border-radius: 8px; color: #fff; font-size: .5625rem; font-weight: 600; letter-spacing: .04em; }
.sv-avatar--card.sv-avatar--lg { padding: 0 7px 6px 0; border-radius: 10px; font-size: .6875rem; }

/* Card art, shared by the list avatar, the detail view and the editor preview */
.sv-avatar--card, .sv-card { background: linear-gradient(135deg, #2b2f38, #11141a); }
[data-brand="visa"] { --sv-card-a: #1a3a8f; --sv-card-b: #0b1f57; }
[data-brand="mastercard"] { --sv-card-a: #3a2a24; --sv-card-b: #15100e; }
[data-brand="uzcard"] { --sv-card-a: #0f6b6b; --sv-card-b: #073b45; }
[data-brand="humo"] { --sv-card-a: #0b7d55; --sv-card-b: #04442f; }
[data-brand="unionpay"] { --sv-card-a: #8e1d2c; --sv-card-b: #4a0c16; }
[data-brand="amex"] { --sv-card-a: #2d6fa3; --sv-card-b: #173f63; }
[data-brand="mir"] { --sv-card-a: #1f7a3c; --sv-card-b: #0d4222; }
.sv-avatar--card[data-brand], .sv-card[data-brand] { background: linear-gradient(135deg, var(--sv-card-a, #2b2f38), var(--sv-card-b, #11141a)); }
.sv-card {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 1.586;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 20px;
  overflow: hidden;
  border-radius: 16px;
  color: #fff;
  box-shadow: 0 14px 30px -12px rgb(16 19 26 / 45%);
  font-variant-numeric: tabular-nums;
}
.sv-card::after { position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: rgb(255 255 255 / 7%); content: ""; pointer-events: none; }
.sv-card__top, .sv-card__bottom, .sv-card__middle { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sv-card__top span { overflow: hidden; font-size: .875rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sv-card__top b { font-size: .9375rem; font-weight: 700; letter-spacing: .02em; font-style: italic; }
.sv-card__pan { font-family: var(--font-mono); font-size: 1.125rem; letter-spacing: .08em; }
.sv-card__bottom { color: rgb(255 255 255 / 80%); font-size: .75rem; letter-spacing: .08em; }
.sv-card__toggle { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: rgb(255 255 255 / 12%); color: #fff; transition: background-color var(--t-fast); }
.sv-card__toggle:hover { background: rgb(255 255 255 / 22%); }
.sv-card__toggle svg { width: 17px; height: 17px; }
.sv-card--preview { width: 100%; max-width: 360px; justify-self: center; margin-bottom: 4px; }

/* Detail */
.sv-detail { min-width: 0; max-height: 72vh; overflow-y: auto; }
.sv-detail__inner { display: grid; gap: 20px; padding: 24px 28px 28px; }
.sv-detail__head { display: flex; align-items: center; gap: 14px; }
.sv-detail .sv-detail__back { display: none; }
.sv-detail__title { min-width: 0; flex: 1; display: grid; gap: 2px; }
.sv-detail__title h2 { margin: 0; overflow: hidden; font-size: 1.25rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sv-detail__title span { color: var(--ink-faint); font-size: .8125rem; }
.sv-detail__actions { display: flex; align-items: center; gap: 6px; }
.sv-detail__actions .button svg { width: 16px; height: 16px; }
.sv-detail__body { display: grid; gap: 18px; }
.sv-detail__meta { margin: 0; color: var(--ink-faint); font-size: .75rem; }
.sv-detail__loading { display: grid; gap: 10px; }
.sv-detail__placeholder, .sv-detail__error { height: 100%; min-height: 420px; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 32px; color: var(--ink-faint); font-size: .875rem; text-align: center; }
.sv-detail__placeholder strong, .sv-detail__error strong { color: var(--ink); font-size: 1rem; font-weight: 600; }
.sv-detail__placeholder-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 14px; background: var(--surface-muted); color: var(--ink-faint); }
.sv-detail__placeholder-icon svg { width: 22px; height: 22px; }
.sv-detail__error .button { margin-top: 8px; }
.sv-quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.sv-quick__btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink);
  font-size: .875rem; font-weight: 560; box-shadow: var(--shadow-xs); transition: background-color var(--t-fast), border-color var(--t-fast);
}
.sv-quick__btn:hover { border-color: #c5c9d1; background: var(--surface-hover); }
.sv-quick__btn svg { width: 17px; height: 17px; color: var(--ink-soft); }

.sv-fields { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; }
.sv-fields__empty { margin: 0; padding: 16px; color: var(--ink-faint); font-size: .875rem; }
.sv-field-row { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px 8px 16px; transition: background-color var(--t-fast); }
.sv-field-row + .sv-field-row { border-top: 1px solid var(--line); }
.sv-field-row:hover { background: var(--surface-soft); }
.sv-field-row__label { color: var(--ink-faint); font-size: .8125rem; }
.sv-field-row__value { min-width: 0; overflow: hidden; color: var(--ink); font-size: .9375rem; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sv-field-row__value.is-multiline { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.sv-field-row__value.is-masked { color: var(--ink-soft); letter-spacing: .12em; }
a.sv-field-row__value { color: var(--accent-strong); text-decoration: none; }
a.sv-field-row__value:hover { text-decoration: underline; }
.sv-field-row__actions { display: flex; gap: 2px; opacity: .55; transition: opacity var(--t-fast); }
.sv-field-row:hover .sv-field-row__actions, .sv-field-row__actions:focus-within { opacity: 1; }
.sv-icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-soft); transition: background-color var(--t-fast), color var(--t-fast);
}
.sv-icon-btn:hover { background: var(--surface-hover); color: var(--ink); }
.sv-icon-btn svg { width: 17px; height: 17px; }
.sv-icon-btn.is-done { color: var(--accent); }
.sv-icon-btn.is-on { background: var(--accent-soft); color: var(--accent-strong); }
.sv-icon-btn--lg { width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-xs); }

.sv-finance-link {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.sv-finance-link:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.sv-finance-link > svg { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); }
.sv-finance-link span { display: grid; gap: 2px; }
.sv-finance-link strong { font-size: .875rem; font-weight: 600; }
.sv-finance-link small { color: var(--ink-faint); font-size: .8125rem; }
.sv-finance-link__chevron svg { width: 16px; height: 16px; color: var(--ink-faint); }

/* Contacts */
.sv-avatar--person { border-radius: 50%; font-size: .9375rem; }
.sv-avatar--person.sv-avatar--lg { font-size: 1.125rem; }
.sv-contact-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-contact-action {
  min-width: 92px; display: grid; justify-items: center; gap: 6px; flex: 1 1 0;
  padding: 12px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  color: var(--ink); font-size: .8125rem; font-weight: 560; text-decoration: none;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.sv-contact-action:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.sv-contact-action span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); }
.sv-contact-action span svg { width: 18px; height: 18px; }
.sv-contact-action[href^="tel:"] span { background: var(--accent); color: #fff; }
/* Editor dialog */
html body .app-dialog.sv-dialog { width: min(calc(100% - 24px), 560px); max-width: 560px; }
.sv-dialog form { display: grid; gap: 16px; padding: 0 20px; }
.sv-dialog .dialog-header { margin-inline: -20px; padding-bottom: 4px; }
.sv-dialog .dialog-actions { margin-top: 4px; }
.sv-kind { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.sv-kind label { position: relative; cursor: pointer; }
.sv-kind input { position: absolute; opacity: 0; pointer-events: none; }
.sv-kind span { min-height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-soft); font-size: .875rem; font-weight: 560; transition: background-color var(--t-fast), color var(--t-fast); }
.sv-kind label:hover span { color: var(--ink); }
.sv-kind input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%); }
.sv-kind input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.sv-form { display: grid; gap: 14px; }
.sv-more summary { width: fit-content; color: var(--ink-soft); font-size: .8125rem; font-weight: 560; cursor: pointer; }
.sv-more summary:hover { color: var(--ink); }
.sv-more[open] summary { margin-bottom: 8px; }
.sv-templates { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-templates button {
  min-height: 32px; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--ink-soft); font-size: .8125rem; font-weight: 560; transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.sv-templates button:hover { background: var(--surface-hover); color: var(--ink); }
.sv-templates button.is-active { border-color: var(--brand-900); background: var(--brand-900); color: #fff; }
.sv-custom { display: grid; gap: 8px; }
.sv-custom:empty { display: none; }
.sv-custom__row { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) 32px 32px; align-items: center; gap: 6px; }
.sv-custom__row input {
  min-width: 0; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem;
}
.sv-custom__row input:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
.sv-custom__name { color: var(--ink-soft) !important; font-weight: 560; }
.sv-add-field {
  width: fit-content; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--accent-strong); font-size: .8125rem; font-weight: 600; transition: background-color var(--t-fast);
}
.sv-add-field:hover { background: var(--accent-soft); }
.sv-add-field svg { width: 16px; height: 16px; }

@media (max-width: 860px) {
  .sv-body { grid-template-columns: 1fr; min-height: 0; }
  .sv-list { max-height: none; border-right: 0; }
  .sv-detail { display: none; max-height: none; }
  .sv-body.has-selection .sv-list { display: none; }
  .sv-body.has-selection .sv-detail { display: block; }
  .sv-detail .sv-detail__back { display: grid; }
  .sv-detail__inner { padding: 16px; }
  .sv-detail__actions .button { padding-inline: 10px; }
  .sv-field-row { grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 8px 10px 14px; }
  .sv-field-row__label { grid-column: 1 / -1; }
  .sv-field-row__actions { grid-row: 2; grid-column: 2; opacity: 1; }
  .sv-search { flex: 1 1 100%; min-width: 0; }
  .sv-tabs { flex: 1 1 100%; }
  .sv-head { padding-top: 8px; }
  .sv-status { display: none; }
}
@media (max-width: 520px) {
  .sv-head [data-vault-lock], .sv-detail__actions .button { width: 38px; min-width: 38px; gap: 0; padding: 0; font-size: 0; }
  .sv-head [data-vault-lock] svg, .sv-detail__actions .button svg { width: 17px; height: 17px; }
  .sv-detail__head { gap: 10px; }
  .sv-detail__head .sv-avatar--lg { width: 44px; height: 44px; }
  .sv-detail__title h2 { font-size: 1.0625rem; }
  .sv-card { padding: 14px 16px; }
  .sv-card__pan { font-size: 1rem; }
  .sv-gate__card { padding: 24px 18px; }
  .sv-grid, .sv-grid--3 { grid-template-columns: 1fr; }
  .sv-custom__row { grid-template-columns: minmax(0, 1fr) 32px 32px; }
  .sv-custom__name { grid-column: 1 / -1; }
}

/* Telegram organizer -------------------------------------------------------------- */
.tg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding-bottom: 72px; }
.tg > * { min-width: 0; }
.tg-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 4px; }
.tg-head h1 { margin: 0; font-size: clamp(1.75rem, 2.3vw, 2.25rem); line-height: 1.15; }
.tg-head__actions { display: flex; align-items: center; gap: 12px; }
.tg-head .button svg { width: 16px; height: 16px; }
.tg-updated, .tg-hint { color: var(--ink-faint); font-size: .8125rem; }
.tg-loading { display: grid; gap: 10px; }
.tg-loading span { height: 64px; border-radius: 14px; background: linear-gradient(90deg, var(--surface-muted), #f8f9fb, var(--surface-muted)); background-size: 200% 100%; animation: sv-shimmer 1.2s ease-in-out infinite; }
.tg-empty { display: grid; gap: 4px; padding: 48px 16px; border: 1px dashed var(--line-strong); border-radius: 16px; color: var(--ink-faint); text-align: center; }
.tg-empty strong { color: var(--ink); font-size: 1rem; }
[data-tg-app] { display: grid; gap: 22px; }
.tg-accounts { display: inline-flex; width: fit-content; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.tg-accounts button { min-height: 32px; padding: 5px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: .8125rem; font-weight: 560; }
.tg-accounts button:hover { color: var(--ink); background: rgb(255 255 255 / 60%); }
.tg-accounts button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%); }
.tg-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tg-stat { display: grid; gap: 2px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs); }
.tg-stat strong { font-family: var(--font-display); font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tg-stat span { color: var(--ink-faint); font-size: .8125rem; }
.tg-stat.is-accent { border-color: transparent; background: var(--brand-900); color: #fff; }
.tg-stat.is-accent span { color: rgb(255 255 255 / 70%); }
.tg-section { display: grid; gap: 12px; }
.tg-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tg-section__head h2 { margin: 0; font-size: 1.125rem; font-weight: 620; }
.tg-section__tools { display: flex; gap: 4px; }
.tg-note { margin: -4px 0 0; color: var(--ink-faint); font-size: .8125rem; }
.tg-link { padding: 4px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--accent-strong); font-size: .8125rem; font-weight: 600; }
.tg-link:hover { background: var(--accent-soft); }
.tg-list { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.tg-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 14px; color: var(--ink); text-decoration: none; transition: background-color var(--t-fast); }
.tg-row + .tg-row { border-top: 1px solid var(--line); }
a.tg-row:hover, label.tg-row:hover { background: var(--surface-soft); }
.tg-row--check { grid-template-columns: 18px 36px minmax(0, 1fr) auto; cursor: pointer; }
.tg-row--check input { width: 18px; height: 18px; margin: 0; }
.tg-row--journal { grid-template-columns: 10px minmax(0, 1fr) auto; }
.tg-row__text { display: grid; gap: 1px; min-width: 0; }
.tg-row__text strong { overflow: hidden; font-size: .875rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tg-row__text small { color: var(--ink-faint); font-size: .8125rem; }
.tg-error { color: var(--danger-600) !important; }
.tg-empty-line { margin: 0; padding: 16px; color: var(--ink-faint); font-size: .875rem; }
.tg-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-muted); color: var(--ink-soft); font-weight: 650; }
.tg-avatar--contact { background: #e8f0fe; color: #2f5fd0; }
.tg-avatar--group { background: #e9f7f0; color: #0a7f56; border-radius: 11px; }
.tg-avatar--channel { background: #fdf0e3; color: #b25e09; border-radius: 11px; }
.tg-avatar--bot { background: #f3ecfd; color: #6a4fb0; border-radius: 11px; }
.tg-badge { min-width: 24px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 650; text-align: center; }
.tg-badge--quiet { background: var(--surface-muted); color: var(--ink-faint); font-weight: 560; }
.tg-action { padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.tg-action--archive { background: var(--surface-muted); color: var(--ink-soft); }
.tg-action--mute { background: #fdf0e3; color: #b25e09; }
.tg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.tg-dot--done { background: var(--accent); }
.tg-dot--failed { background: var(--danger-600); }
.tg-dot--queued, .tg-dot--running { background: #f5a524; animation: tg-pulse 1.2s ease-in-out infinite; }
@keyframes tg-pulse { 50% { opacity: .35; } }
.tg-existing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tg-chip { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: .8125rem; }
.tg-chip--toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.tg-chip--toggle:hover { border-color: #e5a3a1; background: var(--danger-100); }
.tg-chip--toggle.is-removing { border-color: var(--danger-600); background: var(--danger-100); color: var(--danger-600); text-decoration: line-through; }
.tg-chip__x { color: var(--ink-faint); font-size: .875rem; line-height: 1; text-decoration: none; }
.tg-chip--toggle.is-removing .tg-chip__x { color: var(--danger-600); }
.tg-limit { padding: 3px 10px; border-radius: 999px; background: var(--surface-muted); color: var(--ink-soft); font-size: .8125rem; font-weight: 600; }
.tg-limit.is-over, [data-tg-summary].is-over { color: var(--danger-600); }
.tg-limit.is-over { background: var(--danger-100); }
.tg-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tg-folder { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.tg-folder.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.tg-folder.is-exists { opacity: .55; }
.tg-folder__check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tg-folder__check input { width: 18px; height: 18px; margin: 0; }
.tg-folder__emoji { font-size: 1.25rem; }
.tg-folder__body { display: grid; gap: 2px; min-width: 0; }
.tg-folder__body small { color: var(--ink-faint); font-size: .75rem; }
.tg-folder__title { width: 100%; min-width: 0; padding: 2px 6px; margin-left: -6px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--ink); font: inherit; font-size: .9375rem; font-weight: 600; }
.tg-folder__title:hover:not(:disabled) { border-color: var(--line); }
.tg-folder__title:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
.tg-folder__side { display: grid; justify-items: end; gap: 2px; }
.tg-folder__side b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.tg-bar {
  position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border: 1px solid var(--line); border-radius: 14px; background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(12px); font-size: .875rem; font-weight: 560;
}
html body .app-dialog.tg-dialog { width: min(calc(100% - 24px), 520px); max-width: 520px; }
.tg-dialog form { display: grid; gap: 12px; padding: 0 20px; }
.tg-dialog .dialog-header { margin-inline: -20px; }
.tg-dialog .dialog-actions { justify-content: space-between; align-items: center; }
.tg-search { position: relative; }
.tg-search svg { position: absolute; top: 50%; left: 12px; width: 16px; height: 16px; color: var(--ink-faint); transform: translateY(-50%); }
.tg-search input { width: 100%; min-height: 38px; padding: 8px 12px 8px 36px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; font-size: .875rem; }
.tg-members { max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 860px) {
  .tg-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tg-updated { display: none; }
  .tg-bar { bottom: 84px; }
}

/* Tony dropdown (select.js) ------------------------------------------------------ */
.tsel {
  position: fixed;
  z-index: 1001;
  inset: auto;
  height: auto;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  animation: tony-drop .14s var(--ease);
  scrollbar-width: thin;
}
.tsel[hidden] { display: none; }
.tsel__option {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: .875rem;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
}
.tsel__option > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsel__option.is-active { background: var(--surface-hover); }
.tsel__option.is-selected { font-weight: 600; }
.tsel__option svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--accent); }
.tsel__option[aria-disabled="true"] { color: #b9bdc6; cursor: not-allowed; background: transparent; }
.tsel__group { padding: 10px 10px 4px; color: var(--ink-faint); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.tsel__group:first-child { padding-top: 6px; }
html body select[aria-expanded="true"] { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-ring) !important; }
@keyframes tony-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Layout pass, November 2026: pages use the full column, blocks stay inside
   their cards, filters collapse. Everything below builds on the tokens above.
   ========================================================================== */

@media (min-width: 1020px) and (max-width: 1400px) {
  html body:not(.is-telegram-mini-app) .main-content { padding-inline: 28px; }
}

/* Today: the assistant card is just the composer and its prompt chips. */
html body:not(.is-telegram-mini-app) .tony-card--wide { display: block; padding: 16px; }
html body:not(.is-telegram-mini-app) .tony-card--wide .tony-composer { width: 100%; margin-top: 0; }
html body:not(.is-telegram-mini-app) .tony-card--wide .prompt-chips { flex-wrap: wrap; margin-top: 12px; overflow: visible; }
html body:not(.is-telegram-mini-app) .tony-card--wide .tony-response { margin-top: 12px; }

/* Tasks: "Проекты, контакты и встречи" is its own section, not the tail of the
   shopping card; an empty list never leaves a stray hairline panel behind. */
html body .work-center { margin-top: 40px; }
html body .work-center > .section-heading { align-items: center; margin-bottom: 0; }
html body .work-center > .section-heading h2 { margin: 0; }
html body .section-heading .button,
html body .finance-section-heading .button { flex: 0 0 auto; white-space: nowrap; }
html body .work-list:empty,
html body .work-card-grid:empty { display: none; }
html body .work-list { padding: 6px 18px; border-radius: var(--radius-lg); }
html body .work-row { padding: 14px 0; }
html body .work-row button { padding: 5px 9px; border-radius: 8px; color: var(--accent-strong); font-size: .8125rem; transition: background-color var(--t-fast); }
html body .work-row button:hover { background: var(--accent-soft); }
html body .work-empty { border-style: dashed; box-shadow: none; }
html body .work-empty h2 { margin: 0 0 4px; font-size: 1rem; }
html body .work-empty p { margin: 0; color: var(--ink-faint); font-size: .875rem; }

/* Tasks / calendar switcher: quiet page tabs instead of a full-width slab. */
html body .task-suite-nav,
html body:not(.is-telegram-mini-app) .task-suite-nav.panel {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  box-shadow: none;
}
html body .task-suite-nav a {
  min-height: 44px;
  margin-bottom: -1px;
  padding: 8px 14px 9px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ink-soft);
  transition: color var(--t-fast), border-color var(--t-fast);
}
html body .task-suite-nav a:hover { background: none; color: var(--ink); }
html body .task-suite-nav a.is-active { border-bottom-color: var(--brand-900); background: none; box-shadow: none; color: var(--ink); }
html body .task-suite-nav a strong { color: inherit; font-weight: 560; }
html body .task-suite-nav a.is-active strong { font-weight: 620; }

/* Calendar ----------------------------------------------------------------------- */
html body .calendar-page { gap: 16px; padding-top: 0; }
html body .calendar-page__header { align-items: center; padding: 20px 0 0; }
html body .calendar-page__header h1 { margin: 0; }

html body .calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
html body .calendar-toolbar__navigation { min-width: 0; gap: 8px; }
html body .calendar-toolbar__filters { gap: 8px; }
html body .calendar-toolbar__arrows {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
html body .calendar-toolbar__arrows button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  transition: background-color var(--t-fast), color var(--t-fast);
}
html body .calendar-toolbar__arrows button + button { border-left: 1px solid var(--line); }
html body .calendar-toolbar__arrows button:hover { background: var(--surface-hover); color: var(--ink); }
html body .calendar-toolbar__arrows svg { width: 16px; height: 16px; }
html body .calendar-toolbar__navigation strong {
  display: inline-block;
  min-width: 0;
  margin-left: 8px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 620;
  letter-spacing: -.02em;
  text-align: left;
}
html body .calendar-toolbar__navigation strong::first-letter { text-transform: uppercase; }
html body .calendar-toolbar select { min-height: 38px; border-radius: 10px; background-color: var(--surface); }

html body .calendar-layout { grid-template-columns: 264px minmax(0, 1fr); gap: 16px; }
html body .calendar-backlog { top: 80px; gap: 12px; max-height: calc(100vh - 104px); padding: 16px; }
html body .calendar-backlog__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
html body .calendar-backlog h2 { margin: 0; font-size: .9375rem; font-weight: 620; }
html body .calendar-backlog__hint { color: var(--ink-faint); font-size: .75rem; white-space: nowrap; }
html body .calendar-backlog > [data-calendar-backlog] { gap: 6px; }
html body .calendar-backlog-item {
  gap: 2px;
  padding: 10px 12px 10px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--task-color);
  border-radius: 10px;
  background: var(--surface);
  cursor: grab;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
html body .calendar-backlog-item:hover { border-color: var(--line-strong); border-left-color: var(--task-color); box-shadow: var(--shadow-sm); }
html body .calendar-backlog-item:active { cursor: grabbing; }
html body .calendar-backlog-item strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: .875rem;
  font-weight: 560;
  line-height: 1.35;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
html body .calendar-backlog-item small { display: block !important; color: var(--ink-faint); font-size: .75rem; }
html body .calendar-backlog-item.is-selected {
  border-color: var(--accent);
  outline: 0;
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
html body .calendar-backlog__empty {
  padding: 20px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--ink-faint);
  font-size: .8125rem;
  text-align: center;
}

html body .calendar-board { overflow: hidden; border-radius: var(--radius-lg); }
html body .calendar-loading { background: rgb(255 255 255 / 82%); color: var(--ink-faint); font-size: .875rem; }

/* Week and day */
html body .calendar-timeline__header { background: var(--surface); backdrop-filter: none; }
html body .calendar-timeline__header button {
  min-height: 72px;
  flex-direction: column;
  gap: 4px;
  border-left: 1px solid var(--line);
  color: var(--ink-faint);
}
html body .calendar-timeline__header button span { font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
html body .calendar-timeline__header button strong {
  width: 34px;
  height: 34px;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast);
}
html body .calendar-timeline__header button:hover { background: transparent; }
html body .calendar-timeline__header button:hover strong { background: var(--surface-muted); }
html body .calendar-timeline__header button.is-today span { color: var(--accent-strong); }
html body .calendar-timeline__header button.is-today strong,
html body .calendar-timeline__header button.is-today:hover strong { background: var(--accent); color: #fff; }
html body .calendar-timeline--week .calendar-timeline__header button:nth-child(n+7):not(.is-today) span { color: #c08a8a; }
html body .calendar-timeline__scroll { min-height: 420px; max-height: calc(100vh - 352px); }
html body .calendar-timeline__times span { right: 10px; color: var(--ink-faint); font-size: .6875rem; font-variant-numeric: tabular-nums; }
html body .calendar-timeline__times span:first-child { display: none; }
html body .calendar-timeline__day {
  border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 47px, var(--line) 47px, var(--line) 48px);
}
html body .calendar-timeline--week .calendar-timeline__day:nth-child(n+7) { background-color: var(--surface-soft); }
html body .calendar-timeline__day.is-today,
html body .calendar-timeline--week .calendar-timeline__day.is-today { background-color: rgb(16 165 113 / 5%); }
html body .calendar-task-block {
  right: 6px;
  left: 6px;
  /* A flex column keeps the title visible even in a 30-minute block. */
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px 6px 10px;
  border: 0;
  border-left: 3px solid var(--task-color);
  border-radius: 8px;
  background: color-mix(in srgb, var(--task-color) 14%, var(--surface));
  box-shadow: none;
}
html body .calendar-task-block strong { flex: 0 0 auto; font-weight: 600; }
html body .calendar-task-block span { flex: 0 0 auto; color: var(--ink-soft); line-height: 1.3; font-variant-numeric: tabular-nums; }
html body .calendar-task-block:hover { box-shadow: var(--shadow-sm); }

/* Month */
html body .calendar-month__weekday {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: left;
}
html body .calendar-month__weekday:nth-child(n+6) { color: #c08a8a; }
html body .calendar-month__day {
  min-height: clamp(104px, calc((100vh - 316px) / 6), 172px);
  gap: 4px;
  padding: 6px 6px 8px;
  border-color: var(--line);
}
html body .calendar-month__day:nth-child(7n+6):not(.is-today),
html body .calendar-month__day:nth-child(7n):not(.is-today) { background: var(--surface-soft); }
html body .calendar-month__day:nth-last-child(-n+7) { border-bottom: 0; }
html body .calendar-month__number {
  width: 28px;
  height: 28px;
  align-self: flex-start;
  margin: 0 0 2px 2px;
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast);
}
html body .calendar-month__number:hover { background: var(--surface-muted); }
html body .calendar-month__day.is-outside .calendar-month__number { color: #b0b4bc; font-weight: 500; }
html body .calendar-month__day.is-today .calendar-month__number:hover { background: var(--accent-strong); }
html body .calendar-month__day > small { padding: 0 8px; color: var(--ink-faint); font-size: .75rem; }
html body .calendar-chip {
  min-height: 24px;
  padding: 3px 8px;
  border-left: 3px solid var(--task-color);
  border-radius: 6px;
  background: color-mix(in srgb, var(--task-color) 12%, var(--surface));
}
html body .calendar-chip strong { font-size: .75rem; font-weight: 560; }
html body .calendar-chip span { color: var(--ink-soft); font-size: .6875rem; font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  html body .calendar-layout { grid-template-columns: 1fr; }
  html body .calendar-backlog { position: static; max-height: 220px; }
  html body .calendar-toolbar__navigation strong { font-size: 1.0625rem; }
}
@media (max-width: 640px) {
  html body .calendar-page__header { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  html body .calendar-page__header h1 { text-align: left; }
  html body .calendar-page__header .button { width: auto; flex: 0 0 auto; }
  html body .calendar-toolbar__navigation { flex-wrap: wrap; }
  html body .calendar-toolbar__navigation strong { order: 3; width: 100%; margin: 4px 0 0; }
  html body .calendar-toolbar__filters { width: 100%; }
  html body .calendar-toolbar__filters > label { flex: 1; width: auto; }
  html body .calendar-month__day { min-height: 96px; }
}

/* Notes ---------------------------------------------------------------------------
   The page is a board of paper notes: coloured sheets with a folded corner, laid
   out as a masonry. The Telegram Mini App keeps its own compact cards. */
.life-filter-group { display: contents; }

html body:not(.is-telegram-mini-app) .life-os--notes { gap: 0; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero { align-items: center; padding: 20px 0 18px; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero h1 { margin: 0; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero__actions { flex-direction: row; align-items: center; gap: 8px; width: auto; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero__actions .icon-button { width: 38px; height: 38px; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero__actions .icon-button svg { width: 17px; height: 17px; }
html body:not(.is-telegram-mini-app) .life-os--notes .life-hero__actions .button { width: auto; }

html body:not(.is-telegram-mini-app) .life-filterbar--notes {
  min-height: 0;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-search {
  min-width: 0;
  max-width: 460px;
  min-height: 40px;
  flex: 1 1 260px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-search svg { flex: 0 0 auto; }
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-search input { min-height: 38px; font-size: .875rem; }
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-group {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
}
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-chip {
  min-height: 32px;
  padding: 5px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 560;
}
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-chip:hover { background: rgb(255 255 255 / 60%); color: var(--ink); }
html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-chip.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(16 19 26 / 8%), 0 0 0 1px rgb(16 19 26 / 4%);
}

html body:not(.is-telegram-mini-app) .life-note-grid {
  display: block;
  columns: 272px;
  column-gap: 16px;
  /* The shadow is cast by the grid so that it follows each sheet's cut corner. */
  filter: drop-shadow(0 1px 1px rgb(16 19 26 / 7%)) drop-shadow(0 6px 14px rgb(16 19 26 / 6%));
}
html body:not(.is-telegram-mini-app) .life-note-grid > :not(.life-note) { column-span: all; }
html body:not(.is-telegram-mini-app) .life-note {
  --note-fold: 22px;
  position: relative;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 16px;
  padding: 16px 18px 14px;
  break-inside: avoid;
  border: 0;
  border-radius: 12px;
  background: var(--note-color, #fff8de);
  box-shadow: none;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--note-fold)), calc(100% - var(--note-fold)) 100%, 0 100%);
  cursor: pointer;
}
html body:not(.is-telegram-mini-app) .life-note::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--note-fold);
  height: var(--note-fold);
  border-top-left-radius: 7px;
  background: color-mix(in srgb, var(--note-color, #fff8de) 84%, #101318);
  content: "";
}
html body:not(.is-telegram-mini-app) .life-note:hover { box-shadow: none; }
html body:not(.is-telegram-mini-app) .life-note.is-archived { cursor: default; opacity: .8; }
html body:not(.is-telegram-mini-app) .life-note > header {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 0;
  opacity: 0;
  transition: opacity var(--t-fast);
}
html body:not(.is-telegram-mini-app) .life-note:hover > header,
html body:not(.is-telegram-mini-app) .life-note:focus-within > header { opacity: 1; }
@media (hover: none) {
  html body:not(.is-telegram-mini-app) .life-note > header { opacity: 1; }
  html body:not(.is-telegram-mini-app) .life-note h3 { padding-right: 64px; }
}
html body:not(.is-telegram-mini-app) .life-note__actions {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--note-color, #fff8de) 80%, #fff);
  box-shadow: 0 1px 3px rgb(16 19 26 / 14%);
}
html body:not(.is-telegram-mini-app) .life-note > header button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border-radius: 7px;
  color: rgb(17 19 24 / 62%);
  letter-spacing: 0;
  transition: background-color var(--t-fast), color var(--t-fast);
}
html body:not(.is-telegram-mini-app) .life-note > header button:hover { background: rgb(17 19 24 / 8%); color: var(--ink); }
html body:not(.is-telegram-mini-app) .life-note > header [data-note-delete]:hover { background: var(--danger-100); color: var(--danger-600); }
html body:not(.is-telegram-mini-app) .life-note h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.3;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
html body .life-note__pin { display: inline-block; margin-right: 6px; vertical-align: -1px; color: rgb(17 19 24 / 55%); }
html body:not(.is-telegram-mini-app) .life-note > p {
  margin: 0;
  color: rgb(17 19 24 / 76%);
  font-size: .875rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 9;
}
html body:not(.is-telegram-mini-app) .life-note footer {
  gap: 6px;
  margin-top: auto;
  padding: 8px var(--note-fold) 0 0;
  color: rgb(17 19 24 / 52%);
  font-size: .75rem;
}
html body:not(.is-telegram-mini-app) .life-note footer span { padding: 2px 8px; border-radius: 999px; background: rgb(255 255 255 / 55%); color: rgb(17 19 24 / 70%); }
@media (max-width: 640px) {
  html body:not(.is-telegram-mini-app) .life-os--notes .life-hero { display: flex; }
  html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-search { max-width: none; flex-basis: 100%; }
  html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-group { width: 100%; margin-left: 0; }
  html body:not(.is-telegram-mini-app) .life-filterbar--notes .life-filter-chip { flex: 1; }
}

/* Collapsible filters (app.js, [data-filter-toggle]) ------------------------------- */
html body .filter-toggle { gap: 8px; white-space: nowrap; }
html body .filter-toggle svg { color: var(--ink-faint); }
html body .filter-toggle[aria-expanded="true"] { border-color: #c5c9d1; background: var(--surface-muted); }
html body .filter-toggle b {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

html body .work-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0; }
html body .work-search { position: relative; min-width: 0; display: flex; flex: 1 1 220px; align-items: center; }
html body .work-search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none; }
html body .work-search input {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: .875rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
html body .work-search input:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-ring); }
html body .work-toolbar .button { flex: 0 0 auto; }
html body .work-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 280px)); gap: 12px; padding: 14px 16px; }
html body .work-filters label { display: grid; gap: 6px; color: var(--ink-soft); font-size: .8125rem; font-weight: 560; }
html body .work-filters select { width: 100%; }

/* Finance ---------------------------------------------------------------------------- */
html body .finance-period-bar { flex-wrap: wrap; }
html body .finance-currency-switch { align-items: center; margin: 0 0 0 auto; }
html body .finance-currency-switch button { min-height: 30px; padding: 4px 11px; border-radius: 999px; font-size: .8125rem; font-weight: 560; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
html body .finance-currency-switch button:hover:not(.is-active) { border-color: var(--line-strong); background: var(--surface-hover); color: var(--ink); }
/* The summary currency only matters on the overview tab. */
html body .finance-center:has(#finance-overview[hidden]) .finance-currency-switch { display: none; }
html body .finance-section-heading { align-items: center; }
html body .finance-section-heading h2 { margin: 0; }
html body .finance-section-heading__actions { align-items: center; }

html body .finance-panel--operations { grid-column: 1 / -1; }
@media (min-width: 1020px) {
  html body .finance-overview-grid { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 12px; }
}
@media (min-width: 1500px) {
  /* Wide screens: flow, latest operations and the payments/accounts stack side by side. */
  html body .finance-overview-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(320px, .8fr); }
  html body .finance-panel--flow { grid-column: 1; grid-row: 1 / span 2; }
  html body .finance-panel--operations { grid-column: 2; grid-row: 1 / span 2; }
  html body .finance-panel--upcoming { grid-column: 3; grid-row: 1; }
  html body .finance-panel--accounts { grid-column: 3; grid-row: 2; }
}

html body .finance-debt-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
html body .finance-debt-card {
  /* minmax(0, 1fr): long rows shrink or wrap instead of pushing out of the card. */
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
html body .finance-debt-card > header { gap: 12px; }
html body .finance-debt-card > header small { font-size: .75rem; }
html body .finance-debt-card h3 { font-size: .9375rem; font-weight: 620; }
html body .finance-debt-card .status-badge { padding: 4px 10px; white-space: nowrap; }
html body .finance-debt-card:not(.finance-debt-card--receivable) .status-badge--active { background: var(--danger-100); color: var(--danger-600); }
html body .finance-debt-card__amount span,
html body .finance-debt-card__amount small { font-size: .75rem; }
html body .finance-debt-card__amount strong { font-family: var(--font-display); font-size: 1.375rem; font-weight: 650; letter-spacing: -.02em; }
html body .finance-progress > span { font-size: .75rem; }
html body .finance-debt-card dl { gap: 6px; }
html body .finance-debt-card dl > div { padding: 8px 10px; border-radius: 10px; }
html body .finance-debt-card dt { overflow: hidden; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
html body .finance-debt-card dd { font-size: .8125rem; }
html body .finance-debt-card footer {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
html body .finance-debt-card footer .button { margin-right: 4px; white-space: nowrap; }
html body .finance-debt-card footer .row-action {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: .8125rem;
  white-space: nowrap;
  transition: background-color var(--t-fast);
}
html body .finance-debt-card footer .row-action:hover { background: var(--surface-hover); }
html body .finance-debt-card footer [data-debt-cancel] { order: 9; margin-left: auto; }
html body .finance-debt-card footer [data-debt-cancel]:hover { background: var(--danger-100); }
html body .finance-history-caption { font-size: .75rem; }

/* Section pages (Дела, Подписки, Что посмотреть): same title scale and top
   rhythm as the other pages. */
html body:not(.is-telegram-mini-app) .main-content > .dashboard-section { padding-top: 20px; }
html body:not(.is-telegram-mini-app) .dashboard-section > .section-heading { align-items: center; margin-bottom: 16px; }
html body:not(.is-telegram-mini-app) .dashboard-section > .section-heading :is(h1, h2) {
  margin: 0;
  font-size: clamp(1.75rem, 2.3vw, 2.25rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -.025em;
}

/* Settings: both panels share one width and line up with the page title. */
html body:not(.is-telegram-mini-app) .life-os--standalone .life-hero { align-items: center; padding: 20px 0 8px; }
html body:not(.is-telegram-mini-app) .life-os--standalone .life-hero h1 { margin: 0; }
html body:not(.is-telegram-mini-app) .life-os--settings .life-family-members { max-width: none; }
html body:not(.is-telegram-mini-app) .life-os--settings .life-section-heading { margin: 8px 0 12px; padding-inline: 0; }
html body:not(.is-telegram-mini-app) .life-os--settings .life-section-heading h2 { margin: 0; font-size: 1.25rem; }

/* Analytics: KPI values never wrap into their labels; short ranges fill the chart. */
html body .analytics-kpi { gap: 4px; }
html body .analytics-kpi strong { padding-top: 12px; overflow-wrap: normal; font-size: 1.375rem; white-space: nowrap; }
html body .analytics-kpi small { font-size: .75rem; }
@media (min-width: 1200px) and (max-width: 1499px) {
  html body .analytics-kpis:not(.analytics-kpis--activity) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
html body .analytics-bars { width: max-content; min-width: 100%; }
html body .analytics-bars__item { flex: 1 0 clamp(28px, 4vw, 52px); }
html body .analytics-bars__columns i { width: min(18px, 42%); }

/* Watchlist: actions sit on one baseline whatever the title length. */
html body .watch-card { display: flex; flex-direction: column; }
html body .watch-card > div { min-width: 0; }
html body .watch-card > div > div { min-width: 0; }
html body .watch-card h2,
html body .watch-card p { overflow-wrap: anywhere; }
html body .watch-card footer { margin-top: auto; padding-top: 14px; }
html body .watch-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }

/* Subscriptions: the table always fits its card. Columns share the width, long
   lines wrap, and on phones every subscription becomes a compact card. */
html body .subscription-panel .table-wrap { overflow-x: visible; }
html body .subscription-panel .data-table { table-layout: fixed; }
html body .subscription-panel .data-table th { background: var(--surface-soft); }
html body .subscription-panel .data-table th:nth-child(1) { width: 24%; }
html body .subscription-panel .data-table th:nth-child(2) { width: 26%; }
html body .subscription-panel .data-table th:nth-child(3) { width: auto; }
html body .subscription-panel .data-table th:nth-child(4) { width: 112px; }
html body .subscription-panel .data-table th:nth-child(5) { width: 204px; }
html body .subscription-panel .data-table td { padding: 14px; white-space: normal; overflow-wrap: anywhere; }
html body .subscription-panel .data-table td:first-child { min-width: 0; gap: 12px; }
html body .subscription-panel .cell-primary { min-width: 0; }
html body .subscription-panel .subscription-price { min-width: 0; }
html body .subscription-panel .data-table td small { line-height: 1.4; }
html body .subscription-panel .status-badge { white-space: nowrap; }
html body .subscription-panel .row-actions { flex-wrap: wrap; gap: 6px; }
html body .subscription-panel .row-action {
  padding: 6px 10px;
  border-color: var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
html body .subscription-panel .row-action:hover { border-color: #c5c9d1; background: var(--surface-hover); }
html body .subscription-panel .row-action[data-subscription-pay] { border-color: rgb(16 165 113 / 30%); background: var(--accent-soft); color: var(--accent-strong); }
html body .subscription-panel .row-action[data-subscription-pay]:hover { border-color: var(--accent); }
@media (max-width: 1180px) {
  html body .subscription-panel .data-table th:nth-child(5) { width: 118px; }
  html body .subscription-panel .row-actions { flex-direction: column; align-items: stretch; }
}
@media (max-width: 760px) {
  html body .subscription-panel .data-table,
  html body .subscription-panel .data-table tbody,
  html body .subscription-panel .data-table td { display: block; width: auto; }
  html body .subscription-panel .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  html body .subscription-panel .data-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 14px;
    border-top: 1px solid var(--line);
  }
  html body .subscription-panel .data-table td { padding: 0; border: 0; }
  html body .subscription-panel .data-table td:nth-child(1) { display: flex; grid-column: 1; }
  html body .subscription-panel .data-table td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: start; }
  html body .subscription-panel .data-table td:nth-child(2),
  html body .subscription-panel .data-table td:nth-child(3),
  html body .subscription-panel .data-table td:nth-child(5) { grid-column: 1 / -1; }
  html body .subscription-panel .row-actions { flex-direction: row; justify-content: flex-start; }
}
