:root {
  --bg-0: #f5f7fb;
  --bg-1: #eef2f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --stroke: #e2e8f0;
  --stroke-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;

  --accent: #4f7df5;
  --accent-2: #8b5cf6;
  --danger: #e11d48;
  --ok: #059669;
  --warn: #d97706;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
button { font-family: inherit; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  top: calc(30px + var(--safe-t));
  transform: translate(-50%, -12px);
  z-index: 999;
  max-width: calc(100% - 40px);
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { border-color: rgba(225, 29, 72, .35); color: var(--danger); }

/* ============ Экран входа ============ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background:
    radial-gradient(1100px 700px at 8% 0%, rgba(79, 125, 245, .16), transparent 60%),
    radial-gradient(900px 700px at 92% 100%, rgba(139, 92, 246, .14), transparent 60%),
    linear-gradient(160deg, #f8fafd 0%, #eef2f8 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: var(--r-lg);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  align-self: center;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20%;                       /* iOS-style squircle */
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow:
    0 8px 24px rgba(79, 125, 245, .25),
    0 1px 3px rgba(15, 23, 42, .08),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden;
  position: relative;
}
.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  display: block;
}

/* Лёгкий синий градиент за логотипом */
.login-logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 20%,
    rgba(79, 125, 245, .10),
    transparent 70%
  );
  pointer-events: none;
}
.login-title { margin: 2px 0 0; font-size: 20px; text-align: center; letter-spacing: .2px; }
.login-sub   { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-align: center; }

.login-error {
  min-height: 16px;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.35;
}
.login-forgot__actions { display: flex; gap: 8px; margin-top: 4px; }
.login-forgot__actions .btn { flex: 1 1 0; }

/* ============ Поля / кнопки ============ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field__label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field__input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .15);
}
select.field__input { appearance: none; }
.field--check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text);
}
.field--check input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-soft);
  border-color: var(--stroke);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 125, 245, .25);
}
.btn--ghost { background: #ffffff; }
.btn--danger {
  background: linear-gradient(135deg, #f43f5e, #be123c);
  border-color: transparent;
  color: #fff;
}
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn--link {
  height: auto; padding: 4px;
  background: none; border: none;
  color: var(--muted); font-weight: 500; font-size: 13px;
  text-decoration: underline; text-underline-offset: 3px;
  box-shadow: none;
}

/* ============ Рабочий стол (с обоями) ============ */
.os {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  background: #eef2f8;
}

/* Градиентный слой (виден, если обои не заданы / не загрузились) */
.os::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 800px at 10% 0%, rgba(79, 125, 245, .10), transparent 55%),
    radial-gradient(900px 700px at 90% 100%, rgba(139, 92, 246, .09), transparent 55%),
    radial-gradient(700px 500px at 50% 120%, rgba(56, 189, 248, .08), transparent 60%),
    linear-gradient(160deg, #f8fafd 0%, #eef2f8 100%);
}

/* Слой обоев — поверх градиента, под контентом */
.os::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--os-wall, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.os-topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(15px + var(--safe-t)) 15px 15px;
  flex: 0 0 auto;
}
.os-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 12px 3px 3px;   /* было 4px 10px 4px 4px */
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #ffffff;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.os-brand__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, .35);
  box-shadow:
    0 2px 6px rgba(79, 125, 245, .35),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden;
}
.os-brand__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.os-topbar__right { display: flex; align-items: center; gap: 10px; }

