:root {
  --rose-50: #fef8fc;
  --rose-100: #f8eef5;
  --rose-200: #ecdde8;
  --lavender: #e8e4f2;
  --periwinkle: #9bb0eb;
  --accent: #5f78c9;
  --accent-deep: #4a63b5;
  --accent-soft: #d7e0f8;
  --ink: #2a2834;
  --muted: #6b6578;
  --line: #e5dce8;
  --surface: rgba(254, 250, 253, 0.78);
  --surface-solid: #fffcfe;
  --online: #2f8f5b;
  --online-soft: #d8f0e3;
  --offline: #9a6b2f;
  --offline-soft: #f6e6cf;
  --danger: #b42318;
  --shadow: 0 20px 48px rgba(72, 48, 88, 0.08);
  --shadow-soft: 0 8px 24px rgba(72, 48, 88, 0.05);
  --radius: 20px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--rose-50);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.brand {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: 0.06em;
  font-size: 1.35rem;
  color: var(--ink);
}

/* ——— Login atmosphere ——— */
.login-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(165deg, #fef8fc 0%, #f3eef8 42%, #eef2fb 100%);
}

.login-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.login-mesh {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 50% 40% at 18% 22%, rgba(155, 176, 235, 0.45), transparent 60%),
    radial-gradient(ellipse 45% 35% at 82% 18%, rgba(232, 180, 210, 0.38), transparent 55%),
    radial-gradient(ellipse 40% 40% at 70% 78%, rgba(180, 170, 220, 0.32), transparent 55%),
    radial-gradient(ellipse 35% 30% at 25% 85%, rgba(200, 210, 245, 0.4), transparent 50%);
  animation: mesh-drift 18s ease-in-out infinite alternate;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}

.login-orb-a {
  width: min(42vw, 380px);
  height: min(42vw, 380px);
  left: -8%;
  top: 12%;
  background: radial-gradient(circle at 35% 35%, rgba(155, 176, 235, 0.55), rgba(155, 176, 235, 0));
  animation: orb-float 14s ease-in-out infinite;
}

.login-orb-b {
  width: min(36vw, 320px);
  height: min(36vw, 320px);
  right: -6%;
  top: 8%;
  background: radial-gradient(circle at 40% 40%, rgba(230, 170, 200, 0.42), rgba(230, 170, 200, 0));
  animation: orb-float 16s ease-in-out infinite reverse;
  animation-delay: -3s;
}

.login-orb-c {
  width: min(48vw, 420px);
  height: min(48vw, 420px);
  left: 35%;
  bottom: -18%;
  background: radial-gradient(circle at 50% 40%, rgba(180, 195, 235, 0.35), transparent 65%);
  animation: orb-float 20s ease-in-out infinite;
  animation-delay: -7s;
}

.login-noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
  mix-blend-mode: multiply;
}

@keyframes mesh-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2%, -1.5%, 0) scale(1.04); }
}

@keyframes orb-float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(18px, -22px, 0); }
}

@keyframes card-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.login-shell {
  width: min(440px, 100%);
  position: relative;
  z-index: 1;
  animation: card-rise 0.7s ease both;
}

.login-card {
  background: rgba(255, 252, 254, 0.62);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  padding: 40px 34px 34px;
}

