:root:not([data-theme]) {
  --bg: #f3f5f8;
  --paper: #fff;
  --ink: #243347;
  --muted: #5d6c80;
  --line: #dce3ec;
  --green: #24624d;
}

.kmk-layout[data-view="profile"] .page-head p:empty { display: none; }
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(12px, 2vw, 22px);
  max-width: 1160px;
  margin-inline: auto;
}
.profile-stack { display: grid; min-width: 0; gap: 14px; }
.profile-layout .card { min-width: 0; }
.profile-layout .card-body, .profile-layout .section-form { padding: 14px 16px; }
.profile-layout .section-description { margin: 0 0 12px; }
.profile-layout .actions { flex-wrap: wrap; }
.profile-layout .form-grid { gap: 12px; }
.profile-layout .form-error:empty { display: none; }
.profile-layout .form-error + .actions { margin-top: 14px; }
.profile-hero {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 14px; padding: 16px;
  border-bottom: 1px solid var(--kmk-line);
  background: linear-gradient(120deg, color-mix(in srgb, var(--kmk-accent-color) 14%, var(--kmk-surface)), var(--kmk-surface) 75%);
}
.profile-identity-details { display: grid; justify-items: start; gap: 4px; min-width: 0; }
.profile-identity-details h2 { overflow-wrap: anywhere; }
.profile-role { font: inherit; font-size: 13px; font-weight: 600; line-height: 18px; color: var(--kmk-link); overflow-wrap: anywhere; }
.profile-portrait {
  display: grid; position: relative; place-items: center;
  width: 72px; height: 72px; padding: 0;
  border: 1px solid var(--kmk-line); border-radius: 14px;
  color: var(--kmk-ink); background: var(--kmk-surface);
}
.profile-portrait .avatar { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; font-size: 23px; }
.profile-portrait-button { cursor: zoom-in; }
.profile-portrait-button > .svg-icon {
  position: absolute; inset: auto 4px 4px auto; width: 20px; height: 20px;
  padding: 3px; border-radius: 50%; background: #122134df; color: white;
  transition: transform 170ms ease;
}
.profile-portrait-button:hover > .svg-icon { transform: scale(1.14); }
.profile-photo-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 9px;
}
.profile-photo-strip:empty { display: none; }
.profile-thumb {
  position: relative;
  display: block; width: 100%; min-width: 0; aspect-ratio: 1; padding: 0;
  overflow: hidden; cursor: zoom-in; border-radius: 7px;
  border: 1px solid var(--kmk-line); background: var(--kmk-sunken);
  transition: border-color 150ms ease, transform 150ms ease;
}
.profile-thumb:hover { border-color: var(--kmk-link); transform: translateY(-2px); }
.profile-thumb:focus-visible, .profile-thumb.current { border-color: var(--kmk-link); }
.profile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-thumb > span {
  display: grid; place-items: center; position: absolute; inset: 3px 3px auto auto;
  width: 19px; height: 19px; border-radius: 50%; color: var(--kmk-accent-text);
  background: var(--kmk-accent);
}
.profile-thumb > span .svg-icon { width: 13px; height: 13px; }
.profile-photos [data-action="profile-photo-more"] { margin-top: 12px; }
#profile-photo-viewer {
  width: min(1120px, calc(100% - 24px)); max-height: calc(100dvh - 20px);
  margin: auto; padding: 0; border: 0; outline: 0; background: transparent;
  box-shadow: none; color: #f0f2f6;
}
#profile-photo-viewer::backdrop { background: #0b0d12ed; }
.profile-viewer-head, .profile-viewer-controls, .profile-zoom-controls, .profile-photo-navigation {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.profile-viewer-head, .profile-viewer-controls { padding: 6px 0; }
.profile-viewer-controls { display: grid; grid-template-columns: 1fr auto 1fr; }
.profile-photo-navigation { justify-content: start; }
.profile-viewer-head h2 { margin: 0; font-size: 16px; }
#profile-photo-position { font-size: 12px; color: #b9bfca; }
#profile-photo-viewer button {
  height: 34px; min-width: 34px; color: inherit; background: transparent; border: 0; box-shadow: none;
}
#profile-photo-viewer .icon-btn { font-size: 23px; }
#profile-photo-viewer button:hover:not(:disabled) { background: #ffffff24; }
#profile-photo-viewer button:focus-visible { outline: 2px solid #9cc6ff; outline-offset: 1px; }
#profile-photo-viewer button:disabled { opacity: .4; }
#profile-photo-viewer button[hidden] { display: none; }
#profile-photo-viewer :is([data-action="profile-photo-delete"], [data-action="profile-photo-crop-current"]) { justify-self: end; }
#profile-photo-viewer [data-action="profile-photo-delete"] { color: #ffaeaa; }
.profile-photo-stage {
  height: min(78dvh, 820px, calc(100dvh - 120px)); outline: 0; overflow: auto;
  scrollbar-width: none; overscroll-behavior: contain; touch-action: none; cursor: grab;
}
.profile-photo-stage:active { cursor: grabbing; }
.profile-photo-surface { display: grid; place-items: center; width: max-content; min-width: 100%; min-height: 100%; }
.profile-photo-stage img {
  display: block; max-width: none; height: auto; user-select: none;
}
#profile-photo-crop {
  width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  color: var(--kmk-ink); background: var(--kmk-surface); border: 1px solid var(--kmk-line);
  border-radius: 12px; padding: 0;
}
.profile-crop-body { display: grid; justify-items: center; gap: 12px; padding: 16px; }
.profile-crop-body canvas { width: min(100%, 360px, 52dvh); height: auto; cursor: grab; touch-action: none; }
.profile-crop-body canvas:active { cursor: grabbing; }
.profile-crop-body label { display: flex; gap: 12px; width: 100%; align-items: center; }
.profile-crop-body input[type="range"] { width: 100%; padding: 0; accent-color: var(--kmk-accent); }
.profile-crop-body p { margin: 0; text-align: center; }
.profile-crop-controls { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--kmk-line); }
@keyframes profile-appear {
  from { opacity: .65; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  .profile-layout > .profile-stack { animation: profile-appear 190ms ease both; }
  .profile-layout > .profile-stack + .profile-stack { animation-delay: 45ms; }
  #profile-photo-viewer[open] { animation: profile-appear 170ms ease; }
}
@media (prefers-reduced-motion: reduce) {
  .profile-thumb, .profile-portrait-button > .svg-icon { transition: none; }
  .profile-thumb:hover, .profile-portrait-button:hover > .svg-icon { transform: none; }
}
@media (max-width: 780px) {
  .profile-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 450px) {
  .profile-hero { grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
  .profile-upload-trigger { grid-column: 2; justify-self: start; }
}

.kmk-layout.layout {
  display: grid;
  grid-template-columns: var(--kmk-sections-offset) minmax(0, 1fr);
  transition: grid-template-columns var(--kmk-nav-transition);
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.kmk-admin-bar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 28;
  justify-content: space-between;
  gap: 12px;
}
.kmk-bar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  min-width: 0;
}
.kmk-identity .avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--kmk-selected);
  color: var(--kmk-ink);
  box-shadow: none;
  font-size: 10px;
  font-weight: 650;
}
.kmk-identity { padding: 0 3px; text-decoration: none; }

