:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d9e2ef;
  --line-soft: #e7edf5;
  --text: #172033;
  --muted: #64748b;
  --primary: #1f5fe7;
  --primary-strong: #194fc4;
  --sidebar: #13213a;
  --sidebar-muted: #b8c7dd;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  white-space: nowrap;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

button:hover {
  background: var(--primary-strong);
  box-shadow: 0 8px 18px rgba(31, 95, 231, 0.18);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  color: #1f2937;
  background: #e8eef6;
}

button.secondary:hover {
  background: #dce6f2;
  box-shadow: none;
}

button.ghost {
  width: 100%;
  color: #dbeafe;
  background: rgba(255, 255, 255, 0.12);
}

input,
select {
  min-height: 38px;
  border: 1px solid #d4dce8;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

.hidden {
  display: none !important;
}

html.auth-pending [data-view] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 35, 60, 0.14);
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.brand strong {
  font-size: 26px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 14px;
}

.brand.small {
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand.small strong {
  color: #fff;
  font-size: 20px;
}

.brand.small span {
  color: var(--sidebar-muted);
  font-size: 13px;
}

.login-form,
.login-form label {
  display: grid;
  gap: 8px;
}

.login-form {
  gap: 16px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.workspace {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 18px;
  background: var(--sidebar);
}

#nav {
  display: grid;
  grid-auto-rows: min-content;
  align-content: start;
  gap: 6px;
  flex: 0 0 auto;
}

#nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  color: #d7e2f1;
  background: transparent;
  border-radius: 6px;
  text-align: left;
}

#nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

#nav button.active {
  color: #fff;
  background: var(--primary);
}

.content {
  min-width: 0;
  padding: 28px 32px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar p:empty {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-actions button {
  width: auto;
  min-width: 72px;
  white-space: nowrap;
}

.topbar-actions button.ghost {
  color: #1f2937;
  background: #fff;
  border: 1px solid var(--line);
}

.topbar-actions button.ghost:hover {
  background: #f8fafc;
  box-shadow: none;
}

.profile-menu {
  position: relative;
}

.topbar-actions .profile-trigger {
  display: grid;
  min-width: 220px;
  grid-template-columns: 34px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  text-align: left;
  background: #fff;
  box-shadow: none;
}

.topbar-actions .profile-trigger:hover,
.topbar-actions .profile-trigger[aria-expanded="true"] {
  border-color: #b8c8df;
  background: #f8fafc;
  box-shadow: 0 4px 14px rgba(31, 41, 55, 0.08);
}

.profile-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.profile-trigger-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.profile-trigger-copy strong,
.profile-trigger-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-trigger-copy strong {
  font-size: 14px;
  font-weight: 600;
}

.profile-trigger-copy small {
  color: var(--muted);
  font-size: 12px;
}

.profile-chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #64748b;
  border-bottom: 1.5px solid #64748b;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.16s ease;
}

.profile-trigger[aria-expanded="true"] .profile-chevron {
  transform: translateY(2px) rotate(225deg);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}

.profile-dropdown-head {
  display: grid;
  gap: 3px;
  padding: 8px 10px 10px;
}

.profile-dropdown-head strong {
  color: var(--text);
  font-size: 15px;
}

.profile-dropdown-head span {
  color: var(--muted);
  font-size: 12px;
}

.profile-context-card {
  display: grid;
  gap: 9px;
  margin: 0 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 10px;
  background: #f8fafc;
}

.profile-context-card > div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}

.profile-context-card dt {
  color: var(--muted);
  font-size: 12px;
}

.profile-context-card dd {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-actions {
  display: grid;
  gap: 3px;
}

.topbar-actions .profile-menu-actions button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: #334155;
  text-align: left;
  background: transparent;
  box-shadow: none;
}

.topbar-actions .profile-menu-actions button:hover {
  background: #f1f5f9;
}

.topbar-actions .profile-menu-actions .profile-logout {
  justify-content: flex-start;
  color: #dc2626;
}