.os-user {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px 0 3px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.os-user:active { transform: scale(.97); }
.os-avatar {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.os-user__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.os-usermenu {
  position: absolute;
  top: calc(48px + var(--safe-t));
  right: 14px;
  z-index: 40;
  width: 210px;
  padding: 6px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-lg);
  animation: menuIn .14s ease-out;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.os-usermenu__head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 4px;
}
.os-usermenu__name { font-size: 13.5px; font-weight: 600; }
.os-usermenu__role { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.os-usermenu__item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
}
.os-usermenu__item i { width: 14px; text-align: center; color: var(--muted); font-size: 12px; }
.os-usermenu__item:hover { background: var(--panel-soft); }
.os-usermenu__item--danger { color: var(--danger); }
.os-usermenu__item--danger i { color: var(--danger); }
.os-usermenu__item--danger:hover { background: rgba(225, 29, 72, .06); }

.os-desktop {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 15px 15px calc(98px + var(--safe-b));
}

/* ============ Иконки приложений ============ */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 6px;
  max-width: 720px;
  margin: 0 auto;
}
@media (min-width: 600px) {
  .app-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 10px; }
}
@media (min-width: 1024px) {
  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    max-width: 720px;
    gap: 18px 12px;
  }
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease;
}
.app-icon:active { transform: scale(.94); }
.app-icon__tile {
  position: relative;
  width: 100%;
  max-width: 52px;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  box-shadow:
    0 3px 8px rgba(15, 23, 42, .12),
    inset 0 1px 0 rgba(255, 255, 255, .35);
  overflow: hidden;
}
.app-icon__tile::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), transparent 45%);
  pointer-events: none;
  z-index: 0;
}
.app-icon__tile i { position: relative; z-index: 1; }
.app-icon__label {
  max-width: calc(100% + 6px);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  color: #ffffff;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 600px) {
	.app-icon__tile { max-width: 56px; font-size: 26px; }
	.app-icon__label { font-size: 11.5px; padding: 2px 8px; }
}

/* ============ Док ============ */
.os-dock {
  position: fixed;
  left: 50%;
  bottom: calc(15px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 20px);
  padding: 10px 10px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .50);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  overflow-x: auto;
  scrollbar-width: none;
}
.os-dock::-webkit-scrollbar { display: none; }

.dock-item {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: none;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 20px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  box-shadow:
    0 2px 6px rgba(15, 23, 42, .14),
    inset 0 1px 0 rgba(255, 255, 255, .3);
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .15s;
}
.dock-item:active { transform: scale(.92); }
@media (hover: hover) and (pointer: fine) {
  .dock-item:hover { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(15, 23, 42, .18); }
}
@media (min-width: 600px) {
  .dock-item { width: 46px; height: 46px; font-size: 22px; }
}

/* ============ Контекстное меню ============ */
.ctx-menu {
  position: fixed;
  z-index: 300;
  min-width: 180px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: menuIn .12s ease-out;
}
.ctx-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}
.ctx-menu__item i { width: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.ctx-menu__item:hover { background: var(--panel-soft); }
.ctx-menu__item:active { background: var(--panel-soft); }

/* ============ Модалка обоев ============ */
.wp-modal { position: fixed; inset: 0; z-index: 200; display: none; }
.wp-modal.is-open { display: block; }

.wp-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .35);
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
}

.wp-modal__window {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.wp-modal.is-open .wp-modal__window { animation: modalIn .18s cubic-bezier(.2, .8, .3, 1); }

.wp-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
}
.wp-modal__title { margin: 0; font-size: 14px; font-weight: 600; }
.wp-modal__close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 13px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.wp-modal__close:active { transform: scale(.92); background: var(--panel-soft); }

.wp-modal__body { padding: 10px; }

.wp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.wp-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  background-color: #e2e8f0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.wp-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .15);
}
.wp-item:active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .25);
}
.wp-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 125, 245, .25);
}
.wp-item.is-active::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 4px; bottom: 4px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  font-size: 9px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
}

/* ============ Модальное окно приложений ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.is-open { display: block; }

.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(148, 163, 184, .22);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.modal__window {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  width: min(900px, calc(100% - 64px));
  max-height: min(720px, calc(100% - 96px));
  border-radius: var(--r-lg);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
  overflow: hidden;
  outline: none;
}
.modal.is-open .modal__window { animation: modalIn .18s cubic-bezier(.2, .8, .3, 1); }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 14px 12px;
  border-bottom: 1px solid var(--stroke);
}
.modal__title { margin: 0; font-size: 15px; font-weight: 600; }
.modal__close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.modal__close:active { transform: scale(.92); background: var(--panel-soft); }

.modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  padding-bottom: calc(14px + var(--safe-b));
  background: var(--bg-0);
}

@media (max-width: 1100px), (hover: none) and (pointer: coarse) {
  .modal__backdrop {
    background: var(--bg-0);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .modal__window {
    left: 0; top: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    background: var(--bg-0);
    box-shadow: none;
  }
  .modal__header { background: #ffffff; }
  .modal.is-open .modal__window { animation: modalInMobile .18s ease-out; }
  @keyframes modalInMobile {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ============ Приложение «Пользователи» ============ */
