:root {
  color-scheme: dark;
  --bg: #060813;
  --bg-deep: #04050d;
  --surface: rgba(15, 20, 39, 0.72);
  --surface-strong: rgba(19, 25, 48, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f4f5fb;
  --muted: #959cb4;
  --faint: #68708b;
  --accent: #9585ff;
  --accent-strong: #755eff;
  --cyan: #55ddff;
  --pink: #ff72bd;
  --danger: #ff6b7a;
  --warning: #ffc766;
  --success: #55e6a5;
  --owner: #7668ff;
  --contact: #24b99a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.2);
  --blur: blur(24px) saturate(135%);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar-width: 258px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(110, 82, 255, 0.18), transparent 30rem),
    radial-gradient(circle at 86% 6%, rgba(25, 188, 232, 0.13), transparent 28rem),
    radial-gradient(circle at 60% 94%, rgba(211, 70, 177, 0.1), transparent 31rem),
    linear-gradient(145deg, #050710 0%, #090d1c 48%, #050711 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 85%);
  content: "";
  pointer-events: none;
}

body::after {
  position: fixed;
  width: 42rem;
  height: 42rem;
  right: -18rem;
  top: 22%;
  z-index: -1;
  border-radius: 50%;
  background: rgba(107, 76, 255, .1);
  filter: blur(90px);
  content: "";
  pointer-events: none;
  animation: ambientFloat 18s ease-in-out infinite alternate;
}

::selection {
  color: #fff;
  background: rgba(139, 121, 255, .48);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.02); }
::-webkit-scrollbar-thumb { background: rgba(173,178,213,.22); border: 3px solid transparent; border-radius: 10px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(173,178,213,.4); }

a {
  color: #a99eff;
  text-decoration: none;
  transition: color .18s ease, opacity .18s ease;
}

a:hover { color: #d1cbff; }

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 16px auto 16px 16px;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 18px 14px 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(155deg, rgba(22, 28, 55, .83), rgba(9, 13, 28, .7));
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
}

.sidebar::before {
  position: absolute;
  width: 190px;
  height: 190px;
  left: -80px;
  top: -100px;
  border-radius: 50%;
  background: rgba(129, 99, 255, .23);
  filter: blur(40px);
  content: "";
  pointer-events: none;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 5px 7px 20px;
  color: var(--text);
}

.brand:hover { color: var(--text); }

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  background: linear-gradient(140deg, #9a8aff 0%, #6c5bff 48%, #3cc8ec 100%);
  box-shadow: 0 10px 28px rgba(112, 89, 255, .38), inset 0 1px rgba(255,255,255,.4);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.08em;
}

.brand-mark::after {
  position: absolute;
  width: 30px;
  height: 12px;
  right: -9px;
  top: 2px;
  transform: rotate(38deg);
  background: rgba(255,255,255,.32);
  filter: blur(5px);
  content: "";
}

.brand-copy { min-width: 0; }
.brand-title { display: block; font-size: 15px; font-weight: 750; letter-spacing: -.02em; }
.brand-subtitle { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; letter-spacing: .15em; text-transform: uppercase; }

.nav-section-label {
  padding: 9px 11px 8px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.nav-links { display: grid; gap: 5px; }

.nav-links a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  padding: 8px 11px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 580;
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}

.nav-links a:hover {
  color: var(--text);
  border-color: rgba(255,255,255,.07);
  background: rgba(255,255,255,.05);
  transform: translateX(2px);
}

.nav-links a.active {
  color: #fff;
  border-color: rgba(154, 139, 255, .24);
  background: linear-gradient(90deg, rgba(125, 102, 255, .23), rgba(82, 199, 235, .06));
  box-shadow: inset 3px 0 0 #9585ff, 0 7px 22px rgba(77, 57, 168, .1);
}

.nav-icon {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  color: #aaa2df;
  font-size: 14px;
}

.active .nav-icon { background: rgba(149,133,255,.2); color: #fff; }

.sidebar-spacer { flex: 1; min-height: 20px; }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 8px 4px 12px;
  padding: 10px 11px;
  border: 1px solid rgba(85,230,165,.11);
  border-radius: 13px;
  background: rgba(85,230,165,.045);
  color: #a7b0c5;
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(85,230,165,.1), 0 0 14px rgba(85,230,165,.7);
  animation: statusPulse 2.6s ease-in-out infinite;
}

