:root {
  color-scheme: light;
  --page: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --hairline: rgba(0, 0, 0, 0.1);
  --blue: #0071e3;
  --blue-soft: #e8f1ff;
  --green: #2e7d32;
  --red: #b3261e;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, #f5f5f7 34%, #eceff3 100%);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.boot {
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

.boot-mark {
  font-size: 44px;
  font-weight: 700;
  color: var(--ink);
}

.shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 0 14px;
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 58px);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0;
}

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

.actor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.pill,
.metric,
.status-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 6px 11px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.actor-select,
.field,
.filter {
  height: 38px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.actor-select:focus,
.field:focus,
.filter:focus {
  border-color: rgba(0, 113, 227, 0.58);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.language-button {
  display: inline-flex;
  height: 32px;
  min-width: 38px;
  order: 99;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.language-button:focus {
  outline: none;
  border-color: rgba(0, 113, 227, 0.58);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}

.metric {
  justify-content: space-between;
  border-radius: var(--radius);
  padding: 16px;
}

.metric strong {
  color: var(--ink);
  font-size: 28px;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.nav-button {
  display: inline-grid;
  min-width: min(260px, 100%);
  gap: 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  padding: 12px 14px;
  text-align: left;
}

.nav-button strong {
  font-size: 14px;
}

.nav-button span {
  color: var(--muted);
  font-size: 12px;
}

.page-shell {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-panel {
  padding-top: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.panel-header,
.vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
}

.panel-header h2,
.vault-header h2,
.detail-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 650;
}

.panel-header p,
.detail-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.filter-bar {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 18px 12px;
}

.filter-bar .filter {
  height: 32px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
}

.search-filter {
  flex: 1 1 190px;
  min-width: 170px;
}

.compact-filter {
  flex: 0 1 150px;
  max-width: 180px;
}

.employee-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.employee-table th,
.employee-table td {
  border-top: 1px solid var(--hairline);
  padding: 12px 18px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  overflow-wrap: break-word;
}

.employee-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

.employee-row {
  transition: background 160ms ease, transform 160ms ease;
}

.employee-row:hover,
.employee-row.selected {
  background: rgba(0, 113, 227, 0.06);
}

.name-block {
  display: grid;
  gap: 2px;
}

.employee-name-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.name-block strong {
  font-weight: 650;
}

.name-block span {
  color: var(--muted);
  font-size: 12px;
}

.tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: #f0f0f2;
  padding: 4px 9px;
  color: #353536;
  font-size: 12px;
}

.tag.blue {
  background: var(--blue-soft);
  color: #0057ad;
}

.tag.green {
  background: #e8f4ea;
  color: var(--green);
}

.tag.red {
  background: #fcebea;
  color: var(--red);
}

.detail-panel {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.detail-card,
.vault-panel {
  padding: 18px;
}

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

.avatar {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #1d1d1f;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.mini-avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.image-avatar {
  display: block;
  object-fit: cover;
  background: #f0f0f2;
}

.detail-main {
  display: flex;
  min-width: 0;
  gap: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.kv strong {
  color: var(--ink);
  font-weight: 500;
}

.section-line {
  height: 1px;
  margin: 18px 0;
  background: var(--hairline);
}

.employee-edit-form {
  display: grid;
  gap: 12px;
}

.edit-head h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 650;
}

.edit-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.edit-grid .full {
  grid-column: 1 / -1;
}

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

.access-grid {
  display: grid;
  gap: 10px;
}

.access-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.66);
  padding: 12px;
}

.access-row strong {
  display: block;
  font-size: 14px;
}

.access-row span {
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn,
.icon-btn {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: #1d1d1f;
  color: #fff;
  padding: 0 14px;
  font-weight: 600;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.icon-btn {
  width: 36px;
  padding: 0;
  font-size: 20px;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn.secondary,
.icon-btn.secondary {
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.btn.blue {
  background: var(--blue);
}

.btn.danger {
  background: var(--red);
}

.btn:disabled,
.icon-btn:disabled {
  cursor: default;
  opacity: 0.38;
  transform: none;
}

.btn.is-loading {
  opacity: 0.7;
}

.vault-controls,
.password-form {
  display: grid;
  gap: 10px;
}

.vault-controls {
  grid-template-columns: 1fr auto;
}

.password-form {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}

.password-form .field.full,
.employee-edit-form .field.full {
  grid-column: 1 / -1;
}

.field.multi {
  height: auto;
  min-height: 76px;
  padding: 8px 10px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.grant-store-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.42fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  padding: 10px;
}

.grant-store-row strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.grant-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  color: var(--ink);
  font-size: 12px;
}

.check-chip input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.vault-results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.secret-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-radius: var(--radius);
  background: #111;
  padding: 12px;
  color: #fff;
}

.secret-row span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.secret {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
}

.empty {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 16px 0 0;
}

.sync-block {
  padding: 0 18px 18px;
}

.sync-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sync-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.sync-head p,
.sync-date {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.mapping-panel {
  margin-top: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
  padding: 14px;
}

.mapping-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mapping-head h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
}

.mapping-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.mapping-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mapping-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 0.85fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--hairline);
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.mapping-department {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.mapping-department strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.mapping-department span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.mapping-department code {
  overflow-wrap: anywhere;
  color: #86868b;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
}

.sync-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.sync-summary span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.66);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.sync-summary strong {
  color: var(--ink);
  font-size: 20px;
}

.sync-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sync-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(160px, 0.8fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
}

.sync-row strong {
  display: block;
  font-size: 13px;
}

.sync-row span {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100% - 44px));
  border-radius: var(--radius);
  background: #1d1d1f;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(245, 245, 247, 0.34);
  backdrop-filter: blur(8px);
}

.busy-card {
  display: inline-flex;
  min-width: 120px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid rgba(0, 113, 227, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .detail-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1500px);
    padding-top: 10px;
  }

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

  .brand {
    display: grid;
    gap: 4px;
  }

  .actor-bar {
    justify-content: flex-start;
  }

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

  .actor-select {
    width: 100%;
  }

  .home-actions,
  .page-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-button {
    width: 100%;
  }

  .metrics,
  .sync-summary,
  .sync-row,
  .mapping-head,
  .mapping-row,
  .grant-store-row,
  .edit-grid,
  .password-form,
  .vault-controls {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 14px;
    scrollbar-width: none;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .search-filter {
    flex: 0 0 180px;
  }

  .compact-filter {
    flex: 0 0 150px;
    max-width: 150px;
  }

  .employee-table th:nth-child(3),
  .employee-table td:nth-child(3),
  .employee-table th:nth-child(4),
  .employee-table td:nth-child(4) {
    display: none;
  }

  .employee-table th,
  .employee-table td {
    padding: 10px 8px;
  }

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

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

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

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