.kmk-layout .kmk-admin-main {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  padding: 0 clamp(16px, 2.3vw, 40px) 36px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.kmk-layout:has(~ .session-control) .kmk-admin-main { padding-bottom: 145px; }
.kmk-admin-main #content { padding-top: 22px; }
.kmk-admin-main :is(.page-head, .nc-heading) {
  gap: 12px;
  flex-wrap: wrap;
  margin-block: 0 16px;
  padding: 0 0 11px;
  border-bottom: 1px solid var(--kmk-line);
}
.kmk-admin-main :is(.page-head, .nc-heading) h1 {
  font-size: 24px;
  letter-spacing: -.32px;
  font-weight: 680;
}
.kmk-admin-main .page-head p { margin-top: 4px; font-size: 13px; }
.kmk-admin-main :is(.card, .appearance-card, .device-tile, .note, .rule-result, .nc-card) {
  border-radius: 8px;
  box-shadow: none;
}
.kmk-admin-main :is(.card-header, .card-body, .section-form, .appearance-card, .settings-integration) { padding: 16px; }
.kmk-admin-main .card-header h2 { font-size: 16px; }
.kmk-admin-main .card-footer { background: var(--kmk-bg); padding: 9px 14px; }
.kmk-admin-main .toolbar { padding: 10px 12px; gap: 8px; }
.kmk-admin-main .search {
  min-height: 32px;
  border: 1px solid var(--kmk-line);
  border-radius: 6px;
  background: var(--kmk-bg);
}
.kmk-admin-main .search input { min-width: 0; }
.kmk-admin-main .tabs {
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--kmk-line);
  border-radius: 6px;
  background: var(--kmk-bg);
}
.kmk-admin-main .tabs button {
  min-height: 27px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  box-shadow: none;
}
.kmk-admin-main .tabs button:hover { background: var(--kmk-hover); }
.kmk-admin-main .tabs button.active {
  color: var(--kmk-link);
  background: var(--kmk-selected);
  border-color: color-mix(in srgb, var(--kmk-accent-color) 45%, var(--kmk-line));
}
.kmk-admin-main :is(.table-wrap, .nc-table-wrap, .settings-audit, .nt-panel),
#modal,
.kmk-theme-popover {
  scrollbar-width: thin;
  scrollbar-color: var(--kmk-scroll) transparent;
}
.kmk-admin-main .table-wrap {
  max-height: min(70vh, 58rem);
  overscroll-behavior: contain;
}
.kmk-admin-main :is(.table-wrap th, .nc-table th) {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--kmk-bg);
  color: var(--kmk-muted);
  padding: 9px 12px;
  letter-spacing: .02em;
  line-height: 1.25;
  font-size: 11px;
  white-space: nowrap;
}
.kmk-admin-main :is(.table-wrap td, .nc-table td) {
  padding: 8px 12px;
  line-height: 1.4;
  font-size: 13px;
  border-color: var(--kmk-line);
}
.kmk-admin-main :is(.table-wrap, .nc-table) tbody tr:hover { background: var(--kmk-hover); }
.kmk-admin-main .list-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--kmk-link);
  background: var(--kmk-selected);
}
.kmk-admin-main .overview-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr));
  gap: 12px;
}
.kmk-admin-main .overview-metrics .metric {
  display: block;
  padding: 14px 16px;
  color: var(--kmk-ink);
  text-decoration: none;
}
.kmk-admin-main .overview-metrics .metric:hover {
  border-color: color-mix(in srgb, var(--kmk-accent-color) 60%, var(--kmk-line));
  background: var(--kmk-hover);
}
.kmk-admin-main .metric-top { align-items: center; gap: 8px; }
.kmk-admin-main .metric-top .kmk-chrome-icon { color: var(--kmk-link); }
.kmk-admin-main .metric-number { font-size: 27px; margin-top: 8px; letter-spacing: -.6px; }
.kmk-admin-main .metric-bottom { margin-top: 5px; }
.kmk-admin-main .note { padding: 10px 12px; }
.kmk-admin-main .nc-root { font-size: 13px; }

