:root {
  color-scheme: light;
  --page: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f7f7f9;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #d2d2d7;
  --border-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-hover: #005fca;
  --accent-soft: #e8f2ff;
  --danger: #d92d20;
  --danger-soft: #fff0ee;
  --success: #16803c;
  --warning: #9a6700;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--page);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.16;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 6px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.muted,
.field-hint {
  color: var(--text-secondary);
}

.field-hint {
  margin: -2px 0 0;
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

::selection {
  background: #cce4ff;
  color: #004c99;
}

input, textarea {
  caret-color: var(--accent);
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 15px;
  background: var(--accent);
  color: #fff;
  font-size: 25px;
  font-weight: 750;
  box-shadow: 0 9px 24px rgba(0, 113, 227, 0.22);
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 17px;
  box-shadow: none;
}

.login-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #fbfbfd 0%, var(--page) 100%);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  width: min(420px, 100%);
  padding: 44px 40px 34px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-heading {
  display: grid;
  justify-items: center;
  margin-bottom: 30px;
  text-align: center;
}

.login-heading .brand-mark {
  margin-bottom: 18px;
}

.product-name {
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.login-card form,
.form-card {
  display: grid;
  gap: 10px;
}

.form-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
  text-align: center;
  font-size: 13px;
}

label {
  color: #3a3a3c;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

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

input[readonly] {
  background: var(--surface-muted);
  color: var(--text-secondary);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.13);
}

.button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

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

.button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button.secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.button.secondary:hover:not(:disabled) {
  border-color: #b7b7bc;
  background: var(--surface-muted);
}

.button.danger {
  background: var(--danger);
  color: #fff;
}

.button.full {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
}

.button:disabled,
.mini-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.button:focus-visible,
.mini-button:focus-visible,
.nav-item:focus-visible,
.mobile-nav-toggle:focus-visible,
.text-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--border-soft);
  background: rgba(251, 251, 253, 0.9);
  backdrop-filter: blur(18px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 7px 25px;
  font-size: 15px;
  font-weight: 720;
}

.mobile-header-actions {
  display: none;
}

.mobile-nav-toggle {
  display: none;
}

.sidebar nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #515154;
  text-align: left;
  font-weight: 600;
  transition: background 130ms ease, color 130ms ease;
}

.nav-item:hover {
  background: #ededf0;
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: #005bbf;
}

.sidebar-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 16px 9px 0;
  border-top: 1px solid var(--border-soft);
  color: var(--text-secondary);
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}

.workspace {
  width: 100%;
  max-width: 1560px;
  min-width: 0;
  margin: 0 auto;
  padding: 34px clamp(22px, 3.5vw, 56px) 56px;
}

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

.connection-state {
  color: var(--success);
  font-size: 12px;
  font-weight: 650;
}