.app-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.app-toolbar .input { flex: 1 1 220px; }

.input {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .15);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
}
.user-card__avatar {
  position: relative;
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  overflow: hidden;
}
.user-card__avatar.has-image {
  background: var(--panel-soft);
  color: transparent;
}
.user-card__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.user-card__main { flex: 1 1 auto; min-width: 0; }
.user-card__name {
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.user-card__meta {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}
.user-card__tags { display: flex; gap: 5px; flex-wrap: wrap; }
.user-card__actions { flex: 0 0 auto; display: flex; gap: 5px; }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.icon-btn:hover { background: var(--panel-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn--danger { color: var(--danger); }
.icon-btn--danger:hover { background: rgba(225, 29, 72, .06); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-xs);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--stroke);
}
.tag--admin { background: rgba(79, 125, 245, .10); color: #3355c7; border-color: rgba(79, 125, 245, .25); }
.tag--off   { background: rgba(225, 29, 72, .08);  color: var(--danger); border-color: rgba(225, 29, 72, .22); }
.tag--warn  { background: rgba(217, 119, 6, .08);  color: var(--warn); border-color: rgba(217, 119, 6, .22); }
.tag--self  { background: rgba(5, 150, 105, .08);  color: var(--ok);   border-color: rgba(5, 150, 105, .22); }

@media (max-width: 720px) {
  .user-card { flex-wrap: wrap; }
  .user-card__tags { order: 4; width: 100%; }
  .user-card__actions { order: 3; }
}

.empty, .skeleton {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ============ Формы внутри приложений ============ */
.form {
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.form__title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}
.form__grid--1 { grid-template-columns: 1fr; }
@media (max-width: 720px) {
  .form__grid { grid-template-columns: 1fr; }
}
.form__error { min-height: 16px; font-size: 12.5px; color: var(--danger); margin: 4px 0 8px; }
.form__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ============ Профиль ============ */
.profile__head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: var(--r-md);
  background: #ffffff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
}
.profile__avatar {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.profile__name { font-size: 15px; font-weight: 600; }
.profile__meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ============ Кнопки в шапке модалки ============ */
.modal__header-right { display: flex; align-items: center; gap: 6px; }
.modal__actions     { display: flex; align-items: center; gap: 6px; }
.modal__action {
  width: 32px; height: 32px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 13px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s, color .15s, border-color .15s;
}
.modal__action:hover  { background: var(--panel-soft); }
.modal__action:active { transform: scale(.92); }
.modal__action.is-active {
  background: rgba(79, 125, 245, .10);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ Metricus ============ */
.metricus__loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.metricus__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
}
.metricus__empty-icon { font-size: 40px; color: #cbd5e1; margin-bottom: 4px; }
.metricus__empty-title { font-size: 16px; font-weight: 600; }
.metricus__empty-text {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 380px;
  line-height: 1.5;
  margin-bottom: 8px;
}

/* ---- Таблица счётчиков ---- */
.metricus-table {
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.metricus-table__head,
.metricus-table__row {
  display: grid;
  grid-template-columns: minmax(150px, 1.15fr) 1fr 1fr 1fr;
  align-items: center;
  gap: 0;
}

.metricus-table__head {
  padding: 10px 14px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--stroke);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.metricus-table__row {
  min-height: 50px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--stroke);
}
.metricus-table__row:last-child { border-bottom: none; }
.metricus-table__row.is-error   { background: rgba(225, 29, 72, .035); }

.metricus-table__cell {
  min-width: 0;
  padding: 0 6px;
}
.metricus-table__cell--name {
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.metricus-table__cell--chart {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 38px;
}

.metricus-counter-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metricus-counter-id {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.metricus-chart-val {
  flex: 0 0 auto;
  min-width: 3ch;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.metricus-spark {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
}

.spark-tooltip {
  position: absolute;
  z-index: 5;
  padding: 3px 8px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .18);
  transform: translateY(0);
  transition: opacity .12s;
}
.spark-tooltip[hidden] { display: none; }

.metricus-empty {
  font-size: 12px;
  color: var(--muted);
  padding-left: 4px;
}

.metricus-table__row.is-loading { opacity: .85; }

.metricus-skeleton {
  display: block;
  width: 100%;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef2f8 25%, #e2e8f0 50%, #eef2f8 75%);
  background-size: 200% 100%;
  animation: metricusShimmer 1.4s infinite linear;
}
@keyframes metricusShimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* На узких экранах — горизонтальный скролл, как у обычной таблицы */
@media (max-width: 720px) {
  .metricus-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .metricus-table__head,
  .metricus-table__row {
    grid-template-columns: 130px 110px 110px 110px;
    min-width: 460px;
  }
  .metricus-table__head { padding: 8px 12px; }
  .metricus-table__row  { padding: 4px 12px; min-height: 50px; }
  .metricus-table__cell { padding: 0 4px; }
  .metricus-table__cell--chart { height: 36px; gap: 6px; }
  .metricus-counter-name { font-size: 12px; }
  .metricus-counter-id   { font-size: 10.5px; }
  .metricus-chart-val    { font-size: 11.5px; min-width: 2ch; }
  .metricus-spark        { height: 26px; }
}

/* Настройки — как было */
.metricus__settings { background: #ffffff; }
.metricus__counters-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.metricus__counter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel-soft);
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
}
.metricus__counter-main { flex: 1 1 auto; min-width: 0; }
.metricus__counter-id    { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metricus__counter-title { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metricus__counter-add { display: flex; gap: 8px; margin-bottom: 8px; }
.metricus__counter-add .input { flex: 1 1 auto; height: 36px; font-size: 14px; }
.field__hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field__hint a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ============ Metricus: детальный вид ============ */

/* Ховер и клик по строке списка счётчиков */
.metricus-table__row { cursor: pointer; transition: background .15s; }
.metricus-table__row:hover { background: var(--panel-soft); }
.metricus-table__row:active { background: rgba(79, 125, 245, .06); }

.metricus-detail { display: flex; flex-direction: column; gap: 16px; }

.metricus-periods { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.metricus-period {
  height: 32px; padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: #ffffff; color: var(--text);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; touch-action: manipulation;
  transition: background .15s, border-color .15s, color .15s;
}
.metricus-period:hover { background: var(--panel-soft); }
.metricus-period.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.metricus-custom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.metricus-custom input[type="date"] {
  height: 32px; padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: #fff; color: var(--text);
  font-family: inherit; font-size: 12.5px;
}

.metricus-section { display: flex; flex-direction: column; gap: 8px; }
.metricus-section__title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin: 0; padding-left: 2px;
}

.metricus-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 600px) { .metricus-tiles { grid-template-columns: 1fr; } }

.metricus-tile {
  background: #ffffff; border: 1px solid var(--stroke);
  border-radius: var(--r-md); padding: 12px;
  box-shadow: var(--shadow-sm);
}
.metricus-tile__label { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.metricus-tile__value {
  font-size: 20px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metricus-tile__value.is-skeleton {
  background: linear-gradient(90deg, #eef2f8 25%, #e2e8f0 50%, #eef2f8 75%);
  background-size: 200% 100%;
  color: transparent;
  border-radius: 4px;
  animation: metricusShimmer 1.4s infinite linear;
}

.metricus-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metricus-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) {
  .metricus-two, .metricus-three { grid-template-columns: 1fr; }
}

.metricus-card {
  background: #ffffff; border: 1px solid var(--stroke);
  border-radius: var(--r-md); padding: 12px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.metricus-card__title {
  font-size: 12.5px; font-weight: 600;
  margin: 0 0 10px; color: var(--text);
}

.metricus-bars { display: flex; flex-direction: column; gap: 8px; }
.metricus-bar {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 3px 8px; font-size: 12px;
}
.metricus-bar__label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metricus-bar__value {
  color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600;
}
.metricus-bar__track {
  height: 6px; background: #eef2f8; border-radius: 3px;
  overflow: hidden; grid-column: 1 / -1;
}
.metricus-bar__fill { height: 100%; border-radius: 3px; transition: width .3s ease; }

.metricus-list { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.metricus-list__item {
	min-width: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, .25);
}
.metricus-list__item:last-child { border-bottom: none; }
.metricus-list__num {
  flex: 0 0 auto; width: 16px; text-align: right;
  color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px;
}
.metricus-list__name { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metricus-list__value {
  flex: 0 0 auto; color: var(--muted);
  font-variant-numeric: tabular-nums; font-weight: 600;
}

.metricus-loading-row {
  padding: 12px 4px; color: var(--muted); font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
}
.metricus-loading-row::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid var(--stroke-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metricus-section__error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  font-size: 12.5px;
  color: var(--danger);
  background: rgba(225, 29, 72, .06);
  border-radius: var(--r-sm);
}

/* Графики внутри плиток сводки/общих показателей */
.metricus-tile { padding-bottom: 8px; }
.metricus-tile__value { margin-bottom: 6px; }
.metricus-tile .metricus-spark {
  height: 24px;
  margin-top: 2px;
}
.metricus-tile .spark-tooltip { font-size: 10px; padding: 2px 6px; }

/* ============ Drag & Drop значков ============ */

/* Отключаем выделение текста на значках и подписях — важно для iOS/Safari,
   где long-press пытается «выделить» подпись под иконкой. */
.app-icon,
.app-icon *,
.dock-item,
.dock-item *,
.os-dock,
.app-grid {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Оригинал во время перетаскивания — полностью скрыт, чтобы не было
   наложения полупрозрачной копии на сам ghost. Место в сетке сохраняется,
   потому что opacity не влияет на layout. */
.app-icon.is-dragging,
.dock-item.is-dragging {
  opacity: 0;
  pointer-events: none;
  transition: none;
}

/* Ghost — только чёткая копия без теней и фильтров.
   Никаких box-shadow и drop-shadow, иначе вокруг всей колонки
   (иконка + подпись) появляется «ореол». */
.app-icon--ghost {
  box-shadow: none;
  filter: none;
  opacity: 1;
  pointer-events: none;
}
.app-icon--ghost .app-icon__tile {
  box-shadow: none;
}

body.is-dragging-app {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grabbing;
}
body.is-dragging-app * {
  cursor: grabbing !important;
}

.app-grid, .os-dock {
  transition: outline-color .15s, box-shadow .15s;
  border-radius: var(--r-md);
}

.app-grid.drag-target {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
}

.os-dock.drag-target {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  box-shadow: 0 0 0 4px rgba(79, 125, 245, .15), var(--shadow-md);
}

/* ============ Бэкапус ============ */
.backupus { display: flex; flex-direction: column; gap: 14px; }

.backupus-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.backupus-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, .18);
  transition: background .2s, box-shadow .2s;
}
.backupus-dot.is-ok {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .18);
  animation: backupusPulse 2s infinite;
}
.backupus-dot.is-fail {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .18);
}
@keyframes backupusPulse {
  0%   { box-shadow: 0 0 0 4px rgba(16, 185, 129, .18); }
  50%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 4px rgba(16, 185, 129, .18); }
}

.backupus-status__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.backupus-status__host {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.backupus-status__label {
  font-size: 12px;
  color: var(--muted);
}

.backupus-body { display: flex; flex-direction: column; gap: 14px; }

.backupus-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--muted);
}
.backupus-head i { margin-right: 4px; color: var(--accent); }
.backupus-head__total {
  font-weight: 600;
  color: var(--text);
}

.backupus-list { display: flex; flex-direction: column; gap: 12px; }

.backupus-group {
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.backupus-group__title {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-soft);
  border-bottom: 1px solid var(--stroke);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.backupus-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke);
  transition: background .12s;
}
.backupus-file:last-child { border-bottom: none; }
.backupus-file:hover { background: var(--panel-soft); }

.backupus-file__icon {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  font-size: 13px;
}
.backupus-file__main { flex: 1 1 auto; min-width: 0; }
.backupus-file__name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}
.backupus-file__meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.backupus-file__size {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .backupus-file { padding: 8px 12px; gap: 8px; }
  .backupus-file__icon { width: 24px; height: 24px; font-size: 11px; }
  .backupus-file__name { font-size: 12px; }
  .backupus-file__meta { font-size: 11px; }
  .backupus-file__size { font-size: 11.5px; }
}

/* ============ Профиль — аватар и смена пароля ============ */
.profile__avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.profile__avatar {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  border: none;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
}
.profile__avatar:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(79, 125, 245, .3);
}
.profile__avatar:active { transform: scale(.96); }
.profile__avatar.has-image { color: transparent; background: var(--panel-soft); }

.profile__avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.profile__avatar-letter {
  position: relative;
  z-index: 1;
}

.profile__avatar-spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .55);
  color: #ffffff;
  font-size: 20px;
  z-index: 2;
}
.profile__avatar.is-loading {
  cursor: progress;
  pointer-events: none;
}
.profile__avatar.is-loading .profile__avatar-img,
.profile__avatar.is-loading .profile__avatar-letter {
  opacity: 0.35;
}