.topbar-actions .profile-menu-actions .profile-logout:hover {
  background: #fff1f2;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.topbar p,
.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.page {
  width: 100%;
}

.apps-grid,
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.app-card,
.table-row,
.note-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.app-card {
  display: flex;
  flex-direction: column;
  min-height: 148px;
  gap: 18px;
  box-shadow: 0 10px 28px rgba(22, 34, 51, 0.05);
}

.app-card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.app-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.app-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 12px;
  white-space: nowrap;
}

.section-head {
  margin-bottom: 14px;
}

.section-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-head-row > button {
  flex-shrink: 0;
}

.device-toolbar {
  min-height: 60px;
  margin-bottom: 16px;
  padding: 10px 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fc;
}

.customer-toolbar,
.user-toolbar {
  min-height: 60px;
  margin-bottom: 16px;
  padding: 10px 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fc;
}

.identity-toolbar {
  min-height: 60px;
  margin-bottom: 16px;
  justify-content: flex-end;
  padding: 10px 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fc;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.user-filter-bar {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
}

.customer-filter-search,
.user-filter-search {
  width: min(100%, 360px);
}

.user-filter-search {
  flex: 1 1 240px;
  max-width: 360px;
}

.customer-filter-search {
  position: relative;
}

.customer-filter-search label {
  display: block;
}

.customer-filter-search input,
.user-filter-search input,
.user-filter-select select {
  min-height: 40px;
  border-color: #cdd8e7;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.customer-filter-search input,
.user-filter-search input {
  width: 100%;
}

.customer-filter-search input {
  padding-right: 44px;
}

.customer-filter-search input::-webkit-search-cancel-button {
  appearance: none;
}

.customer-search-clear {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  width: 32px;
  height: 32px;
  min-height: 32px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  color: #456188;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transform: translateY(-50%);
}

.customer-search-clear:hover {
  color: #1f5fe7;
  background: #edf3ff;
  box-shadow: none;
}

.customer-search-clear:focus-visible {
  outline: 2px solid rgba(31, 95, 231, 0.3);
  outline-offset: 0;
}

.user-filter-select {
  display: grid;
  grid-template-columns: auto minmax(110px, 160px);
  align-items: center;
  gap: 8px;
  color: #41516a;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.user-filter-select select {
  width: 100%;
}

.customer-filter-search input:hover,
.user-filter-search input:hover,
.user-filter-select select:hover {
  border-color: #aebfd5;
}

.customer-filter-search input:focus,
.user-filter-search input:focus,
.user-filter-select select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(31, 95, 231, 0.14);
  outline-offset: 1px;
  box-shadow: none;
}

.device-filter {
  display: grid;
  grid-template-columns: auto minmax(180px, 264px);
  align-items: center;
  gap: 10px;
  color: #41516a;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.device-filter select {
  width: 100%;
  min-height: 40px;
  border-color: #cdd8e7;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.device-filter select:hover {
  border-color: #aebfd5;
}

.device-filter select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(31, 95, 231, 0.14);
  outline-offset: 1px;
  box-shadow: none;
}

.inline-form,
.grid-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-form {
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  align-items: center;
}