:root[data-tone="light"] .kmk-admin-main .nt-root[data-theme="light"],
:root[data-tone="dark"] .kmk-admin-main .nt-root[data-theme="dark"] {
  --nt-bg: var(--kmk-bg);
  --nt-paper: var(--kmk-surface);
  --nt-ink: var(--kmk-ink);
  --nt-muted: var(--kmk-muted);
  --nt-line: var(--kmk-line);
  --nt-accent: var(--kmk-link);
  --nt-field: var(--kmk-surface);
}
.kmk-admin-main .nt-root {
  border-radius: 8px;
  box-shadow: none;
}
.kmk-admin-main .nt-header { padding: 12px 14px; }
.kmk-admin-main .nt-header h2 { font-size: 16px; }

:is(.kmk-admin-main, #modal, .auth-card) :is(.btn, .icon-btn, .nt-button) {
  min-height: 32px;
  border-radius: 6px;
  box-shadow: none;
}
:is(.kmk-admin-main, #modal) .btn { padding: 5px 10px; font-size: 13px; }
:is(.kmk-admin-main, #modal) .icon-btn { width: 32px; height: 32px; }
:is(.kmk-admin-main, #modal) :is(.svg-icon, .nt-icon) { width: 16px; height: 16px; }
:is(.kmk-admin-main, #modal) :is(.field input, .field select, .field textarea, .nc-root select, .appearance-field select, .appearance-theme-control select) {
  padding: 7px 9px;
  border-radius: 6px;
  min-height: 32px;
  height: auto;
}
:is(.kmk-admin-main, #modal, .auth-card) :focus-visible {
  outline-color: var(--kmk-link);
}
#modal {
  background: var(--kmk-raised);
  border-radius: 10px;
  box-shadow: 0 12px 32px #0c111744;
}
#modal::backdrop { background: #0c111777; backdrop-filter: none; }
#modal .modal-head,
#modal .modal-foot {
  padding: 10px 16px;
  background: var(--kmk-raised);
}
#modal .modal-body { padding: 16px; }
#modal .modal-head h2 { font-size: 17px; }

.kmk-layout[data-view="settings"] [popovertarget="kmk-admin-themes"] { display: none; }
.kmk-theme-popover {
  position: fixed;
  inset: calc(var(--kmk-bar-height) + 5px) 12px auto auto;
  width: min(235px, calc(100vw - 24px));
  max-height: calc(100dvh - 65px);
  margin: 0;
  padding: 7px;
  overflow: auto;
  border: 1px solid var(--kmk-line);
  border-radius: 8px;
  background: var(--kmk-raised);
  color: var(--kmk-ink);
  box-shadow: 0 10px 28px #0c111736;
}
.kmk-theme-popover fieldset { margin: 0; padding: 0; border: 0; }
.kmk-theme-popover legend { padding: 4px 6px; font-weight: 650; }
.kmk-theme-popover label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  border-radius: 5px;
  padding: 4px 7px;
  cursor: pointer;
}
.kmk-theme-popover label:hover { background: var(--kmk-hover); }
.kmk-theme-popover input { accent-color: var(--kmk-accent-color); margin: 0; }
.kmk-theme-popover label:has(:checked) { background: var(--kmk-selected); }