/* ----- картинка в шапке ----- */
.os-avatar {
  position: relative;
  overflow: hidden;
}
.os-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

/* ---------- остальные стили меню аватара ---------- */
.profile__avatar-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: menuIn .14s ease-out;
}

.profile__avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.profile__avatar-btn:hover { background: var(--panel-soft); }
.profile__avatar-btn:active { transform: scale(.94); }
.profile__avatar-btn--danger { color: var(--danger); }
.profile__avatar-btn--danger:hover { background: rgba(225, 29, 72, .06); }

.profile__pwd-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile__pwd-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ============ AppDialog (alert / confirm / prompt) ============ */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.app-dialog[hidden] { display: none !important; }

.app-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  opacity: 0;
  transition: opacity .16s ease;
}
.app-dialog.is-open .app-dialog__backdrop { opacity: 1; }

.app-dialog__window {
  position: relative;
  width: min(400px, 100%);
  padding: 26px 22px 18px;
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
  transform: scale(.96);
  opacity: 0;
  transition: transform .18s cubic-bezier(.2, .8, .3, 1), opacity .18s;
  outline: none;
}
.app-dialog.is-open .app-dialog__window {
  transform: scale(1);
  opacity: 1;
}

.app-dialog__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--stroke);
  background: #ffffff;
  border-radius: var(--r-sm);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  touch-action: manipulation;
  transition: background .15s, color .15s, transform .12s;
}
.app-dialog__close:hover  { background: var(--panel-soft); color: var(--text); }
.app-dialog__close:active { transform: scale(.92); }

