:root {
  color: #17221b;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  --background: #f3f5f2;
  --border: #dce3dd;
  --coral: #b85f3d;
  --coral-soft: #f4e3dc;
  --green: #1d6f55;
  --green-dark: #155640;
  --green-soft: #dcece5;
  --ink: #17221b;
  --muted: #637068;
  --surface: #ffffff;
  --surface-muted: #e9eee9;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--background);
  color: var(--ink);
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgb(23 34 27 / 8%);
  display: grid;
  gap: 32px;
  padding: 40px;
  width: min(100%, 440px);
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-lockup > span:last-child {
  display: grid;
  gap: 2px;
}

.brand-lockup strong {
  font-size: 13px;
}

.brand-lockup small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 4px;
  color: #fff;
  display: inline-flex;
  font-size: 17px;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.brand-lockup.compact .brand-mark {
  height: 32px;
  width: 32px;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  margin: 0 0 8px;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.18;
  margin: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  margin: 0;
}

h3 {
  font-size: 13px;
  margin: 0;
}

form {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  background: var(--surface);
  border: 1px solid #cbd5cd;
  border-radius: 4px;
  min-height: 42px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgb(29 111 85 / 15%);
  outline: none;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  align-items: center;
  border-radius: 4px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
}

.primary-button {
  background: var(--green);
  border: 1px solid var(--green);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: var(--surface);
  border: 1px solid #cbd5cd;
}

.secondary-button:hover {
  background: var(--surface-muted);
}

.danger-button {
  background: var(--surface);
  border: 1px solid #d8b2a4;
  color: #984a30;
}

.danger-button:hover {
  background: var(--coral-soft);
}

.text-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.text-button:hover {
  color: var(--ink);
}

.form-error {
  color: #a43c3c;
  font-size: 12px;
  min-height: 18px;
  margin: 0;
}

.environment-note {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  margin: 0;
  padding-top: 18px;
}

.app {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.connection-status {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  gap: 7px;
}

.connection-status::before {
  background: #2b8a63;
  border-radius: 50%;
  content: "";
  height: 7px;
  width: 7px;
}

.connection-status.error::before {
  background: var(--coral);
}

.admin-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: #eef2ee;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 64px);
  padding: 24px 16px;
}

.sidebar-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
  padding: 0 8px 24px;
}

.sidebar-heading > span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sidebar-heading strong {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-heading small {
  color: var(--muted);
  font-size: 10px;
}

.avatar {
  align-items: center;
  background: var(--green-soft);
  border-radius: 50%;
  color: var(--green-dark);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
}

.nav-button:hover {
  background: rgb(255 255 255 / 70%);
  color: var(--ink);
}

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

.sync-status {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 18px 8px 0;
}

.sync-status span,
.sync-status small {
  color: var(--muted);
  font-size: 10px;
}

.sync-status strong {
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 32px;
  position: relative;
}

.page-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 24px;
  max-width: 1280px;
}

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

.source-badge {
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  min-height: 28px;
  padding: 7px 10px;
}

.metrics {
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 auto 24px;
  max-width: 1280px;
}

.metric {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 18px 20px;
}

.metric + .metric {
  border-left: 1px solid var(--border);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

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

.workbench {
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(430px, 1.15fr) minmax(350px, 0.85fr);
  margin: 0 auto;
  max-width: 1280px;
  min-height: 560px;
}

.owner-directory {
  min-width: 0;
}

.directory-toolbar {
  align-items: end;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) 140px;
  padding: 16px;
}

.search-field,
.filter-field {
  display: grid;
  gap: 6px;
}

.directory-header,
.owner-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(170px, 1.4fr) minmax(74px, 0.55fr) minmax(92px, 0.7fr);
}

.directory-header {
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  padding: 11px 16px;
}

.owner-list {
  max-height: 480px;
  overflow: auto;
}

.owner-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #edf0ed;
  min-height: 70px;
  padding: 12px 16px;
  text-align: left;
  width: 100%;
}

.owner-row:hover {
  background: #f7f9f7;
}

.owner-row.selected {
  background: var(--green-soft);
  box-shadow: inset 3px 0 0 var(--green);
}

.owner-identity {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.owner-identity strong,
.owner-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-identity strong {
  font-size: 13px;
}

.owner-identity small {
  color: var(--muted);
  font-size: 11px;
}

.table-value {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  align-items: center;
  background: var(--green-soft);
  border-radius: 999px;
  color: var(--green-dark);
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  width: fit-content;
}

.status-pill.inactive {
  background: var(--surface-muted);
  color: var(--muted);
}

.owner-detail {
  border-left: 1px solid var(--border);
  min-width: 0;
  padding: 24px;
}

.detail-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  height: 100%;
  justify-content: center;
  min-height: 320px;
}