.grid-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.grid-form button {
  grid-column: span 3;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.check input {
  min-height: auto;
}

.table-list {
  display: grid;
  gap: 10px;
  width: 100%;
}

.user-pagination,
.user-pagination-controls,
.user-page-size {
  display: flex;
  align-items: center;
}

.user-pagination {
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  color: #687588;
  font-size: 13px;
}

.user-pagination-controls {
  gap: 8px;
}

.user-page-size {
  gap: 6px;
}

.user-page-size select {
  width: 72px;
  min-height: 34px;
  padding: 4px 8px;
}

.user-pagination-controls button {
  min-height: 34px;
  padding: 5px 10px;
}

.user-pagination-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.user-page-current {
  min-width: 82px;
  text-align: center;
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.admin-table th,
.admin-table td {
  height: 62px;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 14px;
  color: #263245;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  height: 48px;
  color: #6b778c;
  background: #fbfcfe;
  font-weight: 600;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.admin-table tbody tr:hover td {
  background: #f8fbff;
}

.device-table th:nth-child(1),
.device-table td:nth-child(1) {
  width: 12%;
}

.device-table th:nth-child(2),
.device-table td:nth-child(2) {
  width: 11%;
}

.device-table th:nth-child(3),
.device-table td:nth-child(3) {
  width: 8%;
}

.device-table th:nth-child(4),
.device-table td:nth-child(4) {
  width: 10%;
}

.device-table th:nth-child(5),
.device-table td:nth-child(5) {
  width: 9%;
}

.device-table th:nth-child(6),
.device-table td:nth-child(6) {
  width: 15%;
}

.device-table th:nth-child(7),
.device-table td:nth-child(7) {
  width: 14%;
}

.device-table th:nth-child(8),
.device-table td:nth-child(8) {
  width: 16%;
}

.customer-table {
  min-width: 900px;
}

.user-table {
  min-width: 1120px;
}

.identity-table {
  min-width: 1040px;
}

.customer-table th:nth-child(1),
.customer-table td:nth-child(1) {
  width: 24%;
}

.customer-table th:nth-child(2),
.customer-table td:nth-child(2) {
  width: 12%;
}

.customer-table th:nth-child(3),
.customer-table td:nth-child(3) {
  width: 24%;
}

.customer-table th:nth-child(4),
.customer-table td:nth-child(4) {
  width: 20%;
}

.customer-table th:nth-child(5),
.customer-table td:nth-child(5) {
  width: 20%;
}

.user-table th:nth-child(1),
.user-table td:nth-child(1) {
  width: 10%;
}

.user-table th:nth-child(2),
.user-table td:nth-child(2) {
  width: 9%;
}

.user-table td:nth-child(2) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.user-table th:nth-child(3),
.user-table td:nth-child(3) {
  width: 9%;
}

.user-table th:nth-child(4),
.user-table td:nth-child(4) {
  width: 8%;
}

.user-table th:nth-child(5),
.user-table td:nth-child(5) {
  width: 20%;
}

.user-table th:nth-child(6),
.user-table td:nth-child(6) {
  width: 12%;
}

.user-table th:nth-child(7),
.user-table td:nth-child(7) {
  width: 22%;
}

.name-cell {
  font-weight: 600;
}

.person-profile-cell {
  display: grid;
  min-width: 0;
  gap: 3px;
  line-height: 1.3;
}

.person-profile-cell strong,
.person-profile-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-profile-cell strong {
  color: #263245;
  font-size: 14px;
}

.person-profile-cell span,
.profile-unbound {
  color: #6b778c;
  font-size: 12px;
}

.auto-profile-match output {
  display: block;
  min-height: 20px;
  color: #53657c;
  font-size: 13px;
  line-height: 1.5;
}

.auto-profile-match.is-match output {
  color: #166534;
}

.auto-profile-match.is-warning output {
  color: #9a3412;
}

.empty-cell {
  height: 96px;
  color: var(--muted);
  text-align: center !important;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.status-online {
  border-color: #b7ebc6;
  color: #15803d;
  background: #eefdf3;
}

.status-offline {
  border-color: #ffd3d3;
  color: #e5484d;
  background: #fff2f2;
}

.status-unknown {
  border-color: #d9dee8;
  color: #64748b;
  background: #f4f6f9;
}

.table-select {
  width: 138px;
  min-height: 32px;
  border-radius: 4px;
  font-size: 13px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

button.mini {
  min-height: 30px;
  border: 1px solid #d5dfec;
  border-radius: 4px;
  padding: 0 11px;
  color: #304158;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}

button.mini:hover {
  background: #f3f7fc;
  box-shadow: none;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
}

.table-row strong {
  display: block;
  margin-bottom: 5px;
}

.device-row .meta {
  display: block;
}

.device-meta {
  display: grid;
  gap: 4px;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.device-actions select {
  min-width: 132px;
}

button.danger {
  border-color: #fecaca;
  color: #991b1b;
  background: #fee2e2;
}

button.danger:hover {
  background: #fecaca;
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 31, 0.48);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(18, 29, 49, 0.25);
}

.device-detail-panel {
  width: min(840px, calc(100vw - 32px));
}

.user-detail-panel {
  width: min(900px, calc(100vw - 32px));
}

.heartbeat-history-panel {
  width: min(840px, calc(100vw - 32px));
}

.class-card-permission-panel {
  width: min(640px, 100vw);
}

.class-card-permission-drawer {
  display: block;
  overflow: hidden;
}

.class-card-permission-drawer .class-card-permission-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100vw);
  max-height: none;
  overflow-y: auto;
  border-width: 0 0 0 1px;
  border-radius: 0;
  box-shadow: -18px 0 48px rgba(18, 29, 49, 0.18);
}

.device-detail-content {
  padding: 0 22px 22px;
}

.user-detail-content {
  padding: 0 22px 22px;
}

.heartbeat-history-content {
  padding: 0 22px 22px;
}

.device-info-table,
.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.device-info-table th,
.device-info-table td,
.detail-table th,
.detail-table td {
  min-width: 0;
  border: 1px solid var(--line-soft);
  padding: 10px 12px;
  color: #263245;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-info-table th {
  width: 180px;
  color: #5d6878;
  background: #f6f8fb;
  font-weight: 600;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h4 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}

.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-section-head h4 {
  margin-bottom: 0;
}

.detail-table-wrap {
  overflow-x: auto;
}

.detail-table {
  min-width: 620px;
}

.detail-table th {
  color: #6b778c;
  background: #fbfcfe;
  font-weight: 600;
}

.detail-table td {
  white-space: nowrap;
}

.detail-empty {
  min-height: 70px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 14px;
}

.modal-head h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.modal-icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 0;
  color: #1f2937;
  background: #fff;
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
}

.modal-icon-button:hover {
  background: #f6f8fb;
  box-shadow: none;
}

.modal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 22px 22px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.required-label {
  position: relative;
  padding-left: 10px;
}

.required-label::after {
  content: "*";
  position: absolute;
  top: 0;
  left: 0;
  color: #dc2626;
}

#userDialogForm .field.required-label {
  padding-left: 0;
}

#userDialogForm .field.required-label::after {
  content: none;
}

#userDialogForm .field-label {
  display: block;
  min-height: 20px;
}