.account-card {
  display: grid;
  grid-template-columns: 36px minmax(0,1fr) 34px;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
}

.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(149,133,255,.55), rgba(85,221,255,.22));
  color: #fff;
  font-weight: 750;
  text-transform: uppercase;
}

.account-meta { min-width: 0; }
.account-name { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.account-role { margin-top: 1px; color: var(--faint); font-size: 10px; }
.logout-form { display: contents; }

.icon-button, .mobile-menu {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.icon-button:hover, .mobile-menu:hover { background: var(--surface-hover); color: #fff; transform: translateY(-1px); }

.app-main {
  min-height: 100vh;
  margin-left: calc(var(--sidebar-width) + 32px);
}

.mobile-topbar { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  height: 74px;
  padding: 16px 28px 0;
  color: var(--muted);
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15,20,39,.45);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-size: 11px;
}

.container {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 14px 28px 52px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 0 24px;
  animation: riseIn .48s both;
}

.page-heading { min-width: 0; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: #9189c7;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 18px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  content: "";
}

.page-title {
  color: #f8f8fd;
  font-size: clamp(25px, 3vw, 38px);
  font-weight: 720;
  line-height: 1.12;
  letter-spacing: -.045em;
}

.page-sub { margin-top: 7px; color: var(--muted); font-size: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 11px; color: var(--muted); font-size: 12px; }
.back-link:hover { color: #fff; }

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(20,26,50,.74), rgba(12,16,32,.64));
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255,255,255,.025);
  backdrop-filter: var(--blur);
  animation: riseIn .5s both;
}

.card::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255,255,255,.045), transparent 28%, transparent 72%, rgba(121,100,255,.025));
  content: "";
  pointer-events: none;
}