.app-dialog__icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 50%;
}
.app-dialog__icon[hidden] { display: none !important; }
.app-dialog__icon.is-info     { background: rgba(79, 125, 245, .12); color: #4f7df5; }
.app-dialog__icon.is-success  { background: rgba(16, 185, 129, .12); color: #10b981; }
.app-dialog__icon.is-warning  { background: rgba(245, 158, 11, .12); color: #f59e0b; }
.app-dialog__icon.is-danger   { background: rgba(239, 68, 68, .12);  color: #ef4444; }
.app-dialog__icon.is-question { background: rgba(139, 92, 246, .12); color: #8b5cf6; }

.app-dialog__title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.app-dialog__title[hidden] { display: none !important; }

.app-dialog__body { margin: 0 0 18px; }

.app-dialog__text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-dialog__input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  margin-top: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--stroke);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.app-dialog__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .15);
}

.app-dialog__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.app-dialog__actions .btn { min-width: 110px; }

@media (max-width: 480px) {
  .app-dialog { padding: 16px; }
  .app-dialog__window { padding: 22px 18px 16px; }
  .app-dialog__actions .btn { flex: 1 1 0; min-width: 0; }
}

/* ============ Улучшенный toast ============ */
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.toast i {
  flex: 0 0 auto;
  font-size: 14px;
}
.toast[data-type="info"]    i { color: var(--accent); }
.toast[data-type="success"] i { color: var(--ok); }
.toast[data-type="warning"] i { color: var(--warn); }
.toast[data-type="error"]   i { color: var(--danger); }

/* ============ Hover значков (только мышь) ============ */
@media (hover: hover) and (pointer: fine) {
  /* Плавные переходы — только там, где hover уместен */
  .app-icon__tile,
  .app-icon__label {
    transition:
      filter .15s ease,
      box-shadow .15s ease,
      background-color .15s ease,
      color .15s ease;
  }

  /* Плитка — светлее, чуть ярче, с более выраженной тенью */
  .app-icon:hover .app-icon__tile {
    filter: brightness(1.12) saturate(1.05);
    box-shadow:
      0 6px 16px rgba(15, 23, 42, .18),
      inset 0 1px 0 rgba(255, 255, 255, .55);
  }

  /* Плашка под подписью — темнее */
  .app-icon:hover .app-icon__label {
    background-color: rgba(15, 23, 42, .82);
    color: #ffffff;
  }

  /* Подпись без плашки (если когда-то будет) — тоже читаемее */
  .app-icon:hover .app-icon__label::before {
    opacity: 1;
  }

  /* Не «наводим» на перетаскиваемый значок */
  .app-icon.is-dragging:hover .app-icon__tile {
    filter: none;
    box-shadow:
      0 3px 8px rgba(15, 23, 42, .12),
      inset 0 1px 0 rgba(255, 255, 255, .35);
  }
  .app-icon.is-dragging:hover .app-icon__label {
    background-color: rgba(15, 23, 42, .55);
  }
}

/* ============ Метрикус: фавиконы ============ */
.metricus-counter-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
}
.metricus-counter-name__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metricus-counter-favicon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--stroke);
}