.connection-state::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #30b057;
  content: "";
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.surface,
.content-card {
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

.metric {
  min-height: 136px;
  padding: 20px;
  border-radius: var(--radius);
}

.metric.featured {
  border-color: #d4e8ff;
  background: var(--accent-soft);
}

.metric span,
.status-item span {
  color: var(--text-secondary);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.metric.featured strong {
  color: #005dbb;
}

.metric.featured span,
.metric.featured .metric-caption {
  color: #285e91;
}

.metric-link {
  width: 100%;
  color: inherit;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.metric-link:hover {
  border-color: #91bfee;
  background: #f2f8ff;
}

.metric-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.metric-link .metric-caption {
  color: #005dbb;
}

.metric-caption {
  display: block;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.surface {
  border-radius: var(--radius);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.surface > .section-heading {
  margin: 0;
  padding: 19px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.section-heading p {
  margin: 0;
  color: var(--text-secondary);
}

.overview-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.overview-section-heading h2 {
  margin-bottom: 3px;
}

.status-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.status-item {
  min-height: 112px;
  padding: 18px 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.status-item.expiring {
  border-color: #f0dfb1;
  background: #fffaf0;
}

.status-item strong {
  display: block;
  margin-top: 9px;
  font-size: 18px;
  line-height: 1.25;
}

.status-item.expiring strong {
  color: #835900;
}

.status-link {
  width: 100%;
  min-height: 74px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.status-item .status-cta {
  display: block;
  margin-top: 9px;
  color: #0066cc;
  font-weight: 650;
}

.status-link:hover .status-cta {
  text-decoration: underline;
}

.status-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.expiry-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
}

.expiry-filter[hidden] {
  display: none;
}

.expiry-filter button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.expiry-filter button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar input {
  max-width: 320px;
}

.users-toolbar input {
  min-width: min(320px, 100%);
}

.toolbar select {
  max-width: 170px;
}

.toolbar .button {
  margin-left: auto;
}

.mobile-status-sort {
  display: none;
}

.table-wrap {
  overflow: auto;
}

.list-surface {
  overflow: hidden;
}

.pagination {
  display: none;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 16px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-size: 12px;
}

.pagination.visible {
  display: flex;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-total,
.pagination-position {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pagination-position {
  min-width: 76px;
  text-align: center;
}

.pagination-button {
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 620;
}

.pagination-button:hover:not(:disabled) {
  border-color: #b7b7bc;
  background: var(--surface-muted);
}

.pagination-button:disabled {
  color: #aeaeb2;
  cursor: default;
  opacity: 0.72;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

th {
  background: #fafafa;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.table-sort-button:hover,
th[aria-sort="ascending"] .table-sort-button,
th[aria-sort="descending"] .table-sort-button {
  color: var(--accent);
}

.table-sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #fafcff;
}

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

.table-actions {
  display: flex;
  gap: 6px;
}

.audit-table {
  min-width: 680px;
}

.audit-table th:first-child,
.audit-table td:first-child {
  width: 190px;
}

.audit-table th:nth-child(3),
.audit-table td:nth-child(3),
.audit-table th:nth-child(4),
.audit-table td:nth-child(4) {
  width: 140px;
}

.audit-record {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.audit-marker {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8e8e93;
}

.audit-marker.account {
  background: var(--accent);
}

.audit-marker.security {
  background: var(--success);
}

.audit-marker.content {
  background: var(--warning);
}

.audit-marker.device {
  background: #5856d6;
}

.audit-description {
  color: var(--text);
  font-weight: 600;
}

.audit-time,
.audit-source {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.audit-actor {
  color: #3a3a3c;
  font-weight: 560;
}

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

.user-table th,
.user-table td {
  vertical-align: middle;
}

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

.user-account {
  color: var(--text);
  font-weight: 680;
  letter-spacing: -0.01em;
}

.table-value,
.device-count,
.last-active {
  font-variant-numeric: tabular-nums;
}

.device-count {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 680;
}

.last-active {
  color: var(--text-secondary);
  font-size: 13px;
}

.last-active.recent {
  color: var(--success);
  font-weight: 650;
}

.last-active.today {
  color: #3a3a3c;
  font-weight: 620;
}

.last-active.never,
.last-active.old {
  color: #8e8e93;
}

.actions-heading,
.actions-cell {
  text-align: right;
}

.user-actions {
  justify-content: flex-end;
}

.mini-button {
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 620;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.mini-button:hover:not(:disabled) {
  border-color: #b7b7bc;
  background: var(--surface-muted);
}

.mini-button.primary-action {
  border-color: #b9d9fb;
  background: var(--accent-soft);
  color: var(--accent);
}

.mini-button.primary-action:hover:not(:disabled) {
  border-color: #8fc2f5;
  background: #dcecff;
}

.mini-button.danger {
  border-color: #f4c7c3;
  background: #fff;
  color: var(--danger);
}

.mini-button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 980px;
  font-size: 11px;
  font-weight: 700;
}

.user-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.badge.active,
.badge.online,
.badge.published {
  background: #eaf7ed;
  color: var(--success);
}

.badge.inactive,
.badge.archived {
  background: #eeeeef;
  color: #515154;
}

.badge.offline {
  background: #f2f2f4;
  color: #6e6e73;
}

.badge.expired {
  background: #fff5d8;
  color: var(--warning);
}

.badge.deleted {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.platform-wechat {
  background: #edfcf2;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.badge.platform-telegram {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.badge.platform-whatsapp {
  background: #f0fdfa;
  color: #0d9488;
  border: 1px solid #99f6e4;
}

.platform-tags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.platform-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 0 8px;
}

.platform-chip {
  position: relative;
  display: block;
  cursor: pointer;
  user-select: none;
}

.platform-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chip-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
  transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.platform-chip:hover .chip-box {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.chip-icon {
  font-size: 14px;
  line-height: 1;
}

.chip-text {
  flex-shrink: 0;
}

.chip-check {
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.5);
  transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.platform-chip--wechat input[type="checkbox"]:checked ~ .chip-box {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #15803d;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.16);
}

.platform-chip--wechat input[type="checkbox"]:checked ~ .chip-box .chip-check {
  opacity: 1;
  transform: scale(1);
  color: #16a34a;
}

.platform-chip--telegram input[type="checkbox"]:checked ~ .chip-box {
  border-color: #0ea5e9;
  background: #f0f9ff;
  color: #0369a1;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.16);
}

.platform-chip--telegram input[type="checkbox"]:checked ~ .chip-box .chip-check {
  opacity: 1;
  transform: scale(1);
  color: #0284c7;
}

.platform-chip--whatsapp input[type="checkbox"]:checked ~ .chip-box {
  border-color: #14b8a6;
  background: #f0fdfa;
  color: #0f766e;
  box-shadow: 0 2px 6px rgba(20, 184, 166, 0.16);
}

.platform-chip--whatsapp input[type="checkbox"]:checked ~ .chip-box .chip-check {
  opacity: 1;
  transform: scale(1);
  color: #0d9488;
}

.platform-chip input[type="checkbox"]:focus-visible ~ .chip-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.empty {
  display: none;
  padding: 54px 20px;
  color: var(--text-secondary);
  text-align: center;
}

.empty.visible {
  display: block;
}

.content-list {
  display: grid;
  gap: 10px;
}

.content-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 17px 19px;
  border-radius: var(--radius);
}

.content-card p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.content-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(260px, 1fr);
  gap: 18px;
}

.form-card {
  align-content: start;
  padding: 22px;
}

.session-summary {
  align-self: start;
  margin: 4px 0 0;
}

.session-summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.session-summary dt {
  color: var(--text-secondary);
}

.session-summary dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.settings-sessions {
  margin-top: 18px;
}

dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.2);
  color: var(--text);
}

dialog[open] {
  animation: dialog-in 150ms ease-out;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

dialog form {
  display: grid;
  gap: 10px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0;
}

.check-label input {
  width: auto;
  min-height: auto;
}

.renewal-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.renewal-summary > div {
  padding: 13px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: var(--surface-muted);
}

.renewal-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 11px;
}

.renewal-summary strong {
  display: block;
  font-size: 13px;
}

.toast {
  position: fixed;
  z-index: 20;
  top: 20px;
  right: 24px;
  max-width: min(390px, calc(100% - 32px));
  padding: 11px 16px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.94);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.18);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: rgba(190, 35, 27, 0.96);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.runtime-policy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.runtime-policy h2,
.runtime-list-head h2 {
  margin: 0;
  font-size: 17px;
}

.runtime-policy-heading p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.runtime-policy form {
  display: grid;
  grid-template-columns: minmax(140px, 180px) auto;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
}

.runtime-policy select {
  min-width: 0;
}

#runtime-policy-status {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 12px;
}

.runtime-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  gap: 12px;
}

#runtime-table td {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

#runtime-table .muted {
  margin-top: 4px;
  font-size: 12px;
}

#runtime-table summary {
  cursor: pointer;
  color: #005dbb;
}

#runtime-table summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

#runtime-table pre {
  max-width: 320px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  white-space: pre-wrap;
  font-size: 12px;
}

#runtime-table details small {
  color: var(--text-secondary);
}

#runtime-reset-dialog {
  width: min(420px, calc(100% - 28px));
}

.reset-account-name {
  font-size: 15px;
  overflow-wrap: anywhere;
}

#runtime-reset-description {
  margin: 0;
  font-size: 13px;
}