.card > * { position: relative; z-index: 1; }
.card + .card { margin-top: 18px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 15px 19px;
  border-bottom: 1px solid rgba(255,255,255,.075);
  color: #ebecf7;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.card-title { display: flex; align-items: center; gap: 9px; }
.card-icon { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; background: rgba(149,133,255,.12); color: #bcb4ff; }
.card-body { padding: 19px; }
.card-pad { padding: 19px; }
.card-muted { color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.stack { display: grid; gap: 12px; }
.section-gap { margin-bottom: 18px; }
.overflow-auto { overflow-x: auto; }

.stat-grid, .grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat, .stat-card {
  position: relative;
  min-height: 132px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(23,29,57,.74), rgba(12,16,32,.62));
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255,255,255,.035);
  backdrop-filter: var(--blur);
  animation: riseIn .52s both;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.stat:nth-child(2), .stat-card:nth-child(2) { animation-delay: .05s; }
.stat:nth-child(3), .stat-card:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4), .stat-card:nth-child(4) { animation-delay: .15s; }
.stat:hover, .stat-card:hover { transform: translateY(-3px); border-color: rgba(160,147,255,.24); box-shadow: 0 22px 46px rgba(0,0,0,.24); }

.stat::after, .stat-card::after {
  position: absolute;
  width: 110px;
  height: 110px;
  right: -35px;
  bottom: -52px;
  border-radius: 50%;
  background: var(--stat-glow, rgba(149,133,255,.18));
  filter: blur(20px);
  content: "";
}

.stat-val, .stat-value {
  position: relative;
  z-index: 1;
  color: var(--stat-color, #c6c0ff);
  font-size: clamp(27px, 3vw, 36px);
  font-weight: 730;
  line-height: 1;
  letter-spacing: -.045em;
}

.stat-label {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: .035em;
}

.stat-danger { --stat-color: var(--danger); --stat-glow: rgba(255,107,122,.18); }
.stat-warning { --stat-color: var(--warning); --stat-glow: rgba(255,199,102,.17); }
.stat-success { --stat-color: var(--success); --stat-glow: rgba(85,230,165,.16); }
.stat-cyan { --stat-color: var(--cyan); --stat-glow: rgba(85,221,255,.16); }

.storage-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
.storage-item { padding: 21px 18px; text-align: center; border-right: 1px solid rgba(255,255,255,.065); }
.storage-item:last-child { border-right: 0; }
.storage-value { color: #c3bdff; font-size: 21px; font-weight: 720; letter-spacing: -.03em; }
.storage-value.success { color: var(--success); }
.storage-value.warning { color: var(--warning); }
.storage-value.danger { color: var(--danger); }
.storage-label { margin-top: 5px; color: var(--muted); font-size: 11px; }

.progress-track { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--cyan)); box-shadow: 0 0 12px rgba(85,221,255,.35); }
.progress-bar.warning { background: linear-gradient(90deg, #ff9f5b, var(--warning)); }
.progress-bar.danger { background: linear-gradient(90deg, #ff4f8a, var(--danger)); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.065); }
th { color: var(--faint); font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
td { color: #d9dce9; font-size: 12px; vertical-align: middle; }
tbody tr { transition: background .18s ease; }
tbody tr:hover { background: rgba(255,255,255,.032); }
tr:last-child td { border-bottom: 0; }
.table-secondary { color: var(--muted); font-size: 11px; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
code, .code {
  padding: 3px 7px;
  border: 1px solid rgba(149,133,255,.1);
  border-radius: 7px;
  background: rgba(149,133,255,.07);
  color: #bcb4ff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 3px 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  color: #b2b8cb;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}

.badge::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; content: ""; }
.badge-danger, .badge-red { border-color: rgba(255,107,122,.17); background: rgba(255,107,122,.09); color: var(--danger); }
.badge-warning, .badge-yellow { border-color: rgba(255,199,102,.17); background: rgba(255,199,102,.09); color: var(--warning); }
.badge-success { border-color: rgba(85,230,165,.17); background: rgba(85,230,165,.09); color: var(--success); }
.badge-info { border-color: rgba(85,221,255,.15); background: rgba(85,221,255,.075); color: var(--cyan); }
.badge-owner { background: rgba(118,104,255,.11); color: #aaa0ff; }
.badge-contact { background: rgba(36,185,154,.11); color: #5ee2c6; }

.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  box-shadow: inset 0 1px rgba(255,255,255,.025);
  color: #dfe1ed;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
}

.btn:hover { color: #fff; border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.085); box-shadow: 0 8px 22px rgba(0,0,0,.16); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-sm { min-height: 32px; padding: 6px 10px; border-radius: 10px; font-size: 10px; }
.btn-primary { border-color: rgba(168,153,255,.56); background: linear-gradient(135deg, #917fff, #6958e9); box-shadow: 0 9px 24px rgba(103,83,229,.25), inset 0 1px rgba(255,255,255,.22); color: #fff; }
.btn-primary:hover { border-color: rgba(197,188,255,.76); background: linear-gradient(135deg, #a091ff, #7461f1); box-shadow: 0 12px 28px rgba(103,83,229,.35); }
.btn-danger { border-color: rgba(255,107,122,.24); background: rgba(255,107,122,.085); color: #ff8592; }
.btn-danger:hover { border-color: rgba(255,107,122,.45); background: rgba(255,107,122,.14); color: #ffabb3; }
.btn-cyan { border-color: rgba(85,221,255,.2); background: rgba(85,221,255,.08); color: var(--cyan); }
.btn-block { width: 100%; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  outline: none;
  background: rgba(4,7,18,.47);
  box-shadow: inset 0 1px 4px rgba(0,0,0,.14);
  color: var(--text);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

input::placeholder, textarea::placeholder { color: #626a83; }
input:focus, select:focus, textarea:focus { border-color: rgba(149,133,255,.58); background: rgba(8,11,25,.72); box-shadow: 0 0 0 3px rgba(129,106,255,.1), inset 0 1px 4px rgba(0,0,0,.16); }
textarea { min-height: 100px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg,transparent 50%,#858da6 50%),linear-gradient(135deg,#858da6 50%,transparent 50%); background-position: calc(100% - 17px) 18px,calc(100% - 12px) 18px; background-repeat: no-repeat; background-size: 5px 5px; padding-right: 32px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
label { color: #b6bbcd; font-size: 11px; }
.form-grid { display: grid; gap: 11px; }
.form-inline { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.form-inline > input:not([type="hidden"]), .form-inline > select { flex: 1 1 160px; width: auto; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 10px; padding: 14px; margin-bottom: 18px; }
.check-row { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.form-help { margin-top: 8px; color: var(--faint); font-size: 10px; }

.alert { display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px; margin-bottom: 17px; border: 1px solid rgba(255,107,122,.18); border-radius: 15px; background: rgba(255,107,122,.07); color: #ff9ca6; backdrop-filter: blur(15px); }
.alert-info { border-color: rgba(85,221,255,.17); background: rgba(85,221,255,.065); color: #8ce9ff; }

.empty { padding: 52px 24px; color: var(--muted); text-align: center; }
.empty::before { display: block; margin-bottom: 9px; color: #5f6680; font-size: 22px; content: "◇"; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 17px; }
.pagination-label { display: inline-flex; min-height: 32px; align-items: center; padding: 6px 11px; color: var(--muted); font-size: 10px; }

.search-hit { padding: 1px 3px; border-radius: 4px; background: rgba(255,199,102,.85); color: #17100a; }
.break-word { white-space: pre-wrap; word-break: break-word; }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-cyan { color: var(--cyan); }
.text-small { font-size: 11px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 7px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.hidden { display: none !important; }

.chat-list { overflow: hidden; }
.chat-item { display: grid; grid-template-columns: 48px minmax(0,1fr) auto auto; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid rgba(255,255,255,.06); transition: background .18s ease; }
.chat-item:last-child { border-bottom: 0; }
.chat-item:hover { background: rgba(255,255,255,.03); }
.chat-avatar { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid rgba(255,255,255,.14); border-radius: 17px; background: linear-gradient(145deg, rgba(136,113,255,.8), rgba(52,188,219,.52)); box-shadow: 0 10px 24px rgba(64,52,147,.24), inset 0 1px rgba(255,255,255,.25); color: #fff; font-size: 17px; font-weight: 750; }
.chat-main { min-width: 0; }
.chat-name { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.chat-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-username, .chat-details, .chat-time { color: var(--muted); font-size: 10px; }
.chat-preview { margin-top: 5px; overflow: hidden; color: #a6acbe; text-overflow: ellipsis; white-space: nowrap; }
.chat-preview-owner { color: #aaa0ff; }
.chat-details { margin-top: 4px; }
.chat-stats { align-self: start; padding-top: 3px; text-align: right; white-space: nowrap; }
.chat-count { display: inline-block; margin-top: 7px; padding: 3px 8px; border-radius: 99px; background: rgba(149,133,255,.1); color: #aaa0ff; font-size: 9px; }
.chat-actions { display: flex; align-items: center; gap: 7px; }

.dialog-tools, .dialog-thread { width: min(100%, 820px); margin-inline: auto; }
.dialog-tools { display: grid; gap: 11px; margin-top: 12px; }
.profile-details { padding: 15px; }
.profile-details summary { color: #cfd2e1; font-size: 12px; font-weight: 630; cursor: pointer; list-style: none; }
.profile-details summary::-webkit-details-marker { display: none; }
.profile-details summary::before { margin-right: 8px; color: var(--accent); content: "+"; }
.profile-details[open] summary::before { content: "−"; }
.profile-form { display: grid; grid-template-columns: 1.3fr .7fr; gap: 10px; margin-top: 14px; }
.profile-form textarea, .profile-form .profile-wide { grid-column: 1 / -1; }
.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; }
.search-result { color: var(--muted); font-size: 10px; }
.thread-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 13px 0; }
.thread-nav-group { display: flex; gap: 6px; min-width: 90px; }
.thread-nav-group:last-child { justify-content: flex-end; }
.thread-page { color: var(--muted); font-size: 10px; }
.msg-row { display: flex; margin-bottom: 11px; animation: messageIn .35s both; }
.msg-row.owner { flex-direction: row-reverse; }
.msg-bubble { position: relative; max-width: 72%; padding: 11px 14px 9px; border: 1px solid rgba(255,255,255,.08); border-radius: 18px 18px 18px 6px; background: rgba(22,28,49,.71); box-shadow: 0 9px 22px rgba(0,0,0,.12); backdrop-filter: blur(16px); color: #e7e9f3; font-size: 12px; line-height: 1.55; }
.msg-owner { border-color: rgba(149,133,255,.18); border-radius: 18px 18px 6px 18px; background: linear-gradient(140deg, rgba(111,89,232,.42), rgba(80,63,179,.28)); }
.msg-deleted { border-color: rgba(255,107,122,.16); opacity: .58; }
.msg-meta { margin-top: 6px; color: rgba(198,202,219,.55); font-size: 9px; text-align: right; }
.msg-state { display: inline-flex; margin-bottom: 5px; font-size: 9px; font-weight: 650; }
.message-media { max-width: min(310px, 100%); margin-bottom: 8px; overflow: hidden; border-radius: 13px; }
.message-media img, .message-media video { display: block; max-width: 100%; border-radius: 13px; }
.message-media .video-note { width: 230px; max-width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; }

.event-list { overflow: hidden; }
.event-item { padding: 15px 17px; border-bottom: 1px solid rgba(255,255,255,.06); transition: background .18s ease; }
.event-item:last-child { border-bottom: 0; }
.event-item:hover { background: rgba(255,255,255,.025); }
.event-head { display: flex; justify-content: space-between; gap: 10px; }
.event-text { margin-top: 8px; white-space: pre-wrap; word-break: break-word; }
.event-badges { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

.permission-grid { display: flex; gap: 20px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.07); flex-wrap: wrap; }
.user-check-list { padding: 7px 18px; }
.user-check { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.055); cursor: pointer; }
.user-check:last-child { border-bottom: 0; }
.user-check-copy strong { display: block; color: #eceef6; font-size: 12px; }
.user-check-copy span { color: var(--muted); font-size: 10px; }
.form-footer { display: flex; gap: 8px; padding: 13px 18px; border-top: 1px solid rgba(255,255,255,.07); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(2,3,10,.7); backdrop-filter: blur(13px); animation: fadeIn .18s both; }
.modal-card { width: min(370px, 100%); padding: 22px; border: 1px solid var(--border-strong); border-radius: 20px; background: rgba(18,23,44,.92); box-shadow: var(--shadow); }
.modal-title { margin-bottom: 8px; font-size: 16px; font-weight: 680; }
.modal-copy { margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }

.secret-code { display: block; padding: 13px; margin-bottom: 12px; overflow-wrap: anywhere; border: 1px dashed rgba(149,133,255,.23); border-radius: 12px; background: rgba(3,5,14,.42); color: #bcb4ff; }

.password-alert { margin-bottom: 17px; }
.sidebar-overlay { display: none; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-body::after { right: auto; left: -17rem; top: 35%; background: rgba(49,187,220,.1); }
.login-shell { position: relative; display: grid; width: min(920px, 100%); min-height: 570px; grid-template-columns: 1.08fr .92fr; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 32px; background: rgba(13,17,34,.64); box-shadow: 0 40px 110px rgba(0,0,0,.48); backdrop-filter: blur(28px) saturate(145%); animation: loginIn .7s cubic-bezier(.2,.8,.2,1) both; }
.login-visual { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 42px; overflow: hidden; border-right: 1px solid rgba(255,255,255,.08); background: linear-gradient(145deg, rgba(117,94,255,.18), rgba(14,20,43,.18)); }
.login-visual::before { position: absolute; width: 340px; height: 340px; right: -145px; top: 35px; border-radius: 50%; background: linear-gradient(135deg, rgba(132,109,255,.5), rgba(50,198,230,.2)); filter: blur(1px); content: ""; opacity: .48; animation: orbDrift 8s ease-in-out infinite alternate; }
.login-visual::after { position: absolute; width: 220px; height: 220px; right: -20px; bottom: -120px; border-radius: 50%; background: rgba(255,92,188,.18); filter: blur(18px); content: ""; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; color: #fff; }
.login-copy { position: relative; z-index: 1; max-width: 380px; }
.login-kicker { margin-bottom: 10px; color: #a89eff; font-size: 10px; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; }
.login-copy h1 { font-size: clamp(30px, 4vw, 46px); font-weight: 720; line-height: 1.04; letter-spacing: -.055em; }
.login-copy p { margin-top: 16px; color: #a4aac0; line-height: 1.7; }
.login-pulse { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; color: #8991a9; font-size: 10px; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 42px; background: rgba(8,11,24,.35); }
.login-panel h2 { font-size: 23px; font-weight: 690; letter-spacing: -.035em; }
.login-panel > p { margin: 6px 0 25px; color: var(--muted); font-size: 11px; }
.login-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { color: #a8aec1; font-size: 10px; font-weight: 650; letter-spacing: .05em; }
.login-submit { min-height: 45px; margin-top: 3px; }
.login-error { padding: 11px 13px; margin-bottom: 15px; border: 1px solid rgba(255,107,122,.2); border-radius: 12px; background: rgba(255,107,122,.08); color: #ff919c; font-size: 11px; }
.login-foot { margin-top: 18px; color: #626a82; font-size: 9px; text-align: center; }

@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes messageIn { from { opacity: 0; transform: translateY(5px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes loginIn { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes statusPulse { 50% { opacity: .55; box-shadow: 0 0 0 6px rgba(85,230,165,.06), 0 0 18px rgba(85,230,165,.45); } }
@keyframes ambientFloat { to { transform: translate(-8vw, 7vh) scale(1.08); } }
@keyframes orbDrift { to { transform: translate(-35px, 38px) scale(1.08); } }

@media (max-width: 1180px) {
  .stat-grid, .grid-4, .storage-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .storage-item:nth-child(2) { border-right: 0; }
  .storage-item:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.065); }
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { inset: 12px auto 12px 12px; width: min(284px, calc(100vw - 38px)); transform: translateX(calc(-100% - 22px)); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 35; display: block; border: 0; background: rgba(2,3,10,.62); opacity: 0; pointer-events: none; backdrop-filter: blur(6px); transition: opacity .25s ease; }
  body.nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .app-main { margin-left: 0; }
  .topbar { display: none; }
  .mobile-topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; height: 66px; padding: 10px 17px; border-bottom: 1px solid rgba(255,255,255,.07); background: rgba(6,8,19,.68); backdrop-filter: blur(22px) saturate(135%); }
  .mobile-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-size: 12px; font-weight: 700; }
  .mobile-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px; font-size: 14px; }
  .mobile-menu { display: grid; }
  .container { padding: 24px 17px 42px; }
  .filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-grid input { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  body { font-size: 13px; }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: 19px; }
  .page-actions { justify-content: flex-start; }
  .page-title { font-size: 27px; }
  .stat-grid, .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat, .stat-card { min-height: 112px; padding: 17px 15px; border-radius: 17px; }
  .stat-val, .stat-value { font-size: 26px; }
  .storage-grid { grid-template-columns: 1fr; }
  .storage-item { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.065); }
  .storage-item:last-child { border-bottom: 0; }
  .card { border-radius: 17px; }
  .card-header { padding: 14px; }
  .card-body, .card-pad { padding: 14px; }
  .overflow-auto { margin-right: -1px; }
  th, td { padding: 11px 13px; }
  .chat-item { grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; padding: 13px; }
  .chat-avatar { width: 42px; height: 42px; border-radius: 14px; font-size: 15px; }
  .chat-actions { grid-column: 2 / 4; }
  .chat-actions .btn:first-child { flex: 1; }
  .chat-username, .chat-details { display: none; }
  .profile-form { grid-template-columns: 1fr; }
  .profile-form > * { grid-column: 1 !important; }
  .msg-bubble { max-width: 87%; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid input { grid-column: auto; }
  .permission-grid { flex-direction: column; gap: 11px; }
  .login-body { padding: 14px; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; border-radius: 25px; }
  .login-visual { min-height: 210px; padding: 27px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.08); }
  .login-copy h1 { max-width: 300px; font-size: 31px; }
  .login-copy p { display: none; }
  .login-pulse { display: none; }
  .login-panel { padding: 28px 24px; }
}

@media (max-width: 430px) {
  .stat-grid, .grid-4 { grid-template-columns: 1fr 1fr; }
  .stat, .stat-card { min-height: 104px; }
  .stat-label { font-size: 9px; }
  .btn { min-height: 36px; }
  .thread-nav { align-items: stretch; }
  .thread-nav-group { min-width: 0; }
  .thread-page { align-self: center; }
}

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