.metricus__counter {
  display: flex;
  align-items: center;
  gap: 10px;
}
.metricus__counter-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.metricus__counter-info {
  min-width: 0;
  flex: 1 1 auto;
}
.metricus__counter-favicon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--stroke);
}
.metricus__counter-favicon--fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 10px;
}

/* Фавикон в заголовке модалки */
.modal__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow: hidden;
}
.modal__title-favicon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
}

/* ============ Бэкапус: статус дат ============ */
.backupus-head.is-today {
  border-color: rgba(16, 185, 129, .35);
  background: rgba(16, 185, 129, .06);
}
.backupus-head.is-today .backupus-head__date {
  color: #059669;
  font-weight: 600;
}
.backupus-head.is-today .backupus-head__date i {
  color: #10b981;
}

.backupus-head.is-stale {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .05);
}
.backupus-head.is-stale .backupus-head__date {
  color: #dc2626;
  font-weight: 600;
}
.backupus-head.is-stale .backupus-head__date i {
  color: #ef4444;
}

.backupus-head__date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.backupus-head__date i {
  font-size: 13px;
}

.backupus-file__meta--fresh {
  color: #059669;
  font-weight: 600;
}
.backupus-file__meta--stale {
  color: #dc2626;
  font-weight: 600;
}

/* ============ Папки ============ */
.app-icon { position: relative; }

