/* Admin dedicated page */
body { padding: 0 }
.admin-wrap { max-width: 1240px; margin: 0 auto; padding: 16px 16px 80px }
.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04); flex-wrap: wrap; gap: 10px;
}
.admin-top-left { display: flex; align-items: center; gap: 16px }
.admin-top-left h1 { font-size: 1.05em; font-weight: 700; color: #0f172a; margin: 0; letter-spacing: -0.01em }
.admin-top-left h1 .subtitle { font-weight: 400; color: #64748b; font-size: .76em; margin-left: 8px; text-align: left }
.back-link {
  display: inline-flex; align-items: center; gap: 5px; color: #64748b; text-decoration: none;
  padding: 6px 10px; border-radius: 6px; font-size: .82em; font-weight: 500; border: 1px solid transparent;
}
.back-link:hover { background: #f0fdfa; color: #0f766e; border-color: #e2e8f0 }
.back-link svg { width: 14px; height: 14px }
.admin-top-right { display: flex; align-items: center; gap: 8px; font-size: .85em }
.admin-user-label { color: #64748b }
.btn-logout {
  padding: 5px 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff;
  font-size: .82em; cursor: pointer; font-family: inherit; color: #1e293b;
}
.btn-logout:hover { border-color: #dc2626; color: #dc2626 }
.btn-primary {
  display: inline-block; padding: 8px 18px; background: #0f766e; color: #fff; border-radius: 6px;
  text-decoration: none; font-weight: 500; font-size: .9em;
}
.btn-primary:hover { background: #115e59 }

.admin-auth-error {
  background: #fff; border: 1px solid #fca5a5; border-radius: 10px; padding: 30px; text-align: center;
  color: #991b1b;
}
.admin-auth-error h2 { font-size: 1.1em; margin-bottom: 8px }
.admin-auth-error p { margin-bottom: 16px; color: #7f1d1d }

.admin-nav {
  display: flex; gap: 2px; padding: 6px; background: #f1f5f9; border-radius: 10px; margin-bottom: 14px;
  border: 1px solid #e2e8f0;
}
.admin-tab {
  flex: 1; padding: 10px 16px; background: transparent; border: none; border-radius: 6px;
  font-size: .9em; font-weight: 500; color: #64748b; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: all 150ms ease;
}
.admin-tab:hover { color: #0f766e }
.admin-tab.active { background: #fff; color: #0f766e; box-shadow: 0 1px 3px rgba(15,23,42,0.08) }
.admin-tab svg { width: 16px; height: 16px }
.tab-count {
  background: #e2e8f0; color: #475569; padding: 1px 8px; border-radius: 10px; font-size: .82em; font-weight: 600;
}
.admin-tab.active .tab-count { background: #dcfce7; color: #15803d }

.admin-main {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; min-height: 200px;
}
.admin-loading { color: #94a3b8; text-align: center; padding: 40px; font-size: .92em }

/* Users tab - reuse drawer styles but larger */
.admin-main .user-card {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 16px;
  margin-bottom: 10px; cursor: pointer; transition: all .15s;
}
.admin-main .user-card:hover { border-color: #0f766e; background: #f0fdfa }
.admin-main .user-card.expanded { background: #f0fdfa; border-color: #115e59 }
.admin-main .uc-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px }
.admin-main .uc-name { font-weight: 600; color: #1e293b; flex: 1; font-size: .95em }
.admin-main .uc-email { color: #64748b; font-size: .82em; margin-bottom: 8px }
.admin-main .uc-stats { display: flex; gap: 10px; font-size: .8em; color: #475569; flex-wrap: wrap }
.admin-main .uc-stat { background: #fff; padding: 3px 10px; border-radius: 12px; border: 1px solid #e2e8f0 }
.admin-main .uc-stat strong { color: #0f766e }
.admin-main .user-detail { margin-top: 12px; border-top: 1px solid #cbd5e1; padding-top: 12px; display: none }
.admin-main .user-card.expanded .user-detail { display: block }
.admin-main .dt-title { font-size: .75em; color: #64748b; font-weight: 600; text-transform: uppercase; margin: 10px 0 6px; letter-spacing: .03em }
.admin-main .dt-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; font-size: .85em }
.admin-main .dt-item .dt-path { color: #115e59; font-size: .78em; margin-bottom: 3px; word-break: break-word }
.admin-main .dt-item .dt-text { color: #1e293b; white-space: pre-wrap; word-break: break-word; line-height: 1.4 }
.admin-main .dt-item .dt-time { color: #94a3b8; font-size: .74em; margin-top: 3px }
.admin-main .dt-item .dt-status { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: .72em; font-weight: 600; margin-right: 6px }
.admin-main .dt-status.keep { background: #dcfce7; color: #15803d }
.admin-main .dt-status.edit { background: #fef3c7; color: #b45309 }
.admin-main .dt-status.remove { background: #fee2e2; color: #b91c1c }
.admin-main .dt-status.other_dept { background: #e0e7ff; color: #4338ca }
.admin-main .dt-status.deleted { background: #f1f5f9; color: #64748b }
.admin-main .empty { color: #94a3b8; font-size: .9em; text-align: center; padding: 30px; font-style: italic }

/* Orphans — full page table */
.orphan-table { display: flex; flex-direction: column; gap: 8px }
.orphan-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: start;
  padding: 12px 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
}
.or-main { min-width: 0 }
.or-file-line {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.or-file { font-weight: 600; color: #0f172a; font-size: .92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 }
.or-reason {
  font-size: .7em; padding: 2px 9px; border-radius: 10px; font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.or-reason-file_deleted { background: #fee2e2; color: #b91c1c }
.or-reason-section_removed { background: #fef3c7; color: #b45309 }
.or-reason-fuzzy_no_match { background: #e0e7ff; color: #4338ca }
.or-text { font-size: .85em; color: #475569; margin: 4px 0; max-height: 48px; overflow: hidden; line-height: 1.4 }
.or-meta { font-size: .78em; color: #64748b; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px }
.or-meta strong { color: #1e293b }
.or-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 130px }
.or-btn {
  padding: 6px 12px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff;
  cursor: pointer; font-size: .82em; font-family: inherit; color: #1e293b; transition: all .15s; white-space: nowrap;
}
.or-btn:hover { border-color: #0f766e; color: #0f766e }
.or-btn.btn-primary { background: #0f766e; color: #fff; border-color: #0f766e; padding: 6px 12px }
.or-btn.btn-primary:hover { background: #115e59 }
.or-btn.btn-danger { color: #dc2626; border-color: #fca5a5 }
.or-btn.btn-danger:hover { background: #fee2e2; border-color: #dc2626 }
.or-migrate-panel {
  grid-column: 1 / -1; margin-top: 8px; padding-top: 10px; border-top: 1px dashed #cbd5e1;
  display: none; gap: 8px; align-items: center; flex-wrap: wrap;
}
.or-migrate-panel.open { display: flex }
.or-select {
  flex: 1; min-width: 240px; padding: 7px 10px; border-radius: 6px; border: 1px solid #cbd5e1;
  font-family: inherit; font-size: .85em; background: #fff;
}

@media (max-width: 768px) {
  .admin-wrap { padding: 12px 10px 60px }
  .admin-top { padding: 8px 10px }
  .admin-top-left h1 { font-size: .95em }
  .admin-top-left h1 .subtitle { display: none }
  .admin-tab { padding: 8px 10px; font-size: .82em }
  .admin-tab svg { width: 14px; height: 14px }
  .orphan-row { grid-template-columns: 1fr }
  .or-actions { flex-direction: row; min-width: 0 }
  .or-actions .or-btn { flex: 1 }
}

/* Orphan groups */
.orphan-group { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 10px; overflow: hidden }
.og-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9); border-bottom: 1px solid #e2e8f0;
  transition: background .15s;
}
.og-header:hover { background: linear-gradient(180deg, #f0fdfa, #e0f7f4) }
.og-chev { width: 14px; height: 14px; color: #64748b; transition: transform .2s; flex-shrink: 0 }
.orphan-group:not(.collapsed) .og-chev { transform: rotate(90deg) }
.og-file { font-weight: 600; color: #0f172a; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92em }
.og-count {
  background: #e2e8f0; color: #475569; padding: 2px 10px; border-radius: 12px;
  font-size: .78em; font-weight: 600; white-space: nowrap;
}
.og-bulk { white-space: nowrap }
.og-body { padding: 10px }
.orphan-group.collapsed .og-body { display: none }
.orphan-group .orphan-row { background: #f8fafc }

@media (max-width: 768px) {
  .og-header { flex-wrap: wrap; gap: 6px }
  .og-file { flex-basis: 100%; order: 1 }
  .og-chev { order: 0 }
  .og-count { order: 2 }
  .og-bulk { order: 3; margin-left: auto }
}

/* User card actions + password form */
.uc-top { cursor: pointer }
.uc-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap }
.uc-pw-form {
  margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  gap: 8px; flex-wrap: wrap; align-items: center;
}
.uc-pw-form input {
  flex: 1; min-width: 200px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-family: inherit; font-size: .85em; outline: none; background: #fff; color: #1e293b;
}
.uc-pw-form input:focus { border-color: #0f766e; box-shadow: 0 0 0 3px rgba(15,118,110,.1) }

/* Assignees tab */
.as-form {
  background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
}
.as-form h3 { font-size: .92em; color: #0f766e; margin: 0 0 10px; font-weight: 600 }
.as-form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch }
.as-form-row input {
  flex: 1; min-width: 160px; padding: 7px 12px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-family: inherit; font-size: .88em; outline: none; background: #fff; color: #1e293b;
}
.as-form-row input:focus { border-color: #0f766e; box-shadow: 0 0 0 3px rgba(15,118,110,.1) }

.as-section { margin-bottom: 20px }
.as-section h3 {
  font-size: .78em; color: #64748b; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 600; margin: 0 0 10px;
}
.as-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 6px;
}
.as-row-user { background: #fff }
.as-info { flex: 1; min-width: 0 }
.as-name { font-weight: 600; color: #0f172a; font-size: .92em; display: flex; align-items: center; gap: 8px }
.as-note { font-size: .84em; color: #475569; margin-top: 2px }
.as-meta { font-size: .76em; color: #94a3b8; margin-top: 2px }
