:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #161616;
  --panel-3: #1c1c1c;
  --line: #222222;
  --line-strong: #2e2e2e;
  --text: #ededed;
  --muted: #8a8a8a;
  --accent: #e07a4f;
  --accent-hover: #eb885c;
  --good: #3ecf8e;
  --danger: #f07178;
  --warn: #e6b450;
  --info: #6cb6ff;
  --radius: 8px;
  --font: "Noto Sans SC", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  font-family: var(--font);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.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;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 24;
  font-size: 18px;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
}
.mi-sm { font-size: 16px !important; }

/* Login — quiet centered card */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.login-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin-bottom: 4px;
}
.login-brand-row strong { color: var(--text); font-weight: 600; font-size: 14px; }
.login-brand-row .material-symbols-outlined { color: var(--accent); font-size: 20px; }

.login-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
}
.login-desc {
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

/* App chrome */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chrome {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.chrome-left,
.chrome-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.chrome-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  white-space: nowrap;
}
.chrome-brand .material-symbols-outlined { color: var(--accent); font-size: 20px; }
.chrome-brand strong { font-size: 14px; font-weight: 600; }

.chrome-links {
  display: flex;
  align-items: center;
  gap: 14px;
}
.chrome-link {
  font-size: 13px;
  color: var(--muted);
}
.chrome-link.active { color: var(--text); }
.muted-link { opacity: .7; }

.chrome-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  min-width: 200px;
}
.chrome-search kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: #666;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--panel-2);
}

.chrome-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chrome-avatar,
#edit-user-avatar,
.operator span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.chrome-user-meta { display: none; }
@media (min-width: 1100px) {
  .chrome-user-meta { display: block; line-height: 1.2; }
  .chrome-user-meta strong { display: block; font-size: 12px; }
  .chrome-user-meta small { color: var(--muted); font-size: 11px; }
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--good);
  font-size: 12px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
}

