/* =====================================================
   ADMIN STYLES
   ===================================================== */

.container { max-width: 1280px; }

/* Access denied */
.access-denied {
  text-align: center;
  padding: 60px 20px;
  color: #c62828;
}
.access-denied .icon { font-size: 48px; margin-bottom: 10px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 24px;
}
.tab-btn {
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #333; }
.tab-btn.active { color: #2196F3; border-bottom-color: #2196F3; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.toolbar input:focus { outline: none; border-color: #2196F3; }

/* Buttons */
.btn-primary {
  background: #2196F3;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.btn-primary:hover { background: #1976D2; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.btn-sm.save { background: #4CAF50; color: white; }
.btn-sm.save:hover { background: #43A047; }
.btn-sm.cancel { background: #eee; color: #666; }
.btn-sm.cancel:hover { background: #ddd; }
.btn-sm.danger { background: #f44336; color: white; }
.btn-sm.danger:hover { background: #d32f2f; }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  background: #f5f5f5;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
  color: #333;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  color: #444;
}
.admin-table tr:hover { background: #fafafa; }

.action-link {
  color: #2196F3;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}
.action-link:hover { text-decoration: underline; }
.action-link.danger { color: #f44336; }

/* Badge */
.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.admin-badge.admin { background: #e3f2fd; color: #1565c0; }
.admin-badge.supervisor { background: #f3e5f5; color: #7b1fa2; }
.admin-badge.assessor { background: #f5f5f5; color: #666; }
.admin-badge.active { background: #e8f5e9; color: #2e7d32; }
.admin-badge.disabled { background: #ffebee; color: #c62828; }
.admin-badge.invited { background: #fff3e0; color: #e65100; }

/* Empty state */
.admin-empty {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: white;
  border-radius: 8px;
  padding: 28px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 16px 0; color: #333; }
.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 4px;
}
.modal .field input,
.modal .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.modal .field input:focus,
.modal .field select:focus { outline: none; border-color: #2196F3; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Status messages */
.status-msg {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}
.status-msg.show { display: block; }
.status-msg.success { background: #e8f5e9; color: #2e7d32; }
.status-msg.error { background: #ffebee; color: #c62828; }

/* Status tab — project picker */
.status-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}
.status-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.status-picker-select-wrap {
  flex: 1;
  position: relative;
}
.status-picker-select-wrap::after {
  content: '\25BC';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #999;
  pointer-events: none;
}
.status-picker-select-wrap select {
  width: 100%;
  padding: 12px 36px 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  color: #333;
  background: white;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.status-picker-select-wrap select:hover {
  border-color: #bbb;
}
.status-picker-select-wrap select:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33,150,243,0.12);
}

/* Status management tab — tree hierarchy */
.status-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.status-section-header {
  font-weight: 600;
  font-size: 13px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 16px 0 6px 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 4px;
}
.status-section-header:first-child {
  padding-top: 0;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fafafa;
  transition: opacity 0.2s;
}
.status-row:hover { background: #f0f0f0; }
.status-row.depth-0 {
  background: #e8f5e9;
  font-weight: 600;
}
.status-row.depth-1 {
  margin-left: 24px;
}
.status-row.depth-2 {
  margin-left: 48px;
  font-size: 12px;
}
.status-row.parent-inactive {
  opacity: 0.45;
  pointer-events: none;
}
.status-row .icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.status-row .name {
  flex: 1;
  font-size: 13px;
  color: #333;
}
.status-row.depth-2 .name {
  font-size: 12px;
}
.status-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
  flex-shrink: 0;
}
.status-toggle.active { background: #4CAF50; }
.status-toggle.inactive { background: #ccc; }
.status-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.status-toggle.active::after { transform: translateX(20px); }
.status-toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.status-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  width: 56px;
  text-align: center;
}
.status-label.active { color: #2e7d32; }
.status-label.inactive { color: #999; }

/* Collapsible site groups */
.site-group {
  margin-bottom: 2px;
}
.site-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
  border-radius: 4px;
  user-select: none;
}
.site-chevron:hover {
  color: #333;
  background: rgba(0,0,0,0.06);
}
.site-chevron.expanded {
  transform: rotate(90deg);
}
.facility-count {
  font-size: 11px;
  color: #999;
  background: #eee;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.site-facilities {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.site-facilities.expanded {
  max-height: 5000px;
  transition: max-height 0.4s ease;
}

/* Quick-add forms */
.status-picker-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.status-picker-row .status-picker-select-wrap {
  flex: 1;
}
.quick-add-btn {
  width: 42px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  font-size: 20px;
  font-weight: 600;
  color: #4CAF50;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.quick-add-btn:hover {
  border-color: #4CAF50;
  background: #e8f5e9;
}
.quick-add-btn.refresh {
  color: #666;
  font-size: 22px;
  font-weight: 400;
}
.quick-add-btn.refresh:hover {
  border-color: #2196F3;
  background: #e3f2fd;
  color: #2196F3;
}
.quick-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0 0 0;
}
.quick-add-form.depth-2 {
  margin-left: 48px;
  padding: 6px 0;
}
.quick-add-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.quick-add-input:focus {
  border-color: #4CAF50;
}
.quick-add-input.quick-add-phase {
  max-width: 140px;
  flex: 0 1 140px;
}
.quick-add-save {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #4CAF50;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.quick-add-save:hover { background: #388E3C; }
.quick-add-save:disabled { opacity: 0.5; cursor: not-allowed; }
.quick-add-cancel {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: #eee;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.quick-add-cancel:hover { background: #ddd; }
.quick-add-inline-btn {
  display: block;
  margin: 4px 0 4px 24px;
  padding: 6px 14px;
  border: 1px dashed #ccc;
  border-radius: 6px;
  background: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.quick-add-inline-btn:hover {
  border-color: #4CAF50;
  color: #4CAF50;
}
.quick-add-inline-btn.depth-2 {
  margin-left: 48px;
}

/* Project members section */
.project-selector {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}
.project-selector select {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}
.project-selector select:focus { outline: none; border-color: #2196F3; }

/* =====================================================
   ACTIVITY LOG
   ===================================================== */
.activity-date-group {
  margin-bottom: 20px;
}
.activity-date-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #999;
  padding: 8px 0 6px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
}
.activity-row:last-child {
  border-bottom: none;
}
.activity-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #f5f5f5;
  border-radius: 50%;
}
.activity-content {
  flex: 1;
  min-width: 0;
}
.activity-main {
  font-size: 13px;
  color: #333;
  line-height: 1.4;
}
.activity-location {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}
.activity-time {
  flex-shrink: 0;
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
}
.activity-action {
  font-weight: 600;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 3px;
}
.activity-action.action-added {
  background: #e8f5e9;
  color: #2e7d32;
}
.activity-action.action-updated {
  background: #e3f2fd;
  color: #1565c0;
}
.activity-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f5f5f5;
  color: #666;
}
.activity-severity {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}
.activity-severity.major { background: #ffebee; color: #c62828; }
.activity-severity.moderate { background: #fff3e0; color: #e65100; }
.activity-severity.minor { background: #f5f5f5; color: #666; }

/* Team summary table */
.summary-table {
  margin-bottom: 8px;
}
.summary-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.summary-table tr[data-user]:hover {
  background: #f5f5f5;
}
.summary-table .stale-row td {
  color: #c62828;
}
.summary-table .stale-row td:last-child {
  font-weight: 600;
}

/* =====================================================
   PROJECT COSTS TAB
   ===================================================== */

.cost-help-text {
  font-size: 13px;
  color: #666;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

/* Cost table rows */
.cost-row { cursor: default; }
.cost-row.has-override { background: #fffde7; }
.cost-row:hover { background: #f5f5f5; }
.cost-row.has-override:hover { background: #fff9c4; }

.cost-expand-cell {
  width: 30px;
  text-align: center;
  padding: 8px 4px !important;
}
.cost-expand-btn {
  display: inline-block;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  user-select: none;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.cost-expand-btn:hover {
  color: #333;
  background: rgba(0,0,0,0.06);
}

.cost-asset-name {
  font-weight: 500;
  color: #333;
}

.cost-uom {
  color: #888;
  font-size: 12px;
}

.cost-value {
  text-align: right;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 13px;
  color: #555;
}

.cost-input-cell {
  width: 140px;
}
.cost-input-cell.life {
  width: 100px;
}

.cost-life-default {
  text-align: center;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 13px;
  color: #555;
}
.cost-input {
  width: 120px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  text-align: right;
}
.cost-input:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33,150,243,0.12);
}
.cost-input.small {
  width: 100px;
  font-size: 12px;
  padding: 4px 6px;
}
.cost-input.life {
  width: 80px;
  text-align: center;
}
/* Hide number input spinners */
.cost-input::-webkit-outer-spin-button,
.cost-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cost-input { -moz-appearance: textfield; }

.cost-status-cell {
  text-align: center;
  width: 80px;
}

/* Cost badges */
.cost-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.cost-badge.default { background: #f5f5f5; color: #999; }
.cost-badge.saved { background: #e3f2fd; color: #1565c0; }
.cost-badge.pending { background: #fff3e0; color: #e65100; }

/* Detail row for deficiency-type overrides */
.cost-detail-row td {
  padding: 0 !important;
  border-bottom: 2px solid #e0e0e0;
  background: #fafafa;
}
.cost-overrides-grid {
  padding: 10px 16px 14px;
}
.cost-overrides-header {
  display: grid;
  grid-template-columns: 1fr 100px 120px;
  gap: 8px;
  padding: 4px 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 6px;
}
.cost-overrides-header span:nth-child(2),
.cost-overrides-header span:nth-child(3) {
  text-align: right;
}
.cost-override-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
}
.cost-override-row:last-child {
  border-bottom: none;
}
.cost-override-name {
  font-size: 12px;
  color: #555;
}
.cost-override-default {
  font-size: 12px;
  color: #888;
  text-align: right;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
}

/* Actions bar */
.cost-actions-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}
.cost-change-count {
  font-size: 13px;
  color: #e65100;
  font-weight: 500;
  margin-right: auto;
}