.brand-hero {
  font-size: clamp(2.6rem, 8vw, 3.35rem);
  line-height: 1;
  letter-spacing: 0.08em;
  margin: 0;
  background: linear-gradient(120deg, var(--ink) 20%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-card h1 {
  margin: 10px 0 0;
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.65rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lede {
  color: var(--muted);
  margin: 10px 0 26px;
  line-height: 1.45;
  font-size: 0.98rem;
}

.login-form { display: grid; gap: 14px; }
.login-form label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.login-form input,
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-form input:focus,
.search input:focus {
  outline: none;
  border-color: var(--periwinkle);
  box-shadow: 0 0 0 3px rgba(155, 176, 235, 0.28);
}

.password-field {
  position: relative;
  display: grid;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--accent);
  background: rgba(155, 176, 235, 0.14);
  outline: none;
}

.login-form button[type="submit"],
.seg-btn,
.ghost,
.tile,
.room-chip {
  font: inherit;
}

.login-form button[type="submit"] {
  margin-top: 8px;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #7d93db, var(--accent));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(95, 120, 201, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.login-form button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(95, 120, 201, 0.34);
}

.error {
  background: #fdecec;
  color: var(--danger);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

/* ——— App shell ——— */
.app-body {
  position: relative;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -8%, #efe4f2 0%, transparent 55%),
    radial-gradient(780px 400px at 96% 0%, #e2e9fb 0%, transparent 52%),
    linear-gradient(180deg, var(--rose-50), #f4eef6 55%, #f0eef6);
}

.app-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.app-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
}

.app-glow-a {
  width: 360px;
  height: 360px;
  top: -80px;
  left: 10%;
  background: #e8d4e8;
}

.app-glow-b {
  width: 420px;
  height: 420px;
  top: 120px;
  right: -80px;
  background: #d5dff5;
}

.app {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 56px;
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.top-brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.top-brand .brand {
  font-size: 1.55rem;
  letter-spacing: 0.07em;
}

.top-title {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 650;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search input { min-width: 240px; }

.seg {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(8px);
}

.seg-btn,
.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.seg-btn.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.ghost:hover {
  border-color: var(--periwinkle);
  color: var(--ink);
}

/* KPI */
.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -24px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  opacity: 0.7;
  pointer-events: none;
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.kpi-card strong {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 650;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.kpi-card.is-online strong { color: var(--online); }
.kpi-card.is-offline strong { color: var(--offline); }
.kpi-card.is-accent strong { color: var(--accent-deep); }

/* Room chips (sticky) */
.room-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 14px;
  margin-bottom: 4px;
  background: linear-gradient(180deg, rgba(254, 248, 252, 0.94) 60%, rgba(254, 248, 252, 0));
  backdrop-filter: blur(10px);
}

.room-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.room-chip:hover {
  border-color: var(--periwinkle);
  transform: translateY(-1px);
}

.room-chip.is-active {
  background: linear-gradient(180deg, #e8eefc, #dce5f8);
  border-color: #b8c6ec;
  color: var(--accent-deep);
}

.room-chip .chip-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 2px 7px;
}

.room-chip.is-active .chip-count {
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.95);
}

.room-chip .chip-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 3px var(--online-soft);
}

/* Map / rooms */
.map-wrap {
  background: rgba(255, 252, 254, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 20px 20px 28px;
  backdrop-filter: blur(14px);
}

.map-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.map-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 650;
}

.map-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.fleet-rooms {
  display: grid;
  gap: 22px;
  min-height: 160px;
}

.room {
  scroll-margin-top: 72px;
}

.room[hidden] { display: none; }

.room-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.room-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 650;
}

.room-stats {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.room-stats b {
  color: var(--online);
  font-weight: 700;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

.tile {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background:
    linear-gradient(165deg, #ffffff 0%, #faf5fa 100%);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  min-height: 156px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: auto -25% -45% -25%;
  height: 72%;
  background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.tile.is-online::before {
  background: radial-gradient(circle at 50% 0%, #d4efe0, transparent 70%);
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(55, 40, 70, 0.1);
  border-color: #cfc2db;
}

.tile:focus-visible {
  outline: 2px solid var(--periwinkle);
  outline-offset: 2px;
}

.tile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--offline);
  box-shadow: 0 0 0 4px var(--offline-soft);
}

.tile.is-online .dot {
  background: var(--online);
  box-shadow: 0 0 0 4px var(--online-soft);
}

.tile-ext {
  position: relative;
  z-index: 1;
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
}

.tile-fio {
  position: relative;
  z-index: 1;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
  min-height: 2.1em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-fio.is-empty {
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}

.tile-meta {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.tile-meta b {
  color: var(--ink);
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 12px;
}

/* Drawer */
.drawer[hidden] { display: none; }

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(42, 36, 48, 0.28);
  backdrop-filter: blur(3px);
  display: grid;
  justify-items: end;
  z-index: 40;
}

.drawer-panel {
  width: min(440px, 100%);
  height: 100%;
  background: linear-gradient(180deg, #fffcfe, #f8f2f8);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(40, 30, 50, 0.12);
  padding: 22px;
  overflow: auto;
  animation: slide 0.22s ease;
}

@keyframes slide {
  from { transform: translateX(18px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.drawer-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.drawer-head h2 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 2.1rem;
  line-height: 1;
}

.drawer-subtitle {
  margin: 8px 0 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
}

.drawer-body { display: grid; gap: 4px; }

.row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.row span { color: var(--muted); }
.row b { font-weight: 600; word-break: break-word; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

.badge.online { background: var(--online-soft); color: #176b3d; }
.badge.offline { background: var(--offline-soft); color: #7a4f16; }

@media (max-width: 900px) {
  .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search input { min-width: 180px; }
}

@media (max-width: 560px) {
  .app { width: calc(100% - 20px); }
  .kpi { grid-template-columns: 1fr 1fr; }
  .top-actions { width: 100%; }
  .search { flex: 1; }
  .search input { min-width: 0; width: 100%; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .row { grid-template-columns: 1fr; gap: 2px; }
  .login-card { padding: 32px 24px 28px; }
}

/* Staff sync banner */
.staff-banner {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,252,254,0.85);
  color: var(--muted);
  font-size: 0.9rem;
}
.staff-banner.is-warn {
  border-color: #e6c38a;
  background: #fff8ec;
  color: #7a4f16;
}
.staff-banner .warn { font-weight: 600; }
.staff-banner b { color: var(--ink); }

.otdel { margin-top: 14px; }
.otdel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
}
.otdel-head h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.tile-lines {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
}