/* Плитка папки — 2x2 превью */
.app-icon__tile.app-folder__tile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  padding: 4px;
  place-items: stretch;
  background: linear-gradient(145deg, #cbd5e1, #94a3b8);
  color: #475569;
}
.app-folder__cell {
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  color: #fff;
  font-size: 10px;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.app-folder__cell--empty {
  background: rgba(255, 255, 255, .18);
}

/* Подсказка слияния значков */
.app-icon.merge-hint .app-icon__tile {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .6), 0 8px 24px rgba(79, 125, 245, .4);
  transition: transform .15s, box-shadow .15s;
}
/* .app-icon.merge-hint::after { */
  /* content: '+'; */
  /* position: absolute; */
  /* top: -4px; */
  /* right: -4px; */
  /* width: 20px; */
  /* height: 20px; */
  /* background: var(--accent); */
  /* color: #fff; */
  /* border-radius: 50%; */
  /* display: grid; */
  /* place-items: center; */
  /* font-size: 13px; */
  /* font-weight: 700; */
  /* box-shadow: 0 2px 8px rgba(79, 125, 245, .5); */
  /* z-index: 2; */
/* } */

/* Подсветка папки при добавлении в неё */
.app-folder.drop-into .app-folder__tile {
  box-shadow: 0 0 0 3px var(--accent), 0 8px 24px rgba(79, 125, 245, .4);
  transform: scale(1.05);
  transition: transform .15s, box-shadow .15s;
}
/* ============ Модалка папки ============ */
.folder-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: block;
  pointer-events: none;
}
.folder-modal[hidden] { display: none !important; }