@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .status-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .login-shell {
    padding: 20px 14px;
  }

  .login-card {
    padding: 34px 24px 26px;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .sidebar-brand {
    min-width: 0;
    padding: 0 4px;
  }

  .mobile-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
  }

  .mobile-connection-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
  }

  .mobile-connection-state::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #30b057;
    content: "";
  }

  .mobile-nav-toggle {
    display: inline-flex;
    min-width: 58px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 650;
    box-shadow: var(--shadow-soft);
  }

  .sidebar nav {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-top: 12px;
  }

  .sidebar.nav-open nav {
    display: grid;
  }

  .nav-item {
    min-height: 44px;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace {
    padding: 22px 12px 40px;
  }

  .topbar {
    margin-bottom: 20px;
  }

  .topbar .connection-state {
    display: none;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .runtime-policy {
    display: block;
    padding: 18px;
    margin-bottom: 20px;
  }

  .runtime-policy form {
    margin-top: 16px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .runtime-policy .button {
    min-height: 44px;
  }

  .runtime-list-head {
    padding: 0 0 14px;
  }

  .metric-grid {
    gap: 8px;
  }

  .metric {
    min-height: 126px;
    padding: 15px;
  }

  .metric strong {
    font-size: 26px;
  }

  .status-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .status-item {
    min-height: 0;
    padding: 15px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar input,
  .toolbar select {
    max-width: none;
    flex: 1 1 150px;
  }

  .toolbar .button {
    margin-left: 0;
  }

  .users-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .users-toolbar input {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }

  .users-toolbar .button {
    width: 100%;
    align-self: stretch;
    justify-content: center;
    margin-left: 0;
  }

  .mobile-status-sort {
    display: inline-flex;
    align-items: center;
    gap: 7px;
  }

  .pagination.visible {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .pagination-controls {
    width: 100%;
    justify-content: space-between;
  }

  .pagination-button {
    min-height: 44px;
    padding-inline: 16px;
  }

  .table-wrap {
    overflow: visible;
  }

  .list-surface {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .mobile-card-table,
  .audit-table,
  .user-table {
    min-width: 0;
    white-space: normal;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 10px;
  }

  .mobile-card-table tbody tr {
    display: block;
    overflow: hidden;
    padding: 5px 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .mobile-card-table tbody tr:hover {
    background: var(--surface);
  }

  .mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    min-width: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    overflow-wrap: anywhere;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table td::before {
    color: var(--text-secondary);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
  }

  .mobile-card-table .table-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .mobile-card-table .badge {
    justify-self: start;
  }

  .mobile-card-table .mini-button {
    min-height: 44px;
    padding-inline: 13px;
  }

  .mobile-card-table .audit-record {
    align-items: flex-start;
    white-space: normal;
  }

  .settings-sessions {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .settings-sessions > .section-heading {
    margin-bottom: 10px;
    padding: 0;
    border: 0;
  }

  .empty.visible {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface);
  }

  th,
  td {
    padding: 12px;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .section-heading > .button {
    width: 100%;
    min-height: 44px;
  }

  .content-card {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .content-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .content-meta .mini-button {
    min-height: 44px;
  }

  .form-grid,
  .renewal-summary {
    grid-template-columns: 1fr;
  }

  .check-label {
    padding-top: 0;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
    min-height: 44px;
  }

  dialog {
    max-height: calc(100dvh - 24px);
  }

  dialog form {
    max-height: calc(100dvh - 24px);
    padding: 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .toast {
    top: 12px;
    right: 16px;
    max-width: calc(100% - 32px);
  }
}

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