#userDialogForm .field.required-label .field-label {
  position: relative;
  padding-left: 10px;
}

#userDialogForm .field.required-label .field-label::before {
  content: "*";
  position: absolute;
  top: 0;
  left: 0;
  color: #dc2626;
}

.field input,
.field select {
  width: 100%;
}

.identity-class-card-role-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.identity-class-card-role-control button {
  min-height: 42px;
}

input.invalid-control,
select.invalid-control,
textarea.invalid-control {
  border-color: #dc2626 !important;
  background: #fff7f7;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

.modal-form .check {
  display: flex;
  align-items: center;
  min-height: 38px;
}

.product-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 28px;
  min-height: 38px;
}

.product-options .check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  white-space: nowrap;
}

.product-options .check input {
  width: auto;
  flex: 0 0 auto;
}

.membership-options {
  display: grid;
  max-height: 260px;
  min-height: 46px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.membership-options .check {
  display: grid;
  min-height: 46px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 12px;
}

.membership-options .check:last-child {
  border-bottom: 0;
}

.membership-options .check:hover {
  background: #f8fbff;
}

.membership-options .check input {
  width: auto;
  margin: 0;
}

.membership-unit-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #334155;
  line-height: 1.45;
}

.membership-options .check small {
  color: #7b8799;
  font-size: 12px;
  white-space: nowrap;
}

.membership-options input:disabled {
  opacity: 1;
}