.auth-page { background: var(--kmk-bg); }
.auth-card {
  border-radius: 10px;
  padding: clamp(20px, 4vw, 30px);
  box-shadow: 0 10px 32px #0c111710;
}
.auth-card h1 { font-size: 24px; }
.auth-brand .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--kmk-selected);
  color: var(--kmk-link);
  font-size: 17px;
}

@media (max-width: 1024px) {
  .kmk-layout .kmk-admin-main { padding-inline: 16px; }
  .kmk-admin-main #content { padding-top: 15px; }
  .kmk-admin-main :is(.page-head, .nc-heading) h1 { font-size: 21px; }
  .kmk-admin-main :is(.table-wrap, .nc-table-wrap) { max-height: 68vh; }
}

.kmk-field-label,
.kmk-action-with-help {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kmk-field-label > label { margin: 0; }
.kmk-help { display: inline-flex; flex: none; }
.kmk-help-trigger {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--kmk-muted);
}
.kmk-help-trigger:is(:hover, :focus-visible) {
  background: var(--kmk-hover);
  color: var(--kmk-link);
}
.kmk-help-tooltip {
  position: absolute;
  z-index: 4;
  inset-inline-start: 0;
  bottom: calc(100% + 4px);
  width: min(254px, calc(100vw - 64px));
  padding: 8px 11px;
  border: 1px solid var(--kmk-line);
  border-radius: 10px;
  background: var(--kmk-raised);
  color: var(--kmk-ink);
  box-shadow: 0 6px 16px #0c111742;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  visibility: hidden;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 130ms ease, transform 130ms ease, visibility 130ms;
}
.kmk-help-tooltip::after {
  content: '';
  position: absolute;
  inset: 100% 0 auto;
  height: 6px;
}
.kmk-help:is(:hover, :focus-within) > .kmk-help-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}
#modal:has(.recovery-controls) {
  width: min(435px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid var(--kmk-line);
  border-radius: 18px;
  box-shadow: 0 18px 56px #0c111764;
}
#modal[open]:has(.recovery-controls) {
  animation: recovery-entrance 170ms ease-out both;
}
@keyframes recovery-entrance {
  from { opacity: 0; transform: translateY(5px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#modal .recovery-controls .modal-head {
  justify-content: start;
  gap: 10px;
  padding: 13px 16px;
}
.recovery-controls .modal-head .icon-btn {
  margin-inline-start: auto;
  border-radius: 50%;
}
.recovery-symbol {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: var(--kmk-selected);
  color: var(--kmk-link);
}
#modal .recovery-controls .modal-body { padding: 13px 16px 15px; }
.recovery-intro {
  margin: 0 0 10px;
  color: var(--kmk-muted);
  font-size: 13px;
  line-height: 1.45;
}
.recovery-intro code { color: var(--kmk-ink); }
.recovery-fields { display: grid; gap: 8px; }
#modal .recovery-fields .field { margin: 0; gap: 3px; }
#modal .recovery-fields input { min-height: 34px; border-radius: 9px; }
.recovery-guide {
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid var(--kmk-line);
  border-radius: 10px;
  font-size: 12px;
}
.recovery-guide summary { color: var(--kmk-link); cursor: pointer; }
.recovery-guide p { margin-top: 6px; color: var(--kmk-muted); line-height: 1.45; }
.recovery-controls .form-error:empty { display: none; }
.recovery-controls .form-error { margin-top: 8px; }
#modal .recovery-controls .modal-foot { gap: 6px; padding: 10px 16px; }
#modal .recovery-controls .modal-foot .btn { border-radius: 9px; }
@media (prefers-reduced-motion: reduce) {
  #modal[open]:has(.recovery-controls) { animation: none; }
  .kmk-help-tooltip { transition: none; }
}


.kmk-layout span.avatar[data-person-color] {
  background: hsl(var(--source-hue) 58% 30%);
  color: #fff;
}
.kmk-layout img.avatar[data-person-color] {
  border: 1px solid hsl(var(--source-hue) 56% 51%);
}