.detail-content {
  display: grid;
  gap: 24px;
}

.detail-header {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.detail-header div {
  min-width: 0;
}

.detail-header h2,
.detail-header p {
  overflow-wrap: anywhere;
}

.owner-source {
  color: var(--green);
  display: block;
  font-size: 10px;
  font-weight: 750;
  margin-top: 7px;
}

.detail-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 0;
}

.detail-section {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 14px;
  padding-top: 20px;
}

.detail-section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.detail-section-heading span {
  color: var(--muted);
  font-size: 11px;
}

.access-switch {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: 13px;
  gap: 12px;
  justify-content: space-between;
}

.switch {
  display: inline-flex;
  position: relative;
}

.switch input {
  height: 1px;
  min-height: 0;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch-track {
  background: #b8c2ba;
  border-radius: 999px;
  display: inline-block;
  height: 24px;
  position: relative;
  transition: background 150ms ease;
  width: 42px;
}

.switch-track::after {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(23 34 27 / 22%);
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 150ms ease;
  width: 18px;
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgb(29 111 85 / 16%);
}

.property-checks {
  border: 1px solid var(--border);
  max-height: 220px;
  overflow: auto;
}

.property-option {
  align-items: center;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 18px minmax(0, 1fr);
  padding: 11px 12px;
}

.property-option + .property-option {
  border-top: 1px solid #edf0ed;
}

.property-option:hover {
  background: #f7f9f7;
}

.property-option input {
  accent-color: var(--green);
  height: 16px;
  min-height: 0;
  padding: 0;
  width: 16px;
}

.property-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.property-name strong {
  font-size: 12px;
}

.property-name small {
  color: var(--muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

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

.session-stat {
  background: var(--background);
  display: grid;
  gap: 5px;
  padding: 12px;
}

.session-stat span {
  color: var(--muted);
  font-size: 10px;
}

.session-stat strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.audit-list {
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0 auto;
  max-width: 1280px;
}

.audit-row {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 150px minmax(160px, 0.8fr) minmax(240px, 1.4fr);
  padding: 15px 18px;
}

.audit-row + .audit-row {
  border-top: 1px solid #edf0ed;
}

.audit-time,
.audit-detail {
  color: var(--muted);
  font-size: 11px;
}

.audit-event {
  display: grid;
  gap: 4px;
}

.audit-event strong {
  font-size: 12px;
}

.audit-event small {
  color: var(--muted);
  font-size: 10px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  padding: 32px 18px;
  text-align: center;
}

.toast {
  background: var(--ink);
  border-radius: 4px;
  bottom: 24px;
  color: #fff;
  font-size: 12px;
  left: 50%;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 10;
}

.toast.error {
  background: #8e3e31;
}

.credential-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  max-width: min(460px, calc(100vw - 32px));
  padding: 0;
  width: 100%;
}

.credential-dialog::backdrop {
  background: rgb(23 34 27 / 48%);
}

.credential-dialog form {
  gap: 18px;
  padding: 28px;
}

.dialog-owner,
.dialog-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.credential-value {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.credential-value input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(160px, 1fr) auto;
    min-height: 0;
    padding: 14px 20px;
  }

  .sidebar-heading,
  .sync-status {
    display: none;
  }

  .nav-list {
    display: flex;
  }

  .nav-button {
    min-width: 110px;
    text-align: center;
  }

  .content {
    padding: 24px 20px;
  }

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

  .owner-detail {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .connection-status {
    display: none;
  }

  .content {
    padding: 22px 14px;
  }

  .page-heading {
    align-items: flex-start;
    gap: 16px;
  }

  h1 {
    font-size: 24px;
  }

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

  .page-actions {
    display: grid;
    flex: 0 0 auto;
  }

  .source-badge {
    justify-content: center;
  }

  .metric + .metric {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .directory-toolbar {
    grid-template-columns: 1fr;
  }

  .directory-header {
    display: none;
  }

  .owner-row {
    gap: 7px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .owner-row .table-value {
    display: none;
  }

  .owner-list {
    max-height: 360px;
  }

  .owner-detail {
    padding: 20px 16px;
  }

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

  .detail-actions {
    display: grid;
  }

  .detail-actions button {
    width: 100%;
  }

  .audit-row {
    gap: 7px;
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 28px 22px;
  }

  .credential-value {
    grid-template-columns: 1fr;
  }
}