.unit-product-access {
  display: grid;
  min-width: 0;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.unit-product-access > strong {
  color: #334155;
  font-size: 14px;
  line-height: 1.4;
}

.unit-product-access .product-options {
  min-height: 30px;
}

.user-identity-field {
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfe;
}

.user-identity-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-identity-field-head .field-label {
  min-height: auto;
  font-weight: 600;
}

.user-identity-summary {
  min-height: 28px;
}

.field-span-2 {
  grid-column: span 2;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.class-card-scope-field {
  display: grid;
  gap: 8px;
}

.class-card-section-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.class-card-scope-panel,
.class-card-permission-options {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #d8e1ee;
  border-radius: 8px;
  background: #fbfcfe;
}

.class-card-scope-section {
  display: grid;
  gap: 8px;
}

.class-card-scope-section small {
  color: #718096;
  font-size: 12px;
  font-weight: 600;
}

.class-card-check-grid,
.class-card-permission-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.class-card-check-grid {
  display: grid;
  gap: 8px;
}

.class-card-check {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid #e1e8f2;
  border-radius: 8px;
  padding: 0 12px;
  color: #60708a;
  background: #fff;
  cursor: pointer;
}

.class-card-check input {
  width: 16px;
  height: 16px;
  min-height: auto;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: #2f57a7;
}

.class-card-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.class-card-check:has(input:checked) {
  border-color: #b9c8e8;
  color: #2f57a7;
  background: #f4f7ff;
}

.class-card-permission-check {
  min-height: 40px;
  font-weight: 700;
}

.class-card-permission-options {
  display: block;
  padding: 12px;
  overflow-x: auto;
}

.class-card-permission-collapse {
  overflow: hidden;
  border: 1px solid #dfe6f1;
  border-radius: 10px;
  background: #fff;
}

.class-card-permission-collapse > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 14px;
  color: #2f4161;
  background: #f7f9fc;
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}

.class-card-permission-collapse > summary::-webkit-details-marker {
  display: none;
}

.class-card-permission-collapse > summary::after {
  content: "⌄";
  margin-left: 10px;
  color: #71809a;
  font-size: 18px;
  transition: transform .18s ease;
}

.class-card-permission-collapse[open] > summary::after {
  transform: rotate(180deg);
}

.class-card-permission-collapse > summary span {
  margin-right: auto;
  font-weight: 700;
}

.class-card-permission-collapse > summary strong {
  color: #60708a;
  font-size: 12px;
}

.class-card-permission-collapse[open] > summary {
  border-bottom: 1px solid #e7ecf3;
}

.class-card-permission-matrix {
  min-width: 560px;
  overflow: hidden;
  border: 1px solid #dfe6f1;
  border-radius: 10px;
  background: #fff;
}

.class-card-permission-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) repeat(4, minmax(72px, 1fr));
  align-items: center;
  min-height: 46px;
  border-top: 1px solid #edf1f6;
}

.class-card-permission-row:first-child {
  border-top: 0;
}

.class-card-permission-row > strong,
.class-card-permission-row > span,
.class-card-permission-row > label {
  padding: 10px 12px;
}

.class-card-permission-head {
  min-height: 40px;
  color: #60708a;
  background: #f6f8fc;
  font-size: 12px;
  font-weight: 700;
}

.class-card-permission-head span:not(:first-child) {
  text-align: center;
}

.class-card-permission-row > strong {
  color: #223451;
  font-size: 13px;
}

.class-card-action-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #42526d;
  cursor: pointer;
  font-size: 12px;
}

.class-card-action-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #2f57a7;
}

.class-card-action-empty {
  color: #b6c0cf;
  text-align: center;
}

.class-card-empty {
  color: var(--muted);
  font-size: 13px;
}

.class-card-permission-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 -22px -22px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.class-card-permission-actions button {
  min-width: 120px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.row-actions button {
  min-width: 86px;
}

.toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  min-height: 46px;
  border: 1px solid #ffd98a;
  border-radius: 8px;
  padding: 11px 18px;
  color: #9a5b00;
  background: #fff8e8;
  box-shadow: 0 12px 32px rgba(160, 103, 0, 0.18);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  transform: translateX(-50%);
  pointer-events: none;
  animation: toast-enter 0.18s ease-out;
}

.toast::before {
  content: "!";
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
  border-radius: 50%;
  color: #fffdf7;
  background: #f3a323;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.toast[data-type="success"] {
  border-color: #9ddbb5;
  color: #176b3a;
  background: #edf9f1;
  box-shadow: 0 12px 32px rgba(22, 128, 70, 0.16);
}