.shell-body {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 12px 8px 20px;
  overflow: auto;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  margin: 14px 10px 6px;
  font-size: 11px;
  color: #555;
  letter-spacing: 0.06em;
}
.nav-group:first-child { margin-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover {
  background: #151515;
  color: #ddd;
}
.nav-item.active {
  background: #1a1a1a;
  color: #fff;
}
.nav-item.active .nav-ico {
  font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 0, "opsz" 24;
}

.workspace {
  min-width: 0;
  padding: 20px 24px 40px;
  background: var(--bg);
}

.page-head {
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0;
  color: #fff;
}
.page-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.view-panel {
  display: grid;
  gap: 12px;
  animation: fadeSoft .22s ease;
}
@keyframes fadeSoft {
  from { opacity: 0; }
  to { opacity: 1; }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  min-width: 200px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}
.filter-field input {
  border: 0;
  background: transparent;
  height: 100%;
  padding: 0;
  box-shadow: none;
  min-width: 140px;
}
.filter-field input:focus { outline: none; box-shadow: none; }

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.table-meta strong { color: var(--text); font-weight: 600; }

form { display: grid; gap: 12px; }
label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #cfcfcf;
}
label small { color: var(--muted); font-weight: 400; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: var(--panel);
}
input, select { height: 34px; padding: 0 10px; }
textarea { min-height: 92px; padding: 10px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: #3a3a3a;
}
option { background: #161616; }

.primary,
.secondary,
.danger,
.icon-button {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.primary {
  height: 34px;
  padding: 0 14px;
  background: var(--accent);
  color: #1a100c;
  font-weight: 600;
  font-size: 13px;
}
.primary:hover { background: var(--accent-hover); }
.primary.wide { width: 100%; height: 38px; margin-top: 4px; }

.secondary {
  height: 34px;
  padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
}
.secondary:hover { background: var(--panel-3); }

.danger {
  height: 34px;
  padding: 0 12px;
  background: #3a1d1f;
  color: var(--danger);
  border: 1px solid #5a2b2f;
  font-weight: 600;
  font-size: 13px;
}

.icon-button {
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: transparent;
}
.icon-button:hover {
  color: var(--text);
  background: #1a1a1a;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: #777;
  font-weight: 500;
  font-size: 12px;
  background: #101010;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover { background: #151515; }
tbody tr:last-child td { border-bottom: 0; }

.user-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-cell > span { display: none; }
.user-cell strong {
  display: block;
  color: #fff;
  font-weight: 500;
}
.user-cell small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

.rank {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: #1f2a36;
  color: var(--info);
}
.rank.admin { background: #322022; color: #f18a90; }
.rank.beta { background: #322a18; color: var(--warn); }
.rank.user { background: #1f2a36; color: var(--info); }

.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  padding: 0;
  height: auto;
  border-radius: 0;
}
.status-pill.active { color: var(--good); }
.status-pill.banned,
.status-pill.expired { color: var(--danger); }

.row-action {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
}
.row-action .material-symbols-outlined { font-size: 18px; }
.row-action:hover {
  color: var(--text);
  background: #1f1f1f;
}

.risk-events-table { min-width: 980px; }
.risk-events-table th,
.risk-events-table td {
  padding: 9px 12px;
  white-space: nowrap;
}
.risk-events-table td.risk-time,
.risk-events-table td.risk-detail {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.risk-events-table td.risk-detail {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.risk-app-pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #32261f;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}
.risk-level {
  display: inline-flex;
  min-width: 40px;
  justify-content: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.risk-level.critical,
.risk-level.high { color: var(--danger); background: #2a1719; }
.risk-level.medium { color: var(--warn); background: #2a2415; }
.risk-level.low { color: var(--good); background: #14241c; }
.risk-level.unknown { color: var(--muted); background: #1a1a1a; }

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 6px;
}
.empty-ico { font-size: 32px !important; color: #555; }
.empty-state strong { color: var(--text); font-size: 14px; }

.panel-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 18px;
}
.panel-card.narrow { max-width: 720px; }
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}
h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.revision {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--panel-2);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.quick-days {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.quick-days > span { color: var(--muted); font-size: 12px; }
.quick-days button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
}
.quick-days button.selected,
.quick-days button:hover {
  border-color: #4a342a;
  background: #2a1f1a;
  color: var(--accent);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.check-row input { width: auto; height: auto; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.segmented button {
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.segmented button.active {
  background: #222;
  color: #fff;
}

.identity-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.identity-card strong,
.identity-card small { display: block; }
.identity-card small {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
  font-family: var(--mono);
}

dialog {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0;
  width: min(92vw, 520px);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
}
dialog::backdrop { background: rgba(0,0,0,.65); }

.dialog-card { padding: 18px; gap: 12px; }
.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.dialog-actions.split {
  justify-content: space-between;
  align-items: center;
}
.dialog-actions.split > div { display: flex; gap: 8px; }

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(320px, calc(100vw - 24px));
  display: grid;
  gap: 8px;
  z-index: 50;
}
.toast {
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  font-size: 13px;
}
.toast.error {
  border-color: #5a2b2f;
  background: #2a1719;
  color: var(--danger);
}

.toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.audit-filters input,
.audit-filters select {
  min-width: 140px;
  height: 34px;
}
.audit-table-shell { overflow: auto; }
.audit-data-table th {
  background: #101010;
}
.audit-data-table .mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.audit-pill {
  display: inline-flex;
  height: 22px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #1f2a36;
  color: var(--info);
  font-size: 12px;
}
.audit-summary-cell {
  color: var(--muted);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audit-list { display: none; }

.mobile-nav { display: none; }
.mobile-only { display: none !important; }

.nect-kick-mask {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 40%, rgba(0, 0, 0, 0.62));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  animation: nect-kick-mask-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  color-scheme: inherit;
}
.nect-kick-mask.is-leaving { animation: nect-kick-mask-out 0.22s ease forwards; }
.nect-kick-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transform: translateY(18px) scale(0.96);
  opacity: 0;
  animation: nect-kick-card-in 0.38s cubic-bezier(0.16, 1, 0.3, 1) 0.04s forwards;
}
.nect-kick-mask.is-leaving .nect-kick-card { animation: nect-kick-card-out 0.2s ease forwards; }
.nect-kick-accent {
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--warn));
}
.nect-kick-body { padding: 22px 22px 10px; }
.nect-kick-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nect-kick-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
}
.nect-kick-lead {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.nect-kick-card button,
#nect-kick-ok {
  appearance: none;
  width: calc(100% - 44px);
  margin: 8px 22px 18px;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #141414;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.nect-kick-card button:hover,
#nect-kick-ok:hover {
  background: var(--accent-hover);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 32%, transparent);
}
.nect-kick-card button:active,
#nect-kick-ok:active { transform: translateY(1px); }

/* Optional light surface if Admin later flips color-scheme / data-theme */
html[data-theme="light"] .nect-kick-mask,
:root[data-theme="light"] .nect-kick-mask {
  background: color-mix(in srgb, #f4f4f5 45%, rgba(15, 23, 42, 0.35));
}
html[data-theme="light"] .nect-kick-card,
:root[data-theme="light"] .nect-kick-card {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .nect-kick-card h2,
:root[data-theme="light"] .nect-kick-card h2 { color: #111827; }
html[data-theme="light"] .nect-kick-lead,
:root[data-theme="light"] .nect-kick-lead { color: #6b7280; }
html[data-theme="light"] .nect-kick-card button,
html[data-theme="light"] #nect-kick-ok,
:root[data-theme="light"] .nect-kick-card button,
:root[data-theme="light"] #nect-kick-ok {
  color: #fff;
}
@keyframes nect-kick-mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nect-kick-mask-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes nect-kick-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes nect-kick-card-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(10px) scale(0.98); }
}

@media (max-width: 900px) {
  .chrome-links,
  .chrome-search { display: none; }
  .shell-body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { padding: 16px 14px 80px; }
  .field-grid { grid-template-columns: 1fr; }
  .mobile-only { display: grid !important; }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    inset: auto 0 0 0;
    height: 60px;
    border-top: 1px solid var(--line);
    background: #0d0d0d;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav.owner-mode { grid-template-columns: repeat(5, 1fr); }
  .mobile-nav .nav-item {
    flex-direction: column;
    gap: 2px;
    justify-content: center;
    font-size: 11px;
    border-radius: 0;
    padding: 8px 4px;
  }
  .mobile-nav .nav-item.active {
    background: transparent;
    box-shadow: inset 0 2px 0 var(--accent);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
