/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; position: relative; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-md); font-weight: 600; font-size: .9375rem; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--sunken); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-quiet-danger { background: transparent; border-color: var(--line-strong); color: var(--danger-ink); }
.btn-quiet-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn.is-loading { cursor: progress; pointer-events: none; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.bell-badge { position: absolute; top: 5px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--cyan); color: #04202A; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; }

/* Forms */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.label { font-weight: 600; font-size: .875rem; }
.input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); font-size: 1rem; }
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.field-hint { font-size: .8125rem; color: var(--ink-3); }
.field-error { font-size: .8125rem; color: var(--danger-ink); }
.field-error:empty { display: none; }
.field-status { font-size: .8125rem; color: var(--ink-3); }
.field-status.is-ok { color: var(--success-ink); }
.field-status.is-bad { color: var(--danger-ink); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-toggle { position: absolute; right: 4px; top: 2px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-3); display: grid; place-items: center; cursor: pointer; }
.input-toggle:hover { color: var(--ink); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength i { height: 4px; border-radius: 2px; background: var(--line-strong); }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] i:nth-child(-n+2) { background: #E0A100; }
.strength[data-level="3"] i:nth-child(-n+3) { background: var(--cyan); }
.strength[data-level="4"] i { background: var(--success); }
.form-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); font-size: .9375rem; }
.form-alert .icon { margin-top: 2px; }
.form-alert.is-error { background: var(--danger-soft); color: var(--danger-ink); }
.form-alert.is-success { background: var(--success-soft); color: var(--success-ink); }

/* Choice controls */
.seg { display: inline-grid; grid-auto-flow: column; padding: 3px; border-radius: 12px; background: var(--sunken); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 19, 48, .14); }
.switch { position: relative; flex: none; width: 48px; height: 28px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background-color .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Identity */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; color: var(--primary); }
.brand-word { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.035em; }
.brand-word span { color: var(--primary); }
.brand--light { color: #fff; }
.brand--light .brand-mark { color: #fff; --cyan: #4FE0F5; }
.brand--light .brand-word span { color: #7FEAFB; }
.avatar { --s: 44px; position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--s); height: var(--s);
  overflow: hidden; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font: 700 calc(var(--s) * .36)/1 var(--font-display); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { --s: 28px; } .avatar--sm { --s: 36px; } .avatar--lg { --s: 68px; } .avatar--xl { --s: 104px; }
.avatar-wrap { position: relative; display: inline-flex; }
.presence { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--cyan); border: 2px solid var(--surface); }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: .75rem; font-weight: 700; }
.badge--muted { background: var(--sunken); color: var(--ink-2); }

/* Lists and states */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; color: inherit; cursor: pointer; }
.row:hover { background: var(--sunken); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--ink-2); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { display: grid; justify-items: center; gap: 8px; max-width: 360px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 4px; border-radius: 18px; background: var(--primary-soft); color: var(--primary); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty--error .empty-icon { background: var(--danger-soft); color: var(--danger-ink); }
.empty h2 { font-size: 1.125rem; }
.empty p { color: var(--ink-2); font-size: .9375rem; }
.empty .btn { margin-top: 12px; }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunken) 25%, var(--line) 37%, var(--sunken) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.skel-circle { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.skel-lines { flex: 1; display: grid; gap: 8px; }
.skel-line { height: 12px; }
.notif { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); }
.notif.is-unread { background: var(--primary-soft); }
.notif strong { font-weight: 600; }
.notif p { color: var(--ink-2); font-size: .9375rem; }
.notif time { color: var(--ink-3); font-size: .8125rem; }

/* Overlays */
dialog { padding: 0; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
  width: min(440px, calc(100vw - 32px)); max-height: min(680px, calc(100dvh - 32px)); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; animation: pop-in .18s ease-out; }
dialog::backdrop { background: rgba(10, 15, 38, .55); }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 88dvh; }
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 1.125rem; }
.sheet-body { overflow: auto; padding: 8px; }
.dialog-body { padding: 22px 22px 8px; }
.dialog-body h2 { font-size: 1.25rem; }
.dialog-body p { margin-top: 8px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 22px; }
.toasts { position: fixed; z-index: 150; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: 24px; } }
.toast { display: flex; align-items: center; gap: 10px; max-width: 440px; padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); pointer-events: auto; animation: pop-in .2s ease-out; }
.toast .icon { color: var(--cyan); }
.toast.is-error .icon { color: #FF8C9C; }
.offline-banner { position: fixed; z-index: 160; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; background: var(--warn-soft); color: var(--warn-ink); font-size: .875rem; font-weight: 500; }