.toast[data-type="success"]::before {
  content: "✓";
  color: #f7fff9;
  background: #26a65b;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.toolbar-actions,
.modal-head-actions,
.identity-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity-management-unit {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #526176;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.identity-management-unit select {
  width: 220px;
  min-height: 36px;
  padding: 0 32px 0 10px;
  background: #fff;
}

.wide-modal-panel {
  width: min(980px, calc(100vw - 32px));
}

.modal-content {
  padding: 0 22px 22px;
}

.identity-switch-form {
  display: block;
}

.identity-switch-list {
  display: grid;
  gap: 18px;
}

.identity-selection-modal {
  z-index: 50;
}

.identity-selection-modal .modal-backdrop {
  background: rgba(8, 15, 31, 0.36);
  backdrop-filter: blur(1px);
}

.switch-modal-panel {
  width: min(520px, calc(100vw - 32px));
}

.unit-switch-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.unit-switch-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: inherit;
  text-align: left;
  background: #fff;
  box-shadow: none;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.unit-switch-option:hover {
  border-color: #adc3e8;
  background: #f8fbff;
  box-shadow: 0 4px 12px rgba(31, 95, 231, 0.08);
}

.unit-switch-option.is-current {
  border-color: #8caeea;
  background: #f3f7ff;
  box-shadow: 0 0 0 1px rgba(31, 95, 231, 0.08);
}

.unit-switch-option:focus-visible {
  outline: 3px solid rgba(31, 95, 231, 0.18);
  outline-offset: 2px;
}

.unit-switch-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.unit-switch-option > span {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.unit-switch-option strong {
  font-size: 15px;
}

.unit-switch-option small {
  color: var(--muted);
  font-size: 12px;
}

.unit-switch-option em {
  min-width: 52px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #1d4ed8;
  background: #eaf1ff;
  font-size: 12px;
  font-weight: 600;
  font-style: normal;
  text-align: center;
  white-space: nowrap;
}

.modal-actions-between {
  justify-content: space-between;
}

.identity-switch-group h4,
.identity-editor-form h4,
.identity-manager-layout h4 {
  margin: 0;
  color: #263245;
  font-size: 15px;
}

.identity-switch-options {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.identity-switch-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
}

.identity-switch-option:hover,
.identity-switch-option.is-current {
  border-color: #8fb1fa;
  background: #f4f8ff;
}

.identity-switch-option.is-disabled,
.identity-role-option.is-disabled,
.identity-card.is-disabled {
  opacity: 0.62;
}

.identity-switch-option input,
.identity-role-option input {
  min-height: auto;
}

.identity-switch-option span,
.identity-role-option span,
.identity-card > div:first-child {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.identity-switch-option small,
.identity-role-option small,
.identity-card span,
.identity-summary-item small {
  color: var(--muted);
  font-size: 12px;
}

.identity-switch-option em {
  border-radius: 999px;
  padding: 3px 8px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 12px;
  font-style: normal;
}

.permission-editor {
  display: grid;
  gap: 12px;
}

.permission-product-group {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.permission-product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.permission-product-head span {
  color: var(--muted);
  font-size: 12px;
}

.permission-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.identity-permission-editor {
  gap: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.identity-editor-panel {
  display: flex;
  flex-direction: column;
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.identity-editor-panel .modal-form {
  min-height: 0;
  grid-template-columns: 1fr;
  overflow-y: auto;
  padding-bottom: 0;
}

.identity-editor-panel .field-span-2 {
  grid-column: 1;
}

.identity-permission-editor .permission-product-group {
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0;
  background: #fff;
}

.identity-permission-editor .permission-product-group:last-child {
  border-bottom: 0;
}

.permission-option-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.identity-permission-editor .permission-product-head {
  min-height: 36px;
  margin: 0;
  padding: 0 12px;
  background: #f6f8fb;
}

.identity-permission-editor .permission-option-list .check {
  display: flex;
  min-height: 40px;
  padding: 0 12px;
  border-top: 1px solid #edf1f6;
  white-space: nowrap;
  cursor: pointer;
}

.identity-permission-editor .permission-option-list .check:hover {
  background: #f8fbff;
}

.identity-permission-editor .permission-option-list .check input {
  flex: 0 0 auto;
  width: auto;
  min-height: auto;
}

.identity-permission-editor .permission-option-list .check span {
  min-width: 0;
  white-space: nowrap;
}

.identity-editor-panel .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 -22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.modal-table-wrap .admin-table,
.compact-table {
  min-width: 760px;
}

.compact-table th,
.compact-table td {
  height: 52px;
}

.identity-manager-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 22px;
  padding: 0 22px 22px;
}

.identity-manager-list,
.identity-role-options,
.identity-editor-form {
  display: grid;
  gap: 10px;
}

.identity-manager-list {
  margin-top: 10px;
}

.identity-card,
.identity-role-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.identity-role-option {
  justify-content: flex-start;
  cursor: pointer;
}

.identity-editor-form {
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafc;
}

.identity-editor-form .field {
  display: grid;
  gap: 8px;
}

.identity-editor-form .modal-actions {
  margin-top: 4px;
  padding-top: 12px;
}

.identity-summary-list,
.identity-summary-item {
  display: grid;
  gap: 3px;
}

.identity-summary-item + .identity-summary-item {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--line-soft);
}

.identity-summary-item.is-disabled {
  opacity: 0.58;
}

.identity-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.identity-name-list span {
  border: 1px solid #d7e3f4;
  border-radius: 4px;
  padding: 2px 6px;
  color: #36506f;
  background: #f5f8fc;
  font-size: 12px;
}

.identity-overflow-count {
  align-self: center;
  color: #617087;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.user-detail-unit-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.permission-summary {
  display: grid;
  gap: 5px;
  color: #526176;
  font-size: 12px;
  line-height: 1.45;
}

.permission-summary strong {
  color: #263245;
  font-weight: 600;
}

.identity-grant-options {
  display: grid;
  gap: 8px;
}

.identity-grant-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  cursor: pointer;
}

.identity-grant-option:hover {
  border-color: #aebfd5;
  background: #f8fafc;
}

.identity-grant-option.is-disabled {
  opacity: 0.62;
  cursor: default;
}

.identity-grant-option input {
  min-height: auto;
}

.identity-grant-option span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.identity-grant-option small,
.identity-grant-option em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.identity-table th:nth-child(1),
.identity-table td:nth-child(1) {
  width: 16%;
}

.identity-table th:nth-child(2),
.identity-table td:nth-child(2) {
  width: 11%;
}

.identity-table th:nth-child(3),
.identity-table td:nth-child(3) {
  width: 38%;
}

.identity-table th:nth-child(4),
.identity-table td:nth-child(4) {
  width: 9%;
}

.identity-table th:nth-child(5),
.identity-table td:nth-child(5) {
  width: 10%;
}

.identity-table th:nth-child(6),
.identity-table td:nth-child(6) {
  width: 16%;
}

@media (max-width: 820px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 12px;
  }

  #nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 20px 16px 32px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    align-items: flex-end;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-actions .profile-trigger {
    min-width: 190px;
  }

  .profile-dropdown {
    width: min(300px, calc(100vw - 32px));
  }

  .apps-grid,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .section-head-row {
    flex-direction: column;
  }

  .section-head-row > button {
    width: 100%;
  }

  .device-filter {
    width: 100%;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .user-filter-bar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .user-filter-search,
  .user-filter-select {
    width: 100%;
  }

  .user-filter-search {
    flex: 0 1 auto;
    max-width: none;
  }

  .user-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-pagination-controls {
    flex-wrap: wrap;
  }

  .user-filter-select {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .device-filter select {
    width: 100%;
  }

  .inline-form,
  .grid-form,
  .table-row {
    grid-template-columns: 1fr;
  }

  .device-actions {
    justify-content: flex-start;
  }

  .modal-panel {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
  }

  .unit-switch-options {
    grid-template-columns: 1fr;
  }

  .class-card-permission-drawer .class-card-permission-panel {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
  }

  .modal-form {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .identity-class-card-role-control {
    grid-template-columns: 1fr;
  }

  .class-card-check-grid,
  .class-card-permission-options {
    grid-template-columns: 1fr;
  }

  .class-card-permission-actions {
    margin: 0 -22px -22px;
  }

  .toolbar-actions,
  .modal-head-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .toolbar-actions button,
  .modal-head-actions button {
    flex: 1 1 140px;
  }

  .identity-management-unit {
    width: 100%;
  }

  .identity-management-unit select {
    width: auto;
    flex: 1 1 auto;
  }

  .identity-manager-layout,
  .permission-option-grid,
  .permission-option-list {
    grid-template-columns: 1fr;
  }

  .identity-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-form button {
    grid-column: auto;
  }
}
