:root {
  --bg-main: #f4f6fb;
  --bg-soft: #eef2f8;
  --panel: #ffffff;
  --panel-muted: #f8faff;
  --line: #d9dee8;
  --line-strong: #cfd5e2;
  --text: #1d2433;
  --text-soft: #5e677a;
  --text-mute: #8a94a8;
  --primary: #172238;
  --primary-soft: #e8edf8;
  --success-soft: #e9f8ef;
  --warn-soft: #fff4e5;
  --danger-soft: #fdecef;
  --danger: #ba3a50;
  --shadow-1: 0 1px 2px #0b11201a;
  --shadow-2: 0 10px 28px #1016280f;
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "Aptos", "IBM Plex Sans", "Trebuchet MS", sans-serif;
  font-weight: 400;
  background:
    radial-gradient(circle at 4% -10%, #dde8ff 0%, #f4f6fb 28%),
    radial-gradient(circle at 100% 0%, #edf2ff 0%, #f4f6fb 32%),
    var(--bg-main);
  line-height: 1.34;
}

a {
  color: #2f4f8b;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0 0 0.7rem;
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Trebuchet MS", sans-serif;
  letter-spacing: 0.01em;
  color: #232d42;
  font-weight: 650;
}

h1 {
  font-size: 1.85rem;
}

h2 {
  font-size: 1.27rem;
}

h3 {
  font-size: 1.04rem;
}

p {
  margin: 0.25rem 0 0.75rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, #f9fbff 92%, #ffffff 8%);
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #0f1829;
  background: linear-gradient(160deg, #212f4a 0%, #111827 100%);
  color: #f9fbff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brand-block {
  min-width: 0;
}

.brand {
  font-size: 1.02rem;
  font-weight: 680;
  letter-spacing: 0.02em;
  color: #202a3f;
}

.crumbs {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--text-mute);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  max-width: 100%;
  overflow-x: auto;
}

.topbar-right > * {
  flex: 0 0 auto;
}

.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 0.86rem;
  color: #2f3f63;
}

.topbar-form {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
}

.topbar-form select {
  min-height: 36px;
  width: auto;
  max-width: 320px;
}

.topbar-form button {
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  border-color: #d7dce7;
  background: #ffffff;
  color: #49546a;
  box-shadow: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.topbar-form button:hover {
  box-shadow: none;
  filter: none;
  background: #f3f6fc;
  transform: translateY(0);
}

.container {
  width: 100%;
  margin: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.content-col {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem 1.4rem 0;
}

.nav {
  position: sticky;
  top: 64px;
  flex: 0 0 220px;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 0.85rem 0.55rem 1rem;
  border-right: 1px solid #dfe3ec;
  background: #f6f7fa;
  box-shadow: inset -1px 0 0 #ffffff;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav-group-title {
  padding: 0.2rem 0.5rem 0.25rem;
  color: #8a91a0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav a,
.nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.52rem;
  min-height: 35px;
  padding: 0.44rem 0.56rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #4d5669;
  font-size: 0.91rem;
  font-weight: 500;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.nav .nav-ico {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7d8699;
}

.nav .nav-ico svg {
  width: 15px;
  height: 15px;
  display: block;
}

.nav a:hover,
.nav .nav-link:hover {
  text-decoration: none;
  border-color: #d8dde7;
  background: #edf1f7;
  color: #343f58;
}

.nav a.active,
.nav .nav-link.active {
  border-color: #d8dde7;
  background: #e8ebf2;
  color: #27324b;
  font-weight: 600;
}

.nav a.active .nav-ico,
.nav .nav-link.active .nav-ico {
  color: #27324b;
}

.msg {
  border-radius: var(--radius-lg);
  border: 1px solid #cbddf7;
  background: #edf4ff;
  color: #224575;
  box-shadow: var(--shadow-1);
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.8rem;
}

.panel {
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 4px 14px #111b2d0c;
  padding: 1rem 1.1rem;
  margin-bottom: 0.78rem;
  animation: panel-in 180ms ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.small {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
  padding: 0.16rem 0.56rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #42506b;
  font-size: 0.78rem;
}

label {
  display: block;
  margin: 0.42rem 0 0.26rem;
  font-size: 0.88rem;
  color: #4f5970;
  font-weight: 500;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 0.48rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #9aa3b4;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  padding: 0;
  accent-color: #2f4f8b;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #7f9bd4;
  box-shadow: 0 0 0 3px #d8e5ff;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0.43rem 0.84rem;
  border: 1px solid #1a2740;
  border-radius: 12px;
  background: linear-gradient(180deg, #1f2e49 0%, #162238 100%);
  color: #f7f9fd;
  font-size: 0.86rem;
  font-weight: 550;
  letter-spacing: 0.005em;
  cursor: pointer;
  box-shadow: 0 1px 0 #ffffff14 inset, 0 2px 8px #111b2d24;
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease, background 130ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 18px #0f182a2e;
  filter: brightness(1.02);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

button.warn {
  border-color: #d9dee8;
  background: #ffffff;
  color: #3d465c;
  box-shadow: 0 1px 0 #ffffff inset, 0 1px 4px #111b2d12;
}

button.danger {
  border-color: #e5b8c1;
  background: #fff4f6;
  color: var(--danger);
  box-shadow: 0 1px 0 #ffffff inset, 0 1px 4px #111b2d12;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.actions button {
  white-space: nowrap;
}

.device-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.72rem;
  margin: 0.55rem 0 0.85rem;
}

.device-filter-item {
  flex: 1 1 220px;
  min-width: 180px;
}

.device-filter-search {
  flex: 1.8 1 340px;
}

.device-filter-status {
  flex: 0.9 1 180px;
}

.device-filter-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-self: flex-end;
}

.two-col {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 1rem;
}

.profile-stack {
  display: flex;
  flex-direction: column;
  gap: 0.86rem;
}

.profile-stack > div {
  display: flex;
  flex-direction: column;
  gap: 0.86rem;
}

.profile-stack .panel {
  margin-bottom: 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.91rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

thead th {
  background: linear-gradient(180deg, #f8faff 0%, #f2f5fb 100%);
  color: #4a566f;
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 0.86rem;
  font-weight: 620;
}

th,
td {
  padding: 0.58rem 0.62rem;
  border-bottom: 1px solid #e6ebf3;
  border-right: 1px solid #edf1f7;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: none;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

tbody tr:hover {
  background: #f4f8ff;
}

@media (max-width: 1240px) {
  .container {
    flex-direction: column;
  }

  .nav {
    position: relative;
    top: 0;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
    overflow: auto;
    max-height: none;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #dfe3ec;
    padding: 0.65rem 0.8rem;
  }

  .content-col {
    padding: 1rem 1rem 0;
  }

  .nav-group {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .nav-group-title {
    width: 100%;
    padding-left: 0.2rem;
  }

  .nav a {
    white-space: nowrap;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .topbar-form {
    flex: 1 1 auto;
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-form select {
    width: 100%;
    max-width: 100%;
  }

  .grid-2,
  .grid-3,
  .two-col {
    grid-template-columns: 1fr;
  }

  .device-filter-actions {
    flex-wrap: wrap;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 0.5rem;
  }
}