.folder-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: auto;
}
.folder-modal.is-open .folder-modal__backdrop { opacity: 1; }

.folder-modal__window {
  position: absolute;
  width: min(340px, calc(100vw - 32px));
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  opacity: 0;
  transform: translateY(-6px) scale(.96);
  transition: opacity .16s ease, transform .16s ease, border-color .15s, box-shadow .15s;
  pointer-events: auto;
}

.folder-modal.is-open .folder-modal__window {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Подсветка «вытащить за пределы» */
.folder-modal__window.folder-drop-outside {
  border-color: rgba(239, 68, 68, .55);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 0 0 3px rgba(239, 68, 68, .18);
}
.folder-modal__window.folder-drop-outside .folder-modal__grid {
  opacity: .55;
}

/* ---- Заголовок и поле переименования ---- */
.folder-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 8px;
}
.folder-modal__title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.folder-modal__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
  cursor: text;
  user-select: none;
}
.folder-modal__edit {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  border-radius: var(--r-xs);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, background .15s, color .15s;
  display: grid;
  place-items: center;
}
@media (hover: hover) and (pointer: fine) {
  .folder-modal__title-wrap:hover .folder-modal__edit {
    opacity: 1;
    pointer-events: auto;
  }
}
.folder-modal__title-wrap.show-edit .folder-modal__edit {
  opacity: 1;
  pointer-events: auto;
}
.folder-modal__edit:hover { background: var(--panel-soft); color: var(--text); }

.folder-modal__input {
  flex: 1 1 auto;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .15);
  min-width: 0;
}

.folder-modal__close {
  width: 26px;
  height: 26px;
  border: 1px solid var(--stroke);
  background: #fff;
  border-radius: var(--r-xs);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}
.folder-modal__close:hover { background: var(--panel-soft); color: var(--text); }

/* ---- Сетка значков внутри папки ---- */
.folder-modal__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 4px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding: 4px 2px 6px;
}
@media (min-width: 600px) {
  .folder-modal__grid { gap: 18px 6px; }
}

.folder-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0;
  /* Ячейка должна визуально совпадать с главным экраном:
     ширина сетки 340 - 20 (padding) = 320 / 3 = 106px,
     из них 52–56px уходит на плитку, остаток — на подпись. */
}
.folder-app:active { transform: scale(.94); }

/* 
   ВАЖНО: НЕ переопределяем .folder-app .app-icon__tile и
   .folder-app .app-icon__label — они наследуются от глобальных правил
   главного экрана. В глобальных:
     .app-icon__tile  { max-width: 52px (56 на ≥600); aspect-ratio:1; font-size:24/26px }
     .app-icon__label { max-width: calc(100% + 6px); font-size:11/11.5px;
                        padding:2px 7px; background rgba(15,23,42,.55); ellipsis }
   Именно из-за прежнего переопределения .folder-app .app-icon__label
   с max-width:100% подписи в папке были уже и обрезались.
*/

@media (hover: hover) and (pointer: fine) {
  .folder-app:hover .app-icon__tile {
    filter: brightness(1.08);
    box-shadow:
      0 6px 16px rgba(15, 23, 42, .18),
      inset 0 1px 0 rgba(255, 255, 255, .55);
  }
}

/* Перетаскивание внутри папки */
.folder-app.is-dragging {
  opacity: 0;
  pointer-events: none;
}
.folder-app--ghost {
  box-shadow: none;
  filter: none;
}